|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.LjMaterial;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.LjElectrical
|
|
|
|
|
{
|
|
|
|
|
public partial class FrmElectrical : Form
|
|
|
|
|
{
|
|
|
|
|
public FrmElectrical()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int _id;
|
|
|
|
|
|
|
|
|
|
public FrmElectrical(int id) : this()
|
|
|
|
|
{
|
|
|
|
|
this._id = id;
|
|
|
|
|
ElectricalView view = new ElectricalView();
|
|
|
|
|
view = ElectricalPlc.UpFromPlc(id);
|
|
|
|
|
if (null != view)
|
|
|
|
|
{
|
|
|
|
|
this.Speed.Text = view.Speed.ToString();
|
|
|
|
|
this.Speed.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnOK_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var speed = Speed.Text.Trim();
|
|
|
|
|
if (!float.TryParse(speed, out var sp))
|
|
|
|
|
{
|
|
|
|
|
Speed.Focus();
|
|
|
|
|
MessageBox.Show("请输入正确的值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var watchDog = LjHelp.WatchDog;
|
|
|
|
|
if (watchDog == 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("PLC通讯失败");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ElectricalView view = new ElectricalView();
|
|
|
|
|
view.Id = _id;
|
|
|
|
|
view.Speed = Convert.ToSingle(speed);
|
|
|
|
|
ElectricalPlc.DownToPlc(new List<ElectricalView>()
|
|
|
|
|
{
|
|
|
|
|
view
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//select Id, Name, Speed from ElectricalSetting
|
|
|
|
|
string sql = $"update ElectricalSetting set Speed={view.Speed} where id={view.Id}";
|
|
|
|
|
DBHelp.ExecuteNonQuery(sql);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.DialogResult = DialogResult.OK;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|