|
|
@@ -59,11 +59,42 @@ namespace BPASmartClient.DosingSystem |
|
|
|
} |
|
|
|
} |
|
|
|
Thread.Sleep(200); |
|
|
|
}), "设备状态监听",true); |
|
|
|
}), "设备状态监听", true); |
|
|
|
} |
|
|
|
|
|
|
|
private void aa(int num, string name) |
|
|
|
{ |
|
|
|
DeviceLists.TryAdd($"192.168.1.{num}", new DeviceStatus() { DeviceName = $"{name}" }); |
|
|
|
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() |
|
|
|
{ |
|
|
|
DeviceName = $"{name}", |
|
|
|
DeviceNum = num, |
|
|
|
Weight = new Random().Next(100, 10000) / 100.0 |
|
|
|
}); |
|
|
|
Global.DeviceRawMaterials.Add(new RawMaterialModel() |
|
|
|
{ |
|
|
|
DeviceIp = $"192.168.1.{num}", |
|
|
|
RawMaterialName = $"{name}", |
|
|
|
}); |
|
|
|
devices.Add(new Devices() |
|
|
|
{ |
|
|
|
DeviceName = $"{name}", |
|
|
|
DeviceNum = num, |
|
|
|
IpAddress = $"192.168.1.{num}", |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private void TestData() |
|
|
|
{ |
|
|
|
|
|
|
|
//aa(1, "盐"); |
|
|
|
//aa(2, "郫县豆瓣"); |
|
|
|
//aa(3, "芥菜"); |
|
|
|
//aa(4, "调味剂"); |
|
|
|
//aa(5, "香料"); |
|
|
|
//aa(6, "鸡精"); |
|
|
|
//aa(7, "味精"); |
|
|
|
|
|
|
|
for (int i = 0; i < 8; i++) |
|
|
|
{ |
|
|
|
DeviceLists.TryAdd($"192.168.1.{i + 1}", new DeviceStatus() { DeviceName = $"测试设备{i + 1}" }); |
|
|
@@ -169,7 +200,7 @@ namespace BPASmartClient.DosingSystem |
|
|
|
}*/ |
|
|
|
for (int i = 0; i < 15; i++) |
|
|
|
{ |
|
|
|
IPLists.Add($"{IPSegment}{(i+1)*10}"); |
|
|
|
IPLists.Add($"{IPSegment}{(i + 1) * 10}"); |
|
|
|
} |
|
|
|
|
|
|
|
IPLists.ForEach((item) => |
|
|
@@ -177,7 +208,7 @@ namespace BPASmartClient.DosingSystem |
|
|
|
Ping myPing = new Ping(); |
|
|
|
myPing.PingCompleted += new PingCompletedEventHandler(_myPing_PingCompleted); |
|
|
|
myPing.SendAsync(item, 1000, null); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
@@ -281,7 +312,7 @@ namespace BPASmartClient.DosingSystem |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if(e.Reply !=null) |
|
|
|
if (e.Reply != null) |
|
|
|
IPQueues.Enqueue(e.Reply.Address.ToString()); |
|
|
|
} |
|
|
|
} |
|
|
@@ -356,39 +387,39 @@ 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; |
|
|
|
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; |
|
|
|
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; |
|
|
|
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; |
|
|
|
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; |
|
|
|
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; |
|
|
|
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.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},配料参数下发完成"); |
|
|
|
} |
|
|
|
//prop9: |
|
|
|
// modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方重量 |
|
|
|