|
|
@@ -347,12 +347,36 @@ namespace BPASmartClient.DosingSystem |
|
|
|
{ |
|
|
|
TaskManage.GetInstance.StartLong(new Action(() => |
|
|
|
{ |
|
|
|
this.DeviceName = modbusTcp.Read<string>(DeviceAddress.DeviceName.ToAdd(), 20).Content.Trim().Replace(" ", ""); |
|
|
|
deviceStatus.RunStatus = (ushort)this.modbusTcp.Read<ushort>(DeviceAddress.RunStatus.ToAdd()).Content; //获取设备运行状态 |
|
|
|
deviceStatus.WeightFeedback = (float)this.modbusTcp.Read<uint>(DeviceAddress.WeightFeedback.ToAdd()).Content;//获取设备料仓剩余重量 |
|
|
|
deviceStatus.NowWeightFeedback = this.modbusTcp.Read<float>(DeviceAddress.CutWeightFeedback.ToAdd()).Content;//获取下料重量 |
|
|
|
deviceStatus.DeviceNum = (ushort)this.modbusTcp.Read<ushort>(DeviceAddress.DeviceNum.ToAdd()).Content;//获取设备编号 |
|
|
|
deviceStatus.DeviceAlarmCode = (ushort)this.modbusTcp.Read<ushort>(DeviceAddress.DeviceAlarmCode.ToAdd()).Content;//获取设备故障编码 |
|
|
|
var dn = modbusTcp.Read<string>(DeviceAddress.DeviceName.ToAdd(), 20); |
|
|
|
if (dn.IsSuccess) this.DeviceName = dn.Content.Trim().Replace(" ", ""); |
|
|
|
|
|
|
|
//获取设备运行状态 |
|
|
|
var rs = this.modbusTcp.Read<ushort>(DeviceAddress.RunStatus.ToAdd()); |
|
|
|
if (rs.IsSuccess) deviceStatus.RunStatus = rs.Content; |
|
|
|
|
|
|
|
////获取设备料仓剩余重量 |
|
|
|
var wf = this.modbusTcp.Read<uint>(DeviceAddress.WeightFeedback.ToAdd()); |
|
|
|
if (wf.IsSuccess) deviceStatus.WeightFeedback = (float)(wf.Content); |
|
|
|
|
|
|
|
////获取下料重量 |
|
|
|
var nwf = this.modbusTcp.Read<float>(DeviceAddress.CutWeightFeedback.ToAdd()); |
|
|
|
if (nwf.IsSuccess) deviceStatus.NowWeightFeedback = nwf.Content; |
|
|
|
|
|
|
|
////获取设备编号 |
|
|
|
var dnum = this.modbusTcp.Read<ushort>(DeviceAddress.DeviceNum.ToAdd()); |
|
|
|
if (dnum.IsSuccess) deviceStatus.DeviceNum = dnum.Content; |
|
|
|
|
|
|
|
////获取设备故障编码 |
|
|
|
var dac = this.modbusTcp.Read<ushort>(DeviceAddress.DeviceAlarmCode.ToAdd()); |
|
|
|
if (dac.IsSuccess) deviceStatus.DeviceAlarmCode = dac.Content; |
|
|
|
|
|
|
|
|
|
|
|
//this.DeviceName = modbusTcp.Read<string>(DeviceAddress.DeviceName.ToAdd(), 20).Content.Trim().Replace(" ", ""); |
|
|
|
//deviceStatus.RunStatus = (ushort)this.modbusTcp.Read<ushort>(DeviceAddress.RunStatus.ToAdd()).Content; //获取设备运行状态 |
|
|
|
//deviceStatus.WeightFeedback = (float)this.modbusTcp.Read<uint>(DeviceAddress.WeightFeedback.ToAdd()).Content;//获取设备料仓剩余重量 |
|
|
|
//deviceStatus.NowWeightFeedback = this.modbusTcp.Read<float>(DeviceAddress.CutWeightFeedback.ToAdd()).Content;//获取下料重量 |
|
|
|
//deviceStatus.DeviceNum = (ushort)this.modbusTcp.Read<ushort>(DeviceAddress.DeviceNum.ToAdd()).Content;//获取设备编号 |
|
|
|
//deviceStatus.DeviceAlarmCode = (ushort)this.modbusTcp.Read<ushort>(DeviceAddress.DeviceAlarmCode.ToAdd()).Content;//获取设备故障编码 |
|
|
|
|
|
|
|
AlarmHelper<AlarmInfo>.GetInstance(DeviceName).EStop1 = deviceStatus.DeviceAlarmCode.GetBitValue(1); |
|
|
|
AlarmHelper<AlarmInfo>.GetInstance(DeviceName).Servo = deviceStatus.DeviceAlarmCode.GetBitValue(2); |
|
|
@@ -389,40 +413,6 @@ namespace BPASmartClient.DosingSystem |
|
|
|
var res = Json<DevicePar>.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName); |
|
|
|
if (res != null) |
|
|
|
{ |
|
|
|
//prop1: |
|
|
|
//modbusTcp.SetReal(DeviceAddress.SlowlyAddWeight, res.SlowlyAddWeight); |
|
|
|
//var Value1 = (float)this.modbusTcp.GetReal(DeviceAddress.SlowlyAddWeight); |
|
|
|
//if (Value1 != null && Value1.ToString() != res.SlowlyAddWeight.ToString()) goto prop1; |
|
|
|
//prop2: |
|
|
|
//modbusTcp.SetReal(DeviceAddress.PreCloseValveWeight, res.PreCloseValveWeight); |
|
|
|
//var Value2 = (float)this.modbusTcp.GetReal(DeviceAddress.PreCloseValveWeight); |
|
|
|
//if (Value2 != null && Value2.ToString() != res.PreCloseValveWeight.ToString()) goto prop2; |
|
|
|
//prop3: |
|
|
|
//modbusTcp.SetUint(DeviceAddress.RapidAcceleration, (uint)res.RapidAcceleration); |
|
|
|
//var Value3 = this.modbusTcp.GetUint(DeviceAddress.RapidAcceleration); |
|
|
|
//if (Value3 != null && Value3.ToString() != res.RapidAcceleration.ToString()) goto prop3; |
|
|
|
//prop4: |
|
|
|
//modbusTcp.SetUint(DeviceAddress.SlowAcceleration, (uint)res.SlowAcceleration); |
|
|
|
//var Value4 = this.modbusTcp.GetUint(DeviceAddress.SlowAcceleration); |
|
|
|
//if (Value4 != null && Value4.ToString() != res.SlowAcceleration.ToString()) goto prop4; |
|
|
|
//prop5: |
|
|
|
//modbusTcp.SetUint(DeviceAddress.ServoManualSpeed, (uint)res.ServoManualSpeed); |
|
|
|
//var Value5 = this.modbusTcp.GetUint(DeviceAddress.ServoManualSpeed); |
|
|
|
//if (Value5 != null && Value5.ToString() != res.ServoManualSpeed.ToString()) goto prop5; |
|
|
|
//prop6: |
|
|
|
//modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight); |
|
|
|
//var Value6 = this.modbusTcp.GetUint(DeviceAddress.SiloUpperLimitWeight); |
|
|
|
//if (Value6 != null && Value6.ToString() != res.SiloUpperLimitWeight.ToString()) goto prop6; |
|
|
|
//prop7: |
|
|
|
//modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo); |
|
|
|
//var Value7 = this.modbusTcp.GetUint(DeviceAddress.LowerLimitWeightOfSilo); |
|
|
|
//if (Value7 != null && Value7.ToString() != res.LowerLimitWeightOfSilo.ToString()) goto prop7; |
|
|
|
//prop8: |
|
|
|
//modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed); |
|
|
|
//var Value8 = this.modbusTcp.GetUint(DeviceAddress.StirringSpeed); |
|
|
|
//if (Value8 != null && Value8.ToString() != res.StirringSpeed.ToString()) goto prop8; |
|
|
|
//MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},配料参数下发完成"); |
|
|
|
|
|
|
|
modbusTcp.Write(DeviceAddress.SlowlyAddWeight.ToAdd(), res.SlowlyAddWeight); |
|
|
|
modbusTcp.Write(DeviceAddress.PreCloseValveWeight.ToAdd(), res.PreCloseValveWeight); |
|
|
|
modbusTcp.Write(DeviceAddress.RapidAcceleration.ToAdd(), (uint)res.RapidAcceleration); |
|
|
@@ -433,14 +423,6 @@ namespace BPASmartClient.DosingSystem |
|
|
|
modbusTcp.Write(DeviceAddress.StirringSpeed.ToAdd(), (uint)res.StirringSpeed); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},配料参数下发完成"); |
|
|
|
} |
|
|
|
//prop9: |
|
|
|
// modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方重量 |
|
|
|
// var Value9 = this.modbusTcp.GetReal(DeviceAddress.WeightSet); |
|
|
|
// if (Value9 != null && Value9.ToString() != Value.ToString()) goto prop9; |
|
|
|
//prop10: |
|
|
|
// modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入 |
|
|
|
// var Value10 = (short[])this.modbusTcp.Read(DeviceAddress.Start); |
|
|
|
// if (Value10 != null && Value10[0] != 1) goto prop10; |
|
|
|
modbusTcp.Write(DeviceAddress.WeightSet.ToAdd(), Value);//写入配方重量 |
|
|
|
modbusTcp.Write(DeviceAddress.Start.ToAdd(), (ushort)1);//设备启动写入 |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置重量:{Value},味魔方启动配料"); |
|
|
|