终端一体化运控平台
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

832 Zeilen
53 KiB

  1. //#define Debug
  2. extern alias aliyun;
  3. using BPA.Helper;
  4. using BPASmartClient.CustomResource.Pages.Model;
  5. using BPASmartClient.CustomResource.UserControls;
  6. using BPASmartClient.CustomResource.UserControls.MessageShow;
  7. using BPASmartClient.DosingSystem.ViewModel;
  8. using BPASmartClient.Model;
  9. using System;
  10. using System.Collections.Concurrent;
  11. using System.Collections.ObjectModel;
  12. using System.Collections.Specialized;
  13. using System.Diagnostics;
  14. using System.Linq;
  15. using System.Threading;
  16. using System.Threading.Tasks;
  17. using aliyun.uPLibrary.Networking.M2Mqtt.Messages;
  18. using System.Collections.Generic;
  19. using aliyun::BPA.PahoMQ;
  20. using System.Configuration;
  21. using BPA.Communication;
  22. using Newtonsoft.Json;
  23. using System.Reflection;
  24. using System.Text;
  25. using BPASmartClient.DosingSystem.Model;
  26. using Microsoft.EntityFrameworkCore.Metadata.Internal;
  27. using System.Collections;
  28. using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
  29. using System.Windows.Navigation;
  30. using System.Text.RegularExpressions;
  31. using static System.Resources.ResXFileRef;
  32. using BPASmartClient.DosingSystem.Model.Dto;
  33. using BPASmartClient.DosingSystem.Model.MQTT;
  34. namespace BPASmartClient.DosingSystem
  35. {
  36. /// <summary>
  37. /// 业务逻辑执行类
  38. /// </summary>
  39. public class ExcuteControl
  40. {
  41. private static ExcuteControl Instance;
  42. public static ExcuteControl GetInstance => Instance ??= new ExcuteControl();
  43. public ConcurrentDictionary<string, aliyun.BPA.PahoMQ.MessageHandler> mqttCollection = new ConcurrentDictionary<string, aliyun.BPA.PahoMQ.MessageHandler>();
  44. public ConcurrentDictionary<string, string> aliyun = new ConcurrentDictionary<string, string>();
  45. public ObservableCollection<RecipeModel> Recipes { get; set; } = Json<LocalRecipe>.Data.Recipes;
  46. public ObservableCollection<StockStatusModel> StockStatus = new ObservableCollection<StockStatusModel>();
  47. public string CurrentRecipeName { get; set; }
  48. /// <summary>
  49. /// 当前正在制作的配方
  50. /// </summary>
  51. public ObservableCollection<RecipeModel> recipeProcesses { get; set; } = new ObservableCollection<RecipeModel>();
  52. /// <summary>
  53. /// 等待制作的配方
  54. /// </summary>
  55. public ObservableCollection<RecipeModel> UserTreeWait { get; set; } = new ObservableCollection<RecipeModel>();
  56. /// <summary>
  57. /// 已完成的配方
  58. /// </summary>
  59. public ObservableCollection<RecipeModel> UserTreeCompelete { get; set; } = new ObservableCollection<RecipeModel>();
  60. public ConcurrentQueue<string> RecipeNames = new ConcurrentQueue<string>();
  61. /// <summary>
  62. /// 配料完成计数
  63. /// </summary>
  64. int Comcount = 0;
  65. public static bool PropertySet = false;//云端属性设置回调主题订阅标志
  66. public static bool PropertyReport = false; //属性上报主题订阅标志
  67. public static bool EventReport = false; //事件上报主题订阅标志
  68. public static bool ServiceCall = false;//服务调用回调主题订阅标志
  69. public NameValueCollection produtInfo;
  70. public NameValueCollection mqttInfo;
  71. public NameValueCollection ConveyerInfo;
  72. public NameValueCollection ServicesInfo;
  73. public bool AliyunIsConnect = false;
  74. public ExcuteControl()
  75. {
  76. ActionManage.GetInstance.Register<object>(new Action<object>((o) =>
  77. {
  78. if (o != null && o is string recipeName)
  79. {
  80. RecipeSend(recipeName);
  81. }
  82. }), "配方下发");
  83. ActionManage.GetInstance.Register<object>(new Action<object>((ob) =>
  84. {
  85. if (ob != null && ob is string recipeName)
  86. {
  87. CancelRecipe(recipeName);
  88. }
  89. }), "取消配方");
  90. //AliYunInit();
  91. //RecipeRun();
  92. //BusinessExcute();
  93. MatchRun();
  94. //ConveyerPropertyReport();
  95. //ThreadTaskInit();
  96. #if Debug
  97. Task.Run(() => {
  98. while (true)
  99. {
  100. if (AliyunIsConnect)
  101. {
  102. for (int i = 0; i < 6; i++)
  103. {
  104. AliyunEventReport($"192.168.0.{i+1}0", new AliyunStockEventReportModel { Result = "1" }, "StockJerk1StatusEvent", AliyunMaterialModelType.StockModel);
  105. AliyunEventReport($"192.168.0.{i + 1}0", new AliyunStockEventReportModel { Result = "1" }, "StockServoFalutEvent", AliyunMaterialModelType.StockModel);
  106. AliyunEventReport($"192.168.0.{i + 1}0", new AliyunStockEventReportModel { Result = "1" }, "StockJerk2StatusEvent", AliyunMaterialModelType.StockModel);
  107. AliyunEventReport($"192.168.0.{i + 1}0", new AliyunStockEventReportModel { Result = "1" }, "StockUpLimitEvent", AliyunMaterialModelType.StockModel);
  108. AliyunEventReport($"192.168.0.{i + 1}0", new AliyunStockEventReportModel { Result = "1" }, "StockDownLimitEvent", AliyunMaterialModelType.StockModel);
  109. AliyunStockPropertyReportModel model = new AliyunStockPropertyReportModel();
  110. model.StockRealWeight = 1;
  111. model.BucketRealWeight = 2;
  112. model.StockDeviceNum = 2;
  113. model.StockDeviceName = "测试";
  114. model.StockWorkModel = 0;
  115. model.StockSlowlyAddWeight = 6;
  116. model.StockPreCloseValueWeight = 7;
  117. model.StockRapidAcceleration = 46;
  118. model.StockSlowAcceleration = 24;
  119. model.StockServoManualSpeed = 35;
  120. model.StockUpperLimitWeight = 57;
  121. model.StockLowerLimitWeight = 34;
  122. model.StockStirringSpeed = 54;
  123. model.StockMaterialType = "粉体";
  124. model.StockBatchStatus = "待机";
  125. StokcPropertyReport($"192.168.0.{i + 1}0", model);
  126. }
  127. AliyunConveyerPropertyReportModel model1 = new AliyunConveyerPropertyReportModel();
  128. model1.TopBucketControlStatus = 1;
  129. model1.DownBucketControlStatus =1;
  130. model1.RunStatus = 1;
  131. model1.WorkModel = 1;
  132. model1.TopBucketSigleCheck = 1;
  133. model1.ButtonBucketSigleCheck = 1;
  134. model1.ConveyerOnlineStatus =1;
  135. var mqdeviceTestProperty = new PostPropertyParams<AliyunConveyerPropertyReportModel>();
  136. mqdeviceTestProperty.sys = new Sys { ack = 1 };
  137. mqdeviceTestProperty.method = "thing.event.property.post";
  138. mqdeviceTestProperty.version = "1.0";
  139. mqdeviceTestProperty.ModelName = $"{produtInfo.Get("Conveyer")}";
  140. mqdeviceTestProperty.Model = model1;
  141. mqdeviceTestProperty.Init();
  142. var message = JsonConvert.SerializeObject(mqdeviceTestProperty);
  143. var topic = $"/sys/{produtInfo.Get("ProductKey")}/Conveyer/thing/event/property/post";//发布主题
  144. var topicReply = $"/sys/{produtInfo.Get("ProductKey")}/Conveyer/thing/event/property/post_reply";//订阅主题
  145. if (mqttCollection.ContainsKey("Conveyer"))
  146. {
  147. try
  148. {
  149. mqttCollection["Conveyer"].Publish((op) =>
  150. {
  151. op.Message = message;
  152. op.Topic = topic;
  153. op.TopicReply = topicReply;
  154. //if (!PropertyReport)
  155. //{
  156. // op.ThresholdCallback += MqttPostProperty_MqttMsgPublishReceived; // MqttPostProperty_MqttMsgPublishReceived;
  157. // PropertyReport = true;
  158. //}
  159. });
  160. }
  161. catch (Exception)
  162. {
  163. //throw;
  164. }
  165. }
  166. SystemEventReport("ProcessRecipe", new { RecipeName = "测试5" });//正在执行配方上报
  167. if (UserTreeWait.Count > 0)
  168. {
  169. string[] recipeNames = new string[UserTreeWait.Count];
  170. for (int i = 0; i < recipeNames.Length; i++)
  171. {
  172. recipeNames[i] = UserTreeWait.ElementAt(i).RecipeName;
  173. }
  174. SystemEventReport("WaitProcessRecipe", new { RecipeNames = recipeNames });//等待执行配方上报
  175. }
  176. else
  177. {
  178. SystemEventReport("WaitProcessRecipe", new { RecipeNames = new string[] { } });//等待执行配方上报
  179. }
  180. }
  181. Thread.Sleep(5000);
  182. }
  183. });
  184. #endif
  185. }
  186. /// <summary>
  187. /// 料仓属性上报
  188. /// </summary>
  189. /// <param name="ipaddres"></param>
  190. /// <param name="model"></param>
  191. public void StokcPropertyReport<T>(string ipaddres, T model)
  192. {
  193. var mqdeviceTestProperty = new PostPropertyParams<T>();
  194. mqdeviceTestProperty.sys = new Sys { ack = 1 };
  195. mqdeviceTestProperty.method = "thing.event.property.post";
  196. mqdeviceTestProperty.version = "1.0";
  197. mqdeviceTestProperty.ModelName = $"{produtInfo.Get("Stock")}";
  198. mqdeviceTestProperty.Model= model;
  199. mqdeviceTestProperty.Init();
  200. var message = JsonConvert.SerializeObject(mqdeviceTestProperty);
  201. var topic = $"/sys/{produtInfo.Get("ProductKey")}/{aliyun[ipaddres]}/thing/event/property/post";//发布主题
  202. var topicReply = $"/sys/{produtInfo.Get("ProductKey")}/{aliyun[ipaddres]}/thing/event/property/post_reply";//订阅主题
  203. if (mqttCollection.ContainsKey(aliyun[ipaddres]))
  204. {
  205. try
  206. {
  207. mqttCollection[aliyun[ipaddres]].Publish((op) =>
  208. {
  209. op.Message = message;
  210. op.Topic = topic;
  211. op.TopicReply = topicReply;
  212. //if (!PropertyReport)
  213. //{
  214. // op.ThresholdCallback += MqttPostProperty_MqttMsgPublishReceived; // MqttPostProperty_MqttMsgPublishReceived;
  215. // PropertyReport = true;
  216. //}
  217. });
  218. }
  219. catch (Exception)
  220. {
  221. //throw;
  222. }
  223. }
  224. }
  225. /// <summary>
  226. /// 业务系统属性上报
  227. /// </summary>
  228. public void SystemPropertyReport<T>(T model)
  229. {
  230. var mqdeviceTestProperty = new PostPropertyParams<T>();
  231. mqdeviceTestProperty.sys = new Sys { ack = 1 };
  232. mqdeviceTestProperty.method = "thing.event.property.post";
  233. mqdeviceTestProperty.version = "1.0";
  234. mqdeviceTestProperty.Model = model;
  235. mqdeviceTestProperty.Init();
  236. var message = JsonConvert.SerializeObject(mqdeviceTestProperty);
  237. var topic = $"/sys/{produtInfo.Get("ProductKey")}/Conveyer/thing/event/property/post";//发布主题
  238. var topicReply = $"/sys/{produtInfo.Get("ProductKey")}/Conveyer/thing/event/property/post_reply";//订阅主题
  239. if (mqttCollection.ContainsKey("Conveyer"))
  240. {
  241. try
  242. {
  243. mqttCollection["Conveyer"].Publish((op) =>
  244. {
  245. op.Message = message;
  246. op.Topic = topic;
  247. op.TopicReply = topicReply;
  248. //if (!PropertyReport)
  249. //{
  250. // op.ThresholdCallback += MqttPostProperty_MqttMsgPublishReceived; // MqttPostProperty_MqttMsgPublishReceived;
  251. // PropertyReport = true;
  252. //}
  253. });
  254. }
  255. catch (Exception)
  256. {
  257. //throw;
  258. }
  259. }
  260. }
  261. /// <summary>
  262. /// 取消配方
  263. /// </summary>
  264. /// <param name="RecipeName"></param>
  265. public async void CancelRecipe(string RecipeName)
  266. {
  267. if (RecipeName != null)
  268. {
  269. //var res = MessageNotify.GetInstance.ShowDialog($"是否取消配方 【{RecipeName}】制作", DialogType.Warning);
  270. //if (res)
  271. //{
  272. int index = Recipes.ToList().FindIndex(p => p.RecipeName == RecipeName);
  273. if (index >= 0 && index < Recipes.Count)
  274. {
  275. await Task.Factory.StartNew(new Action(() =>
  276. {
  277. Recipes.ElementAt(index).IsEnable = true;
  278. Json<LocalRecipe>.Data.Recipes.ElementAt(index).IsEnable = true;
  279. Recipes.ElementAt(index).Are.Set();
  280. App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); }));
  281. //SiemensDevice.GetInstance.MySiemens.Write("M10.5", true);
  282. //MessageNotify.GetInstance.ShowRunLog($"M10.5:true");
  283. Thread.Sleep(1000);
  284. //SiemensDevice.GetInstance.MySiemens.Write("M10.5", false);
  285. //MessageNotify.GetInstance.ShowRunLog($"M10.5:false");
  286. App.Current.Dispatcher.Invoke(() =>
  287. {
  288. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方 [{RecipeName}] 取消成功");
  289. });
  290. MessageNotify.GetInstance.ShowUserLog($"取消配方制作 {RecipeName}");
  291. //取消成功
  292. }));
  293. }
  294. else
  295. {
  296. //取消失败
  297. }
  298. //}
  299. }
  300. else
  301. {
  302. MessageNotify.GetInstance.ShowUserLog($"配方 {RecipeName}取消失败");
  303. }
  304. }
  305. /// <summary>
  306. /// 配方下发
  307. /// </summary>
  308. public void RecipeSend(string RecipeName)
  309. {
  310. if (RecipeName != null)
  311. {
  312. int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeName);
  313. if (index >= 0 && index < Recipes.Count)
  314. {
  315. for (int i = 0; i < Recipes.ElementAt(index).RawMaterials.Count; i++)
  316. {
  317. string ip = Recipes.ElementAt(index).RawMaterials.ElementAt(i).DeviceIp;
  318. var device = DeviceInquire.GetInstance.GetDevice(ip);
  319. if (!device.IsConnected)
  320. {
  321. MessageNotify.GetInstance.ShowDialog($"设备 【{device.DeviceName}】 未连接,不允许下发此配方", DialogType.Error);
  322. return;
  323. }
  324. if (Recipes.ElementAt(index).RawMaterials.ElementAt(i).RawMaterialSource == 1)
  325. {
  326. if (ip == null && ip == "")
  327. {
  328. MessageNotify.GetInstance.ShowDialog($"原料 【{Recipes.ElementAt(index).RawMaterials.ElementAt(i).RawMaterialName}】配料系统无法配料,请人工配置此原料:原料{Recipes.ElementAt(index).RawMaterials.ElementAt(i).RawMaterialName},重量{Recipes.ElementAt(index).RawMaterials.ElementAt(i).RawMaterialWeight}", DialogType.Information);
  329. return;
  330. }
  331. }
  332. }
  333. Recipes.ElementAt(index).IsEnable = false;
  334. Json<LocalRecipe>.Data.Recipes.ElementAt(index).IsEnable = false;
  335. }
  336. MessageNotify.GetInstance.ShowUserLog($"下发工单 {Recipes.ElementAt(index).RecipeName}");
  337. RecipeNames.Enqueue(RecipeName);
  338. var res = Recipes.FirstOrDefault(p => p.RecipeName == RecipeName);
  339. App.Current.Dispatcher.Invoke(() => { UserTreeWait.Add(new RecipeModel { RecipStatus = "等待制作", SerialNum = UserTreeWait.Count + 1, RecipeName = RecipeName, RawMaterials = res.RawMaterials }); });
  340. }
  341. App.Current.Dispatcher.Invoke(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); });
  342. MessageNotify.GetInstance.runLogs.Add(new RunLog() { RunLogInfo = $"下发配方:{RecipeNames.Count}", Time = DateTime.Now.ToString() });
  343. }
  344. public ConcurrentDictionary<string, int> doDeviceCount = new ConcurrentDictionary<string, int>();
  345. int doDecipeCount = 0;
  346. /// <summary>
  347. /// 关闭上位机需要做的处理。
  348. /// </summary>
  349. public void ShutDown()
  350. {
  351. SimensSend.GetInstance.SendSimens.Write("M0.0", false);
  352. SimensSend.GetInstance.SendSimens.Write("M0.1", false);
  353. foreach (var item in DeviceInquire.GetInstance.DeviceLists.Values)
  354. {
  355. item.modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
  356. }
  357. TaskManage.GetInstance.StopTask("设备下发配方");
  358. TaskManage.GetInstance.StopTask("下发设备参数", () =>
  359. {
  360. });
  361. TaskManage.GetInstance.StopTask("控制传送带");
  362. }
  363. public ConcurrentDictionary<string, int> doDeviceCount = new ConcurrentDictionary<string, int>();
  364. int dd = 0;
  365. private void MatchRun()
  366. {
  367. recipeProcesses.Clear();
  368. TaskManage.GetInstance.StartLong(() =>
  369. {
  370. if (RecipeNames.Count > 0)
  371. {
  372. SimensSend.GetInstance.SendSimens.Write("M0.0", true);
  373. SimensSend.GetInstance.SendSimens.Write("M0.1", true);
  374. for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
  375. {
  376. //判断IP是否在列表中
  377. if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
  378. {
  379. //只有设备在等待配料状态才能下发数据
  380. if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1)
  381. {
  382. //判断
  383. 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)
  384. {
  385. if (doDeviceCount.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
  386. {
  387. int index = 0;
  388. int recipeNameNum = doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress];
  389. if (recipeNameNum == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount && recipeNameNum < RecipeNames.Count)
  390. {
  391. //查找
  392. index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(recipeNameNum));
  393. if (index >= 0 && index < Recipes.Count)
  394. {
  395. int maxPail = 0;
  396. //查找配方的最大桶号。
  397. foreach (var rawMaterial in Recipes.ElementAt(index).RawMaterials)
  398. {
  399. if (rawMaterial.Loc > maxPail)
  400. {
  401. maxPail = rawMaterial.Loc;
  402. }
  403. }
  404. //清除下位设备的最大桶号,下位设备认为配方制作完一个了。
  405. DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.DeletePassPail.ToAdd(), 1);
  406. DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.MaxPail.ToAdd(), (ushort)maxPail);
  407. doDeviceCount.TryUpdate(DeviceInquire.GetInstance.devices[i].IpAddress, recipeNameNum + 1, doDeviceCount[DeviceInquire.GetInstance.devices[i].IpAddress]);
  408. App.Current.Dispatcher.Invoke(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方{RecipeNames.ElementAt(recipeNameNum)}{recipeNameNum}下发到设备{DeviceInquire.GetInstance.devices[i].DeviceName}"); });
  409. if (doDeviceCount.ContainsKey("192.168.2.10") && UserTreeWait.Count > 0 && doDeviceCount["192.168.2.10"] > recipeProcesses.Count)
  410. {
  411. App.Current.Dispatcher.Invoke(() =>
  412. {
  413. recipeProcesses.Insert(0, UserTreeWait?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum)));
  414. UserTreeWait.RemoveAt(UserTreeWait.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum)));
  415. });
  416. }
  417. if (DeviceInquire.GetInstance.devices[i].IpAddress == "192.168.2.180" && recipeNameNum > 1 && recipeProcesses.Count > 0)
  418. {
  419. App.Current.Dispatcher.Invoke(() =>
  420. {
  421. RecipeModel recipe = recipeProcesses?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum));
  422. recipe.RecipStatus = "制作完成";
  423. UserTreeCompelete.Insert(0, recipe);
  424. recipeProcesses.RemoveAt(recipeProcesses.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(recipeNameNum)));
  425. });
  426. }
  427. }
  428. }
  429. }
  430. else
  431. {
  432. doDeviceCount.TryAdd(DeviceInquire.GetInstance.devices[i].IpAddress, 0);
  433. }
  434. }
  435. }
  436. }
  437. }
  438. //if (doDeviceCount.ContainsKey("192.168.2.10")&&doDeviceCount.ContainsKey($"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"))
  439. //{
  440. // if (doDeviceCount[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"] > 0 && DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].deviceStatus.DoRecipeCount == doDeviceCount[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"])
  441. // {
  442. // App.Current.Dispatcher.Invoke(new Action(() =>
  443. // {
  444. // UserTreeCompelete.Insert(0, recipeProcesses.Last());
  445. // recipeProcesses.Remove(recipeProcesses.Last());
  446. // }));
  447. // }
  448. // if (DeviceInquire.GetInstance.DeviceLists["192.168.2.10"].deviceStatus.DoRecipeCount == doDeviceCount["192.168.2.10"])
  449. // {
  450. // App.Current.Dispatcher.Invoke(new Action(() =>
  451. // {
  452. // if (UserTreeWait.Count > 0)
  453. // {
  454. // recipeProcesses.Insert(0, UserTreeWait[0]);
  455. // UserTreeWait.RemoveAt(0);
  456. // }
  457. // }));
  458. // }
  459. //}
  460. }
  461. Thread.Sleep(10);
  462. }, "设备下发配方");
  463. TaskManage.GetInstance.StartLong(() =>
  464. {
  465. for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
  466. {
  467. if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress) && doDeviceCount.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
  468. {
  469. //判断桶到位 和 状态为等待配料。
  470. 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)
  471. {
  472. int doCount = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount - 1));
  473. if (doCount >= 0 && doCount < Recipes.Count)
  474. {
  475. //根据物料名称查找
  476. var res = Recipes.ElementAt(doCount).RawMaterials?.ToList().FindAll(a => a.RawMaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
  477. foreach (RawMaterialModel item in res)
  478. {
  479. //可能是多个桶都需要下同一种料,根据已通过桶数和当前物料信息的通号做对比。
  480. if (item != null && item.Loc == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail)
  481. {
  482. DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
  483. if (deviceSet != null && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].IsConnected == true)
  484. {
  485. var deviceModbus = DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp;
  486. //传送带停止
  487. deviceModbus.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
  488. //设置下料重量
  489. deviceModbus.Write<float>(DeviceAddress.WeightSet.ToAdd(), item.RawMaterialWeight);
  490. //设置慢加重量
  491. deviceModbus.Write<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowlyAddWeight);
  492. //设置快慢加速度
  493. deviceModbus.Write<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowAcceleration);
  494. deviceModbus.Write<float>(DeviceAddress.RapidAcceleration.ToAdd(), deviceSet.RapidAcceleration);
  495. //设置提前关阀重量
  496. deviceModbus.Write<float>(DeviceAddress.PreCloseValveWeight.ToAdd(), deviceSet.PreCloseValveWeight);
  497. //设置伺服手动速度
  498. deviceModbus.Write<float>(DeviceAddress.ServoManualSpeed.ToAdd(), deviceSet.ServoManualSpeed);
  499. //设置料仓上下限重量
  500. deviceModbus.Write<float>(DeviceAddress.SiloUpperLimitWeight.ToAdd(), deviceSet.SiloUpperLimitWeight);
  501. deviceModbus.Write<float>(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), deviceSet.LowerLimitWeightOfSilo);
  502. //开始配料信号
  503. deviceModbus.Write<ushort>(DeviceAddress.Start.ToAdd(), (ushort)1);
  504. ////设置搅拌速度
  505. //DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<int>(DeviceAddress.StirringSpeed.ToAdd(), deviceSet.StirringSpeed);
  506. }
  507. }
  508. }
  509. }
  510. }
  511. }
  512. }
  513. Thread.Sleep(10);
  514. }, "下发设备参数");
  515. DeviceStatus nextDevice = new DeviceStatus();
  516. TaskManage.GetInstance.StartLong(() =>
  517. {
  518. for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
  519. {
  520. if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
  521. {
  522. //90 是中转流水线的IP。
  523. if (DeviceInquire.GetInstance.devices[i].IpAddress == "192.168.2.90")
  524. {
  525. //如果中转线的下一个设备有桶的话,就先把中转线停住。
  526. if (DeviceInquire.GetInstance.DeviceLists[ DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1)
  527. {
  528. SimensSend.GetInstance.SendSimens.Write("DB1.DBX702.0", 0);
  529. }
  530. else
  531. {
  532. SimensSend.GetInstance.SendSimens.Write("DB1.DBW104", (ushort)1400);
  533. SimensSend.GetInstance.SendSimens.Write("DB1.DBX702.0", 1);
  534. }
  535. }
  536. if (DeviceInquire.GetInstance.devices[i].IpAddress != $"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}")
  537. {
  538. ushort deviceNum = DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DeviceNum;
  539. string nextIp = "";
  540. if (DeviceInquire.GetInstance.DeviceLists.TryGetValue($"{Json<DevicePar>.Data.BaseParModel.NetworkSegAddress}{(deviceNum+1) * 10}", out nextDevice)&& deviceNum!=0)
  541. {
  542. nextIp = DeviceInquire.GetInstance.DeviceLists.ToList().Find(q => q.Value == nextDevice).Key;
  543. }
  544. if ( nextIp != "")
  545. {
  546. //if (DeviceInquire.GetInstance.DeviceLists["192.168.2.10"].deviceStatus.RunStatus == 1 || DeviceInquire.GetInstance.DeviceLists["192.168.2.10"].deviceStatus.RunStatus == 3)
  547. //{
  548. // DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
  549. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 1000);
  550. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
  551. //}
  552. if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1 || DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3)
  553. {
  554. if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1 && DeviceInquire.GetInstance.DeviceLists[nextIp].deviceStatus.PailArrive == 1)
  555. {
  556. DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(),(ushort)0);
  557. }
  558. else
  559. {
  560. DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 600);
  561. DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1);
  562. }
  563. }
  564. else
  565. {
  566. DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
  567. //传送带停止
  568. }
  569. //DeviceInquire.GetInstance.DeviceLists["192.168.2.130"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 1000);
  570. //DeviceInquire.GetInstance.DeviceLists["192.168.2.130"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
  571. //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)
  572. //{
  573. // //传送带运行
  574. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), (ushort)1);
  575. // DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
  576. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), deviceSet.SendSp);
  577. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
  578. //}
  579. }
  580. else
  581. {
  582. DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
  583. }
  584. }
  585. else
  586. {
  587. if (SimensSend.GetInstance.sendCtrlModel.SendInfo&& DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount) * 10}"].deviceStatus.PailArrive == 1)
  588. {
  589. DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
  590. }
  591. else
  592. {
  593. DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 600);
  594. DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1);
  595. }
  596. }
  597. }
  598. }
  599. Thread.Sleep(10);
  600. }, "控制传送带");
  601. #region 弃用配料流程
  602. //弃用配料流程
  603. //TaskManage.GetInstance.StartLong(() =>
  604. //{
  605. // if (RecipeNames.Count > 0)
  606. // {
  607. // SimensSend.GetInstance.SendSimens.Write("M0.0", true);
  608. // SimensSend.GetInstance.SendSimens.Write("M0.1", true);
  609. // 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)
  610. // {
  611. // recipeProcesses.Remove(recipeProcesses.Last());
  612. // UserTreeCompelete.Insert(0, recipeProcesses.Last());
  613. // }
  614. // for (int i = 0; i < DeviceInquire.GetInstance.devices.Count; i++)
  615. // {
  616. // if (DeviceInquire.GetInstance.DeviceLists.ContainsKey(DeviceInquire.GetInstance.devices[i].IpAddress))
  617. // {
  618. // if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail == 0 || DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1)
  619. // {
  620. // if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.MaxPassPail == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail|| recipeProcesses.Count==0)
  621. // {
  622. // int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(0));
  623. // if (index >= 0 && index < Recipes.Count)
  624. // {
  625. // App.Current.Dispatcher.Invoke(new Action(() =>
  626. // {
  627. // if (UserTreeWait.Count > 0)
  628. // {
  629. // recipeProcesses.Insert(0, UserTreeWait?.ToList().Find(a => a.RecipeName == RecipeNames.ElementAt(0)));
  630. // UserTreeWait.RemoveAt(UserTreeWait.ToList().FindIndex(a => a.RecipeName == RecipeNames.ElementAt(0)));
  631. // }
  632. // }));
  633. // int maxPail = 0;
  634. // foreach (var rawMaterial in Recipes.ElementAt(index).RawMaterials)
  635. // {
  636. // if (rawMaterial.Loc > maxPail)
  637. // {
  638. // maxPail = rawMaterial.Loc;
  639. // }
  640. // }
  641. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.DeletePassPail.ToAdd(), 1);
  642. // //Thread s = new Thread(() => { mmm(); });
  643. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.MaxPail.ToAdd(), (ushort)maxPail);
  644. // }
  645. // }
  646. // if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1 && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1)
  647. // {
  648. // int doCount = Array.FindIndex(Recipes.ToArray(), p => p.SerialNum == (int)DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DoRecipeCount-1) ;
  649. // if (doCount >=0)
  650. // {
  651. // var res = Recipes.ElementAt(doCount).RawMaterials?.ToList().FindAll(a => a.RawMaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
  652. // foreach (RawMaterialModel item in res)
  653. // {
  654. // if (item != null && item.Loc == DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PassPail)
  655. // {
  656. // DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
  657. // if (deviceSet != null)
  658. // {
  659. // //开始配料信号
  660. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), (ushort)1);
  661. // //传送带停止
  662. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
  663. // //设置下料重量
  664. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.WeightSet.ToAdd(), item.RawMaterialWeight);
  665. // //设置慢加重量
  666. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowlyAddWeight);
  667. // //设置快慢加速度
  668. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), deviceSet.SlowAcceleration);
  669. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.RapidAcceleration.ToAdd(), deviceSet.RapidAcceleration);
  670. // //设置提前关阀重量
  671. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.PreCloseValveWeight.ToAdd(), deviceSet.PreCloseValveWeight);
  672. // //设置伺服手动速度
  673. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.ServoManualSpeed.ToAdd(), deviceSet.ServoManualSpeed);
  674. // //设置料仓上下限重量
  675. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.SiloUpperLimitWeight.ToAdd(), deviceSet.SiloUpperLimitWeight);
  676. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<float>(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), deviceSet.LowerLimitWeightOfSilo);
  677. // ////设置搅拌速度
  678. // //DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<int>(DeviceAddress.StirringSpeed.ToAdd(), deviceSet.StirringSpeed);
  679. // }
  680. // }
  681. // }
  682. // }
  683. // }
  684. // }
  685. // 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))
  686. // {
  687. // string passName = RecipeNames.ElementAt(0);
  688. // RecipeNames.TryDequeue(out passName);
  689. // }
  690. // if (DeviceInquire.GetInstance.devices[i].IpAddress != $"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}")
  691. // {
  692. // if (DeviceInquire.GetInstance.DeviceLists["192.168.2.10"].deviceStatus.RunStatus == 1 || DeviceInquire.GetInstance.DeviceLists["192.168.2.10"].deviceStatus.RunStatus == 3)
  693. // {
  694. // DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
  695. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 1000);
  696. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
  697. // }
  698. // //if (DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 1 || DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.RunStatus == 3)
  699. // //{
  700. // // DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
  701. // // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 1000);
  702. // // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
  703. // //}
  704. // //DeviceInquire.GetInstance.DeviceLists["192.168.2.130"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 1000);
  705. // //DeviceInquire.GetInstance.DeviceLists["192.168.2.130"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
  706. // //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)
  707. // //{
  708. // // //传送带运行
  709. // // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.Start.ToAdd(), (ushort)1);
  710. // // DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
  711. // // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), deviceSet.SendSp);
  712. // // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
  713. // //}
  714. // else
  715. // {
  716. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
  717. // //传送带停止
  718. // }
  719. // }
  720. // else
  721. // {
  722. // if (SimensSend.GetInstance.sendCtrlModel.Stop)
  723. // {
  724. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
  725. // }
  726. // else
  727. // {
  728. // DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 1);
  729. // }
  730. // //传送带终点为3则传送带停止,小于3则按照出料状态运行
  731. // }
  732. // }
  733. // }
  734. // }
  735. // Thread.Sleep(10);
  736. //}, "启动配方下发", true);
  737. #endregion
  738. }
  739. }
  740. }