You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lj_plc/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjPressure/FrmPressureUpdate.cs

101 lines
2.8 KiB
C#

1 year ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
using Mesnac.Action.ChemicalWeighing.LjMaterial;
namespace Mesnac.Action.ChemicalWeighing.LjPressure
{
public partial class FrmPressureUpdate : Form
{
public FrmPressureUpdate()
{
InitializeComponent();
}
private int _id;
public FrmPressureUpdate(int id) : this()
{
_id = id;
IList<MyNameValue> ls = new List<MyNameValue>();
ls.Add(new MyNameValue()
{
Id = 1,Name = "超压",
});
ls.Add(new MyNameValue()
{
Id = 0,Name = "正常",
});
this.Alarm.DataSource = ls;
Alarm.ValueMember = "Id";
Alarm.DisplayMember = "Name";
var pressureSettingViews = PressurePLC.UpdateFromPlc(id);
if (pressureSettingViews.Count == 1)
{
var v = pressureSettingViews.First();
this.LowLimit.Text = v.LowLimit.ToString();
this.HighLimit.Text = v.HighLimit.ToString();
foreach (MyNameValue combo in Alarm.Items)
{
if (combo.Id == v.Alarm)
{
Alarm.SelectedItem = combo;
break;
}
}
}
else
{
MessageBox.Show("获取PLC 异常请联系管理员");
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void Alarm_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void btnOK_Click(object sender, EventArgs e)
{
if (!float.TryParse(LowLimit.Text.Trim(), out float a))
{
LowLimit.Focus();
MessageBox.Show("请输入正确的数值");
return;
}
if (!float.TryParse(HighLimit.Text.Trim(), out float b))
{
HighLimit.Focus();
MessageBox.Show("请输入正确的数值");
return;
}
PressureSettingView view = new PressureSettingView()
{
HighLimit = b,
LowLimit = a,
Alarm = Convert.ToInt16(Alarm.SelectedValue)
};
PressurePLC.DownToPlc(new List<PressureSettingView>()
{
view
});
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
}
}