@@ -403,14 +403,14 @@ namespace BPASmartClient.DosingSystem
});
});
UserTreeWait.Add(new RecipeModel { RecipStatus = "等待制作", SerialNum = RecipeNames.Count, RecipeName = RecipeName, RawMaterials = raw });
int count = RecipeNames.Count(p=>p == RecipeName);
UserTreeWait.Add(new RecipeModel { RecipStatus = "等待制作", SerialNum = count, RecipeName = RecipeName, RawMaterials = raw });
send = true;
});
}
}
public ConcurrentDictionary<string, int> doDeviceCount = new ConcurrentDictionary<string, int>();
int dd = 0;
@@ -433,66 +433,33 @@ namespace BPASmartClient.DosingSystem
public void ShutDown()
{
TaskManage.GetInstance.StopTask("设备下发配方");
TaskManage.GetInstance.StopTask("监控允许配料点位 ");
TaskManage.GetInstance.StopTask("下料 控制");
TaskManage.GetInstance.StopTask("配料机设备上线监听 ");
TaskManage.GetInstance.StopTask("起始传送带 控制");
List<Task> tasks = new();
tasks.Add(SimensSend.GetInstance.SendSimens.WriteAsync("M0.0", false));
tasks.Add(SimensSend.GetInstance.SendSimens.WriteAsync("M0.1", false));
/*var writeTasks = DeviceInquire.GetInstance.DeviceLists.Values.Select(async item =>
tasks.Add(new Task(() =>
{
bool writeSuccessful = false;
int maxRetries = 3;
int retryCount = 0;
while (item.deviceStatus.TranspportSwitch == (ushort)1)
{
item.modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
}
while (!writeSuccessful && retryCount < maxRetries)
if (DeviceInquire.GetInstance.devices.Count==18)
{
var result = await item.modbusTcp.WriteAsync<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
if (result.IsSuccess)
{
writeSuccessful = true;
}
else
Parallel.ForEach(DeviceInquire.GetInstance.devices, item =>
{
retryCount++ ;
}
DeviceInquire.GetInstance.DeviceLists[item.IpAddress].ResetAll().Wait();
});
}
});*/
/*tasks.AddRange(writeTasks);*/
}));
Task.WaitAll(tasks.ToArray(), TimeSpan.FromSeconds(5));
}
public ConcurrentDictionary<string, bool> rTrig = new ConcurrentDictionary<string, bool>();
bool send = false;
public ConcurrentDictionary<string, bool> recipeSend = new ConcurrentDictionary<string, bool>();
bool stop = true;
bool start_Send = false;
public void Mr_state()
{
for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
{
string ip = DeviceInquire.GetInstance.devices[i].IpAddress;
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(ip))
{
DeviceInquire.GetInstance.DeviceLists[ip].startAction = ((s, t) =>
{
DeviceInquire.GetInstance.DeviceLists[ip].modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), 0);
recipeProcesses.ElementAt(s).RawMaterials.ElementAt(t).RecipeStatus = 2;
recipeProcesses.ElementAt(s).RawMaterials.ElementAt(t).Status = (Status)1;
MessageNotify.GetInstance.ShowRunLog($"设备{DeviceInquire.GetInstance.DeviceLists[ip].DeviceName}配料状态:正在配料");
DeviceInquire.GetInstance.DeviceLists[ip].recipeC = -1;
});
}
}
}
bool allowStart=false;
public ConcurrentDictionary<string, bool> start_Stop = new ConcurrentDictionary<string, bool>();
bool start_Send = false;
int pas = 1;
@@ -500,14 +467,6 @@ namespace BPASmartClient.DosingSystem
{
recipeProcesses.Clear();
recipeProcesses = Json<OldRecipe>.Data.Recipes;
/*recipeProcesses = new ObservableCollection<RecipeModel>(Json<OnRecipe>.Data.Recipes.ToList()?.FindAll(o => o.RecipStatus == "正在制作"));
foreach (var recipe in recipeProcesses)
{
RecipeNames.Enqueue(recipe.RecipeName);
}
App.Current.Dispatcher.Invoke(() => { recipeProcesses.Add(Recipes.ElementAt(0)); });*/
TaskManage.GetInstance.StartLong(() =>
{
@@ -523,9 +482,20 @@ namespace BPASmartClient.DosingSystem
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
{
string ip = DeviceInquire.GetInstance.devices[i].IpAddress;
if (doDeviceCount .ContainsKey(ip))
if (!recipeSend .ContainsKey(ip))
{
recipeSend.TryAdd(ip, false);
}
if (doDeviceCount.ContainsKey(ip)&& recipeSend.ContainsKey(ip))
{
if (send)
{
recipeSend.ToList().ForEach(o =>
{
recipeSend.TryUpdate(o.Key, true, false);
});
send = false;
}
int index = 0;//配方索引
int maxPail = 0;//最大桶数
List<int> device_Loc = new List<int>();//下发桶号
@@ -551,6 +521,7 @@ namespace BPASmartClient.DosingSystem
}
if (recipeNameNum == 0)
{
recipeSend.TryUpdate(ip, false, true);
index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(recipeNameNum));
if (index >= 0 && dnum > 0)
{
@@ -602,10 +573,11 @@ namespace BPASmartClient.DosingSystem
}
}
}
if (recipeNameNum > 0 && recipeNameNum <= RecipeNames.Count)
bool pailAv = DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.PailArrive;
if (recipeNameNum > 0 && recipeNameNum <= RecipeNames.Count&&!pailAv )
{
index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(recipeNameNum - 1));
if (index >= 0 && dnum > 0)
{
foreach (var rawMaterial in Recipes.ElementAt(index).RawMaterials)
@@ -615,47 +587,65 @@ namespace BPASmartClient.DosingSystem
maxPail = rawMaterial.Loc;
}
}
int recipecount = recipeProcesses.Count - (recipeNameNum - UserTreeCompelete.Count);
int re = 0;
/*if (recipeNameNum - (UserTreeCompelete.Count + recipeProcesses.Count) == 0)
{
re = -1;
recipNameNum_1 = recipeNameNum;
}*/
if (recipecount < recipeProcesses.Count && recipecount >= 0)
{
re = recipeProcesses.ElementAt(recipecount).RawMaterials.ToList().FindIndex(a => a.RawMaterialName == DeviceInquire.GetInstance.DeviceLists[ip].DeviceName && a.Loc == DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.PassPail && a.RecipeStatus != 3);
}
else
{
re = -1;
recipNameNum_1 = recipeNameNum;
}
if (recipeSend[ip])
{
if (re<0)
{
re = -1;
recipNameNum_1 = recipeNameNum;
}
}
if (dnum == 18 && maxPail <= passPail)
{
App.Current.Dispatcher.Invoke(() =>
{
RecipeModel recipe = recipeProcesses?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum - 1));
if (recipe != null)
if (recipecount < recipeProcesses.Count && recipecount >= 0)
{
int res = recipe.RawMaterials.ToList().FindIndex(a => a.RecipeStatus != 3);
if (res < 0)
RecipeModel recipe = recipeProcesses.ElementAt(recipecount);
if (recipe != null)
{
recipe.RecipStatus = "制作完成";
UserTreeCompelete.Insert(0, recipe);
recipeProcesses.RemoveAt(recipeProcesses.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum - 1)));
Json<OnRecipe>.Data.Recipes = recipeProcesses;
Json<OnRecipe>.Save();
Json<OldRecipe>.Data.Recipes.Insert(0, recipe);
Json<OldRecipe>.Save();
ActionManage.GetInstance.Send("配料完成", UserTreeCompelete);
ActionManage.GetInstance.Send("历史记录", Json<OldRecipe>.Data.Recipes);
int res = recipe.RawMaterials.ToList().FindIndex(a => a.RecipeStatus != 3);
if (res < 0)
{
recipe.RecipStatus = "制作完成";
UserTreeCompelete.Insert(0, recipe);
recipeProcesses.RemoveAt(recipecount);
Json<OnRecipe>.Data.Recipes = recipeProcesses;
Json<OnRecipe>.Save();
Json<OldRecipe>.Data.Recipes.Insert(0, recipe);
Json<OldRecipe>.Save();
ActionManage.GetInstance.Send("配料完成", UserTreeCompelete);
ActionManage.GetInstance.Send("历史记录", Json<OldRecipe>.Data.Recipes);
}
}
}
});
}
int recipecount = recipeProcesses.Count - (recipeNameNum - UserTreeCompelete.Count);
int re = 0;
if (recipeNameNum - UserTreeCompelete.Count == 0)
{
re = -1;
}
if (recipecount < recipeProcesses.Count && recipecount >= 0)
{
re = recipeProcesses.ElementAt(recipecount).RawMaterials.ToList().FindIndex(a => a.RawMaterialName == DeviceInquire.GetInstance.DeviceLists[ip].DeviceName && a.Loc == DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.PassPail && a.RecipeStatus != 3);
});
}
if (maxPail <= passPail && recipeNameNum < RecipeNames.Count && !DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.PailArrive&&re<0&& recipNameNum_1==recipeNameNum)
if (maxPail <= passPail && recipeNameNum < RecipeNames.Count &&re<0&& recipNameNum_1==recipeNameNum)
{
SimensSend.GetInstance.SendSimens.Write<ushort>($"DB1.DBW{810 + 2 * (dnum - 1)}", 0);
MessageNotify.GetInstance.ShowRunLog($"设备{dnum}桶数已清零");
recipeSend.TryUpdate(ip, false, true);
doDeviceCount.TryUpdate(ip, recipeNameNum + 1, doDeviceCount[ip]);
recipeNameNum = doDeviceCount[ip];
index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(recipeNameNum - 1));
@@ -679,7 +669,7 @@ namespace BPASmartClient.DosingSystem
{
App.Current.Dispatcher.Invoke(() =>
{
RecipeModel recipe = UserTreeWait?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum - 1) );
RecipeModel recipe = UserTreeWait.ElementAt(0 );
if (recipe != null)
{
recipe.RecipStatus = "正在配料";
@@ -687,7 +677,7 @@ namespace BPASmartClient.DosingSystem
ActionManage.GetInstance.Send("正在配料", recipeProcesses);
/* Json<OnRecipe>.Data.Recipes.Insert(0, recipe);
Json<OnRecipe>.Save();*/
UserTreeWait.RemoveAt(UserTreeWait.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum - 1)) );
UserTreeWait.RemoveAt(0 );
}
@@ -796,7 +786,6 @@ namespace BPASmartClient.DosingSystem
if ( rep== DeviceInquire.GetInstance.devices.Count&&!allowStart)
{
App.Current.Dispatcher.Invoke(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"可以开始放入配料桶!"); });
/*Mr_state();*/
allowStart = true;
}
}
@@ -857,406 +846,6 @@ namespace BPASmartClient.DosingSystem
}
Thread.Sleep(100);
}, "起始传送带控制");
/*TaskManage.GetInstance.StartLong(() =>
{
for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
{
string ip = DeviceInquire.GetInstance.devices[i].IpAddress;
if (!start_Stop.ContainsKey(ip))
{
start_Stop.TryAdd(ip,false);
}
int dnum = DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.DeviceNum;
int passPail = -1;
string nextIp = "";
if (dnum < 18)
{
nextIp = $"192.168.2.{(dnum + 1) * 10}";
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(nextIp))
{
passPail = DeviceInquire.GetInstance.DeviceLists[nextIp].deviceStatus.PassPail;
}
}
else
{
passPail = 0;
}
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(ip) &&doDeviceCount.ContainsKey(ip))
{
int recipeNameNum = doDeviceCount[ip];
bool finish_mt = DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.Finish_mt;
bool recipe_fn = DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.RecipeFinish;
if (finish_mt && passPail==0&& DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.PailArrive)
{
int recipecount = recipeProcesses.Count - (recipeNameNum - UserTreeCompelete.Count);
if (recipecount < recipeProcesses.Count && recipecount >= 0)
{
int re_1 = recipeProcesses.ElementAt(recipecount).RawMaterials.ToList().FindIndex(a => a.RawMaterialName == DeviceInquire.GetInstance.DeviceLists[ip].DeviceName && a.Loc == DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.PassPail && a.RecipeStatus == 2);
if (re_1 >= 0)
{
Thread.Sleep(200);
float xx = DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.CutWeightFeedback;
recipeProcesses.ElementAt(recipecount).RawMaterials.ElementAt(re_1).TotalWeight = xx;
float t = Math.Abs(recipeProcesses.ElementAt(recipecount).RawMaterials.ElementAt(re_1).TotalWeight - recipeProcesses.ElementAt(recipecount).RawMaterials.ElementAt(re_1).RawMaterialWeight);
if (t > 2)
{
SimensSend.GetInstance.SendSimens.Write<bool>("M11.2", true);
while (!MessageNotify.GetInstance.ShowDialog($"设备{dnum}物料下料超出范围报警,请处理后点击确认!", DialogType.Warning))
{
App.Current.Dispatcher.Invoke(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"需确认处理后才能继续运行!"); });
}
SimensSend.GetInstance.SendSimens.Write<bool>("M11.2", false);
}
int status = 2;
while (status != 3)
{
recipeProcesses.ElementAt(recipecount).RawMaterials.ElementAt(re_1).RecipeStatus = 3;
recipeProcesses.ElementAt(recipecount).RawMaterials.ElementAt(re_1).Status = (Status)2;
status = recipeProcesses.ElementAt(recipecount).RawMaterials.ElementAt(re_1).RecipeStatus;
}
MessageNotify.GetInstance.ShowRunLog($"设备{dnum}配料状态:完成配料");
Json<OnRecipe>.Data.Recipes = recipeProcesses;
Json<OnRecipe>.Save();
while (finish_mt)
{
ushort reset = 0;
reset = reset.SetBitValue(1, true);
DeviceInquire.GetInstance.DeviceLists[ip].modbusTcp.Write<ushort>(DeviceAddress.Finish_Point.ToAdd(), reset);
Thread.Sleep(10);
finish_mt = DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.Finish_mt;
}
DeviceInquire.GetInstance.DeviceLists[ip].modbusTcp.Write<ushort>(DeviceAddress.Finish_Point.ToAdd(), 0);
MessageNotify.GetInstance.ShowRunLog($"设备{dnum}配料完成已复位");
while (!recipe_fn)
{
SimensSend.GetInstance.SendSimens.Write<bool>($"DB1.DBX70{(int)((dnum - 1) / 8)}.{(dnum - 1) % 8}", true);
Thread.Sleep(10);
recipe_fn = DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.RecipeFinish;
}
MessageNotify.GetInstance.ShowRunLog($"设备{dnum}传送带置为true");
ActionManage.GetInstance.Send("正在配料", recipeProcesses);
MessageNotify.GetInstance.ShowRunLog($"设备{ip}已下料{recipeProcesses.ElementAt(recipecount).RawMaterials.ElementAt(re_1).TotalWeight}g");
MessageNotify.GetInstance.ShowRunLog($"设备{dnum}下发完成信号");
while (recipe_fn)
{
SimensSend.GetInstance.SendSimens.Write<bool>($"DB1.DBX70{(int)((dnum - 1) / 8)}.{(dnum - 1) % 8}", false);
Thread.Sleep(10);
recipe_fn = DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.RecipeFinish;
}
MessageNotify.GetInstance.ShowRunLog($"设备{dnum}传送带置为false");
MessageNotify.GetInstance.ShowRunLog($"设备{dnum}确认配料完成,输出通过桶数{DeviceInquire.GetInstance.DeviceLists[ip].deviceStatus.PassPail},输出当前配方数{recipeNameNum},输出总配方数{RecipeNames.Count},输出允许配料状态{DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive}");
}
}
}
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus != 1 && start_Stop[ip])
{
Thread.Sleep(50);
while (!DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), 0).IsSuccess)
{
MessageNotify.GetInstance.ShowRunLog($"设备{dnum}下发开始配料复位信号失败");
}
start_Stop.TryUpdate(ip, false, true);
MessageNotify.GetInstance.ShowRunLog($"设备{dnum}下发开始配料复位信号");
}
}
}
Thread.Sleep(10);
}, "下料控制");
MessageNotify.GetInstance.ShowRunLog($"下料控制运行");*/
//弃用
/*TaskManage.GetInstance.StartLong(() =>
{
for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
{
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 && doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress] >= 0)
{
int recipeNameNum = doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress];
int doCount = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(recipeNameNum));
var res = Recipes.ElementAt(doCount).RawMaterials?.ToList().Find(a => a.RawMaterialName == DeviceInquire.GetInstance.devices[i].DeviceName && a.Loc == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail);
if (res != null)
{
var deviceModbus = DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp;
deviceModbus.Write<float>(DeviceAddress.WeightSet.ToAdd(), res.RawMaterialWeight);
deviceModbus.Write<bool>(DeviceAddress.Start.ToAdd(), true);
}
}
}
}
Thread.Sleep(10);
}, "下发设备参数");*/
/*DeviceStatus nextDevice = new DeviceStatus();
TaskManage.GetInstance.StartLong(() =>
{
for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
{
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
{
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);
}
else
{
SimensSend.GetInstance.SendSimens.Write("DB1.DBW104", (ushort)1400);
SimensSend.GetInstance.SendSimens.Write("DB1.DBX702.0", 1);
}
}
if (DeviceInquire.GetInstance.devices[i].IpAddress != $"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}")
{
ushort deviceNum = DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DeviceNum;
string nextIp = "";
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey($"{Json<DevicePar>.Data.BaseParModel.NetworkSegAddress}{(deviceNum + 1) * 10}") && deviceNum != 0)
{
nextIp = $"{Json<DevicePar>.Data.BaseParModel.NetworkSegAddress}{(deviceNum + 1) * 10}";
}
if (nextIp != "")
{
//if (DeviceInquire.GetInstance.DeviceLists["192.168.2.10"].deviceStatus.RunStatus == 1 || DeviceInquire.GetInstance.DeviceLists["192.168.2.10"].deviceStatus.RunStatus == 3)
//{
// DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 1000);
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
//}
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1 || DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3)
{
if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1 && DeviceInquire.GetInstance.DeviceLists[nextIp].deviceStatus.PailArrive == 1)
{
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
}
else
{
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 600);
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1);
}
}
else
{
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
//传送带停止
}
//DeviceInquire.GetInstance.DeviceLists["192.168.2.130"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 1000);
//DeviceInquire.GetInstance.DeviceLists["192.168.2.130"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
//else if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i + 1].IpAddress].deviceStatus.PailArrive == 1)
//{
// //传送带运行
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), (ushort)1);
// DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), deviceSet.SendSp);
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
//}
}
else
{
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
}
}
else
{
var runstatus = DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount) * 10}"].deviceStatus.RunStatus;
if (runstatus == 1 || runstatus == 3)
{
if ((SimensSend.GetInstance.sendCtrlModel.SendInfo && DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount) * 10}"].deviceStatus.PailArrive == 1))
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
}
else
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 600);
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1);
}
}
else
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
}
}
}
}
Thread.Sleep(10);
}, "控制传送带");*/
#region 弃用配料流程
//弃用配料流程
//TaskManage.GetInstance.StartLong(() =>
//{
// if (RecipeNames.Count > 0)
// {
// SimensSend.GetInstance.SendSimens.Write("M0.0", true);
// SimensSend.GetInstance.SendSimens.Write("M0.1", true);
// if (DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].deviceStatus.MaxPassPail != 0 && DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].deviceStatus.MaxPassPail == DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].deviceStatus.PassPail && DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].deviceStatus.RunStatus == 1)
// {
// recipeProcesses.Remove(recipeProcesses.Last());
// UserTreeCompelete.Insert(0, recipeProcesses.Last());
// }
// for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
// {
// if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
// {
// if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail == 0 || 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|| recipeProcesses.Count==0)
// {
// int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(0));
// if (index >= 0 && index < Recipes.Count)
// {
// App.Current.Dispatcher.Invoke(new Action(() =>
// {
// if (UserTreeWait.Count > 0)
// {
// recipeProcesses.Insert(0, UserTreeWait?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(0)));
// UserTreeWait.RemoveAt(UserTreeWait.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(0)));
// }
// }));
// int maxPail = 0;
// foreach (var rawMaterial in Recipes.ElementAt(index).RawMaterials)
// {
// if (rawMaterial.Loc > maxPail)
// {
// maxPail = rawMaterial.Loc;
// }
// }
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.DeletePassPail.ToAdd(), 1);
// //Thread s = new Thread(() => { mmm(); });
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.MaxPail.ToAdd(), (ushort)maxPail);
// }
// }
// if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1)
// {
// int doCount = Array.FindIndex(Recipes.ToArray(), p => p.SerialNum == (int)DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount-1) ;
// if (doCount >=0)
// {
// 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].modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), (ushort)1);
// //传送带停止
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
// //设置下料重量
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.WeightSet.ToAdd(), item.RawMaterialWeight);
// //设置慢加重量
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.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);
// //设置提前关阀重量
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.PreCloseValveWeight.ToAdd(), deviceSet.PreCloseValveWeight);
// //设置伺服手动速度
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.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);
// ////设置搅拌速度
// //DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<int>(DeviceAddress.StirringSpeed.ToAdd(), deviceSet.StirringSpeed);
// }
// }
// }
// }
// }
// }
// if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail != 0 && (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail))
// {
// string passName = RecipeNames.ElementAt(0);
// RecipeNames.TryDequeue(out passName);
// }
// if (DeviceInquire.GetInstance.devices[i].IpAddress != $"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}")
// {
// if (DeviceInquire.GetInstance.DeviceLists["192.168.2.10"].deviceStatus.RunStatus == 1 || DeviceInquire.GetInstance.DeviceLists["192.168.2.10"].deviceStatus.RunStatus == 3)
// {
// DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 1000);
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
// }
// //if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1 || DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3)
// //{
// // DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
// // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 1000);
// // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
// //}
// //DeviceInquire.GetInstance.DeviceLists["192.168.2.130"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 1000);
// //DeviceInquire.GetInstance.DeviceLists["192.168.2.130"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
// //else if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i + 1].IpAddress].deviceStatus.PailArrive == 1)
// //{
// // //传送带运行
// // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), (ushort)1);
// // DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
// // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), deviceSet.SendSp);
// // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
// //}
// else
// {
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
// //传送带停止
// }
// }
// else
// {
// if (SimensSend.GetInstance.sendCtrlModel.Stop)
// {
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
// }
// else
// {
// DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
// }
// //传送带终点为3则传送带停止,小于3则按照出料状态运行
// }
// }
// }
// }
// Thread.Sleep(10);
//}, "启动配方下发", true);
#endregion
}