소스 검색

11

一拖四味魔方配料系统
ZhaoGang 1 년 전
부모
커밋
a4801ebd90
2개의 변경된 파일32개의 추가작업 그리고 12개의 파일을 삭제
  1. +29
    -12
      DosingSystem/ExcuteControl .cs
  2. +3
    -0
      DosingSystem/Model/DeviceInquire.cs

+ 29
- 12
DosingSystem/ExcuteControl .cs 파일 보기

@@ -1379,19 +1379,25 @@ namespace BPASmartClient.DosingSystem
recipeProcesses.Clear();
TaskManage.GetInstance.StartLong(() =>
{
//起始和中转的流水线一直开启。
SimensSend.GetInstance.SendSimens.Write("M0.0", true);
SimensSend.GetInstance.SendSimens.Write("M0.1", true);
//已经下发在排队的配方。
if (RecipeNames.Count > 0)
{

for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
{
//判断IP是否在列表中
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
{
//只有设备在等待配料状态才能下发数据
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1)
{
//判断
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail <= DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 0)
{
//因通信差,添加该代码。
if (!doDeviceCount.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
{
doDeviceCount.TryAdd(DeviceInquire.GetInstance.devices[i].IpAddress,0);
@@ -1403,11 +1409,13 @@ namespace BPASmartClient.DosingSystem
int recipeNameNum = doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress];
if (doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress] == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount&& doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress]< RecipeNames.Count)
{
//查找
index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(recipeNameNum));
if (index >= 0 && index < Recipes.Count)
{
MessageNotify.GetInstance.runLogs.Add(new RunLog() { RunLogInfo = $"下发配方{RecipeNames.ElementAt(recipeNameNum)}到设备{DeviceInquire.GetInstance.devices[i].DeviceName}",Time = DateTime.Now.ToString()});
int maxPail = 0;
//查找配方的最大桶号。
foreach (var rawMaterial in Recipes.ElementAt(index).RawMaterials)
{
if (rawMaterial.Loc > maxPail)
@@ -1415,11 +1423,13 @@ namespace BPASmartClient.DosingSystem
maxPail = rawMaterial.Loc;
}
}
//清除下位设备的最大桶号,下位设备认为配方制作完一个了。
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.DeletePassPail.ToAdd(), 1);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.MaxPail.ToAdd(), (ushort)maxPail);
doDeviceCount.TryUpdate(DeviceInquire.GetInstance.devices[i].IpAddress, doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress] + 1, doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress]);
App.Current.Dispatcher.Invoke(new Action(() =>
{
//doDeviceCount 集合 键为各个设备,值为该设备执行过的配方。
if (doDeviceCount.ContainsKey("192.168.2.10")&&UserTreeWait.Count > 0 && doDeviceCount["192.168.2.10"] > recipeProcesses.Count)
{
recipeProcesses.Insert(0, UserTreeWait?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum)));
@@ -1475,38 +1485,44 @@ namespace BPASmartClient.DosingSystem
{
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress) && doDeviceCount.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
{
//判断桶到位 和 状态为等待配料。
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount > 0)
{
int doCount = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount - 1));
if (doCount >= 0 && doCount < Recipes.Count)
{
//根据物料名称查找
var res = Recipes.ElementAt(doCount).RawMaterials?.ToList().FindAll(a => a.RawMaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
foreach (RawMaterialModel item in res)
{
//可能是多个桶都需要下同一种料,根据已通过桶数和当前物料信息的通号做对比。
if (item != null && item.Loc == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail)
{
DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
if (deviceSet != null && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].IsConnected == true)
{
MessageNotify.GetInstance.runLogs.Add(new RunLog() { RunLogInfo = $"下发配料信息{Recipes.ElementAt(doCount).RecipeName}到设备{DeviceInquire.GetInstance.devices[i].DeviceName}",Time = DateTime.Now.ToString() });
var deviceModbus = DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp;
MessageNotify.GetInstance.ShowRunLog( $"下发配料信息{Recipes.ElementAt(doCount).RecipeName}到设备{DeviceInquire.GetInstance.devices[i].DeviceName}");
//传送带停止
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
deviceModbus.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
//设置下料重量
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.WeightSet.ToAdd(), item.RawMaterialWeight);
deviceModbus.Write<float>(DeviceAddress.WeightSet.ToAdd(), item.RawMaterialWeight);
//设置慢加重量
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowlyAddWeight);
deviceModbus.Write<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowlyAddWeight);
//设置快慢加速度
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowAcceleration);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.RapidAcceleration.ToAdd(), deviceSet.RapidAcceleration);
deviceModbus.Write<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowAcceleration);
deviceModbus.Write<float>(DeviceAddress.RapidAcceleration.ToAdd(), deviceSet.RapidAcceleration);
//设置提前关阀重量
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.PreCloseValveWeight.ToAdd(), deviceSet.PreCloseValveWeight);
deviceModbus.Write<float>(DeviceAddress.PreCloseValveWeight.ToAdd(), deviceSet.PreCloseValveWeight);
//设置伺服手动速度
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.ServoManualSpeed.ToAdd(), deviceSet.ServoManualSpeed);
deviceModbus.Write<float>(DeviceAddress.ServoManualSpeed.ToAdd(), deviceSet.ServoManualSpeed);
//设置料仓上下限重量
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.SiloUpperLimitWeight.ToAdd(), deviceSet.SiloUpperLimitWeight);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), deviceSet.LowerLimitWeightOfSilo);
deviceModbus.Write<float>(DeviceAddress.SiloUpperLimitWeight.ToAdd(), deviceSet.SiloUpperLimitWeight);
deviceModbus.Write<float>(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), deviceSet.LowerLimitWeightOfSilo);
//开始配料信号
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), (ushort)1);
deviceModbus.Write<ushort>(DeviceAddress.Start.ToAdd(), (ushort)1);
////设置搅拌速度
//DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<int>(DeviceAddress.StirringSpeed.ToAdd(), deviceSet.StirringSpeed);
}
@@ -1530,9 +1546,10 @@ namespace BPASmartClient.DosingSystem
{
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
{
//90 是中转流水线的IP。
if (DeviceInquire.GetInstance.devices[i].IpAddress == "192.168.2.90")
{
//如果中转线的下一个设备有桶的话,就先把中专线停住。
if (DeviceInquire.GetInstance.DeviceLists[ DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1)
{
SimensSend.GetInstance.SendSimens.Write("DB1.DBX702.0", 0);


+ 3
- 0
DosingSystem/Model/DeviceInquire.cs 파일 보기

@@ -27,6 +27,9 @@ namespace BPASmartClient.DosingSystem
private DeviceInquire() { }

string IPSegment = "192.168.2.";
/// <summary>
/// 设备列表集合
/// </summary>
public ConcurrentDictionary<string, DeviceStatus> DeviceLists = new ConcurrentDictionary<string, DeviceStatus>();
List<string> InvalidIP = new List<string>();//无效 IP 集合
List<string> IPLists = new List<string>();//启动 Ping 任务IP集合


불러오는 중...
취소
저장