|
|
@@ -401,12 +401,11 @@ namespace BPASmartClient.DosingSystem |
|
|
|
|
|
|
|
public void StatusReset() |
|
|
|
{ |
|
|
|
// prop1: |
|
|
|
// prop1: |
|
|
|
this.modbusTcp.Write(DeviceAddress.FinfishStatus.ToAdd(), (ushort)1); |
|
|
|
//MessageNotify.GetInstance.ShowRunLog($"料仓复位,值:{1}"); |
|
|
|
//var value = this.modbusTcp.Read<ushort>(DeviceAddress.FinfishStatus.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
//if (value != null && value.ToString() != 1.ToString()) goto prop1; |
|
|
|
//MessageNotify.GetInstance.ShowRunLog($"料仓复位,值:{this.modbusTcp.Read<ushort>(DeviceAddress.FinfishStatus.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content}"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void Dispose() |
|
|
@@ -421,67 +420,112 @@ namespace BPASmartClient.DosingSystem |
|
|
|
var res = Json<DevicePar>.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName); |
|
|
|
if (res != null) |
|
|
|
{ |
|
|
|
//modbusTcp.Write(DeviceAddress.SlowlyAddWeight.ToAdd(), res.SlowlyAddWeight); |
|
|
|
|
|
|
|
//modbusTcp.Write(DeviceAddress.PreCloseValveWeight.ToAdd(), res.PreCloseValveWeight); |
|
|
|
//modbusTcp.Write(DeviceAddress.RapidAcceleration.ToAdd(), (uint)res.RapidAcceleration); |
|
|
|
//modbusTcp.Write(DeviceAddress.SlowAcceleration.ToAdd(), (uint)res.SlowAcceleration); |
|
|
|
//modbusTcp.Write(DeviceAddress.ServoManualSpeed.ToAdd(), (uint)res.ServoManualSpeed); |
|
|
|
//modbusTcp.Write(DeviceAddress.SiloUpperLimitWeight.ToAdd(), (uint)res.SiloUpperLimitWeight); |
|
|
|
//modbusTcp.Write(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), (uint)res.LowerLimitWeightOfSilo); |
|
|
|
//modbusTcp.Write(DeviceAddress.StirringSpeed.ToAdd(), (uint)res.StirringSpeed); |
|
|
|
|
|
|
|
//MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},配料参数下发完成"); |
|
|
|
|
|
|
|
prop1: |
|
|
|
modbusTcp.Write(DeviceAddress.SlowlyAddWeight.ToAdd(), res.SlowlyAddWeight); |
|
|
|
|
|
|
|
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置慢加重量:{res.SlowlyAddWeight}"); |
|
|
|
var value1 = modbusTcp.Read<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
if (value1 != null && value1.ToString() != res.SlowlyAddWeight.ToString()) goto prop1; |
|
|
|
prop2: |
|
|
|
modbusTcp.Write(DeviceAddress.PreCloseValveWeight.ToAdd(), res.PreCloseValveWeight); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置提前关阀重量:{res.PreCloseValveWeight}"); |
|
|
|
var value2 = modbusTcp.Read<float>(DeviceAddress.PreCloseValveWeight.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
if (value2 != null && value2.ToString() != res.PreCloseValveWeight.ToString()) goto prop2; |
|
|
|
prop3: |
|
|
|
modbusTcp.Write(DeviceAddress.RapidAcceleration.ToAdd(), (uint)res.RapidAcceleration); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置快加速度:{res.RapidAcceleration}"); |
|
|
|
var value3 = modbusTcp.Read<uint>(DeviceAddress.RapidAcceleration.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
if (value3 != null && value3.ToString() != res.RapidAcceleration.ToString()) goto prop3; |
|
|
|
prop4: |
|
|
|
modbusTcp.Write(DeviceAddress.SlowAcceleration.ToAdd(), (uint)res.SlowAcceleration); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置慢加速度:{res.SlowAcceleration}"); |
|
|
|
var value4 = modbusTcp.Read<uint>(DeviceAddress.SlowAcceleration.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
if (value4 != null && value4.ToString() != res.SlowAcceleration.ToString()) goto prop4; |
|
|
|
prop5: |
|
|
|
modbusTcp.Write(DeviceAddress.ServoManualSpeed.ToAdd(), (uint)res.ServoManualSpeed); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置伺服手动速度:{res.ServoManualSpeed}"); |
|
|
|
var value5 = modbusTcp.Read<uint>(DeviceAddress.ServoManualSpeed.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
if (value5 != null && value5.ToString() != res.ServoManualSpeed.ToString()) goto prop5; |
|
|
|
|
|
|
|
prop6: |
|
|
|
modbusTcp.Write(DeviceAddress.SiloUpperLimitWeight.ToAdd(), (uint)res.SiloUpperLimitWeight); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置料仓上限重量:{res.SiloUpperLimitWeight}"); |
|
|
|
var value6 = modbusTcp.Read<uint>(DeviceAddress.SiloUpperLimitWeight.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
if (value6 != null && value6.ToString() != res.SiloUpperLimitWeight.ToString()) goto prop6; |
|
|
|
prop7: |
|
|
|
modbusTcp.Write(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), (uint)res.LowerLimitWeightOfSilo); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置料仓下限重量:{res.LowerLimitWeightOfSilo}"); |
|
|
|
var value7 = modbusTcp.Read<uint>(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
if ((value7 != null && value7.ToString() != res.LowerLimitWeightOfSilo.ToString())) goto prop7; |
|
|
|
prop8: |
|
|
|
modbusTcp.Write(DeviceAddress.StirringSpeed.ToAdd(), (uint)res.StirringSpeed); |
|
|
|
// MessageNotify.GetInstance.ShowRunLog($"当前下发重量:{res.SlowlyAddWeight}:{modbusTcp.Read<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content}"); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置搅拌速度:{res.StirringSpeed}"); |
|
|
|
var value8 = modbusTcp.Read<uint>(DeviceAddress.StirringSpeed.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
if (value8 != null && value8.ToString() != res.StirringSpeed.ToString()) goto prop8; |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},配料参数下发完成"); |
|
|
|
|
|
|
|
//prop1: |
|
|
|
// modbusTcp.Write(DeviceAddress.SlowlyAddWeight.ToAdd(), res.SlowlyAddWeight); |
|
|
|
// var value1 = modbusTcp.Read<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
// if (value1 != null && value1.ToString() != res.SlowlyAddWeight.ToString()) goto prop1; |
|
|
|
// prop2: |
|
|
|
// modbusTcp.Write(DeviceAddress.PreCloseValveWeight.ToAdd(), res.PreCloseValveWeight); |
|
|
|
// var value2 = modbusTcp.Read<float>(DeviceAddress.PreCloseValveWeight.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
// if (value2 != null && value2.ToString() != res.PreCloseValveWeight.ToString()) goto prop2; |
|
|
|
// prop3: |
|
|
|
// modbusTcp.Write(DeviceAddress.RapidAcceleration.ToAdd(), (uint)res.RapidAcceleration); |
|
|
|
// var value3 = modbusTcp.Read<uint>(DeviceAddress.RapidAcceleration.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
// if (value3 != null && value3.ToString() != res.RapidAcceleration.ToString()) goto prop3; |
|
|
|
// prop4: |
|
|
|
// modbusTcp.Write(DeviceAddress.SlowAcceleration.ToAdd(), (uint)res.SlowAcceleration); |
|
|
|
// var value4 = modbusTcp.Read<uint>(DeviceAddress.SlowAcceleration.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
// if (value4 != null && value4.ToString() != res.SlowAcceleration.ToString()) goto prop4; |
|
|
|
// prop5: |
|
|
|
// modbusTcp.Write(DeviceAddress.ServoManualSpeed.ToAdd(), (uint)res.ServoManualSpeed); |
|
|
|
// var value5 = modbusTcp.Read<uint>(DeviceAddress.ServoManualSpeed.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
// if (value5 != null && value5.ToString() != res.ServoManualSpeed.ToString()) goto prop5; |
|
|
|
|
|
|
|
// prop6: |
|
|
|
// modbusTcp.Write(DeviceAddress.SiloUpperLimitWeight.ToAdd(), (uint)res.SiloUpperLimitWeight); |
|
|
|
// var value6 = modbusTcp.Read<uint>(DeviceAddress.SiloUpperLimitWeight.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
// if (value6 != null && value6.ToString() != res.SiloUpperLimitWeight.ToString()) goto prop6; |
|
|
|
// prop7: |
|
|
|
// modbusTcp.Write(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), (uint)res.LowerLimitWeightOfSilo); |
|
|
|
// var value7 = modbusTcp.Read<uint>(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
// if ((value7 != null && value7.ToString() != res.LowerLimitWeightOfSilo.ToString())) goto prop7; |
|
|
|
// prop8: |
|
|
|
// modbusTcp.Write(DeviceAddress.StirringSpeed.ToAdd(), (uint)res.StirringSpeed); |
|
|
|
// var value8 = modbusTcp.Read<uint>(DeviceAddress.StirringSpeed.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
// if (value8 != null && value8.ToString() != res.StirringSpeed.ToString()) goto prop8; |
|
|
|
// MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},配料参数下发完成"); |
|
|
|
} |
|
|
|
prop9: |
|
|
|
//modbusTcp.Write(DeviceAddress.WeightSet.ToAdd(), Value);//写入配方重量 |
|
|
|
//var value9 = modbusTcp.Read<float>(DeviceAddress.WeightSet.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
//if ((value9 != null && value9.ToString() != Value.ToString()) || value9 == 0) goto prop9; |
|
|
|
modbusTcp.Write(DeviceAddress.WeightSet.ToAdd(), Value);//写入配方重量 |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置重量:{Value}"); |
|
|
|
|
|
|
|
var value9 = modbusTcp.Read<float>(DeviceAddress.WeightSet.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
if ((value9 != null && value9.ToString() != Value.ToString()) || value9 == 0) goto prop9; |
|
|
|
//prop10: |
|
|
|
//MessageNotify.GetInstance.ShowRunLog($"写入配方重量,值{Value}:{value9}"); |
|
|
|
//modbusTcp.Write(DeviceAddress.Start.ToAdd(), (ushort)1);//设备启动写入 |
|
|
|
//var value10 = modbusTcp.Read<ushort>(DeviceAddress.Start.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
//if ((value10 != null && value10.ToString() != 1.ToString())||value10==0) goto prop10; |
|
|
|
modbusTcp.Write(DeviceAddress.WeightSet.ToAdd(), Value);//写入配方重量 |
|
|
|
//modbusTcp.Write(DeviceAddress.WeightSet.ToAdd(), Value);//写入配方重量 |
|
|
|
modbusTcp.Write(DeviceAddress.Start.ToAdd(), (ushort)1);//设备启动写入 |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"设备启动写入,值1:{Value}"); |
|
|
|
Task.Run(() => |
|
|
|
{ |
|
|
|
while (true) |
|
|
|
{ |
|
|
|
ushort c = modbusTcp.Read<ushort>(DeviceAddress.DeviceAlarmCode.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"{IpAddress}:LW51,值:{modbusTcp.Read<ushort>(DeviceAddress.DeviceAlarmCode.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content}"); |
|
|
|
string str = DecToBinary(c); |
|
|
|
if (str[8].ToString() == 0.ToString()) |
|
|
|
{ |
|
|
|
modbusTcp.Write(DeviceAddress.Start.ToAdd(), (ushort)1);//设备启动写入 |
|
|
|
} |
|
|
|
else |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置重量:{Value},味魔方启动配料"); |
|
|
|
} |
|
|
|
} |
|
|
|
static string DecToBinary(int a) |
|
|
|
{ |
|
|
|
int r; |
|
|
|
string s = ""; |
|
|
|
do |
|
|
|
{ |
|
|
|
r = a % 2; |
|
|
|
a /= 2; |
|
|
|
s = r + s; |
|
|
|
} |
|
|
|
while (a != 0); |
|
|
|
int length = s.Length; |
|
|
|
for (int i = 0; i < 16 - length; i++) |
|
|
|
{ |
|
|
|
s = 0 + s; |
|
|
|
} |
|
|
|
return s; |
|
|
|
} |
|
|
|
} |
|
|
|
} |