|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
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 v = PressurePLC.UpdateFromPlc(id);
|
|
|
|
|
if (null!=v)
|
|
|
|
|
{
|
|
|
|
|
this.LowLimit.Text = v.LowLimit.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
this.HighLimit.Text = v.HighLimit.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
|
|
|
|
|
foreach (MyNameValue combo in Alarm.Items)
|
|
|
|
|
{
|
|
|
|
|
if (combo.Id == v.Alarm)
|
|
|
|
|
{
|
|
|
|
|
Alarm.SelectedItem = combo;
|
|
|
|
|
Alarm.Enabled = false;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|