终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

7535 rivejä
417 KiB

  1. using BPASmartClient.AGV;
  2. using BPASmartClient.AGV.Enums;
  3. using BPASmartClient.AGV.Feedback;
  4. using BPASmartClient.CustomResource.Pages.Model;
  5. using BPA.Helper;
  6. using BPASmartClient.HubHelper;
  7. using FryPot_DosingSystem.Model;
  8. using FryPot_DosingSystem.ViewModel;
  9. using Newtonsoft.Json;
  10. using System;
  11. using System.Collections.Concurrent;
  12. using System.Collections.Generic;
  13. using System.Collections.ObjectModel;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Threading;
  17. using System.Threading.Tasks;
  18. using System.Windows.Media;
  19. using System.Windows;
  20. using FryPot_DosingSystem.AGV;
  21. using FryPot_DosingSystem.FryPotStatus;
  22. using System.IO;
  23. using System.Runtime.Serialization.Formatters.Binary;
  24. using System.Diagnostics;
  25. using BPASmartClient.CustomResource.UserControls.MessageShow;
  26. using BPASmartClient.CustomResource.UserControls;
  27. using Renci.SshNet.Messages;
  28. namespace FryPot_DosingSystem.Control
  29. {
  30. internal class DosingLogicControl
  31. {
  32. public static DosingLogicControl _instance;
  33. public static DosingLogicControl GetInstance => _instance ??= new DosingLogicControl();
  34. public ushort[] RollerNum = new ushort[] { 101, 102, 103, 104, 105, 106, 107, 108, 201, 202, 203, 204, 205, 206, 207, 208, 301, 302, 303, 304, 305, 306, 307, 308, 401, 402, 403, 404, 405, 406, 407, 408, 501, 502, 503, 504, 505, 506, 507, 508 };
  35. /// <summary>
  36. /// 桶净重
  37. /// </summary>r
  38. public ushort RollerNetweight = 19;//19公斤
  39. /// <summary>
  40. /// 滚筒线PLC数据
  41. /// </summary>
  42. public ConcurrentDictionary<string, object> PlcReadData = new ConcurrentDictionary<string, object>();
  43. public ConcurrentDictionary<string, object> FryOneData = new ConcurrentDictionary<string, object>();
  44. public ConcurrentDictionary<string, object> FryTwoData = new ConcurrentDictionary<string, object>();
  45. public ConcurrentDictionary<string, object> FryThreeData = new ConcurrentDictionary<string, object>();
  46. public ConcurrentDictionary<string, object> FryFourData = new ConcurrentDictionary<string, object>();
  47. public ConcurrentDictionary<string, object> FryFiveData = new ConcurrentDictionary<string, object>();
  48. /// <summary>
  49. /// 线体1配方队列
  50. /// </summary>
  51. public ConcurrentQueue<NewRecipeModel> RecipeQuene = new ConcurrentQueue<NewRecipeModel>();
  52. /// <summary>
  53. /// 线体2配方队列
  54. /// </summary>
  55. public ConcurrentQueue<NewRecipeModel> LTwoRecipeQuene = new ConcurrentQueue<NewRecipeModel>();
  56. /// <summary>
  57. /// 线体3配方队列
  58. /// </summary>
  59. public ConcurrentQueue<NewRecipeModel> LThreeRecipeQuene = new ConcurrentQueue<NewRecipeModel>();
  60. /// <summary>
  61. /// 线体1进料原料队列
  62. /// </summary>
  63. public ConcurrentQueue<MaterialInfo> InputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  64. /// <summary>
  65. /// 线体2进料原料队列
  66. /// </summary>
  67. public ConcurrentQueue<MaterialInfo> LTwoInputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  68. /// <summary>
  69. /// 线体3进料原料队列
  70. /// </summary>
  71. public ConcurrentQueue<MaterialInfo> LThreeInputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  72. /// <summary>
  73. /// 线体1出料原料队列
  74. /// </summary>
  75. public ConcurrentQueue<MaterialInfo> OutputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  76. /// <summary>
  77. /// 线体2出料原料队列
  78. /// </summary>
  79. public ConcurrentQueue<MaterialInfo> LTwoOutputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  80. /// <summary>
  81. /// 线体3出料原料队列
  82. /// </summary>
  83. public ConcurrentQueue<MaterialInfo> LThreeOutputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  84. /// <summary>
  85. /// 全局变量对象声明
  86. /// </summary>
  87. GlobalVariable globalVar;
  88. /// <summary>
  89. /// 线体状态对象声明
  90. /// </summary>
  91. HardWareStatusViewModel hardWareStatusModel;
  92. ///// <summary>
  93. ///// 炒锅1状态
  94. ///// </summary>
  95. //PotOneStatus fryOne;
  96. ///// <summary>
  97. ///// 炒锅2状态
  98. ///// </summary>
  99. //PotTwoStatus fryTwo;
  100. ///// <summary>
  101. ///// 炒锅3状态
  102. ///// </summary>
  103. //PotThreeStatus fryThree;
  104. ///// <summary>
  105. ///// 炒锅4状态
  106. ///// </summary>
  107. //PotFourStatus fryFour;
  108. ///// <summary>
  109. ///// 炒锅5状态
  110. ///// </summary>
  111. //PotFiveStatus fryFive;
  112. /// <summary>
  113. /// 报警信息对象声明
  114. /// </summary>
  115. #region 上位机内部变量
  116. int FryPotAlarm = 0;//炒锅1滚筒故障信号 1:无故障 -1:故障
  117. int FryPotTwoAlarm = 0;//炒锅2滚筒故障信号 1:无故障 -1:故障
  118. int FryPotThreeAlarm = 0;//炒锅3滚筒故障信号 1:无故障 -1:故障
  119. int FryPotFourAlarm = 0;//炒锅4滚筒故障信号 1:无故障 -1:故障
  120. int FryPotFiveAlarm = 0;//炒锅5滚筒故障信号 1:无故障 -1:故障
  121. int ReicpeNum = 0;//记录接收到的配方数
  122. bool ErrorRecipe;//线体1错误配方标识
  123. bool LTwoErrorRecipe;//线体2错误配方标识
  124. bool LThreeErrorRecipe;//线体3错误配方标识
  125. string fryOneRecipe = string.Empty;
  126. string fryTwoRecipe = string.Empty;
  127. string fryThreeRecipe = string.Empty;
  128. string fryFourRecipe = string.Empty;
  129. string fryFiveRecipe = string.Empty;
  130. #endregion
  131. #region agv临时变量
  132. //bool agvArriveUpLoad = false;//agv是否到达线体1上料位置
  133. //bool agvArriveLTwoUpLoad = false;//agv是否到达线体2上料位置
  134. //bool agvArriveLThreeUpLoad = false;//agv是否到达线体3上料位置
  135. //bool agvArriveUnLoad = false;//线体1 agv是否到达炒锅送料位置
  136. //bool LTwoagvArriveUnLoad = false;//线体2 agv是否到达炒锅送料位置
  137. //bool LThreeagvArriveUnLoad = false;//线体3 agv是否到达炒锅送料位置
  138. //bool agvFryPotEmptyRollerArrive = false;// 线体1的agv是否拿到炒锅空桶
  139. //bool LTwoagvFryPotEmptyRollerArrive = false; //线体2的agv是否拿到炒锅空桶
  140. //bool LThreeagvFryPotEmptyRollerArrive = false;//线体3的agv是否拿到炒锅空桶
  141. string LOnerobotJobId = string.Empty;//线体1当前上游系统任务号,全局唯一 从线体1到炒锅路径
  142. string LTworobotJobId = string.Empty;//线体2当前上游系统任务号,全局唯一 从线体2到炒锅路径
  143. string LThreerobotJobId = string.Empty;//线体3当前上游系统任务号,全局唯一 从线体3到炒锅路径
  144. string LFourrobotJobId = string.Empty;//线体4当前上游系统任务号,全局唯一 从炒锅1、4到线体4路径
  145. string LFiverobotJobId = string.Empty; //从炒锅2、5到线体4路径
  146. string LSixrobotJobId = string.Empty; //从炒锅3到线体4路径
  147. List<string> LSevenrobotJobId = new List<string>(); //从线体1到清洗台路径
  148. List<string> LEightrobotJobId = new List<string>();//从线体2到清洗台路径
  149. List<string> LNinerobotJobId = new List<string>(); //从线体3到清洗台路径
  150. List<string> LTenrobotJobId = new List<string>(); //从清洗台到线体4路径
  151. Dictionary<string, int> agvCode = new Dictionary<string, int>() { { "ZT11-21", 1 }, { "ZT11-22", 2 }, { "ZT11-23", 3 }, { "ZT11-24", 4 } };//agv小车的编号对AGV动画小车编号
  152. private static readonly object Obj_Lock = new object();//3条滚筒线洗桶线程互斥锁
  153. private static readonly object Pot_Lock = new object();//炒股工艺工艺下发锁
  154. public int CleanNum = 0;//当前清洗台桶数
  155. ushort LOneCurrentRollerNum = 0;//当前线体1的空桶桶号
  156. ushort LTwoCurrentRollerNum = 0;//当前线体2的空桶桶号
  157. ushort LThreeCurrentRollerNum = 0;//当前线体3的空桶桶号
  158. public NewRecipeModel potOneCurrentRecipe = null;
  159. public NewRecipeModel potTwoCurrentRecipe = null;
  160. public NewRecipeModel potThreeCurrentRecipe = null;
  161. public NewRecipeModel potFourCurrentRecipe = null;
  162. public NewRecipeModel potFiveCurrentRecipe = null;
  163. #endregion
  164. /// <summary>
  165. /// 调试命令注册
  166. /// </summary>
  167. public void CommandRegist()
  168. {
  169. #region 线体空桶清洗及回收调试
  170. ActionManage.GetInstance.Register(new Action(() =>
  171. {
  172. globalVar.agvArriveLineOneLoadEmptyRoller = true;
  173. }), "AgvArriveLineOneEmptyRollerLoc");
  174. ActionManage.GetInstance.Register(new Action(() =>
  175. {
  176. globalVar.agvArriveLineTwoLoadEmptyRoller = true;
  177. }), "AgvArriveLineTwoEmptyRollerLoc");
  178. ActionManage.GetInstance.Register(new Action(() =>
  179. {
  180. globalVar.agvArriveLineThreeLoadEmptyRoller = true;
  181. }), "AgvArriveLineThreeEmptyRollerLoc");
  182. //ActionManage.GetInstance.Register(new Action(() =>
  183. //{
  184. // globalVar.CleanComplete = 1;
  185. //}), "CleanPlateCallAgv");
  186. //ActionManage.GetInstance.Register(new Action(() =>
  187. //{
  188. // globalVar.rollerLineOne.agvArriveCleanUnLoad = true;//清洗台空桶下料就位
  189. // globalVar.rollerLineTwo.agvArriveCleanUnLoad = true;
  190. // globalVar.rollerLineThree.agvArriveCleanUnLoad = true;
  191. //}), "AgvArriveCleanPlateLoc");
  192. ActionManage.GetInstance.Register(new Action(() =>
  193. {
  194. globalVar.agvArriveCleanLoad = true;//清洗台空桶上料就位
  195. }), "AgvArriveCleanPlateLocLoad");
  196. //ActionManage.GetInstance.Register(new Action(() =>
  197. //{
  198. // globalVar.agvArriveLineFour = true;
  199. // globalVar.rollerLineOne.agvArriveLineFour = true;
  200. // globalVar.rollerLineTwo.agvArriveLineFour = true;
  201. // globalVar.rollerLineThree.agvArriveLineFour = true;
  202. //}), "AgvArriveLineFourLoc");
  203. #endregion
  204. //接口调试
  205. //ActionManage.GetInstance.Register(new Action(() =>
  206. //{
  207. // string id = Guid.NewGuid().ToString("D");
  208. // string errorCode = AGVHelper.GetInstance.AgvToLineOneLoadRoller(id);
  209. // if (errorCode == "SUCCESS")
  210. // {
  211. // MessageNotify.GetInstance.ShowRunLog($"AGV任务下发成功");
  212. // }
  213. // else if (errorCode == "Analysis Error")
  214. // {
  215. // MessageNotify.GetInstance.ShowRunLog($"提示:AGV 调用API失败,请检查请求报文");
  216. // }
  217. // else
  218. // {
  219. // MessageNotify.GetInstance.ShowRunLog($"提示:AGV任务下发失败,错误码:{errorCode}");
  220. // }
  221. //}), "AgvDebug");
  222. //ActionManage.GetInstance.Register(() =>
  223. //{
  224. // MessageNotify.GetInstance.ShowRunLog("清洗台卸桶完成");
  225. //}, "AgvArriveCleanPlateLocCom");
  226. //ActionManage.GetInstance.Register(() =>
  227. //{
  228. // MessageNotify.GetInstance.ShowRunLog("清洗台空桶在【4】号线卸桶完成");
  229. // MessageNotify.GetInstance.ShowRunLog("【1】号线炒锅空桶在【4】号线卸桶完成");
  230. // MessageNotify.GetInstance.ShowRunLog("【2】号线炒锅空桶在【4】号线卸桶完成");
  231. // MessageNotify.GetInstance.ShowRunLog("【3】号线炒锅空桶在【4】号线卸桶完成");
  232. //}, "AgvArriveLineFourLocCom");
  233. //ActionManage.GetInstance.Register(() =>
  234. //{
  235. // MessageNotify.GetInstance.ShowRunLog("清洗台空桶装载完成");
  236. //}, "AgvArriveCleanPlateLocLoadCom");
  237. //ActionManage.GetInstance.Register(() =>
  238. //{
  239. // // globalVar.rollerLineOne.RecipeCompleteSingle = 1;
  240. //}, "LineOneRecipeComSignal");
  241. //ActionManage.GetInstance.Register(() =>
  242. //{
  243. // // globalVar.rollerLineTwo.RecipeCompleteSingle = 1;
  244. //}, "LineTwoRecipeComSignal");
  245. //ActionManage.GetInstance.Register(() =>
  246. //{
  247. // // globalVar.rollerLineThree.RecipeCompleteSingle = 1;
  248. //}, "LineThreeRecipeComSignal");
  249. //ActionManage.GetInstance.Register(new Action(() =>
  250. //{
  251. // globalVar.agvArriveLineOneLoadCom = true;
  252. //}), "AgvLineOneLoadEmptyCom");
  253. //ActionManage.GetInstance.Register(new Action(() =>
  254. //{
  255. // globalVar.agvArriveLineTwoLoadCom = true;
  256. //}), "AgvLineTwoLoadEmptyCom");
  257. //ActionManage.GetInstance.Register(new Action(() =>
  258. //{
  259. // globalVar.agvArriveLineThreeLoadCom = true;
  260. //}), "AgvLineThreeLoadEmptyCom");
  261. //ActionManage.GetInstance.Register(new Action(() =>
  262. //{
  263. // globalVar.rollerLineOne.CanRun = true;
  264. //}), "AGVLineOneLoadCom");
  265. //ActionManage.GetInstance.Register(new Action(() =>
  266. //{
  267. // globalVar.rollerLineTwo.CanRun = true;
  268. //}), "AGVLineTwoLoadCom");
  269. //ActionManage.GetInstance.Register(new Action(() =>
  270. //{
  271. // globalVar.rollerLineThree.CanRun = true;
  272. //}), "AGVLineThreeLoadCom");
  273. //ActionManage.GetInstance.Register(new Action(() =>
  274. //{
  275. // globalVar.rollerLineOne.OutMaterialingSingle = 1;
  276. //}), "RollerLineRunning");
  277. //ActionManage.GetInstance.Register(new Action<object>((obj) =>
  278. //{
  279. // globalVar.rollerLineOne.StationEight = (ushort)obj;
  280. //}), "EightWorkLoc");
  281. //ActionManage.GetInstance.Register(new Action(() =>
  282. //{
  283. // globalVar.fryPotOne.InputMaterialArrivedSingle = 1;
  284. // globalVar.fryPotFour.InputMaterialArrivedSingle = 1;
  285. //}), "FryPotInputArrive");
  286. //ActionManage.GetInstance.Register(new Action(() =>
  287. //{
  288. // globalVar.fryPotOne.EmptyBarrelArrivedSingle = 1;
  289. // globalVar.fryPotFour.EmptyBarrelArrivedSingle = 1;
  290. //}), "FryPotEmptyRollerArrive");
  291. ActionManage.GetInstance.Register(new Action(() =>
  292. {
  293. globalVar.agvArriveUpLoad = true;
  294. }), "AGVLOneArrive");
  295. ActionManage.GetInstance.Register(new Action(() =>
  296. {
  297. globalVar.agvArriveUnLoad = true;
  298. }), "AGVFryPotDownArrive");
  299. ActionManage.GetInstance.Register(new Action(() =>
  300. {
  301. globalVar.agvArriveUpLoad = true;
  302. }), "AGVFryPotUpArrive");
  303. //ActionManage.GetInstance.Register(new Action(() =>
  304. //{
  305. // globalVar.agvFryPotEmptyRollerArrive = true;
  306. //}), "AGVFryPotGetEmptyRoller");
  307. //滚筒线2
  308. //ActionManage.GetInstance.Register(new Action(() =>
  309. //{
  310. // globalVar.rollerLineTwo.OutMaterialingSingle = 1;
  311. //}), "RollerLineTwoRunning");
  312. //ActionManage.GetInstance.Register(new Action<object>((obj) =>
  313. //{
  314. // globalVar.rollerLineTwo.StationEight = (ushort)obj;
  315. //}), "TwoEightWorkLoc");
  316. //ActionManage.GetInstance.Register(new Action(() =>
  317. //{
  318. // globalVar.fryPotTwo.InputMaterialArrivedSingle = 1;
  319. // globalVar.fryPotFive.InputMaterialArrivedSingle = 1;
  320. //}), "FryPotTwoInputArrive");
  321. //ActionManage.GetInstance.Register(new Action(() =>
  322. //{
  323. // globalVar.fryPotTwo.EmptyBarrelArrivedSingle = 1;
  324. // globalVar.fryPotFive.EmptyBarrelArrivedSingle = 1;
  325. //}), "FryPotTwoEmptyRollerArrive");
  326. ActionManage.GetInstance.Register(new Action(() =>
  327. {
  328. globalVar.agvArriveLTwoUpLoad = true;
  329. }), "AGVLTwoArrive");
  330. ActionManage.GetInstance.Register(new Action(() =>
  331. {
  332. globalVar.LTwoagvArriveUnLoad = true;
  333. }), "AGVFryPotTwoDownArrive");
  334. ActionManage.GetInstance.Register(new Action(() =>
  335. {
  336. globalVar.agvArriveLTwoUpLoad = true;
  337. }), "AGVFryPotTwoUpArrive");
  338. //ActionManage.GetInstance.Register(new Action(() =>
  339. //{
  340. // globalVar.LTwoagvFryPotEmptyRollerArrive = true;
  341. //}), "AGVFryPotTwoGetEmptyRoller");
  342. //滚筒线3
  343. //ActionManage.GetInstance.Register(new Action(() =>
  344. //{
  345. // globalVar.rollerLineThree.OutMaterialingSingle = 1;
  346. //}), "RollerLineThreeRunning");
  347. //ActionManage.GetInstance.Register(new Action<object>((obj) =>
  348. //{
  349. // globalVar.rollerLineThree.StationEight = (ushort)obj;
  350. //}), "ThreeEightWorkLoc");
  351. //ActionManage.GetInstance.Register(new Action(() =>
  352. //{
  353. // globalVar.fryPotThree.InputMaterialArrivedSingle = 1;
  354. //}), "FryPotThreeInputArrive");
  355. //ActionManage.GetInstance.Register(new Action(() =>
  356. //{
  357. // globalVar.fryPotThree.EmptyBarrelArrivedSingle = 1;
  358. //}), "FryPotThreeEmptyRollerArrive");
  359. ActionManage.GetInstance.Register(new Action(() =>
  360. {
  361. globalVar.agvArriveLThreeUpLoad = true;
  362. }), "AGVLThreeArrive");
  363. ActionManage.GetInstance.Register(new Action(() =>
  364. {
  365. globalVar.LThreeagvArriveUnLoad = true;
  366. }), "AGVFryPotThreeDownArrive");
  367. ActionManage.GetInstance.Register(new Action(() =>
  368. {
  369. globalVar.agvArriveLThreeUpLoad = true;
  370. }), "AGVFryPotThreeUpArrive");
  371. //ActionManage.GetInstance.Register(new Action(() =>
  372. //{
  373. // globalVar.LThreeagvFryPotEmptyRollerArrive = true;
  374. //}), "AGVFryPotThreeGetEmptyRoller");
  375. }
  376. public DosingLogicControl()
  377. {
  378. globalVar = new GlobalVariable();
  379. //fryOne = new PotOneStatus();
  380. //fryTwo = new PotTwoStatus();
  381. //fryThree = new PotThreeStatus();
  382. //fryFour = new PotFourStatus();
  383. //fryFive = new PotFiveStatus();
  384. hardWareStatusModel = HardWareStatusViewModel.GetInstance;
  385. DateTimeJudge();
  386. FileRegClean();
  387. ActionManage.GetInstance.Register(new Action<object[]>(RecipeDataParse), "RecipeSetDown");
  388. //ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.Clear(); LTwoInputMaterialQuene.Clear(); LTwoOutputMaterialQuene.Clear(); LThreeInputMaterialQuene.Clear(); LThreeOutputMaterialQuene.Clear(); }), "ClearRecipes");
  389. ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.Clear(); }), "ClearOneRecipes");
  390. ActionManage.GetInstance.Register(new Action(() => { LTwoRecipeQuene.Clear(); LTwoInputMaterialQuene.Clear(); LTwoOutputMaterialQuene.Clear(); }), "ClearTwoRecipes");
  391. ActionManage.GetInstance.Register(new Action(() => { LThreeRecipeQuene.Clear(); LThreeInputMaterialQuene.Clear(); LThreeOutputMaterialQuene.Clear(); }), "ClearThreeRecipes");
  392. //ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 1; }), "StartPlcInite");
  393. //ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 0; }), "EndPlcInite");
  394. ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitLineOneTask = true; LineOneTaskRestart(); }), "LineOneTaskExit");
  395. ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitLineTwoTask = true; LineTwoTaskRestart(); }), "LineTwoTaskExit");
  396. ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitLineThreeTask = true; LineThreeTaskRestart(); }), "LineThreeTaskExit");
  397. ActionManage.GetInstance.Register(new Action(() =>
  398. {
  399. globalVar.ExitLineOneTask = true;
  400. LineOneEmptyRollerCleanTaskRestart();
  401. }), "EmptyRollerCleanTaskRestart");
  402. ActionManage.GetInstance.Register(new Action(() =>
  403. {
  404. globalVar.ExitLineTwoTask = true;
  405. LineTwoEmptyRollerCleanTaskRestart();
  406. }), "LineTwoEmptyRollerCleanTaskRestart");
  407. ActionManage.GetInstance.Register(new Action(() =>
  408. {
  409. globalVar.ExitLineThreeTask = true;
  410. LineThreeEmptyRollerCleanTaskRestart();
  411. }), "LineThreeEmptyRollerCleanTaskRestart");
  412. HubHelper.GetInstance.Report = new Action<object>(AgvTaskUpReportDataAnalysis);
  413. HubHelper.GetInstance.Upstreamrequest = new Action<object>(AgvFeedBackUpReportDataAnalysis);
  414. //ResetProgram();
  415. ReadPlcData();
  416. HeatBeatToPlc();
  417. SaveFryPotData();
  418. MainTask();
  419. CommandRegist();
  420. }
  421. private void HeatBeatToPlc()
  422. {
  423. TaskManage.GetInstance.StartLong(new Action(() => {
  424. DeviceOperate.GetInstance.WritePlcData("D0001", 1);
  425. Thread.Sleep(500);
  426. DeviceOperate.GetInstance.WritePlcData("D0001", 0);
  427. Thread.Sleep(500);
  428. }), "上位机心跳下发滚筒线", true);
  429. TaskManage.GetInstance.StartLong(new Action(() =>
  430. {
  431. DeviceOperate.GetInstance.WritePotOnePlcData("D0001", 1);
  432. Thread.Sleep(500);
  433. DeviceOperate.GetInstance.WritePotOnePlcData("D0001", 0);
  434. Thread.Sleep(500);
  435. }), "上位机心跳下发1号炒锅", true);
  436. TaskManage.GetInstance.StartLong(new Action(() =>
  437. {
  438. DeviceOperate.GetInstance.WritePotTwoPlcData("D0001", 1);
  439. Thread.Sleep(500);
  440. DeviceOperate.GetInstance.WritePotTwoPlcData("D0001", 0);
  441. Thread.Sleep(500);
  442. }), "上位机心跳下发2号炒锅", true);
  443. TaskManage.GetInstance.StartLong(new Action(() =>
  444. {
  445. DeviceOperate.GetInstance.WritePotThreePlcData("D0001", 1);
  446. Thread.Sleep(500);
  447. DeviceOperate.GetInstance.WritePotThreePlcData("D0001", 0);
  448. Thread.Sleep(500);
  449. }), "上位机心跳下发3号炒锅", true);
  450. TaskManage.GetInstance.StartLong(new Action(() =>
  451. {
  452. DeviceOperate.GetInstance.WritePotFourPlcData("D0001", 1);
  453. Thread.Sleep(500);
  454. DeviceOperate.GetInstance.WritePotFourPlcData("D0001", 0);
  455. Thread.Sleep(500);
  456. }), "上位机心跳下发4号炒锅", true);
  457. TaskManage.GetInstance.StartLong(new Action(() =>
  458. {
  459. DeviceOperate.GetInstance.WritePotFivePlcData("D0001", 1);
  460. Thread.Sleep(500);
  461. DeviceOperate.GetInstance.WritePotFivePlcData("D0001", 0);
  462. Thread.Sleep(500);
  463. }), "上位机心跳下发5号炒锅", true);
  464. }
  465. /// <summary>
  466. /// 文件数据定期清理
  467. /// </summary>
  468. /// <exception cref="NotImplementedException"></exception>
  469. private void FileRegClean()
  470. {
  471. try
  472. {
  473. int days = 5; //清除期限
  474. string[] filesOne = Directory.GetDirectories("AccessFile//DB//炒锅1状态数据");
  475. if (filesOne.Count() > 0)
  476. {
  477. foreach (var item in filesOne)
  478. {
  479. FileInfo info = new FileInfo(item);
  480. DateTime createTime = info.CreationTime;
  481. DateTime timeNow = DateTime.Now;
  482. if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days)
  483. {
  484. Directory.Delete(item, true);
  485. }
  486. }
  487. }
  488. string[] filesTwo = Directory.GetDirectories("AccessFile//DB//炒锅2状态数据");
  489. if (filesTwo.Count() > 0)
  490. {
  491. foreach (var item in filesTwo)
  492. {
  493. FileInfo info = new FileInfo(item);
  494. DateTime createTime = info.CreationTime;
  495. DateTime timeNow = DateTime.Now;
  496. if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days)
  497. {
  498. Directory.Delete(item, true);
  499. }
  500. }
  501. }
  502. string[] filesThree = Directory.GetDirectories("AccessFile//DB//炒锅3状态数据");
  503. if (filesThree.Count() > 0)
  504. {
  505. foreach (var item in filesThree)
  506. {
  507. FileInfo info = new FileInfo(item);
  508. DateTime createTime = info.CreationTime;
  509. DateTime timeNow = DateTime.Now;
  510. if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days)
  511. {
  512. Directory.Delete(item, true);
  513. }
  514. }
  515. }
  516. string[] filesFour = Directory.GetDirectories("AccessFile//DB//炒锅4状态数据");
  517. if (filesFour.Count() > 0)
  518. {
  519. foreach (var item in filesFour)
  520. {
  521. FileInfo info = new FileInfo(item);
  522. DateTime createTime = info.CreationTime;
  523. DateTime timeNow = DateTime.Now;
  524. if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days)
  525. {
  526. Directory.Delete(item, true);
  527. }
  528. }
  529. }
  530. string[] filesFive = Directory.GetDirectories("AccessFile//DB//炒锅5状态数据");
  531. if (filesFive.Count() > 0)
  532. {
  533. foreach (var item in filesFive)
  534. {
  535. FileInfo info = new FileInfo(item);
  536. DateTime createTime = info.CreationTime;
  537. DateTime timeNow = DateTime.Now;
  538. if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days)
  539. {
  540. Directory.Delete(item, true);
  541. }
  542. }
  543. }
  544. }
  545. catch (Exception)
  546. {
  547. // throw;
  548. }
  549. }
  550. /// <summary>
  551. /// 时间差计算
  552. /// </summary>
  553. /// <param name="t">当前时间</param>
  554. /// <param name="t2">创建时间</param>
  555. /// <returns></returns>
  556. private int TimeDiff(DateTime t, DateTime t2)
  557. {
  558. long lReturn = -1;
  559. System.TimeSpan NowValue = new TimeSpan(t.Ticks);
  560. System.TimeSpan TimeValue = new TimeSpan(t2.Ticks);
  561. System.TimeSpan DateDiff = TimeSpan.Zero;
  562. try
  563. {
  564. //计算时间差
  565. //DateDiff = TimeValue.Subtract(NowValue).Duration();
  566. DateDiff = NowValue.Subtract(TimeValue);
  567. int h = DateDiff.Hours;
  568. int m = DateDiff.Minutes;
  569. return DateDiff.Days;
  570. }
  571. catch
  572. {
  573. return -1;
  574. }
  575. }
  576. /// <summary>
  577. /// 炒锅数据实时保存
  578. /// </summary>
  579. /// <exception cref="NotImplementedException"></exception>
  580. private void SaveFryPotData()
  581. {
  582. Task.Run(new Action(() =>
  583. {
  584. while (true)
  585. {
  586. FryPotDataSaveToBinaryFile(); Thread.Sleep(1000);
  587. }
  588. }));
  589. }
  590. /// <summary>
  591. /// 时间判断,数据处理
  592. /// </summary>
  593. private void DateTimeJudge()
  594. {
  595. #region sqlite数据库保存
  596. //if (Sqlite<PotOneStatus>.GetInstance.GetData().Count > 0)
  597. //{
  598. // string time1 = Sqlite<PotOneStatus>.GetInstance.GetData().Last().Time;
  599. // if (time1.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样
  600. // {
  601. // FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy = Sqlite<PotOneStatus>.GetInstance.GetData().Last().TotalOilCapactiy;
  602. // FryPotMonitorManage.GetInstance.fryOne.TotalProduct = Sqlite<PotOneStatus>.GetInstance.GetData().Last().TotalProduct;
  603. // }
  604. //}
  605. //if (Sqlite<PotTwoStatus>.GetInstance.GetData().Count > 0)
  606. //{
  607. // string time2 = Sqlite<PotTwoStatus>.GetInstance.GetData().Last().Time;
  608. // if (time2.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样
  609. // {
  610. // FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy = Sqlite<PotTwoStatus>.GetInstance.GetData().Last().TotalOilCapactiy;
  611. // FryPotMonitorManage.GetInstance.fryTwo.TotalProduct = Sqlite<PotTwoStatus>.GetInstance.GetData().Last().TotalProduct;
  612. // }
  613. //}
  614. //if (Sqlite<PotThreeStatus>.GetInstance.GetData().Count > 0)
  615. //{
  616. // string time3 = Sqlite<PotThreeStatus>.GetInstance.GetData().Last().Time;
  617. // if (time3.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样
  618. // {
  619. // FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy = Sqlite<PotThreeStatus>.GetInstance.GetData().Last().TotalOilCapactiy;
  620. // FryPotMonitorManage.GetInstance.fryThree.TotalProduct = Sqlite<PotThreeStatus>.GetInstance.GetData().Last().TotalProduct;
  621. // }
  622. //}
  623. //if (Sqlite<PotFourStatus>.GetInstance.GetData().Count > 0)
  624. //{
  625. // string time4 = Sqlite<PotFourStatus>.GetInstance.GetData().Last().Time;
  626. // if (time4.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样
  627. // {
  628. // FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy = Sqlite<PotFourStatus>.GetInstance.GetData().Last().TotalOilCapactiy;
  629. // FryPotMonitorManage.GetInstance.fryFour.TotalProduct = Sqlite<PotFourStatus>.GetInstance.GetData().Last().TotalProduct;
  630. // }
  631. //}
  632. //if (Sqlite<PotFiveStatus>.GetInstance.GetData().Count > 0)
  633. //{
  634. // string time5 = Sqlite<PotFiveStatus>.GetInstance.GetData().Last().Time;
  635. // if (time5.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样
  636. // {
  637. // FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy = Sqlite<PotFiveStatus>.GetInstance.GetData().Last().TotalOilCapactiy;
  638. // FryPotMonitorManage.GetInstance.fryFive.TotalProduct = Sqlite<PotFiveStatus>.GetInstance.GetData().Last().TotalProduct;
  639. // }
  640. //}
  641. #endregion
  642. string p1 = "AccessFile//" + "Statistic//" + "FryOne.txt";
  643. string p2 = "AccessFile//" + "Statistic//" + "FryTwo.txt";
  644. string p3 = "AccessFile//" + "Statistic//" + "FryThree.txt";
  645. string p4 = "AccessFile//" + "Statistic//" + "FryFour.txt";
  646. string p5 = "AccessFile//" + "Statistic//" + "FryFive.txt";
  647. if (!Directory.Exists("AccessFile//" + "Statistic"))
  648. Directory.CreateDirectory("AccessFile//" + "Statistic");
  649. if (File.Exists(p1))
  650. {
  651. using (StreamReader sReader = new StreamReader(p1, Encoding.UTF8))
  652. {
  653. string time = sReader.ReadLine();
  654. string statistic = sReader.ReadLine();
  655. if (DateTime.Now.ToShortDateString() == time)
  656. {
  657. FryPotMonitorManage.GetInstance.fryOne.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]);
  658. FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]);
  659. }
  660. }
  661. }
  662. if (File.Exists(p2))
  663. {
  664. using (StreamReader sReader = new StreamReader(p2, Encoding.UTF8))
  665. {
  666. string time = sReader.ReadLine();
  667. string statistic = sReader.ReadLine();
  668. if (DateTime.Now.ToShortDateString() == time)
  669. {
  670. FryPotMonitorManage.GetInstance.fryTwo.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]);
  671. FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]);
  672. }
  673. }
  674. }
  675. if (File.Exists(p3))
  676. {
  677. using (StreamReader sReader = new StreamReader(p3, Encoding.UTF8))
  678. {
  679. string time = sReader.ReadLine();
  680. string statistic = sReader.ReadLine();
  681. if (DateTime.Now.ToShortDateString() == time)
  682. {
  683. FryPotMonitorManage.GetInstance.fryThree.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]);
  684. FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]);
  685. }
  686. }
  687. }
  688. if (File.Exists(p4))
  689. {
  690. using (StreamReader sReader = new StreamReader(p4, Encoding.UTF8))
  691. {
  692. string time = sReader.ReadLine();
  693. string statistic = sReader.ReadLine();
  694. if (DateTime.Now.ToShortDateString() == time)
  695. {
  696. FryPotMonitorManage.GetInstance.fryFour.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]);
  697. FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]);
  698. }
  699. }
  700. }
  701. if (File.Exists(p5))
  702. {
  703. using (StreamReader sReader = new StreamReader(p5, Encoding.UTF8))
  704. {
  705. string time = sReader.ReadLine();
  706. string statistic = sReader.ReadLine();
  707. if (DateTime.Now.ToShortDateString() == time)
  708. {
  709. FryPotMonitorManage.GetInstance.fryFive.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]);
  710. FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]);
  711. }
  712. }
  713. }
  714. }
  715. /// <summary>
  716. /// AGV上下料上报数据解析
  717. /// </summary>
  718. /// <param name="obj"></param>
  719. private void AgvFeedBackUpReportDataAnalysis(object obj)
  720. {
  721. //if (obj != null && obj is byte[] datas)
  722. //{
  723. //string strData = Encoding.UTF8.GetString(datas);
  724. EventData objData = JsonConvert.DeserializeObject<EventData>(obj.ToString());
  725. if (objData != null)
  726. {
  727. AGVHelper.GetInstance.UpDownFeedBack(objData.agvCode, objData.jobId, objData.msgId);
  728. #region 线体到炒锅请求上下料
  729. //线体1请求上下料
  730. if (objData.equipmentId == 1 && objData.command == "LOAD")//同一任务号且处于上料阶段,AGV请求上料
  731. {
  732. globalVar.agvArriveUpLoad = true;//AGV到达上料位置
  733. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.agvCode}】AGV【1】号滚筒线上料请求");
  734. }
  735. if ((objData.equipmentId == 5 || objData.equipmentId == 8) && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  736. {
  737. globalVar.agvArriveUnLoad = true;//AGV到达下料位置
  738. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.agvCode}】AGV【{globalVar.LOneFryPotSerial}】号炒锅下料请求");
  739. }
  740. //线体2请求上下料
  741. if (objData.equipmentId == 2 && objData.command == "LOAD")
  742. {
  743. globalVar.agvArriveLTwoUpLoad = true;//AGV到达上料位置
  744. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.agvCode}】AGV【2】号滚筒线上料请求");
  745. }
  746. if ((objData.equipmentId == 6 || objData.equipmentId == 9) && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  747. {
  748. globalVar.LTwoagvArriveUnLoad = true;//AGV到达下料位置
  749. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.agvCode}】AGV【{globalVar.LTwoFryPotSerial}】号炒锅下料请求");
  750. }
  751. //线体3请求上下料
  752. if (objData.equipmentId == 3 && objData.command == "LOAD")
  753. {
  754. globalVar.agvArriveLThreeUpLoad = true;//AGV到达上料位置
  755. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.agvCode}】AGV【3】号滚筒线上料请求");
  756. }
  757. if (objData.equipmentId == 7 && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  758. {
  759. globalVar.LThreeagvArriveUnLoad = true;//AGV到达下料位置
  760. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.agvCode}】AGV【{globalVar.LThreeFryPotSerial}】号炒锅下料请求");
  761. }
  762. #endregion
  763. #region 炒锅到线体4请求上下料
  764. //炒锅1,4到线体4
  765. if ((objData.equipmentId == 5 || objData.equipmentId == 8) && objData.command == "LOAD")//同一任务号且处于上料阶段,AGV请求上料
  766. {
  767. globalVar.agvArriveUpLoad = true;//AGV到达上料位置
  768. MessageNotify.GetInstance.ShowRunLog($"编号【{objData.agvCode}】AGV到达【{globalVar.LOneFryPotSerial}】号炒锅空桶上料位置");
  769. AgvArriveFryPotOneOrFourOutEmptyRollerSingleSetDown();//发送AGV到位信号
  770. }
  771. if (objData.equipmentId == 40 && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  772. {
  773. globalVar.rollerLineOne.agvArriveLineFour = true;//AGV到达下料位置
  774. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.agvCode}】AGV回桶线下料请求");
  775. }
  776. //炒锅2,5到线体4
  777. if ((objData.equipmentId == 6 || objData.equipmentId == 9) && objData.command == "LOAD")
  778. {
  779. globalVar.agvArriveLTwoUpLoad = true;//AGV到达上料位置
  780. MessageNotify.GetInstance.ShowRunLog($"编号【{objData.agvCode}】AGV到达【{globalVar.LTwoFryPotSerial}】号炒锅空桶上料位置");
  781. AgvArriveFryPotTwoOrFiveOutEmptyRollerSingleSetDown();//发送AGV到位信号
  782. }
  783. if (objData.equipmentId == 41 && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  784. {
  785. globalVar.rollerLineTwo.agvArriveLineFour = true;//AGV到达下料位置
  786. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.agvCode}】AGV回桶线下料请求");
  787. }
  788. //炒锅3到线体4
  789. if (objData.equipmentId == 7 && objData.command == "LOAD")
  790. {
  791. globalVar.agvArriveLThreeUpLoad = true;//AGV到达上料位置
  792. MessageNotify.GetInstance.ShowRunLog($"编号【{objData.agvCode}】AGV到达【{globalVar.LThreeFryPotSerial}】号炒锅空桶上料位置");
  793. AgvArriveFryPotThreeOutEmptyRollerSingleSetDown();//发送AGV到位信号
  794. }
  795. if (objData.equipmentId == 42 && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  796. {
  797. globalVar.rollerLineThree.agvArriveLineFour = true;//AGV到达下料位置
  798. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.agvCode}】AGV回桶线下料请求");
  799. }
  800. #endregion
  801. #region 线体123到清洗台请求上下料
  802. //线体1到清洗台
  803. if (objData.equipmentId == 11 && objData.command == "LOAD")//同一任务号且处于上料阶段,AGV请求上料
  804. {
  805. globalVar.agvArriveLineOneLoadEmptyRoller = true;//AGV到达上料位置
  806. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.agvCode}】AGV【1】号滚筒线上料请求");
  807. }
  808. if (objData.equipmentId == 10 && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  809. {
  810. globalVar.rollerLineOne.agvArriveCleanUnLoad = true;//AGV到达下料位置
  811. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.agvCode}】AGV洗桶机下料请求");
  812. }
  813. //线体2到清洗台
  814. if (objData.equipmentId == 22 && objData.command == "LOAD")
  815. {
  816. globalVar.agvArriveLineTwoLoadEmptyRoller = true;//AGV到达上料位置
  817. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.agvCode}】AGV【2】号滚筒线上料请求");
  818. }
  819. if (objData.equipmentId == 20 && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  820. {
  821. globalVar.rollerLineTwo.agvArriveCleanUnLoad = true;//AGV到达下料位置
  822. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.agvCode}】AGV洗桶机下料请求");
  823. }
  824. if (objData.equipmentId == 33 && objData.command == "LOAD")
  825. {
  826. globalVar.agvArriveLineThreeLoadEmptyRoller = true;//AGV到达上料位置
  827. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.agvCode}】AGV【3】号滚筒线上料请求");
  828. }
  829. if (objData.equipmentId == 30 && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  830. {
  831. globalVar.rollerLineThree.agvArriveCleanUnLoad = true;//AGV到达下料位置
  832. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.agvCode}】AGV洗桶机下料请求");
  833. }
  834. #endregion
  835. #region 清洗台到线体4请求上下料
  836. if (objData.equipmentId == 10 && objData.command == "LOAD")
  837. {
  838. globalVar.agvArriveCleanLoad = true;//agv到达清洗台上料位置
  839. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.agvCode}】AGV洗桶机上料请求");
  840. }
  841. if (objData.equipmentId == 44 && objData.command == "UNLOAD")
  842. {
  843. globalVar.agvArriveLineFour = true;//agv到达线体4下料位置
  844. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.agvCode}】AGV回桶线下料请求");
  845. }
  846. #endregion
  847. }
  848. }
  849. /// <summary>
  850. /// AGV搬运任务上报数据解析
  851. /// </summary>
  852. /// <param name="obj"></param>
  853. private void AgvTaskUpReportDataAnalysis(object obj)
  854. {
  855. TaskEventData objData;
  856. try
  857. {
  858. objData = JsonConvert.DeserializeObject<TaskEventData>(obj.ToString());
  859. }
  860. catch (Exception)
  861. {
  862. MessageNotify.GetInstance.ShowRunLog("Agv任务回报数据异常");
  863. objData = null;
  864. }
  865. if (objData != null)
  866. {
  867. if (objData.state == "ABNORMAL_COMPLETED")
  868. {
  869. if (objData.robotJobId == LOnerobotJobId)
  870. {
  871. globalVar.LineOneRobotTaskError = true;
  872. MessageNotify.GetInstance.ShowRunLog($"编号【{objData.jobData.agvCode}】AGV小车任务【{objData.robotJobId}】执行异常,请人工介入");
  873. }
  874. if (objData.robotJobId == LTworobotJobId)
  875. {
  876. globalVar.LineTwoRobotTaskError = true;
  877. MessageNotify.GetInstance.ShowRunLog($"编号【{objData.jobData.agvCode}】AGV小车任务【{objData.robotJobId}】执行异常,请人工介入");
  878. }
  879. if (objData.robotJobId == LThreerobotJobId)
  880. {
  881. globalVar.LineThreeRobotTaskError = true;
  882. MessageNotify.GetInstance.ShowRunLog($"编号【{objData.jobData.agvCode}】AGV小车任务【{objData.robotJobId}】执行异常,请人工介入");
  883. }
  884. if (objData.robotJobId == LFourrobotJobId)
  885. {
  886. globalVar.LineFourRobotTaskError = true;
  887. MessageNotify.GetInstance.ShowRunLog($"编号【{objData.jobData.agvCode}】AGV小车任务【{objData.robotJobId}】执行异常,请人工介入");
  888. }
  889. if (objData.robotJobId == LFiverobotJobId)
  890. {
  891. globalVar.LineFiveRobotTaskError = true;
  892. MessageNotify.GetInstance.ShowRunLog($"编号【{objData.jobData.agvCode}】AGV小车任务【{objData.robotJobId}】执行异常,请人工介入");
  893. }
  894. if (objData.robotJobId == LSixrobotJobId)
  895. {
  896. globalVar.LineSixRobotTaskError = true;
  897. MessageNotify.GetInstance.ShowRunLog($"编号【{objData.jobData.agvCode}】AGV小车任务【{objData.robotJobId}】执行异常,请人工介入");
  898. }
  899. if (LSevenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null)
  900. {
  901. globalVar.LineSevenRobotTaskError = true;
  902. MessageNotify.GetInstance.ShowRunLog($"编号【{objData.jobData.agvCode}】AGV小车任务【{objData.robotJobId}】执行异常,请人工介入");
  903. }
  904. if (LEightrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null)
  905. {
  906. globalVar.LineEightRobotTaskError = true;
  907. MessageNotify.GetInstance.ShowRunLog($"编号【{objData.jobData.agvCode}】AGV小车任务【{objData.robotJobId}】执行异常,请人工介入");
  908. }
  909. if (LNinerobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null)
  910. {
  911. globalVar.LineNineRobotTaskError = true;
  912. MessageNotify.GetInstance.ShowRunLog($"编号【{objData.jobData.agvCode}】AGV小车任务【{objData.robotJobId}】执行异常,请人工介入");
  913. }
  914. if (LTenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null)
  915. {
  916. globalVar.LineTenRobotTaskError = true;
  917. MessageNotify.GetInstance.ShowRunLog($"编号【{objData.jobData.agvCode}】AGV小车任务【{objData.robotJobId}】执行异常,请人工介入");
  918. }
  919. }
  920. #region 线体上下料任务信息回报
  921. //线体1任务上报
  922. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LOnerobotJobId && objData.jobData.startPointCode == "sTEwzw")// AGV正在上料,指线体上料
  923. {
  924. }
  925. //线体2任务上报
  926. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LTworobotJobId && objData.jobData.startPointCode == "PChS6R")// AGV正在上料,指线体上料
  927. {
  928. //日志
  929. }
  930. //线体3任务上报
  931. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LThreerobotJobId && objData.jobData.startPointCode == "HHif8Z")// AGV正在上料,指线体上料
  932. {
  933. //日志
  934. }
  935. //线体1任务上报
  936. if (objData.state == "LOAD_COMPLETED" && objData.robotJobId == LOnerobotJobId && objData.jobData.startPointCode == "sTEwzw")//指定上料点上料完成,这里指线体上料
  937. {
  938. DeviceOperate.GetInstance.WritePlcData("D1052", 0);
  939. globalVar.agvLineOneLoadCom = true;
  940. AgvViewModel.GetInstance().Set滚筒线上数量(1, (--globalVar.LOneMaterialNum).ToString());
  941. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.Yes);
  942. if (globalVar.LOneFryPotSerial == 1)
  943. {
  944. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.yc_1_1);
  945. }
  946. else if (globalVar.LOneFryPotSerial == 4)
  947. {
  948. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.yc_1_4);
  949. }
  950. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV线体1→炒锅【{globalVar.LOneFryPotSerial}】上料完成信号,任务号【{objData.robotJobId}】");
  951. }
  952. //线体2任务上报
  953. if (objData.state == "LOAD_COMPLETED" && objData.robotJobId == LTworobotJobId && objData.jobData.startPointCode == "PChS6R")//指定上料点上料完成,这里指线体上料
  954. {
  955. DeviceOperate.GetInstance.WritePlcData("D1053", 0);
  956. globalVar.agvLineTwoLoadCom = true;
  957. AgvViewModel.GetInstance().Set滚筒线上数量(2, (--globalVar.LTwoMaterialNum).ToString());
  958. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.Yes);
  959. if (globalVar.LTwoFryPotSerial == 2)
  960. {
  961. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.yc_2_2);
  962. }
  963. else if (globalVar.LTwoFryPotSerial == 5)
  964. {
  965. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.yc_2_5);
  966. }
  967. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV线体2→炒锅【{globalVar.LTwoFryPotSerial}】上料完成信号,任务号【{objData.robotJobId}】");
  968. }
  969. //线体3任务上报
  970. if (objData.state == "LOAD_COMPLETED" && objData.robotJobId == LThreerobotJobId && objData.jobData.startPointCode == "HHif8Z")//指定上料点上料完成,这里指线体上料
  971. {
  972. DeviceOperate.GetInstance.WritePlcData("D1054", 0);
  973. globalVar.agvLineThreeLoadCom = true;
  974. AgvViewModel.GetInstance().Set滚筒线上数量(3, (--globalVar.LThreeMaterialNum).ToString());
  975. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.Yes);
  976. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.yc_3_3);
  977. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV线体3→炒锅【{globalVar.LThreeFryPotSerial}】上料完成信号,任务号【{objData.robotJobId}】");
  978. }
  979. //线体1任务上报
  980. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LOnerobotJobId && (objData.jobData.targetPointCode == "DXDnMJ" || objData.jobData.targetPointCode == "naFssQ"))//指定下料点正在下料,指线体到炒锅下料
  981. {
  982. }
  983. //线体2任务上报
  984. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LTworobotJobId && (objData.jobData.targetPointCode == "PChS6R" || objData.jobData.targetPointCode == "sxSX88"))//指定下料点正在下料,指线体到炒锅下料
  985. {
  986. }
  987. //线体3任务上报
  988. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LThreerobotJobId && objData.jobData.targetPointCode == "biZG87")//指定下料点正在下料,指线体到炒锅下料
  989. {
  990. }
  991. //线体1任务上报
  992. if (objData.state == "DONE" && objData.robotJobId == LOnerobotJobId && (objData.jobData.targetPointCode == "DXDnMJ" || objData.jobData.targetPointCode == "naFssQ"))//指定下料位置下料完成,指线体到炒锅下料
  993. {
  994. if (objData.jobData.targetPointCode == "DXDnMJ")
  995. {
  996. DeviceOperate.GetInstance.WritePlcData("D1055", 0);
  997. }
  998. else
  999. {
  1000. DeviceOperate.GetInstance.WritePlcData("D1058", 0);
  1001. }
  1002. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  1003. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hj);
  1004. AgvViewModel.GetInstance().Set小车停止(agvCode[objData.jobData.agvCode]);
  1005. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  1006. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV炒锅【{globalVar.LOneFryPotSerial}】下料完成信号,任务号【{objData.robotJobId}】");
  1007. }
  1008. //线体2任务上报
  1009. if (objData.state == "DONE" && objData.robotJobId == LTworobotJobId && (objData.jobData.targetPointCode == "CDPGde" || objData.jobData.targetPointCode == "sxSX88"))//指定下料位置下料完成,指线体到炒锅下料
  1010. {
  1011. if (objData.jobData.targetPointCode == "CDPGde")
  1012. {
  1013. DeviceOperate.GetInstance.WritePlcData("D1056", 0);
  1014. }
  1015. else
  1016. {
  1017. DeviceOperate.GetInstance.WritePlcData("D1059", 0);
  1018. }
  1019. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  1020. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hj);
  1021. AgvViewModel.GetInstance().Set小车停止(agvCode[objData.jobData.agvCode]);
  1022. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  1023. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV炒锅【{globalVar.LTwoFryPotSerial}】下料完成信号,任务号【{objData.robotJobId}】");
  1024. }
  1025. //线体3任务上报
  1026. if (objData.state == "DONE" && objData.robotJobId == LThreerobotJobId && objData.jobData.targetPointCode == "biZG87")//指定下料位置下料完成,指线体到炒锅下料
  1027. {
  1028. DeviceOperate.GetInstance.WritePlcData("D1057", 0);
  1029. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  1030. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hj);
  1031. AgvViewModel.GetInstance().Set小车停止(agvCode[objData.jobData.agvCode]);
  1032. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  1033. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV炒锅【{globalVar.LThreeFryPotSerial}】下料完成信号,任务号【{objData.robotJobId}】");
  1034. }
  1035. #endregion
  1036. #region 炒锅空桶上下料任务信息回报
  1037. //线体1任务上报
  1038. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LFourrobotJobId && (objData.jobData.startPointCode == "DXDnMJ" || objData.jobData.startPointCode == "naFssQ"))// AGV正在上料,指炒锅空桶上料
  1039. {
  1040. //日志
  1041. }
  1042. //线体2任务上报
  1043. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LFiverobotJobId && (objData.jobData.startPointCode == "CDPGde" || objData.jobData.startPointCode == "sxSX88"))// AGV正在上料,指炒锅空桶上料
  1044. {
  1045. //日志
  1046. }
  1047. //线体3任务上报
  1048. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LSixrobotJobId && objData.jobData.startPointCode == "biZG87")// AGV正在上料,指炒锅空桶上料
  1049. {
  1050. //日志
  1051. }
  1052. //线体1任务上报
  1053. if (objData.state == "LOAD_COMPLETED" && objData.robotJobId == LFourrobotJobId && (objData.jobData.startPointCode == "DXDnMJ" || objData.jobData.startPointCode == "naFssQ"))//指定上料点上料完成,这里指炒锅空桶上料
  1054. {
  1055. if (objData.jobData.startPointCode == "DXDnMJ")
  1056. {
  1057. DeviceOperate.GetInstance.WritePlcData("D1060", 0);
  1058. }
  1059. else
  1060. {
  1061. DeviceOperate.GetInstance.WritePlcData("D1063", 0);
  1062. }
  1063. globalVar.agvFryPotEmptyRollerArrive = true;
  1064. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.OnllYes);
  1065. if (globalVar.LOneFryPotSerial == 1)
  1066. {
  1067. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hs_1);
  1068. }
  1069. else if (globalVar.LOneFryPotSerial == 4)
  1070. {
  1071. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hs_4);
  1072. }
  1073. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV炒锅【{globalVar.LOneFryPotSerial}】上料完成信号,任务号【{objData.robotJobId}】");
  1074. }
  1075. //线体2任务上报
  1076. if (objData.state == "LOAD_COMPLETED" && objData.robotJobId == LFiverobotJobId && (objData.jobData.startPointCode == "CDPGde" || objData.jobData.startPointCode == "sxSX88"))//指定上料点上料完成,这里指炒锅空桶上料
  1077. {
  1078. if (objData.jobData.startPointCode == "CDPGde")
  1079. {
  1080. DeviceOperate.GetInstance.WritePlcData("D1061", 0);
  1081. }
  1082. else
  1083. {
  1084. DeviceOperate.GetInstance.WritePlcData("D1064", 0);
  1085. }
  1086. globalVar.LTwoagvFryPotEmptyRollerArrive = true;
  1087. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.OnllYes);
  1088. if (globalVar.LTwoFryPotSerial == 2)
  1089. {
  1090. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hs_2);
  1091. }
  1092. else if (globalVar.LTwoFryPotSerial == 5)
  1093. {
  1094. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hs_5);
  1095. }
  1096. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV炒锅【{globalVar.LTwoFryPotSerial}】上料完成信号,任务号【{objData.robotJobId}】");
  1097. }
  1098. //线体3任务上报
  1099. if (objData.state == "LOAD_COMPLETED" && objData.robotJobId == LSixrobotJobId && objData.jobData.startPointCode == "biZG87")//指定上料点上料完成,这里指炒锅空桶上料
  1100. {
  1101. DeviceOperate.GetInstance.WritePlcData("D1062", 0);
  1102. globalVar.LThreeagvFryPotEmptyRollerArrive = true;
  1103. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.OnllYes);
  1104. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.hs_3);
  1105. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV炒锅【{globalVar.LThreeFryPotSerial}】上料完成信号,任务号【{objData.robotJobId}】");
  1106. }
  1107. //线体1任务上报
  1108. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LFourrobotJobId && objData.jobData.targetPointCode == "w2jZhM")//指定下料点正在下料,指炒锅空桶下料
  1109. {
  1110. AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
  1111. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  1112. }
  1113. //线体2任务上报
  1114. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LFiverobotJobId && objData.jobData.targetPointCode == "w2jZhM")//指定下料点正在下料,指炒锅空桶下料
  1115. {
  1116. AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
  1117. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  1118. }
  1119. //线体3任务上报
  1120. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LSixrobotJobId && objData.jobData.targetPointCode == "w2jZhM")//指定下料点正在下料,指炒锅空桶下料
  1121. {
  1122. AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
  1123. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  1124. }
  1125. //线体1任务上报
  1126. if (objData.state == "DONE" && objData.robotJobId == LFourrobotJobId && objData.jobData.targetPointCode == "w2jZhM")//指定下料位置下料完成,指炒锅空桶下料
  1127. {
  1128. MessageNotify.GetInstance.ShowRunLog("1号线炒锅空桶在4号线卸桶完成");
  1129. DeviceOperate.GetInstance.WritePlcData("D1067", 0);
  1130. if (globalVar.LFourRollerNum >= 8)
  1131. {
  1132. AgvViewModel.GetInstance().Set滚筒线上数量(4, "8");
  1133. }
  1134. else
  1135. {
  1136. AgvViewModel.GetInstance().Set滚筒线上数量(4, (++globalVar.LFourRollerNum).ToString());
  1137. }
  1138. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], AgvViewModel.GetInstance().GetCommandValue("hj"));
  1139. AgvViewModel.GetInstance().Set小车停止(agvCode[objData.jobData.agvCode]);
  1140. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  1141. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV炒锅【{globalVar.LOneFryPotSerial}】→回桶线下料完成信号,任务号【{objData.robotJobId}】");
  1142. }
  1143. //线体2任务上报
  1144. if (objData.state == "DONE" && objData.robotJobId == LFiverobotJobId && objData.jobData.targetPointCode == "w2jZhM")//指定下料位置下料完成,指炒锅空桶下料
  1145. {
  1146. MessageNotify.GetInstance.ShowRunLog("2号线炒锅空桶在4号线卸桶完成");
  1147. DeviceOperate.GetInstance.WritePlcData("D1067", 0);
  1148. if (globalVar.LFourRollerNum >= 8)
  1149. {
  1150. AgvViewModel.GetInstance().Set滚筒线上数量(4, "8");
  1151. }
  1152. else
  1153. {
  1154. AgvViewModel.GetInstance().Set滚筒线上数量(4, (++globalVar.LFourRollerNum).ToString());
  1155. }
  1156. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], AgvViewModel.GetInstance().GetCommandValue("hj"));
  1157. AgvViewModel.GetInstance().Set小车停止(agvCode[objData.jobData.agvCode]);
  1158. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  1159. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV【{globalVar.LTwoFryPotSerial}】→回桶线下料完成信号,任务号【{objData.robotJobId}】");
  1160. }
  1161. //线体3任务上报
  1162. if (objData.state == "DONE" && objData.robotJobId == LSixrobotJobId && objData.jobData.targetPointCode == "w2jZhM")//指定下料位置下料完成,指炒锅空桶下料
  1163. {
  1164. MessageNotify.GetInstance.ShowRunLog("3号线炒锅空桶在4号线卸桶完成");
  1165. DeviceOperate.GetInstance.WritePlcData("D1067", 0);
  1166. if (globalVar.LFourRollerNum >= 8)
  1167. {
  1168. AgvViewModel.GetInstance().Set滚筒线上数量(4, "8");
  1169. }
  1170. else
  1171. {
  1172. AgvViewModel.GetInstance().Set滚筒线上数量(4, (++globalVar.LFourRollerNum).ToString());
  1173. }
  1174. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], AgvViewModel.GetInstance().GetCommandValue("hj"));
  1175. AgvViewModel.GetInstance().Set小车停止(agvCode[objData.jobData.agvCode]);
  1176. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  1177. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV【{globalVar.LThreeFryPotSerial}】→回桶线下料完成信号,任务号【{objData.robotJobId}】");
  1178. }
  1179. #endregion
  1180. #region 线体123空桶到清戏台
  1181. //线体1任务上报
  1182. if (objData.state == "LOAD_COMPLETED" && LSevenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "sTEwzw")//指定上料点上料完成,这里指线体1空桶上料
  1183. {
  1184. DeviceOperate.GetInstance.WritePlcData("D1052", 0);
  1185. globalVar.agvArriveLineOneLoadCom = true;
  1186. AgvViewModel.GetInstance().Set滚筒线上数量(1, (--globalVar.LOneMaterialNum).ToString());
  1187. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.OnllYes);
  1188. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.tqx_1);
  1189. //到清洗处
  1190. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV线体1→洗桶机上料完成信号,任务号【{objData.robotJobId}】");
  1191. }
  1192. //线体2任务上报
  1193. if (objData.state == "LOAD_COMPLETED" && LEightrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "PChS6R")//指定上料点上料完成,这里指线体2空桶上料
  1194. {
  1195. DeviceOperate.GetInstance.WritePlcData("D1053", 0);
  1196. globalVar.agvArriveLineTwoLoadCom = true;
  1197. AgvViewModel.GetInstance().Set滚筒线上数量(2, (--globalVar.LTwoMaterialNum).ToString());
  1198. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.OnllYes);
  1199. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.tqx_2);
  1200. //到清洗处
  1201. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV线体2→洗桶机上料完成信号,任务号【{objData.robotJobId}】");
  1202. }
  1203. //线体3任务上报
  1204. if (objData.state == "LOAD_COMPLETED" && LNinerobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "HHif8Z")//指定上料点上料完成,这里指线体3空桶上料
  1205. {
  1206. DeviceOperate.GetInstance.WritePlcData("D1054", 0);
  1207. globalVar.agvArriveLineThreeLoadCom = true;
  1208. AgvViewModel.GetInstance().Set滚筒线上数量(3, (--globalVar.LThreeMaterialNum).ToString());
  1209. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.OnllYes);
  1210. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.tqx_3);
  1211. //到清洗处
  1212. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV线体3→洗桶机上料完成信号,任务号【{objData.robotJobId}】");
  1213. }
  1214. if (objData.state == "DONE" && LSevenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.targetPointCode == "TitRYC")//指定下料位置下料完成,指从线体1到清戏台空桶下料
  1215. {
  1216. DeviceOperate.GetInstance.WritePlcData("D1065", 0);
  1217. LSevenrobotJobId.Remove(objData.robotJobId);
  1218. MessageNotify.GetInstance.ShowRunLog("线体【1】空桶在清洗台卸桶完成");
  1219. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  1220. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.qxt_hj);
  1221. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  1222. AgvViewModel.GetInstance().SetCleanRollerNum(++CleanNum);
  1223. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV线体1→洗桶机下料完成信号,任务号【{objData.robotJobId}】");
  1224. }
  1225. if (objData.state == "DONE" && LEightrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.targetPointCode == "TitRYC")//指定下料位置下料完成,指从线体2到清戏台空桶下料
  1226. {
  1227. DeviceOperate.GetInstance.WritePlcData("D1065", 0);
  1228. LEightrobotJobId.Remove(objData.robotJobId);
  1229. MessageNotify.GetInstance.ShowRunLog("线体【2】空桶在清洗台卸桶完成");
  1230. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  1231. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.qxt_hj);
  1232. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  1233. AgvViewModel.GetInstance().SetCleanRollerNum(++CleanNum);
  1234. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV线体2→洗桶机下料完成信号,任务号【{objData.robotJobId}】");
  1235. }
  1236. if (objData.state == "DONE" && LNinerobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.targetPointCode == "TitRYC")//指定下料位置下料完成,指从线体3到清戏台空桶下料
  1237. {
  1238. DeviceOperate.GetInstance.WritePlcData("D1065", 0);
  1239. LNinerobotJobId.Remove(objData.robotJobId);
  1240. MessageNotify.GetInstance.ShowRunLog("线体【3】空桶在清洗台卸桶完成");
  1241. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  1242. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.qxt_hj);
  1243. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  1244. AgvViewModel.GetInstance().SetCleanRollerNum(++CleanNum);
  1245. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV线体3→洗桶机下料完成信号,任务号【{objData.robotJobId}】");
  1246. }
  1247. #endregion
  1248. #region 清洗台到线体4
  1249. if (objData.state == "LOAD_COMPLETED" && LTenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.startPointCode == "TitRYC")//指定上料位置上料完成,指清戏台空桶到上料
  1250. {
  1251. DeviceOperate.GetInstance.WritePlcData("D1066", 0);
  1252. // globalVar.AllowNextEmptyRollerToClean = true;//AGV到滚筒线搬运空桶的允许标志
  1253. MessageNotify.GetInstance.ShowRunLog("清洗台空桶装载完成");
  1254. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.OnllYes);
  1255. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], CartMotionTrajectory.qxt_4);//去四号空桶线
  1256. AgvViewModel.GetInstance().SetCleanRollerNum(--CleanNum);
  1257. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV洗桶机上料完成信号,任务号【{objData.robotJobId}】");
  1258. }
  1259. if (objData.state == "ROLLER_UNLOAD_DOING" && LTenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.targetPointCode == "TitRYC")//指定下料点正在下料,指清洗台空桶到线体4下料
  1260. {
  1261. AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
  1262. MessageNotify.GetInstance.ShowRunLog($"收到编号【{objData.jobData.agvCode}】AGV回桶线下料完成信号,任务号【{objData.robotJobId}】");
  1263. }
  1264. if (objData.state == "DONE" && LTenrobotJobId.FirstOrDefault(p => p == objData.robotJobId) != null && objData.jobData.targetPointCode == "w2jZhM")//指定下料位置下料完成,指清戏台空桶到线体4下料
  1265. {
  1266. DeviceOperate.GetInstance.WritePlcData("D1067", 0);
  1267. LTenrobotJobId.Remove(objData.robotJobId);
  1268. MessageNotify.GetInstance.ShowRunLog("【4】号线空桶回桶完成");
  1269. if (globalVar.LFourRollerNum >= 8)
  1270. {
  1271. AgvViewModel.GetInstance().Set滚筒线上数量(4, "8");
  1272. }
  1273. else
  1274. {
  1275. AgvViewModel.GetInstance().Set滚筒线上数量(4, (++globalVar.LFourRollerNum).ToString());
  1276. }
  1277. AgvViewModel.GetInstance().Set小车是否承载物品(agvCode[objData.jobData.agvCode], IsBool.No);
  1278. AgvViewModel.GetInstance().Set小车运动(agvCode[objData.jobData.agvCode], AgvViewModel.GetInstance().GetCommandValue("hj"));
  1279. AgvViewModel.GetInstance().Set小车停止(agvCode[objData.jobData.agvCode]);
  1280. AgvViewModel.GetInstance().Set停车桩(agvCode[objData.jobData.agvCode], IsBool.Yes);
  1281. }
  1282. #endregion
  1283. }
  1284. }
  1285. /// <summary>
  1286. /// 主任务重启
  1287. /// </summary>
  1288. private void ResetProgram()
  1289. {
  1290. TaskManage.GetInstance.StartLong(new Action(() =>
  1291. {
  1292. if (RTrig.GetInstance("ResetProgram").Start(globalVar.PlcInite == 1))//判断是否初始化 一初始化就重启主任务
  1293. {
  1294. MessageNotify.GetInstance.ShowUserLog("主任务正在重启");
  1295. TaskManage.GetInstance.StopTask("MainViewReadPlcData", new Action(() =>
  1296. {
  1297. //ActionManage.GetInstance.CancelRegister("RecipeSetDown");
  1298. //ActionManage.GetInstance.Register(new Action<object>(RecipeDataParse), "RecipeSetDown");
  1299. // ActionManage.GetInstance.Send("ClearRecipes");
  1300. TaskManage.GetInstance.StopTask("滚筒线1任务线程", new Action(() =>
  1301. {
  1302. TaskManage.GetInstance.StopTask("滚筒线2任务线程", new Action(() =>
  1303. {
  1304. TaskManage.GetInstance.StopTask("滚筒线3任务线程", new Action(() =>
  1305. {
  1306. globalVar = null;
  1307. globalVar = new GlobalVariable();
  1308. ReicpeNum = 0;
  1309. ReadPlcData();
  1310. MainTask();
  1311. MessageNotify.GetInstance.ShowUserLog("主任务重启完成");
  1312. }));
  1313. }));
  1314. }));
  1315. }));
  1316. }
  1317. Thread.Sleep(10);
  1318. }), "ResetProgram");
  1319. }
  1320. public void LineOneTaskRestart()
  1321. {
  1322. TaskManage.GetInstance.StopTask("滚筒线1任务线程", new Action(() =>
  1323. {
  1324. WritePlcData("D1101", 0);//复位开始执行指令
  1325. ActionManage.GetInstance.Send("ClearOneRecipes");
  1326. //globalVar.rollerLineOne = null;
  1327. //globalVar.rollerLineOne = new RollerLineOne();
  1328. //globalVar.fryPotOne = null;
  1329. //globalVar.fryPotOne = new FryPotOne();
  1330. //globalVar.fryPotFour = null;
  1331. //globalVar.fryPotFour = new FryPotFour();
  1332. globalVar.rollerLineOne.RecipeComMidSingle = 1;
  1333. globalVar.rollerLineOne.LowSignalJude = false;
  1334. globalVar.rollerLineOne.NextStart = false;
  1335. globalVar.rollerLineOne.IsEpmtyBefore = false;
  1336. globalVar.rollerLineOne.CanRun = true;
  1337. globalVar.ExitLineOneTask = false;
  1338. globalVar.LOneCurrentRecipeName = string.Empty;
  1339. globalVar.AllowAgvToLineLoadRoller = true;
  1340. globalVar.InOrOutputLock = false;
  1341. globalVar.LoadRoller = false;
  1342. globalVar.AgvToFryPot = false;
  1343. globalVar.PotOneInputMaterialArrive = false;
  1344. globalVar.PotOneOutputRollerArrive = false;
  1345. globalVar.AgvArrivePot = false;
  1346. globalVar.LOneMaterialNum = 0;
  1347. globalVar.LOneCurrentCookingStep = 0;
  1348. globalVar.LFourCurrentCookingStep = 0;
  1349. globalVar.agvArriveUpLoad = false;
  1350. globalVar.agvArriveUnLoad = false;
  1351. globalVar.agvFryPotEmptyRollerArrive = false;
  1352. globalVar.rollerLineOne.agvArriveLineFour = false;
  1353. globalVar.agvLineOneLoadCom = false;
  1354. ErrorRecipe = false;
  1355. TaskManage.GetInstance.StartLong(new Action(() => { LineOneProcessExecute(); Thread.Sleep(10); }), "滚筒线1任务线程");
  1356. MessageNotify.GetInstance.ShowUserLog("滚筒线【1】任务重启成功");
  1357. }));
  1358. }
  1359. public void LineTwoTaskRestart()
  1360. {
  1361. TaskManage.GetInstance.StopTask("滚筒线2任务线程", new Action(() =>
  1362. {
  1363. WritePlcData("D1102", 0);//复位开始执行指令
  1364. ActionManage.GetInstance.Send("ClearTwoRecipes");
  1365. //globalVar.rollerLineTwo = null;
  1366. //globalVar.rollerLineTwo = new RollerLineTwo();
  1367. //globalVar.fryPotTwo = null;
  1368. //globalVar.fryPotTwo = new FryPotTwo();
  1369. //globalVar.fryPotFive = null;
  1370. //globalVar.fryPotFive = new FryPotFive();
  1371. globalVar.rollerLineTwo.RecipeComMidSingle = 1;
  1372. globalVar.rollerLineTwo.LowSignalJude = false;
  1373. globalVar.rollerLineTwo.NextStart = false;
  1374. globalVar.rollerLineTwo.IsEpmtyBefore = false;
  1375. globalVar.rollerLineTwo.CanRun = true;
  1376. globalVar.ExitLineTwoTask = false;
  1377. globalVar.LTwoCurrentRecipeName = string.Empty;
  1378. globalVar.AllowAgvToLineTwoLoadRoller = true;
  1379. globalVar.LTwoInOrOutputLock = false;
  1380. globalVar.LTwoLoadRoller = false;
  1381. globalVar.LTwoAgvToFryPot = false;
  1382. globalVar.LTwoPotInputMaterialArrive = false;
  1383. globalVar.LTwoPotOutputRollerArrive = false;
  1384. globalVar.LTwoAgvArrivePot = false;
  1385. globalVar.LTwoMaterialNum = 0;
  1386. globalVar.LTwoCurrentCookingStep = 0;
  1387. globalVar.LFiveCurrentCookingStep = 0;
  1388. globalVar.agvArriveLTwoUpLoad = false;
  1389. globalVar.LTwoagvArriveUnLoad = false;
  1390. globalVar.LTwoagvFryPotEmptyRollerArrive = false;
  1391. globalVar.rollerLineTwo.agvArriveLineFour = false;
  1392. globalVar.agvLineTwoLoadCom = false;
  1393. LTwoErrorRecipe = false;
  1394. TaskManage.GetInstance.StartLong(new Action(() => { LineTwoProcessExecute(); Thread.Sleep(10); }), "滚筒线2任务线程");
  1395. MessageNotify.GetInstance.ShowUserLog("滚筒线【2】任务重启成功");
  1396. }));
  1397. }
  1398. public void LineThreeTaskRestart()
  1399. {
  1400. TaskManage.GetInstance.StopTask("滚筒线3任务线程", new Action(() =>
  1401. {
  1402. WritePlcData("D1103", 0);//复位开始执行指令
  1403. ActionManage.GetInstance.Send("ClearThreeRecipes");
  1404. //globalVar.rollerLineThree = null;
  1405. //globalVar.rollerLineThree = new RollerLineThree();
  1406. //globalVar.fryPotThree = null;
  1407. //globalVar.fryPotThree = new FryPotThree();
  1408. globalVar.rollerLineTwo.RecipeComMidSingle = 1;
  1409. globalVar.rollerLineTwo.LowSignalJude = false;
  1410. globalVar.rollerLineTwo.NextStart = false;
  1411. globalVar.rollerLineTwo.IsEpmtyBefore = false;
  1412. globalVar.rollerLineTwo.CanRun = true;
  1413. globalVar.ExitLineThreeTask = false;
  1414. globalVar.AllowAgvToLineThreeLoadRoller = true;
  1415. globalVar.LThreeInOrOutputLock = false;
  1416. globalVar.LThreeCurrentRecipeName = string.Empty;
  1417. globalVar.LThreeLoadRoller = false;
  1418. globalVar.LThreeAgvToFryPot = false;
  1419. globalVar.LThreePotInputMaterialArrive = false;
  1420. globalVar.LThreePotOutputRollerArrive = false;
  1421. globalVar.LThreeAgvArrivePot = false;
  1422. globalVar.LThreeMaterialNum = 0;
  1423. globalVar.LThreeCurrentCookingStep = 0;
  1424. globalVar.agvArriveLThreeUpLoad = false;
  1425. globalVar.LThreeagvArriveUnLoad = false;
  1426. globalVar.LThreeagvFryPotEmptyRollerArrive = false;
  1427. globalVar.rollerLineThree.agvArriveLineFour = false;
  1428. globalVar.agvLineThreeLoadCom = false;
  1429. LThreeErrorRecipe = false;
  1430. TaskManage.GetInstance.StartLong(new Action(() => { LineThreeProcessExecute(); Thread.Sleep(10); }), "滚筒线3任务线程");
  1431. MessageNotify.GetInstance.ShowUserLog("滚筒线【3】任务重启成功");
  1432. }));
  1433. }
  1434. public void LineOneEmptyRollerCleanTaskRestart()
  1435. {
  1436. TaskManage.GetInstance.StopTask("滚筒线1空桶清洗任务线程", new Action(() =>
  1437. {
  1438. globalVar.rollerLineOne.StationEight = 0;
  1439. globalVar.ExitLineOneTask = false;
  1440. //globalVar.rollerLineOne.EmptyRollerNums.Clear();
  1441. globalVar.rollerLineOne.IsEpmtyBefore = false;
  1442. globalVar.rollerLineOne.CanRun = true;
  1443. globalVar.agvArriveLineFour = false;
  1444. globalVar.agvArriveCleanLoad = false;
  1445. globalVar.rollerLineOne.agvArriveCleanUnLoad = false;
  1446. globalVar.agvArriveLineOneLoadEmptyRoller = false;
  1447. globalVar.agvArriveLineOneLoadCom = false;
  1448. TaskManage.GetInstance.StartLong(new Action(() => { LineOneToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线1空桶清洗任务线程");
  1449. MessageNotify.GetInstance.ShowUserLog("滚筒线【1】空桶清洗任务重启成功");
  1450. }));
  1451. }
  1452. public void LineTwoEmptyRollerCleanTaskRestart()
  1453. {
  1454. TaskManage.GetInstance.StopTask("滚筒线2空桶清洗任务线程", new Action(() =>
  1455. {
  1456. globalVar.rollerLineTwo.StationEight = 0;
  1457. globalVar.ExitLineTwoTask = false;
  1458. // globalVar.rollerLineTwo.EmptyRollerNums.Clear();
  1459. globalVar.rollerLineTwo.IsEpmtyBefore = false;
  1460. globalVar.rollerLineTwo.CanRun = true;
  1461. globalVar.agvArriveLineFour = false;
  1462. globalVar.agvArriveCleanLoad = false;
  1463. globalVar.rollerLineTwo.agvArriveCleanUnLoad = false;
  1464. globalVar.agvArriveLineTwoLoadEmptyRoller = false;
  1465. globalVar.agvArriveLineTwoLoadCom = false;
  1466. TaskManage.GetInstance.StartLong(new Action(() => { LineTwoToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线2空桶清洗任务线程");
  1467. MessageNotify.GetInstance.ShowUserLog("滚筒线【2】空桶清洗任务重启成功");
  1468. }));
  1469. }
  1470. public void LineThreeEmptyRollerCleanTaskRestart()
  1471. {
  1472. TaskManage.GetInstance.StopTask("滚筒线3空桶清洗任务线程", new Action(() =>
  1473. {
  1474. globalVar.rollerLineThree.StationEight = 0;
  1475. globalVar.ExitLineThreeTask = false;
  1476. // globalVar.rollerLineThree.EmptyRollerNums.Clear();
  1477. globalVar.rollerLineThree.IsEpmtyBefore = false;
  1478. globalVar.rollerLineThree.CanRun = true;
  1479. globalVar.agvArriveLineFour = false;
  1480. globalVar.agvArriveCleanLoad = false;
  1481. globalVar.rollerLineThree.agvArriveCleanUnLoad = false;
  1482. globalVar.agvArriveLineThreeLoadEmptyRoller = false;
  1483. globalVar.agvArriveLineThreeLoadCom = false;
  1484. TaskManage.GetInstance.StartLong(new Action(() => { LineThreeToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线3空桶清洗任务线程");
  1485. MessageNotify.GetInstance.ShowUserLog("滚筒线【3】空桶清洗任务重启成功");
  1486. }));
  1487. }
  1488. /// <summary>
  1489. /// 实时获取plc数据
  1490. /// </summary>
  1491. public void ReadPlcData()
  1492. {
  1493. TaskManage.GetInstance.StartLong(new Action(() =>
  1494. {
  1495. GetAddressData("D0000", new Action<ushort[]>((data) =>
  1496. {
  1497. try
  1498. {
  1499. if (data.Count() > 0)
  1500. {
  1501. //globalVar.rollerLineOne.StationOne = data[0];
  1502. if (globalVar.LineHeartBeat!= data[0])
  1503. {
  1504. if (globalVar.LBeatStopTimes >= 10)
  1505. {
  1506. ActionManage.GetInstance.Send("HeartBeatCheck", false);
  1507. MessageNotify.GetInstance.ShowRunLog("滚筒线心跳恢复");
  1508. }
  1509. globalVar.CanPlaceOrder = true;//允许下单
  1510. globalVar.LBeatStopTimes = 0;
  1511. globalVar.LineHeartBeat = data[0];
  1512. }
  1513. else
  1514. {
  1515. globalVar.LBeatStopTimes++;
  1516. if (globalVar.LBeatStopTimes >= 10)
  1517. {
  1518. globalVar.CanPlaceOrder = false;//不允许下单
  1519. ActionManage.GetInstance.Send("HeartBeatCheck", true);
  1520. if(globalVar.LBeatStopTimes>=10&& globalVar.LBeatStopTimes<13)
  1521. MessageNotify.GetInstance.ShowRunLog("滚筒线心跳心跳异常");
  1522. }
  1523. }
  1524. }
  1525. }
  1526. catch (Exception)
  1527. {
  1528. // throw;
  1529. }
  1530. }));
  1531. Thread.Sleep(500);
  1532. }), "滚筒线心跳检测");
  1533. TaskManage.GetInstance.StartLong(new Action(() =>
  1534. {
  1535. GetFryOneData("D0000", new Action<ushort[]>((data) =>
  1536. {
  1537. try
  1538. {
  1539. if (data.Count() > 0)
  1540. {
  1541. //globalVar.rollerLineOne.StationOne = data[0];
  1542. if (globalVar.PotOneHeartBeat != data[0])
  1543. {
  1544. if (globalVar.POneBeatStopTimes >= 10)
  1545. {
  1546. ActionManage.GetInstance.Send("HeartBeatCheck", false);
  1547. MessageNotify.GetInstance.ShowRunLog("1号炒锅心跳恢复");
  1548. }
  1549. globalVar.POneBeatStopTimes = 0;
  1550. globalVar.PotOneHeartBeat = data[0];
  1551. }
  1552. else
  1553. {
  1554. globalVar.POneBeatStopTimes++;
  1555. if (globalVar.POneBeatStopTimes >= 10)
  1556. {
  1557. ActionManage.GetInstance.Send("HeartBeatCheck", true);
  1558. if (globalVar.POneBeatStopTimes >= 10 && globalVar.POneBeatStopTimes < 13)
  1559. MessageNotify.GetInstance.ShowRunLog("1号炒锅心跳异常");
  1560. }
  1561. //不允许下单
  1562. }
  1563. }
  1564. }
  1565. catch (Exception)
  1566. {
  1567. // throw;
  1568. }
  1569. }));
  1570. Thread.Sleep(500);
  1571. }), "炒锅1心跳检测");
  1572. TaskManage.GetInstance.StartLong(new Action(() =>
  1573. {
  1574. GetFryTwoData("D0000", new Action<ushort[]>((data) =>
  1575. {
  1576. try
  1577. {
  1578. if (data.Count() > 0)
  1579. {
  1580. //globalVar.rollerLineOne.StationOne = data[0];
  1581. if (globalVar.PotTwoHeartBeat != data[0])
  1582. {
  1583. if (globalVar.PTwoBeatStopTimes >= 10)
  1584. {
  1585. ActionManage.GetInstance.Send("HeartBeatCheck", false);
  1586. MessageNotify.GetInstance.ShowRunLog("2号炒锅心跳恢复");
  1587. }
  1588. globalVar.PTwoBeatStopTimes = 0;
  1589. globalVar.PotTwoHeartBeat = data[0];
  1590. }
  1591. else
  1592. {
  1593. globalVar.PTwoBeatStopTimes++;
  1594. if (globalVar.PTwoBeatStopTimes >= 10)
  1595. {
  1596. ActionManage.GetInstance.Send("HeartBeatCheck", true);
  1597. if (globalVar.PTwoBeatStopTimes >= 10 && globalVar.PTwoBeatStopTimes < 13)
  1598. MessageNotify.GetInstance.ShowRunLog("2号炒锅心跳异常");
  1599. }
  1600. //不允许下单
  1601. }
  1602. }
  1603. }
  1604. catch (Exception)
  1605. {
  1606. // throw;
  1607. }
  1608. }));
  1609. Thread.Sleep(500);
  1610. }), "炒锅2心跳检测");
  1611. TaskManage.GetInstance.StartLong(new Action(() =>
  1612. {
  1613. GetFryThreeData("D0000", new Action<ushort[]>((data) =>
  1614. {
  1615. try
  1616. {
  1617. if (data.Count() > 0)
  1618. {
  1619. //globalVar.rollerLineOne.StationOne = data[0];
  1620. if (globalVar.PotThreeHeartBeat != data[0])
  1621. {
  1622. if (globalVar.PThreeBeatStopTimes >= 10)
  1623. {
  1624. ActionManage.GetInstance.Send("HeartBeatCheck", false);
  1625. MessageNotify.GetInstance.ShowRunLog("3号炒锅心跳恢复");
  1626. }
  1627. globalVar.PThreeBeatStopTimes = 0;
  1628. globalVar.PotThreeHeartBeat = data[0];
  1629. }
  1630. else
  1631. {
  1632. globalVar.PThreeBeatStopTimes++;
  1633. if (globalVar.PThreeBeatStopTimes >= 10)
  1634. {
  1635. ActionManage.GetInstance.Send("HeartBeatCheck", true);
  1636. if (globalVar.PThreeBeatStopTimes >= 10 && globalVar.PThreeBeatStopTimes < 13)
  1637. MessageNotify.GetInstance.ShowRunLog("3号炒锅心跳异常");
  1638. }
  1639. //不允许下单
  1640. }
  1641. }
  1642. }
  1643. catch (Exception)
  1644. {
  1645. // throw;
  1646. }
  1647. }));
  1648. Thread.Sleep(500);
  1649. }), "炒锅3心跳检测");
  1650. TaskManage.GetInstance.StartLong(new Action(() =>
  1651. {
  1652. GetFryFourData("D0000", new Action<ushort[]>((data) =>
  1653. {
  1654. try
  1655. {
  1656. if (data.Count() > 0)
  1657. {
  1658. //globalVar.rollerLineOne.StationOne = data[0];
  1659. if (globalVar.PotFourHeartBeat != data[0])
  1660. {
  1661. if (globalVar.PFourBeatStopTimes >= 10)
  1662. {
  1663. ActionManage.GetInstance.Send("HeartBeatCheck", false);
  1664. MessageNotify.GetInstance.ShowRunLog("4号炒锅心跳恢复");
  1665. }
  1666. globalVar.PFourBeatStopTimes = 0;
  1667. globalVar.PotFourHeartBeat = data[0];
  1668. }
  1669. else
  1670. {
  1671. globalVar.PFourBeatStopTimes++;
  1672. if (globalVar.PFourBeatStopTimes >= 10)
  1673. {
  1674. ActionManage.GetInstance.Send("HeartBeatCheck", true);
  1675. if (globalVar.PFourBeatStopTimes >= 10 && globalVar.PFourBeatStopTimes < 13)
  1676. MessageNotify.GetInstance.ShowRunLog("4号炒锅心跳异常");
  1677. }
  1678. //不允许下单
  1679. }
  1680. }
  1681. }
  1682. catch (Exception)
  1683. {
  1684. // throw;
  1685. }
  1686. }));
  1687. Thread.Sleep(500);
  1688. }), "炒锅4心跳检测");
  1689. TaskManage.GetInstance.StartLong(new Action(() =>
  1690. {
  1691. GetFryFiveData("D0000", new Action<ushort[]>((data) =>
  1692. {
  1693. try
  1694. {
  1695. if (data.Count() > 0)
  1696. {
  1697. //globalVar.rollerLineOne.StationOne = data[0];
  1698. if (globalVar.PotFiveHeartBeat != data[0])
  1699. {
  1700. if (globalVar.PFiveBeatStopTimes >= 10)
  1701. {
  1702. ActionManage.GetInstance.Send("HeartBeatCheck", false);
  1703. MessageNotify.GetInstance.ShowRunLog("5号炒锅心跳恢复");
  1704. }
  1705. globalVar.PFiveBeatStopTimes = 0;
  1706. globalVar.PotFiveHeartBeat = data[0];
  1707. }
  1708. else
  1709. {
  1710. globalVar.PFiveBeatStopTimes++;
  1711. if (globalVar.PFiveBeatStopTimes >= 10)
  1712. {
  1713. ActionManage.GetInstance.Send("HeartBeatCheck", true);
  1714. if (globalVar.PFiveBeatStopTimes >= 10 && globalVar.PFiveBeatStopTimes < 13)
  1715. MessageNotify.GetInstance.ShowRunLog("5号炒锅心跳异常");
  1716. }
  1717. //不允许下单
  1718. }
  1719. }
  1720. }
  1721. catch (Exception)
  1722. {
  1723. // throw;
  1724. }
  1725. }));
  1726. Thread.Sleep(500);
  1727. }), "炒锅5心跳检测");
  1728. //PLC数据读取
  1729. TaskManage.GetInstance.StartLong(new Action(() =>
  1730. {
  1731. GetAddressData("D2001", new Action<ushort[]>((data) =>
  1732. {
  1733. try
  1734. {
  1735. if (data.Count() > 0)
  1736. {
  1737. globalVar.rollerLineOne.StationOne = data[0];
  1738. globalVar.rollerLineOne.StationTwo = data[1];
  1739. globalVar.rollerLineOne.StationThree = data[2];
  1740. globalVar.rollerLineOne.StationFour = data[3];
  1741. globalVar.rollerLineOne.StationFive = data[4];
  1742. globalVar.rollerLineOne.StationSix = data[5];
  1743. globalVar.rollerLineOne.StationSeven = data[6];
  1744. globalVar.rollerLineOne.StationEight = data[7];
  1745. }
  1746. }
  1747. catch (Exception)
  1748. {
  1749. // throw;
  1750. }
  1751. }));
  1752. GetAddressData("D2011", new Action<ushort[]>((data) =>
  1753. {
  1754. try
  1755. {
  1756. if (data.Count() > 0)
  1757. {
  1758. globalVar.rollerLineTwo.StationOne = data[0];
  1759. globalVar.rollerLineTwo.StationTwo = data[1];
  1760. globalVar.rollerLineTwo.StationThree = data[2];
  1761. globalVar.rollerLineTwo.StationFour = data[3];
  1762. globalVar.rollerLineTwo.StationFive = data[4];
  1763. globalVar.rollerLineTwo.StationSix = data[5];
  1764. globalVar.rollerLineTwo.StationSeven = data[6];
  1765. globalVar.rollerLineTwo.StationEight = data[7];
  1766. }
  1767. }
  1768. catch (Exception)
  1769. {
  1770. // throw;
  1771. }
  1772. }));
  1773. GetAddressData("D2021", new Action<ushort[]>((data) =>
  1774. {
  1775. try
  1776. {
  1777. if (data.Count() > 0)
  1778. {
  1779. globalVar.rollerLineThree.StationOne = data[0];
  1780. globalVar.rollerLineThree.StationTwo = data[1];
  1781. globalVar.rollerLineThree.StationThree = data[2];
  1782. globalVar.rollerLineThree.StationFour = data[3];
  1783. globalVar.rollerLineThree.StationFive = data[4];
  1784. globalVar.rollerLineThree.StationSix = data[5];
  1785. globalVar.rollerLineThree.StationSeven = data[6];
  1786. globalVar.rollerLineThree.StationEight = data[7];
  1787. }
  1788. }
  1789. catch (Exception)
  1790. {
  1791. //throw;
  1792. }
  1793. }));
  1794. GetAddressData("D2031", new Action<ushort[]>((data) =>
  1795. {
  1796. //globalVar.rollerLineOne.OutMaterialingSingle = data[3];
  1797. //globalVar.rollerLineTwo.OutMaterialingSingle = data[4];
  1798. //globalVar.rollerLineThree.OutMaterialingSingle = data[5];
  1799. //AlarmHelper<AlarmInfo>.GetInstance().LineOneRollerRunning = data[3];
  1800. //AlarmHelper<AlarmInfo>.GetInstance().LineTwoRollerRunning = data[4];
  1801. //AlarmHelper<AlarmInfo>.GetInstance().LineThreeRollerRunning = data[5];
  1802. try
  1803. {
  1804. if (data.Count() > 0)
  1805. {
  1806. AlarmHelper<AlarmInfo>.GetInstance("1号滚筒线故障").LOneRollerTrouble = data[6];
  1807. AlarmHelper<AlarmInfo>.GetInstance("2号滚筒线故障").LTwoRollerTrouble = data[7];
  1808. AlarmHelper<AlarmInfo>.GetInstance("3号滚筒线故障").LThreeRollerTrouble = data[8];
  1809. }
  1810. }
  1811. catch (Exception)
  1812. {
  1813. // throw;
  1814. }
  1815. }));
  1816. //GetAddressData("D2040", new Action<ushort[]>((data) =>
  1817. //{
  1818. // globalVar.fryPotOne.InputMaterialRollerRunningSingle = data[0];
  1819. // globalVar.fryPotTwo.InputMaterialRollerRunningSingle = data[1];
  1820. // globalVar.fryPotThree.InputMaterialRollerRunningSingle = data[2];
  1821. // globalVar.fryPotFour.InputMaterialRollerRunningSingle = data[3];
  1822. // globalVar.fryPotFive.InputMaterialRollerRunningSingle = data[4];
  1823. // AlarmHelper<AlarmInfo>.GetInstance().FryPotOneRollerRunning = data[0];
  1824. // AlarmHelper<AlarmInfo>.GetInstance().FryPotTwoRollerRunning = data[1];
  1825. // AlarmHelper<AlarmInfo>.GetInstance().FryPotThreeRollerRunning = data[2];
  1826. // AlarmHelper<AlarmInfo>.GetInstance().FryPotFourRollerRunning = data[3];
  1827. // AlarmHelper<AlarmInfo>.GetInstance().FryPotFiveRollerRunning = data[4];
  1828. //}));
  1829. GetAddressData("D2045", new Action<ushort[]>((data) =>
  1830. {
  1831. try
  1832. {
  1833. if (data.Count() > 0)
  1834. {
  1835. globalVar.fryPotOne.InputMaterialArrivedSingle = data[0];
  1836. globalVar.fryPotTwo.InputMaterialArrivedSingle = data[1];
  1837. globalVar.fryPotThree.InputMaterialArrivedSingle = data[2];
  1838. globalVar.fryPotFour.InputMaterialArrivedSingle = data[3];
  1839. globalVar.fryPotFive.InputMaterialArrivedSingle = data[4];
  1840. }
  1841. }
  1842. catch (Exception)
  1843. {
  1844. // throw;
  1845. }
  1846. }));
  1847. GetAddressData("D2050", new Action<ushort[]>((data) =>
  1848. {
  1849. try
  1850. {
  1851. if (data.Count() > 0)
  1852. {
  1853. globalVar.fryPotOne.EmptyBarrelArrivedSingle = data[0];
  1854. globalVar.fryPotTwo.EmptyBarrelArrivedSingle = data[1];
  1855. globalVar.fryPotThree.EmptyBarrelArrivedSingle = data[2];
  1856. globalVar.fryPotFour.EmptyBarrelArrivedSingle = data[3];
  1857. globalVar.fryPotFive.EmptyBarrelArrivedSingle = data[4];
  1858. }
  1859. }
  1860. catch (Exception)
  1861. {
  1862. //throw;
  1863. }
  1864. }));
  1865. //GetAddressData("D2065", new Action<ushort[]>((data) =>
  1866. //{
  1867. // globalVar.fryPotOne.EmptyBarrelRollerRunningSingle = data[0];
  1868. // globalVar.fryPotTwo.EmptyBarrelRollerRunningSingle = data[1];
  1869. // globalVar.fryPotThree.EmptyBarrelRollerRunningSingle = data[2];
  1870. // globalVar.fryPotFour.EmptyBarrelRollerRunningSingle = data[3];
  1871. // globalVar.fryPotFive.EmptyBarrelRollerRunningSingle = data[4];
  1872. // AlarmHelper<AlarmInfo>.GetInstance().FryPotOneEmptyRollerRunning = data[0];
  1873. // AlarmHelper<AlarmInfo>.GetInstance().FryPotTwoEmptyRollerRunning = data[1];
  1874. // AlarmHelper<AlarmInfo>.GetInstance().FryPotThreeEmptyRollerRunning = data[2];
  1875. // AlarmHelper<AlarmInfo>.GetInstance().FryPotFourEmptyRollerRunning = data[3];
  1876. // AlarmHelper<AlarmInfo>.GetInstance().FryPotFiveEmptyRollerRunning = data[4];
  1877. //}));
  1878. GetAddressData("D2070", new Action<ushort[]>((data) =>
  1879. {
  1880. //globalVar.fryPotOne.RollerTroubleSingle = data[0];
  1881. //globalVar.fryPotTwo.RollerTroubleSingle = data[1];
  1882. //globalVar.fryPotThree.RollerTroubleSingle = data[2];
  1883. //globalVar.fryPotFour.RollerTroubleSingle = data[3];
  1884. //globalVar.fryPotFive.RollerTroubleSingle = data[4];
  1885. try
  1886. {
  1887. if (data.Count() > 0)
  1888. {
  1889. AlarmHelper<AlarmInfo>.GetInstance("1号炒锅滚筒故障").FryPotOneRollerTrouble = data[0];
  1890. AlarmHelper<AlarmInfo>.GetInstance("2号炒锅滚筒故障").FryPotTwoRollerTrouble = data[1];
  1891. AlarmHelper<AlarmInfo>.GetInstance("3号炒锅滚筒故障").FryPotThreeRollerTrouble = data[2];
  1892. AlarmHelper<AlarmInfo>.GetInstance("4号炒锅滚筒故障").FryPotFourRollerTrouble = data[3];
  1893. AlarmHelper<AlarmInfo>.GetInstance("5号炒锅滚筒故障").FryPotFiveRollerTrouble = data[4];
  1894. }
  1895. }
  1896. catch (Exception)
  1897. {
  1898. // throw;
  1899. }
  1900. }));
  1901. //GetAddressData("D2078", new Action<ushort[]>(data =>
  1902. //{
  1903. // //globalVar.rollerLineOne.RecipeCompleteSingle = data[0];
  1904. // //globalVar.rollerLineTwo.RecipeCompleteSingle = data[1];
  1905. // //globalVar.rollerLineThree.RecipeCompleteSingle = data[2];
  1906. //}));
  1907. GetAddressData("D2075", new Action<ushort[]>(data =>
  1908. {
  1909. try
  1910. {
  1911. if (data.Count() > 0)
  1912. {
  1913. AlarmHelper<AlarmInfo>.GetInstance("洗桶机进筒未运行").CleanEnterRollerRunning = data[0];
  1914. globalVar.CleadBarrelEnterSingle = data[0];
  1915. }
  1916. }
  1917. catch (Exception)
  1918. {
  1919. // throw;
  1920. }
  1921. }));
  1922. GetAddressData("D2076", new Action<ushort[]>(data =>
  1923. {
  1924. try
  1925. {
  1926. if (data.Count() > 0)
  1927. globalVar.CleanComplete = data[0];//洗桶出桶agv呼叫信号
  1928. }
  1929. catch (Exception)
  1930. {
  1931. //throw;
  1932. }
  1933. }));
  1934. GetAddressData("D2077", new Action<ushort[]>(data =>
  1935. {
  1936. try
  1937. {
  1938. if (data.Count() > 0)
  1939. {
  1940. AlarmHelper<AlarmInfo>.GetInstance("洗桶机出桶未运行").CleanOutputRollerRunning = data[0];
  1941. globalVar.CleadBarrelExitSingle = data[0];
  1942. }
  1943. }
  1944. catch (Exception)
  1945. {
  1946. // throw;
  1947. }
  1948. }));
  1949. //滚筒线123开始信号
  1950. GetAddressData("D2101", new Action<ushort[]>(data =>
  1951. {
  1952. try
  1953. {
  1954. if (data.Count() > 0)
  1955. {
  1956. globalVar.rollerLineOne.ExcuteIsConfirm = data[0];
  1957. globalVar.rollerLineTwo.ExcuteIsConfirm = data[1];
  1958. globalVar.rollerLineThree.ExcuteIsConfirm = data[2];
  1959. }
  1960. }
  1961. catch (Exception)
  1962. {
  1963. //throw;
  1964. }
  1965. }));
  1966. GetAddressData("D4400", new Action<ushort[]>(data =>
  1967. {
  1968. try
  1969. {
  1970. if (data.Count() > 0)
  1971. globalVar.rollerLineOne.EmptyRollerNum = data[0];
  1972. }
  1973. catch (Exception)
  1974. {
  1975. // throw;
  1976. }
  1977. }));
  1978. GetAddressData("D4410", new Action<ushort[]>(data =>
  1979. {
  1980. try
  1981. {
  1982. if (data.Count() > 0)
  1983. globalVar.rollerLineTwo.EmptyRollerNum = data[0];
  1984. }
  1985. catch (Exception)
  1986. {
  1987. //throw;
  1988. }
  1989. }));
  1990. GetAddressData("D4420", new Action<ushort[]>(data =>
  1991. {
  1992. try
  1993. {
  1994. if (data.Count() > 0)
  1995. globalVar.rollerLineThree.EmptyRollerNum = data[0];
  1996. }
  1997. catch (Exception)
  1998. {
  1999. //throw;
  2000. }
  2001. }));
  2002. GetAddressData("D2111", new Action<ushort[]>(data =>
  2003. {
  2004. try
  2005. {
  2006. if (data.Count() > 0)
  2007. {
  2008. globalVar.rollerLineOne.WashEmptyRollerModel = data[0];
  2009. globalVar.rollerLineTwo.WashEmptyRollerModel = data[1];
  2010. globalVar.rollerLineThree.WashEmptyRollerModel = data[2];
  2011. globalVar.rollerLineOne.WashRollerArriveSignal = data[3];
  2012. globalVar.rollerLineTwo.WashRollerArriveSignal = data[4];
  2013. globalVar.rollerLineThree.WashRollerArriveSignal = data[5];
  2014. }
  2015. }
  2016. catch (Exception)
  2017. {
  2018. // throw;
  2019. }
  2020. }));
  2021. //炒锅1状态数据
  2022. GetFryOneData("D0258", new Action<ushort[]>(data =>
  2023. {
  2024. try
  2025. {
  2026. if (data.Count() > 0)
  2027. FryPotMonitorManage.GetInstance.fryOne.Temperature = data[0] / 10.0;
  2028. }
  2029. catch (Exception)
  2030. {
  2031. // throw;
  2032. }
  2033. }));
  2034. GetFryOneData("D0510", new Action<ushort[]>(data =>
  2035. {
  2036. try
  2037. {
  2038. if (data.Count() > 0)
  2039. FryPotMonitorManage.GetInstance.fryOne.SmallFire = data[0];
  2040. }
  2041. catch (Exception)
  2042. {
  2043. //throw;
  2044. }
  2045. }));
  2046. GetFryOneData("D0512", new Action<ushort[]>(data =>
  2047. {
  2048. try
  2049. {
  2050. if (data.Count() > 0)
  2051. FryPotMonitorManage.GetInstance.fryOne.MidFire = data[0];
  2052. }
  2053. catch (Exception)
  2054. {
  2055. //throw;
  2056. }
  2057. }));
  2058. GetFryOneData("D0514", new Action<ushort[]>(data =>
  2059. {
  2060. try
  2061. {
  2062. if (data.Count() > 0)
  2063. FryPotMonitorManage.GetInstance.fryOne.BigFire = data[0];
  2064. }
  2065. catch (Exception)
  2066. {
  2067. // throw;
  2068. }
  2069. }));
  2070. GetFryOneData("D0516", new Action<ushort[]>(data =>
  2071. {
  2072. try
  2073. {
  2074. if (data.Count() > 0)
  2075. FryPotMonitorManage.GetInstance.fryOne.StrongFire = data[0];
  2076. }
  2077. catch (Exception)
  2078. {
  2079. // throw;
  2080. }
  2081. }));
  2082. GetFryOneData("D2500", new Action<ushort[]>(data =>
  2083. {
  2084. try
  2085. {
  2086. if (data.Count() > 0)
  2087. FryPotMonitorManage.GetInstance.fryOne.Speed = data[0] / 10.0;
  2088. }
  2089. catch (Exception)
  2090. {
  2091. // throw;
  2092. }
  2093. }));
  2094. GetFryOneData("D0600", new Action<ushort[]>(data =>
  2095. {
  2096. try
  2097. {
  2098. if (data.Count() > 0)
  2099. FryPotMonitorManage.GetInstance.fryOne.FryPotWeight = data[0] / 10.0;
  2100. }
  2101. catch (Exception)
  2102. {
  2103. //throw;
  2104. }
  2105. }));
  2106. GetFryOneData("D3000", new Action<ushort[]>(data =>
  2107. {
  2108. try
  2109. {
  2110. if (data.Count() > 0)
  2111. {
  2112. FryPotMonitorManage.GetInstance.fryOne.Step = data[0];
  2113. globalVar.fryPotOne.ProcessStep = data[0];
  2114. }
  2115. }
  2116. catch (Exception)
  2117. {
  2118. //throw;
  2119. }
  2120. }));
  2121. GetFryOneData("D3301", new Action<ushort[]>(data =>
  2122. {
  2123. try
  2124. {
  2125. if (data.Count() > 0)
  2126. globalVar.fryPotOne.RecipeCompleteSingle = data[0];
  2127. }
  2128. catch (Exception)
  2129. {
  2130. //throw;
  2131. }
  2132. }));
  2133. ////炒锅2状态数据
  2134. GetFryTwoData("D0258", new Action<ushort[]>(data =>
  2135. {
  2136. try
  2137. {
  2138. if (data.Count() > 0)
  2139. FryPotMonitorManage.GetInstance.fryTwo.Temperature = data[0] / 10.0;
  2140. }
  2141. catch (Exception)
  2142. {
  2143. //throw;
  2144. }
  2145. }));
  2146. GetFryTwoData("D0510", new Action<ushort[]>(data =>
  2147. {
  2148. try
  2149. {
  2150. if (data.Count() > 0)
  2151. FryPotMonitorManage.GetInstance.fryTwo.SmallFire = data[0];
  2152. }
  2153. catch (Exception)
  2154. {
  2155. //throw;
  2156. }
  2157. }));
  2158. GetFryTwoData("D0512", new Action<ushort[]>(data =>
  2159. {
  2160. try
  2161. {
  2162. if (data.Count() > 0)
  2163. FryPotMonitorManage.GetInstance.fryTwo.MidFire = data[0];
  2164. }
  2165. catch (Exception)
  2166. {
  2167. // throw;
  2168. }
  2169. }));
  2170. GetFryTwoData("D0514", new Action<ushort[]>(data =>
  2171. {
  2172. try
  2173. {
  2174. if (data.Count() > 0)
  2175. FryPotMonitorManage.GetInstance.fryTwo.BigFire = data[0];
  2176. }
  2177. catch (Exception)
  2178. {
  2179. // throw;
  2180. }
  2181. }));
  2182. GetFryTwoData("D0516", new Action<ushort[]>(data =>
  2183. {
  2184. try
  2185. {
  2186. if (data.Count() > 0)
  2187. FryPotMonitorManage.GetInstance.fryTwo.StrongFire = data[0];
  2188. }
  2189. catch (Exception)
  2190. {
  2191. //throw;
  2192. }
  2193. }));
  2194. GetFryTwoData("D2500", new Action<ushort[]>(data =>
  2195. {
  2196. try
  2197. {
  2198. if (data.Count() > 0)
  2199. FryPotMonitorManage.GetInstance.fryTwo.Speed = data[0] / 10.0;
  2200. }
  2201. catch (Exception)
  2202. {
  2203. //throw;
  2204. }
  2205. }));
  2206. GetFryTwoData("D0600", new Action<ushort[]>(data =>
  2207. {
  2208. try
  2209. {
  2210. if (data.Count() > 0)
  2211. FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight = data[0] / 10.0;
  2212. }
  2213. catch (Exception)
  2214. {
  2215. //throw;
  2216. }
  2217. }));
  2218. GetFryTwoData("D3000", new Action<ushort[]>(data =>
  2219. {
  2220. try
  2221. {
  2222. if (data.Count() > 0)
  2223. {
  2224. FryPotMonitorManage.GetInstance.fryTwo.Step = data[0];
  2225. globalVar.fryPotTwo.ProcessStep = data[0];
  2226. }
  2227. }
  2228. catch (Exception)
  2229. {
  2230. // throw;
  2231. }
  2232. }));
  2233. GetFryTwoData("D3301", new Action<ushort[]>(data =>
  2234. {
  2235. try
  2236. {
  2237. if (data.Count() > 0)
  2238. globalVar.fryPotTwo.RecipeCompleteSingle = data[0];
  2239. }
  2240. catch (Exception)
  2241. {
  2242. // throw;
  2243. }
  2244. }));
  2245. ////炒锅3状态数据
  2246. GetFryThreeData("D0258", new Action<ushort[]>(data =>
  2247. {
  2248. try
  2249. {
  2250. if (data.Count() > 0)
  2251. FryPotMonitorManage.GetInstance.fryThree.Temperature = data[0] / 10.0;
  2252. }
  2253. catch (Exception)
  2254. {
  2255. //throw;
  2256. }
  2257. }));
  2258. GetFryThreeData("D0510", new Action<ushort[]>(data =>
  2259. {
  2260. try
  2261. {
  2262. if (data.Count() > 0)
  2263. FryPotMonitorManage.GetInstance.fryThree.SmallFire = data[0];
  2264. }
  2265. catch (Exception)
  2266. {
  2267. // throw;
  2268. }
  2269. }));
  2270. GetFryThreeData("D0512", new Action<ushort[]>(data =>
  2271. {
  2272. try
  2273. {
  2274. if (data.Count() > 0)
  2275. FryPotMonitorManage.GetInstance.fryThree.MidFire = data[0];
  2276. }
  2277. catch (Exception)
  2278. {
  2279. // throw;
  2280. }
  2281. }));
  2282. GetFryThreeData("D0514", new Action<ushort[]>(data =>
  2283. {
  2284. try
  2285. {
  2286. if (data.Count() > 0)
  2287. FryPotMonitorManage.GetInstance.fryThree.BigFire = data[0];
  2288. }
  2289. catch (Exception)
  2290. {
  2291. //throw;
  2292. }
  2293. }));
  2294. GetFryThreeData("D0516", new Action<ushort[]>(data =>
  2295. {
  2296. try
  2297. {
  2298. if (data.Count() > 0)
  2299. FryPotMonitorManage.GetInstance.fryThree.StrongFire = data[0];
  2300. }
  2301. catch (Exception)
  2302. {
  2303. //throw;
  2304. }
  2305. }));
  2306. GetFryThreeData("D2500", new Action<ushort[]>(data =>
  2307. {
  2308. try
  2309. {
  2310. if (data.Count() > 0)
  2311. FryPotMonitorManage.GetInstance.fryThree.Speed = data[0] / 10.0;
  2312. }
  2313. catch (Exception)
  2314. {
  2315. //throw;
  2316. }
  2317. }));
  2318. GetFryThreeData("D0600", new Action<ushort[]>(data =>
  2319. {
  2320. try
  2321. {
  2322. if (data.Count() > 0)
  2323. FryPotMonitorManage.GetInstance.fryThree.FryPotWeight = data[0] / 10.0;
  2324. }
  2325. catch (Exception)
  2326. {
  2327. // throw;
  2328. }
  2329. }));
  2330. GetFryThreeData("D3000", new Action<ushort[]>(data =>
  2331. {
  2332. try
  2333. {
  2334. if (data.Count() > 0)
  2335. {
  2336. FryPotMonitorManage.GetInstance.fryThree.Step = data[0];
  2337. globalVar.fryPotThree.ProcessStep = data[0];
  2338. }
  2339. }
  2340. catch (Exception)
  2341. {
  2342. // throw;
  2343. }
  2344. }));
  2345. GetFryThreeData("D3301", new Action<ushort[]>(data =>
  2346. {
  2347. try
  2348. {
  2349. if (data.Count() > 0)
  2350. globalVar.fryPotThree.RecipeCompleteSingle = data[0];
  2351. }
  2352. catch (Exception)
  2353. {
  2354. //throw;
  2355. }
  2356. }));
  2357. //}));
  2358. ////炒锅4状态数据
  2359. GetFryFourData("D0258", new Action<ushort[]>(data =>
  2360. {
  2361. try
  2362. {
  2363. if (data.Count() > 0)
  2364. FryPotMonitorManage.GetInstance.fryFour.Temperature = data[0] / 10.0;
  2365. }
  2366. catch (Exception)
  2367. {
  2368. //throw;
  2369. }
  2370. }));
  2371. GetFryFourData("D0510", new Action<ushort[]>(data =>
  2372. {
  2373. try
  2374. {
  2375. if (data.Count() > 0)
  2376. FryPotMonitorManage.GetInstance.fryFour.SmallFire = data[0];
  2377. }
  2378. catch (Exception)
  2379. {
  2380. // throw;
  2381. }
  2382. }));
  2383. GetFryFourData("D0512", new Action<ushort[]>(data =>
  2384. {
  2385. try
  2386. {
  2387. if (data.Count() > 0)
  2388. FryPotMonitorManage.GetInstance.fryFour.MidFire = data[0];
  2389. }
  2390. catch (Exception)
  2391. {
  2392. //throw;
  2393. }
  2394. }));
  2395. GetFryFourData("D0514", new Action<ushort[]>(data =>
  2396. {
  2397. try
  2398. {
  2399. if (data.Count() > 0)
  2400. FryPotMonitorManage.GetInstance.fryFour.BigFire = data[0];
  2401. }
  2402. catch (Exception)
  2403. {
  2404. //throw;
  2405. }
  2406. }));
  2407. GetFryFourData("D0516", new Action<ushort[]>(data =>
  2408. {
  2409. try
  2410. {
  2411. if (data.Count() > 0)
  2412. FryPotMonitorManage.GetInstance.fryFour.StrongFire = data[0];
  2413. }
  2414. catch (Exception)
  2415. {
  2416. // throw;
  2417. }
  2418. }));
  2419. GetFryFourData("D2500", new Action<ushort[]>(data =>
  2420. {
  2421. try
  2422. {
  2423. if (data.Count() > 0)
  2424. FryPotMonitorManage.GetInstance.fryFour.Speed = data[0] / 10.0;
  2425. }
  2426. catch (Exception)
  2427. {
  2428. // throw;
  2429. }
  2430. }));
  2431. GetFryFourData("D0600", new Action<ushort[]>(data =>
  2432. {
  2433. try
  2434. {
  2435. if (data.Count() > 0)
  2436. FryPotMonitorManage.GetInstance.fryFour.FryPotWeight = data[0] / 10.0;
  2437. }
  2438. catch (Exception)
  2439. {
  2440. //throw;
  2441. }
  2442. }));
  2443. GetFryFourData("D3000", new Action<ushort[]>(data =>
  2444. {
  2445. try
  2446. {
  2447. if (data.Count() > 0)
  2448. {
  2449. FryPotMonitorManage.GetInstance.fryFour.Step = data[0];
  2450. globalVar.fryPotFour.ProcessStep = data[0];
  2451. }
  2452. }
  2453. catch (Exception)
  2454. {
  2455. //throw;
  2456. }
  2457. }));
  2458. GetFryFourData("D3301", new Action<ushort[]>(data =>
  2459. {
  2460. try
  2461. {
  2462. if(data.Count()>0)
  2463. globalVar.fryPotFour.RecipeCompleteSingle = data[0];
  2464. }
  2465. catch (Exception)
  2466. {
  2467. //throw;
  2468. }
  2469. }));
  2470. //}));
  2471. ////炒锅5状态数据
  2472. GetFryFiveData("D0258", new Action<ushort[]>(data =>
  2473. {
  2474. try
  2475. {
  2476. if (data.Count() > 0)
  2477. FryPotMonitorManage.GetInstance.fryFive.Temperature = data[0] / 10.0;
  2478. }
  2479. catch (Exception)
  2480. {
  2481. //throw;
  2482. }
  2483. }));
  2484. GetFryFiveData("D0510", new Action<ushort[]>(data =>
  2485. {
  2486. try
  2487. {
  2488. if (data.Count() > 0)
  2489. FryPotMonitorManage.GetInstance.fryFive.SmallFire = data[0];
  2490. }
  2491. catch (Exception)
  2492. {
  2493. // throw;
  2494. }
  2495. }));
  2496. GetFryFiveData("D0512", new Action<ushort[]>(data =>
  2497. {
  2498. try
  2499. {
  2500. if (data.Count() > 0)
  2501. FryPotMonitorManage.GetInstance.fryFive.MidFire = data[0];
  2502. }
  2503. catch (Exception)
  2504. {
  2505. //throw;
  2506. }
  2507. }));
  2508. GetFryFiveData("D0514", new Action<ushort[]>(data =>
  2509. {
  2510. try
  2511. {
  2512. if (data.Count() > 0)
  2513. FryPotMonitorManage.GetInstance.fryFive.BigFire = data[0];
  2514. }
  2515. catch (Exception)
  2516. {
  2517. //throw;
  2518. }
  2519. }));
  2520. GetFryFiveData("D0516", new Action<ushort[]>(data =>
  2521. {
  2522. try
  2523. {
  2524. if (data.Count() > 0)
  2525. FryPotMonitorManage.GetInstance.fryFive.StrongFire = data[0];
  2526. }
  2527. catch (Exception)
  2528. {
  2529. //throw;
  2530. }
  2531. }));
  2532. GetFryFiveData("D2500", new Action<ushort[]>(data =>
  2533. {
  2534. try
  2535. {
  2536. if (data.Count() > 0)
  2537. FryPotMonitorManage.GetInstance.fryFour.Speed = data[0] / 10.0;
  2538. }
  2539. catch (Exception)
  2540. {
  2541. // throw;
  2542. }
  2543. }));
  2544. GetFryFiveData("D0600", new Action<ushort[]>(data =>
  2545. {
  2546. try
  2547. {
  2548. if (data.Count() > 0)
  2549. FryPotMonitorManage.GetInstance.fryFive.FryPotWeight = data[0] / 10.0;
  2550. }
  2551. catch (Exception)
  2552. {
  2553. //throw;
  2554. }
  2555. }));
  2556. GetFryFiveData("D3000", new Action<ushort[]>(data =>
  2557. {
  2558. try
  2559. {
  2560. if (data.Count() > 0)
  2561. {
  2562. FryPotMonitorManage.GetInstance.fryFive.Step = data[0];
  2563. globalVar.fryPotFive.ProcessStep = data[0];
  2564. }
  2565. }
  2566. catch (Exception)
  2567. {
  2568. // throw;
  2569. }
  2570. }));
  2571. GetFryFiveData("D3301", new Action<ushort[]>(data =>
  2572. {
  2573. try
  2574. {
  2575. if (data.Count() > 0)
  2576. globalVar.fryPotFive.RecipeCompleteSingle = data[0];
  2577. }
  2578. catch (Exception)
  2579. {
  2580. //throw;
  2581. }
  2582. }));
  2583. //}));
  2584. //线体上放空桶
  2585. if (globalVar.rollerLineOne.EmptyRollerNum != 0)
  2586. {
  2587. if (RollerNum.Contains(globalVar.rollerLineOne.EmptyRollerNum))
  2588. {
  2589. if (!globalVar.rollerLineOne.EmptyRollerNums.Contains(globalVar.rollerLineOne.EmptyRollerNum))
  2590. {
  2591. globalVar.rollerLineOne.EmptyRollerNums.Add(globalVar.rollerLineOne.EmptyRollerNum);
  2592. ++globalVar.LOneMaterialNum;
  2593. }
  2594. }
  2595. //是否手动复位PLC
  2596. }
  2597. if (globalVar.rollerLineTwo.EmptyRollerNum != 0)
  2598. {
  2599. if (RollerNum.Contains(globalVar.rollerLineTwo.EmptyRollerNum))
  2600. {
  2601. if (!globalVar.rollerLineTwo.EmptyRollerNums.Contains(globalVar.rollerLineTwo.EmptyRollerNum))
  2602. {
  2603. globalVar.rollerLineTwo.EmptyRollerNums.Add(globalVar.rollerLineTwo.EmptyRollerNum);
  2604. ++globalVar.LTwoMaterialNum;
  2605. }
  2606. }
  2607. //是否手动复位PLC
  2608. }
  2609. if (globalVar.rollerLineThree.EmptyRollerNum != 0)
  2610. {
  2611. if (RollerNum.Contains(globalVar.rollerLineThree.EmptyRollerNum))
  2612. {
  2613. if (!globalVar.rollerLineThree.EmptyRollerNums.Contains(globalVar.rollerLineThree.EmptyRollerNum))
  2614. {
  2615. globalVar.rollerLineThree.EmptyRollerNums.Add(globalVar.rollerLineThree.EmptyRollerNum);
  2616. ++globalVar.LThreeMaterialNum;
  2617. }
  2618. }
  2619. //是否手动复位PLC
  2620. }
  2621. ////炒锅状态数据
  2622. //if (globalVar.fryPotOne.OilConfirm == 1)
  2623. //{
  2624. // FryPotMonitorManage.GetInstance.fryOne.OilCapacity = globalVar.fryPotOne.OilCapacity;
  2625. // FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy += globalVar.fryPotOne.OilCapacity;
  2626. //}
  2627. //if (globalVar.fryPotTwo.OilConfirm == 1)
  2628. //{
  2629. // FryPotMonitorManage.GetInstance.fryTwo.OilCapacity = globalVar.fryPotTwo.OilCapacity;
  2630. // FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy += globalVar.fryPotTwo.OilCapacity;
  2631. //}
  2632. //if (globalVar.fryPotThree.OilConfirm == 1)
  2633. //{
  2634. // FryPotMonitorManage.GetInstance.fryThree.OilCapacity = globalVar.fryPotThree.OilCapacity;
  2635. // FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy += globalVar.fryPotThree.OilCapacity;
  2636. //}
  2637. //if (globalVar.fryPotFour.OilConfirm == 1)
  2638. //{
  2639. // FryPotMonitorManage.GetInstance.fryFour.OilCapacity = globalVar.fryPotFour.OilCapacity;
  2640. // FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy += globalVar.fryPotFour.OilCapacity;
  2641. //}
  2642. //if (globalVar.fryPotFive.OilConfirm == 1)
  2643. //{
  2644. // FryPotMonitorManage.GetInstance.fryFive.OilCapacity = globalVar.fryPotFive.OilCapacity;
  2645. // FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy += globalVar.fryPotFive.OilCapacity;
  2646. //}
  2647. //炒锅状态实时显示
  2648. FryPotStatusDisplay();
  2649. RollerLineStatusDisplay();
  2650. Thread.Sleep(10);
  2651. }), "MainViewReadPlcData");
  2652. }
  2653. /// <summary>
  2654. /// 炒锅状态实时显示
  2655. /// </summary>
  2656. private void FryPotStatusDisplay()
  2657. {
  2658. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneTemp").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.Temperature.ToString();
  2659. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneSmallFire").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.SmallFire.ToString();
  2660. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneMidFire").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.MidFire.ToString();
  2661. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneBigFire").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.BigFire.ToString();
  2662. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneStrongFire").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.StrongFire.ToString();
  2663. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneSpeed").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.Speed.ToString();
  2664. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneWeight").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight.ToString();
  2665. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneProcessStep").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.Step.ToString();
  2666. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneOil").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.OilCapacity.ToString();
  2667. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneTotalOil").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy.ToString();
  2668. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneTotalProduct").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.TotalProduct.ToString();
  2669. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoTemp").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.Temperature.ToString();
  2670. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoSmallFire").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.SmallFire.ToString();
  2671. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoMidFire").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.MidFire.ToString();
  2672. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoBigFire").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.BigFire.ToString();
  2673. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoStrongFire").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.StrongFire.ToString();
  2674. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoSpeed").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.Speed.ToString();
  2675. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoWeight").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight.ToString();
  2676. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoProcessStep").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.Step.ToString();
  2677. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoOil").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity.ToString();
  2678. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoTotalOil").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy.ToString();
  2679. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoTotalProduct").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct.ToString();
  2680. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeTemp").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.Temperature.ToString();
  2681. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeSmallFire").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.SmallFire.ToString();
  2682. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeMidFire").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.MidFire.ToString();
  2683. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeBigFire").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.BigFire.ToString();
  2684. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeStrongFire").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.StrongFire.ToString();
  2685. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeSpeed").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.Speed.ToString();
  2686. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeWeight").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight.ToString();
  2687. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeProcessStep").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.Step.ToString();
  2688. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeOil").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.OilCapacity.ToString();
  2689. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeTotalOil").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy.ToString();
  2690. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeTotalProduct").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.TotalProduct.ToString();
  2691. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourTemp").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.Temperature.ToString();
  2692. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourSmallFire").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.SmallFire.ToString();
  2693. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourMidFire").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.MidFire.ToString();
  2694. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourBigFire").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.BigFire.ToString();
  2695. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourStrongFire").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.StrongFire.ToString();
  2696. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourSpeed").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.Speed.ToString();
  2697. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourWeight").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight.ToString();
  2698. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourProcessStep").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.Step.ToString();
  2699. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourOil").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.OilCapacity.ToString();
  2700. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourTotalOil").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy.ToString();
  2701. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourTotalProduct").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.TotalProduct.ToString();
  2702. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveTemp").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.Temperature.ToString();
  2703. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveSmallFire").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.SmallFire.ToString();
  2704. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveMidFire").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.MidFire.ToString();
  2705. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveBigFire").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.BigFire.ToString();
  2706. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveStrongFire").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.StrongFire.ToString();
  2707. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveSpeed").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.Speed.ToString();
  2708. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveWeight").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight.ToString();
  2709. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveProcessStep").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.Step.ToString();
  2710. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveOil").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.OilCapacity.ToString();
  2711. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveTotalOil").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy.ToString();
  2712. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveTotalProduct").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.TotalProduct.ToString();
  2713. //FryPotMonitorManage.GetInstance.fryFive.Temperature = 10;
  2714. //FryPotMonitorManage.GetInstance.fryFive.HotPower = "9";
  2715. //FryPotMonitorManage.GetInstance.fryFive.Speed = 8;
  2716. //FryPotMonitorManage.GetInstance.fryFive.FryPotWeight=7;
  2717. //FryPotMonitorManage.GetInstance.fryFive.OilCapacity = 6;
  2718. //FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy = 5;
  2719. //FryPotMonitorManage.GetInstance.fryFive.TotalProduct = 4;
  2720. }
  2721. /// <summary>
  2722. /// 炒锅状态数据保存到二进制文件
  2723. /// </summary>
  2724. public void FryPotDataSaveToBinaryFile()
  2725. {
  2726. #region 炒锅1状态数据保存
  2727. if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅1状态数据"))
  2728. {
  2729. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅1状态数据");
  2730. if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString()))
  2731. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString());
  2732. if (globalVar.LOneFryPotSerial == 1 && fryOneRecipe != string.Empty)
  2733. {
  2734. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryOneRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  2735. {
  2736. writeStream.Position = writeStream.Length;
  2737. PotOneStatus p1 = new PotOneStatus { Temperature = FryPotMonitorManage.GetInstance.fryOne.Temperature, SmallFire = FryPotMonitorManage.GetInstance.fryOne.SmallFire, MidFire = FryPotMonitorManage.GetInstance.fryOne.MidFire, BigFire = FryPotMonitorManage.GetInstance.fryOne.BigFire, StrongFire = FryPotMonitorManage.GetInstance.fryOne.StrongFire, Speed = FryPotMonitorManage.GetInstance.fryOne.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryOne.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryOne.TotalProduct, RecipeName = fryOneRecipe, Time = DateTime.Now.ToString("yyyy-MM-dd-HH-mm") };
  2738. BinaryFormatter bf = new BinaryFormatter();
  2739. bf.Serialize(writeStream, p1);
  2740. }
  2741. }
  2742. }
  2743. else
  2744. {
  2745. if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString()))
  2746. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString());
  2747. if (globalVar.LOneFryPotSerial == 1 && fryOneRecipe != string.Empty)
  2748. {
  2749. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryOneRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  2750. {
  2751. writeStream.Position = writeStream.Length;
  2752. PotOneStatus p1 = new PotOneStatus { Temperature = FryPotMonitorManage.GetInstance.fryOne.Temperature, SmallFire = FryPotMonitorManage.GetInstance.fryOne.SmallFire, MidFire = FryPotMonitorManage.GetInstance.fryOne.MidFire, BigFire = FryPotMonitorManage.GetInstance.fryOne.BigFire, StrongFire = FryPotMonitorManage.GetInstance.fryOne.StrongFire, Speed = FryPotMonitorManage.GetInstance.fryOne.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryOne.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryOne.TotalProduct, RecipeName = fryOneRecipe, Time = DateTime.Now.ToString("yyyy-MM-dd-HH-mm") };
  2753. BinaryFormatter bf = new BinaryFormatter();
  2754. bf.Serialize(writeStream, p1);
  2755. }
  2756. }
  2757. }
  2758. #endregion
  2759. #region 炒锅2状态数据保存
  2760. if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅2状态数据"))
  2761. {
  2762. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅2状态数据");
  2763. if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString()))
  2764. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString());
  2765. if (globalVar.LTwoFryPotSerial == 2 && fryTwoRecipe != string.Empty)
  2766. {
  2767. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryTwoRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  2768. {
  2769. writeStream.Position = writeStream.Length;
  2770. PotTwoStatus p1 = new PotTwoStatus { Temperature = FryPotMonitorManage.GetInstance.fryTwo.Temperature, SmallFire = FryPotMonitorManage.GetInstance.fryTwo.SmallFire, MidFire = FryPotMonitorManage.GetInstance.fryTwo.MidFire, BigFire = FryPotMonitorManage.GetInstance.fryTwo.BigFire, StrongFire = FryPotMonitorManage.GetInstance.fryTwo.StrongFire, Speed = FryPotMonitorManage.GetInstance.fryTwo.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct, RecipeName = fryTwoRecipe, Time = DateTime.Now.ToString("yyyy-MM-dd-HH-mm") };
  2771. BinaryFormatter bf = new BinaryFormatter();
  2772. bf.Serialize(writeStream, p1);
  2773. }
  2774. }
  2775. }
  2776. else
  2777. {
  2778. if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString()))
  2779. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString());
  2780. if (globalVar.LTwoFryPotSerial == 2 && fryTwoRecipe != string.Empty)
  2781. {
  2782. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryTwoRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  2783. {
  2784. writeStream.Position = writeStream.Length;
  2785. PotTwoStatus p1 = new PotTwoStatus { Temperature = FryPotMonitorManage.GetInstance.fryTwo.Temperature, SmallFire = FryPotMonitorManage.GetInstance.fryTwo.SmallFire, MidFire = FryPotMonitorManage.GetInstance.fryTwo.MidFire, BigFire = FryPotMonitorManage.GetInstance.fryTwo.BigFire, StrongFire = FryPotMonitorManage.GetInstance.fryTwo.StrongFire, Speed = FryPotMonitorManage.GetInstance.fryTwo.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct, RecipeName = fryTwoRecipe, Time = DateTime.Now.ToString("yyyy-MM-dd-HH-mm") };
  2786. BinaryFormatter bf = new BinaryFormatter();
  2787. bf.Serialize(writeStream, p1);
  2788. }
  2789. }
  2790. }
  2791. #endregion
  2792. #region 炒锅3状态数据保存
  2793. if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅3状态数据"))
  2794. {
  2795. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅3状态数据");
  2796. if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString()))
  2797. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString());
  2798. if (globalVar.LThreeFryPotSerial == 3 && fryThreeRecipe != string.Empty)
  2799. {
  2800. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryThreeRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  2801. {
  2802. writeStream.Position = writeStream.Length;
  2803. PotThreeStatus p1 = new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, SmallFire = FryPotMonitorManage.GetInstance.fryThree.SmallFire, MidFire = FryPotMonitorManage.GetInstance.fryThree.MidFire, BigFire = FryPotMonitorManage.GetInstance.fryThree.BigFire, StrongFire = FryPotMonitorManage.GetInstance.fryThree.StrongFire, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, RecipeName = fryThreeRecipe, Time = DateTime.Now.ToString("yyyy-MM-dd-HH-mm") };
  2804. BinaryFormatter bf = new BinaryFormatter();
  2805. bf.Serialize(writeStream, p1);
  2806. }
  2807. }
  2808. }
  2809. else
  2810. {
  2811. if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString()))
  2812. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString());
  2813. if (globalVar.LThreeFryPotSerial == 3 && fryThreeRecipe != string.Empty)
  2814. {
  2815. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryThreeRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  2816. {
  2817. writeStream.Position = writeStream.Length;
  2818. PotThreeStatus p1 = new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, SmallFire = FryPotMonitorManage.GetInstance.fryThree.SmallFire, MidFire = FryPotMonitorManage.GetInstance.fryThree.MidFire, BigFire = FryPotMonitorManage.GetInstance.fryThree.BigFire, StrongFire = FryPotMonitorManage.GetInstance.fryThree.StrongFire, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, RecipeName = fryThreeRecipe, Time = DateTime.Now.ToString("yyyy-MM-dd-HH-mm") };
  2819. BinaryFormatter bf = new BinaryFormatter();
  2820. bf.Serialize(writeStream, p1);
  2821. }
  2822. }
  2823. }
  2824. #endregion
  2825. #region 炒锅4状态数据保存
  2826. if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅4状态数据"))
  2827. {
  2828. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅4状态数据");
  2829. if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString()))
  2830. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString());
  2831. if (globalVar.LOneFryPotSerial == 4 && fryFourRecipe != string.Empty)
  2832. {
  2833. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryFourRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  2834. {
  2835. writeStream.Position = writeStream.Length;
  2836. PotFourStatus p1 = new PotFourStatus { Temperature = FryPotMonitorManage.GetInstance.fryFour.Temperature, SmallFire = FryPotMonitorManage.GetInstance.fryFour.SmallFire, MidFire = FryPotMonitorManage.GetInstance.fryFour.MidFire, BigFire = FryPotMonitorManage.GetInstance.fryFour.BigFire, StrongFire = FryPotMonitorManage.GetInstance.fryFour.StrongFire, Speed = FryPotMonitorManage.GetInstance.fryFour.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFour.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFour.TotalProduct, RecipeName = fryFourRecipe, Time = DateTime.Now.ToString("yyyy-MM-dd-HH-mm") };
  2837. BinaryFormatter bf = new BinaryFormatter();
  2838. bf.Serialize(writeStream, p1);
  2839. }
  2840. }
  2841. }
  2842. else
  2843. {
  2844. if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString()))
  2845. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString());
  2846. if (globalVar.LOneFryPotSerial == 4 && fryFourRecipe != string.Empty)
  2847. {
  2848. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryFourRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  2849. {
  2850. writeStream.Position = writeStream.Length;
  2851. PotFourStatus p1 = new PotFourStatus
  2852. {
  2853. Temperature = FryPotMonitorManage.GetInstance.fryFour.Temperature,
  2854. SmallFire = FryPotMonitorManage.GetInstance.fryFour.SmallFire,
  2855. MidFire = FryPotMonitorManage.GetInstance.fryFour.MidFire,
  2856. BigFire = FryPotMonitorManage.GetInstance.fryFour.BigFire,
  2857. StrongFire = FryPotMonitorManage.GetInstance.fryFour.StrongFire,
  2858. Speed = FryPotMonitorManage.GetInstance.fryFour.Speed,
  2859. FryPotWeight = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight,
  2860. OilCapacity = FryPotMonitorManage.GetInstance.fryFour.OilCapacity,
  2861. TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy,
  2862. TotalProduct = FryPotMonitorManage.GetInstance.fryFour.TotalProduct,
  2863. RecipeName = fryFourRecipe,
  2864. Time = DateTime.Now.ToString("yyyy-MM-dd-HH-mm")
  2865. };
  2866. BinaryFormatter bf = new BinaryFormatter();
  2867. bf.Serialize(writeStream, p1);
  2868. }
  2869. }
  2870. }
  2871. #endregion
  2872. #region 炒锅5状态数据保存
  2873. if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅5状态数据"))
  2874. {
  2875. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅5状态数据");
  2876. if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString()))
  2877. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString());
  2878. if (globalVar.LTwoFryPotSerial == 5 && fryFiveRecipe != string.Empty)
  2879. {
  2880. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryFiveRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  2881. {
  2882. writeStream.Position = writeStream.Length;
  2883. PotFiveStatus p1 = new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, SmallFire = FryPotMonitorManage.GetInstance.fryFive.SmallFire, MidFire = FryPotMonitorManage.GetInstance.fryFive.MidFire, BigFire = FryPotMonitorManage.GetInstance.fryFive.BigFire, StrongFire = FryPotMonitorManage.GetInstance.fryFive.StrongFire, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, RecipeName = fryFiveRecipe, Time = DateTime.Now.ToString("yyyy-MM-dd-HH-mm") };
  2884. BinaryFormatter bf = new BinaryFormatter();
  2885. bf.Serialize(writeStream, p1);
  2886. }
  2887. }
  2888. }
  2889. else
  2890. {
  2891. if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString()))
  2892. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString());
  2893. if (globalVar.LTwoFryPotSerial == 5 && fryFiveRecipe != string.Empty)
  2894. {
  2895. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryFiveRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  2896. {
  2897. writeStream.Position = writeStream.Length;
  2898. PotFiveStatus p1 = new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, SmallFire = FryPotMonitorManage.GetInstance.fryFive.SmallFire, MidFire = FryPotMonitorManage.GetInstance.fryFive.MidFire, BigFire = FryPotMonitorManage.GetInstance.fryFive.BigFire, StrongFire = FryPotMonitorManage.GetInstance.fryFive.StrongFire, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, RecipeName = fryFiveRecipe, Time = DateTime.Now.ToString("yyyy-MM-dd-HH-mm") };
  2899. BinaryFormatter bf = new BinaryFormatter();
  2900. bf.Serialize(writeStream, p1);
  2901. }
  2902. }
  2903. }
  2904. #endregion
  2905. }
  2906. /// <summary>
  2907. /// 滚筒线运行状态显示
  2908. /// </summary>
  2909. private void RollerLineStatusDisplay()
  2910. {
  2911. hardWareStatusModel.RollerOneModel.LocOneRollerSerial = globalVar.rollerLineOne.StationOne;
  2912. hardWareStatusModel.RollerOneModel.LocTwoRollerSerial = globalVar.rollerLineOne.StationTwo;
  2913. hardWareStatusModel.RollerOneModel.LocThreeRollerSerial = globalVar.rollerLineOne.StationThree;
  2914. hardWareStatusModel.RollerOneModel.LocFourRollerSerial = globalVar.rollerLineOne.StationFour;
  2915. hardWareStatusModel.RollerOneModel.LocFiveRollerSerial = globalVar.rollerLineOne.StationFive;
  2916. hardWareStatusModel.RollerOneModel.LocSixRollerSerial = globalVar.rollerLineOne.StationSix;
  2917. hardWareStatusModel.RollerOneModel.LocSevenRollerSerial = globalVar.rollerLineOne.StationSeven;
  2918. hardWareStatusModel.RollerOneModel.LocEightRollerSerial = globalVar.rollerLineOne.StationEight;
  2919. if (AlarmHelper<AlarmInfo>.GetInstance("1号滚筒线故障").LOneRollerTrouble == 0)
  2920. {
  2921. hardWareStatusModel.RollerOneModel.RollerAlarmState = Color.FromRgb(130, 232, 139);//无故障
  2922. }
  2923. else
  2924. {
  2925. hardWareStatusModel.RollerOneModel.RollerAlarmState = Color.FromRgb(255, 51, 153);//有故障
  2926. }
  2927. if (globalVar.rollerLineOne.OutMaterialingSingle == 1)//运行中
  2928. {
  2929. hardWareStatusModel.RollerOneModel.RollerRunState = Color.FromRgb(130, 232, 139);//运行中
  2930. }
  2931. else
  2932. {
  2933. hardWareStatusModel.RollerOneModel.RollerRunState = Color.FromRgb(84, 84, 84);//未运行
  2934. }
  2935. hardWareStatusModel.RollerTwoModel.LocOneRollerSerial = globalVar.rollerLineTwo.StationOne;
  2936. hardWareStatusModel.RollerTwoModel.LocTwoRollerSerial = globalVar.rollerLineTwo.StationTwo;
  2937. hardWareStatusModel.RollerTwoModel.LocThreeRollerSerial = globalVar.rollerLineTwo.StationThree;
  2938. hardWareStatusModel.RollerTwoModel.LocFourRollerSerial = globalVar.rollerLineTwo.StationFour;
  2939. hardWareStatusModel.RollerTwoModel.LocFiveRollerSerial = globalVar.rollerLineTwo.StationFive;
  2940. hardWareStatusModel.RollerTwoModel.LocSixRollerSerial = globalVar.rollerLineTwo.StationSix;
  2941. hardWareStatusModel.RollerTwoModel.LocSevenRollerSerial = globalVar.rollerLineTwo.StationSeven;
  2942. hardWareStatusModel.RollerTwoModel.LocEightRollerSerial = globalVar.rollerLineTwo.StationEight;
  2943. if (AlarmHelper<AlarmInfo>.GetInstance("2号滚筒线故障").LTwoRollerTrouble == 0)
  2944. {
  2945. hardWareStatusModel.RollerTwoModel.RollerAlarmState = Color.FromRgb(130, 232, 139);//无故障
  2946. }
  2947. else
  2948. {
  2949. hardWareStatusModel.RollerTwoModel.RollerAlarmState = Color.FromRgb(255, 51, 153);//有故障
  2950. }
  2951. if (globalVar.rollerLineTwo.OutMaterialingSingle == 1)//运行中
  2952. {
  2953. hardWareStatusModel.RollerTwoModel.RollerRunState = Color.FromRgb(130, 232, 139);//运行中
  2954. }
  2955. else
  2956. {
  2957. hardWareStatusModel.RollerTwoModel.RollerRunState = Color.FromRgb(84, 84, 84);//未运行
  2958. }
  2959. hardWareStatusModel.RollerThreeModel.LocOneRollerSerial = globalVar.rollerLineThree.StationOne;
  2960. hardWareStatusModel.RollerThreeModel.LocTwoRollerSerial = globalVar.rollerLineThree.StationTwo;
  2961. hardWareStatusModel.RollerThreeModel.LocThreeRollerSerial = globalVar.rollerLineThree.StationThree;
  2962. hardWareStatusModel.RollerThreeModel.LocFourRollerSerial = globalVar.rollerLineThree.StationFour;
  2963. hardWareStatusModel.RollerThreeModel.LocFiveRollerSerial = globalVar.rollerLineThree.StationFive;
  2964. hardWareStatusModel.RollerThreeModel.LocSixRollerSerial = globalVar.rollerLineThree.StationSix;
  2965. hardWareStatusModel.RollerThreeModel.LocSevenRollerSerial = globalVar.rollerLineThree.StationSeven;
  2966. hardWareStatusModel.RollerThreeModel.LocEightRollerSerial = globalVar.rollerLineThree.StationEight;
  2967. if (AlarmHelper<AlarmInfo>.GetInstance("3号滚筒线故障").LThreeRollerTrouble == 0)
  2968. {
  2969. hardWareStatusModel.RollerThreeModel.RollerAlarmState = Color.FromRgb(130, 232, 139);//无故障
  2970. }
  2971. else
  2972. {
  2973. hardWareStatusModel.RollerThreeModel.RollerAlarmState = Color.FromRgb(255, 51, 153);//有故障
  2974. }
  2975. if (globalVar.rollerLineThree.OutMaterialingSingle == 1)//运行中
  2976. {
  2977. hardWareStatusModel.RollerThreeModel.RollerRunState = Color.FromRgb(130, 232, 139);//运行中
  2978. }
  2979. else
  2980. {
  2981. hardWareStatusModel.RollerThreeModel.RollerRunState = Color.FromRgb(84, 84, 84);//未运行
  2982. }
  2983. //滚筒线4
  2984. }
  2985. /// <summary>
  2986. /// 返回滚筒线PLC指定地址指定长度的数据
  2987. /// </summary>
  2988. /// <param name="address"></param>
  2989. /// <returns></returns>
  2990. public void GetAddressData(string address, Action<ushort[]> action)
  2991. {
  2992. PlcReadData = DeviceOperate.GetInstance.GetAllData();
  2993. if (PlcReadData.ContainsKey(address))
  2994. {
  2995. action((ushort[])(PlcReadData[address]));
  2996. }
  2997. }
  2998. public void GetFryOneData(string address, Action<ushort[]> action)
  2999. {
  3000. FryOneData = DeviceOperate.GetInstance.GetFryOneData();
  3001. if (FryOneData.ContainsKey(address))
  3002. {
  3003. action((ushort[])(FryOneData[address]));
  3004. }
  3005. }
  3006. public void GetFryTwoData(string address, Action<ushort[]> action)
  3007. {
  3008. FryTwoData = DeviceOperate.GetInstance.GetFryTwoData();
  3009. if (FryTwoData.ContainsKey(address))
  3010. {
  3011. action((ushort[])(FryTwoData[address]));
  3012. }
  3013. }
  3014. public void GetFryThreeData(string address, Action<ushort[]> action)
  3015. {
  3016. FryThreeData = DeviceOperate.GetInstance.GetFryThreeData();
  3017. if (FryThreeData.ContainsKey(address))
  3018. {
  3019. action((ushort[])(FryThreeData[address]));
  3020. }
  3021. }
  3022. public void GetFryFourData(string address, Action<ushort[]> action)
  3023. {
  3024. FryFourData = DeviceOperate.GetInstance.GetFryFourData();
  3025. if (FryFourData.ContainsKey(address))
  3026. {
  3027. action((ushort[])(FryFourData[address]));
  3028. }
  3029. }
  3030. public void GetFryFiveData(string address, Action<ushort[]> action)
  3031. {
  3032. FryFiveData = DeviceOperate.GetInstance.GetFryFiveData();
  3033. if (FryFiveData.ContainsKey(address))
  3034. {
  3035. action((ushort[])(FryFiveData[address]));
  3036. }
  3037. }
  3038. /// <summary>
  3039. /// 滚筒线写Plc数据
  3040. /// </summary>
  3041. /// <param name="address"></param>
  3042. /// <param name="Value"></param>
  3043. public void WritePlcData(string address, ushort Value)
  3044. {
  3045. DeviceOperate.GetInstance.WritePlcData(address, Value);
  3046. }
  3047. /// <summary>
  3048. /// 炒锅写Plc数据
  3049. /// </summary>
  3050. /// <param name="potNum"></param>
  3051. /// <param name="address"></param>
  3052. /// <param name="value"></param>
  3053. public void WritePotData(int potNum, string address, ushort value)
  3054. {
  3055. switch (potNum)
  3056. {
  3057. case 1: DeviceOperate.GetInstance.WritePotOnePlcData(address, value); break;
  3058. case 2: DeviceOperate.GetInstance.WritePotTwoPlcData(address, value); break;
  3059. case 3: DeviceOperate.GetInstance.WritePotThreePlcData(address, value); break;
  3060. case 4: DeviceOperate.GetInstance.WritePotFourPlcData(address, value); break;
  3061. case 5: DeviceOperate.GetInstance.WritePotFivePlcData(address, value); break;
  3062. }
  3063. }
  3064. /// <summary>
  3065. /// 炒锅写float类型Plc数据
  3066. /// </summary>
  3067. public void WritePotRealData(int potNum, string address, float value)
  3068. {
  3069. switch (potNum)
  3070. {
  3071. case 1: DeviceOperate.GetInstance.WritePotOneRealPlcData(address, value); break;
  3072. case 2: DeviceOperate.GetInstance.WritePotTwoRealPlcData(address, value); break;
  3073. case 3: DeviceOperate.GetInstance.WritePotThreeRealPlcData(address, value); break;
  3074. case 4: DeviceOperate.GetInstance.WritePotFourRealPlcData(address, value); break;
  3075. case 5: DeviceOperate.GetInstance.WritePotFiveRealPlcData(address, value); break;
  3076. }
  3077. }
  3078. /// <summary>
  3079. /// 配方数据接收
  3080. /// </summary>
  3081. public void RecipeDataParse(object obj)
  3082. {
  3083. Task.Run(new Action(() =>
  3084. {
  3085. if (obj != null && obj is NewRecipeModel[] recipes)
  3086. {
  3087. ReicpeNum = ReicpeNum + recipes.Length;
  3088. MessageNotify.GetInstance.ShowUserLog($"新接收到{recipes.Length}个配方,总共{ReicpeNum}个配方");
  3089. for (int i = 0; i < recipes.Length; i++)
  3090. {
  3091. int? res = recipes[i].materialCollection.ElementAt(0).MaterialLoc / 100;
  3092. if (res != null)
  3093. {
  3094. switch (res)
  3095. {
  3096. case 1:
  3097. case 4: RecipeQuene.Enqueue(recipes[i]); break;
  3098. case 3: LThreeRecipeQuene.Enqueue(recipes[i]); break;
  3099. case 2:
  3100. case 5: LTwoRecipeQuene.Enqueue(recipes[i]); break;
  3101. }
  3102. }
  3103. }
  3104. }
  3105. }));
  3106. }
  3107. /// <summary>
  3108. /// 开启主任务
  3109. /// </summary>
  3110. public void MainTask()
  3111. {
  3112. ////RecipeDataToPlc();
  3113. //LOneRecipeDataToPlc();
  3114. //LTwoRecipeDataToPlc();
  3115. //LThreeRecipeDataToPlc();
  3116. ////AgvLoadRoller();
  3117. //LOneLoadRoller();
  3118. //LTwoAgvLoadRoller();
  3119. //LThreeAgvLoadRoller();
  3120. //// FryPotInputMaterial();
  3121. //LOneFryPotInputMaterial();
  3122. //LTwoFryPotInputMaterial();
  3123. //LThreeFryPotInputMaterial();
  3124. ////FryPotOutputMaterial();
  3125. //LOneFryPotOutputMaterial();
  3126. //LTwoFryPotOutputMaterial();
  3127. //LThreeFryPotOutputMaterial();
  3128. TaskManage.GetInstance.StartLong(new Action(() => { LineOneProcessExecute(); Thread.Sleep(10); }), "滚筒线1任务线程");
  3129. TaskManage.GetInstance.StartLong(new Action(() => { LineTwoProcessExecute(); Thread.Sleep(10); }), "滚筒线2任务线程");
  3130. TaskManage.GetInstance.StartLong(new Action(() => { LineThreeProcessExecute(); Thread.Sleep(10); }), "滚筒线3任务线程");
  3131. TaskManage.GetInstance.StartLong(new Action(() => { LineOneToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线1空桶清洗任务线程");
  3132. TaskManage.GetInstance.StartLong(new Action(() => { LineTwoToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线2空桶清洗任务线程");
  3133. TaskManage.GetInstance.StartLong(new Action(() => { LineThreeToCleanProcessExecute(); Thread.Sleep(10); }), "滚筒线3空桶清洗任务线程");
  3134. TaskManage.GetInstance.StartLong(new Action(() => { ToLineFourFromCleanPlate(); Thread.Sleep(10); }), "清洗台空桶回桶任务线程");
  3135. TaskManage.GetInstance.StartLong(new Action(() => { EmptyRollerToLinFourFromPot(); Thread.Sleep(10); }), "炒锅空桶回桶任务线程");
  3136. }
  3137. /// <summary>
  3138. /// 线体1的执行流程
  3139. /// </summary>
  3140. public void LineOneProcessExecute()
  3141. {
  3142. LOneFryPotStepDisplay();
  3143. LOneRecipeDataToPlc();
  3144. LineOneRecipeExecuteConfirm();
  3145. LOneLoadRoller();
  3146. LOneFryPotInputMaterial();
  3147. LOneFallMaterial();
  3148. LOneFryPotOutputMaterial();
  3149. LOneEmptyOperate();
  3150. // globalVar.LOneTaskLock = false;
  3151. //}
  3152. }
  3153. /// <summary>
  3154. /// 线体2的执行流程
  3155. /// </summary>
  3156. public void LineTwoProcessExecute()
  3157. {
  3158. LTwoFryPotStepDisplay();
  3159. LTwoRecipeDataToPlc();
  3160. LineTwoRecipeExecuteConfirm();
  3161. LTwoAgvLoadRoller();
  3162. LTwoFryPotInputMaterial();
  3163. LTwoFallMaterial();
  3164. LTwoFryPotOutputMaterial();
  3165. LTwoEmptyOperate();
  3166. // globalVar.LTwoTaskLock = false;
  3167. //}
  3168. }
  3169. /// <summary>
  3170. /// 线体3的执行流程
  3171. /// </summary>
  3172. public void LineThreeProcessExecute()
  3173. {
  3174. LThreeFryPotStepDisplay();
  3175. LThreeRecipeDataToPlc();
  3176. LineThreeRecipeExecuteConfirm();
  3177. LThreeAgvLoadRoller();
  3178. LThreeFryPotInputMaterial();
  3179. LThreeFallMaterial();
  3180. LThreeFryPotOutputMaterial();
  3181. LThreeEmptyOperate();
  3182. // globalVar.LThreeTaskLock = false;
  3183. //}
  3184. }
  3185. private void LineOneToCleanProcessExecute()
  3186. {
  3187. //线体1到清洗台
  3188. AgvFromLineOneToCleanPlate();
  3189. AgvArriveCleanPlateFromLineOne();
  3190. }
  3191. public void LineTwoToCleanProcessExecute()
  3192. {
  3193. //线体2到清洗台
  3194. AgvFromLineTwoToCleanPlate();
  3195. AgvArriveCleanPlateFromLineTwo();
  3196. }
  3197. public void LineThreeToCleanProcessExecute()
  3198. {
  3199. //线体3到清洗台
  3200. AgvFromLineThreeToCleanPlate();
  3201. AgvArriveCleanPlateFromLineThree();
  3202. }
  3203. private void ToLineFourFromCleanPlate()
  3204. {
  3205. //空桶到线体4
  3206. CallAgvToLineFour();
  3207. CleanPlateUpLoad();
  3208. EmptyRollerToLinFourFromClean();
  3209. }
  3210. private void CleanPlateUpLoad()
  3211. {
  3212. if (globalVar.agvArriveCleanLoad)
  3213. {
  3214. globalVar.agvArriveCleanLoad = false;
  3215. MessageNotify.GetInstance.ShowRunLog("AGV到达清洗台空桶上料位置");
  3216. //plc交互
  3217. WritePlcData("D1066", 1);//AGV空桶出桶就位信号下发PlC
  3218. //erp: if (AlarmHelper<AlarmInfo>.GetInstance("洗桶机出桶未运行").CleanOutputRollerRunning == 0)
  3219. // {
  3220. // //plc交互
  3221. // WritePlcData("D1066", 1);//AGV空桶出桶就位信号下发PlC
  3222. // }
  3223. // else//有故障
  3224. // {
  3225. // while (AlarmHelper<AlarmInfo>.GetInstance("洗桶机出桶未运行").CleanOutputRollerRunning == 1)
  3226. // {
  3227. // Thread.Sleep(1000);
  3228. // if (globalVar.ExitLineOneTask)
  3229. // return;
  3230. // }
  3231. // MessageNotify.GetInstance.ShowRunLog("清洗台空桶出桶滚筒重新运行!!");
  3232. // goto erp;
  3233. // }
  3234. }
  3235. }
  3236. /// <summary>
  3237. /// 线体1到清洗台
  3238. /// </summary>
  3239. private void AgvFromLineOneToCleanPlate()
  3240. {
  3241. if (AlarmHelper<AlarmInfo>.GetInstance("1号滚筒线故障").LOneRollerTrouble == 0)//输送线无故障
  3242. {
  3243. if (TTrig.GetInstance("LineOneModel").Start(Convert.ToBoolean(globalVar.rollerLineOne.WashEmptyRollerModel)))
  3244. {
  3245. MessageNotify.GetInstance.ShowRunLog($"1号滚筒线切换为普通洗桶模式");
  3246. }
  3247. if (globalVar.rollerLineOne.WashEmptyRollerModel == 0)
  3248. {
  3249. try
  3250. {
  3251. lock (Obj_Lock)
  3252. {
  3253. //线体1到清洗台
  3254. if (!globalVar.rollerLineOne.IsEpmtyBefore && globalVar.rollerLineOne.CanRun && globalVar.AllowNextEmptyRollerToClean && globalVar.rollerLineOne.EmptyRollerNums.Count > 0)
  3255. {
  3256. var res = InputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineOne.StationEight);
  3257. if ((globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.EmptyRollerNums.Contains(globalVar.rollerLineOne.StationEight) && InputMaterialQuene.Count > 0 && globalVar.rollerLineOne.StationEight != InputMaterialQuene.ElementAt(0).materialType.MaterialLoc) || (res == null && globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.EmptyRollerNums.Contains(globalVar.rollerLineOne.StationEight)))//一种情况工位8上面有桶且不是配方上的原料桶且工位8的桶号和plc上报的桶号一致,即空桶,另一种在没有下单的情况下,线体上的桶都认为是空桶
  3258. {
  3259. LOneCurrentRollerNum = globalVar.rollerLineOne.StationEight;
  3260. //下发AGV去空桶线洗桶任务
  3261. e: string id = Guid.NewGuid().ToString("D");
  3262. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  3263. goto e;
  3264. string info = AGVHelper.GetInstance.AgvLeaveLOneToClean(id);//1号线到洗桶处
  3265. LSevenrobotJobId.Add(id);
  3266. // Thread.Sleep(500);
  3267. if (LineToCleanCarryTaskErrorCodeAnalysis(info, 1))//AGV呼叫成功
  3268. {
  3269. WritePlcData("D1250", LOneCurrentRollerNum);//下发空桶桶号到洗桶机
  3270. globalVar.rollerLineOne.IsEpmtyBefore = true;
  3271. globalVar.AllowNextEmptyRollerToClean = false;
  3272. }
  3273. else
  3274. {
  3275. LSevenrobotJobId.Remove(id);
  3276. Thread.Sleep(5000);
  3277. }
  3278. }
  3279. // AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
  3280. }
  3281. else
  3282. {
  3283. AgvFromLineOneToClean(LOneCurrentRollerNum);//AGV从线体1到清洗处
  3284. }
  3285. }
  3286. }
  3287. catch (Exception)
  3288. {
  3289. // throw;
  3290. }
  3291. }
  3292. else //统一洗桶模式
  3293. {
  3294. if (RTrig.GetInstance("LineOneModel").Start(Convert.ToBoolean(globalVar.rollerLineOne.WashEmptyRollerModel)))
  3295. MessageNotify.GetInstance.ShowRunLog($"1号滚筒线切换为统一洗桶模式");
  3296. lock (Obj_Lock)
  3297. {
  3298. if (globalVar.rollerLineOne.WashRollerArriveSignal == 1 && globalVar.AllowNextEmptyRollerToClean)//1号线空桶洗桶就位
  3299. {
  3300. //下发AGV去空桶线洗桶任务
  3301. e: string id = Guid.NewGuid().ToString("D");
  3302. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  3303. goto e;
  3304. string info = AGVHelper.GetInstance.AgvLeaveLOneToClean(id);//1号线到洗桶处
  3305. LSevenrobotJobId.Add(id);
  3306. // Thread.Sleep(500);
  3307. if (LineToCleanCarryTaskErrorCodeAnalysis(info, 1))//AGV呼叫成功
  3308. {
  3309. globalVar.AllowNextEmptyRollerToClean = false;
  3310. }
  3311. else
  3312. {
  3313. LSevenrobotJobId.Remove(id);
  3314. Thread.Sleep(5000);
  3315. }
  3316. }
  3317. else
  3318. {
  3319. AgvFromLineOneToClean();//AGV从线体1到清洗处
  3320. }
  3321. }
  3322. }
  3323. }
  3324. }
  3325. /// <summary>
  3326. /// 线体2到清洗台
  3327. /// </summary>
  3328. private void AgvFromLineTwoToCleanPlate()
  3329. {
  3330. // 线体2到清洗台
  3331. if (AlarmHelper<AlarmInfo>.GetInstance("2号滚筒线故障").LTwoRollerTrouble == 0)//输送线无故障
  3332. {
  3333. if (TTrig.GetInstance("LineTwoModel").Start(Convert.ToBoolean(globalVar.rollerLineTwo.WashEmptyRollerModel)))
  3334. {
  3335. MessageNotify.GetInstance.ShowRunLog($"2号滚筒线切换为普通洗桶模式");
  3336. }
  3337. if (globalVar.rollerLineTwo.WashEmptyRollerModel == 0)
  3338. {
  3339. try
  3340. {
  3341. lock (Obj_Lock)
  3342. {
  3343. if (!globalVar.rollerLineTwo.IsEpmtyBefore && globalVar.rollerLineTwo.CanRun && globalVar.AllowNextEmptyRollerToClean && globalVar.rollerLineTwo.EmptyRollerNums.Count > 0)
  3344. {
  3345. var res = LTwoInputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineTwo.StationEight);
  3346. if ((globalVar.rollerLineTwo.StationEight != 0 && globalVar.rollerLineTwo.EmptyRollerNums.Contains(globalVar.rollerLineTwo.StationEight) && LTwoInputMaterialQuene.Count > 0 && globalVar.rollerLineTwo.StationEight != LTwoInputMaterialQuene.ElementAt(0).materialType.MaterialLoc) || (res == null && globalVar.rollerLineTwo.StationEight != 0 && globalVar.rollerLineTwo.EmptyRollerNums.Contains(globalVar.rollerLineTwo.StationEight)))//工位8上面有桶且不是配方上的原料桶,即空桶
  3347. {
  3348. LTwoCurrentRollerNum = globalVar.rollerLineTwo.StationEight;
  3349. //下发AGV去空桶线洗桶任务
  3350. e: string id = Guid.NewGuid().ToString("D");
  3351. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  3352. goto e;
  3353. string info = AGVHelper.GetInstance.AgvLeaveLTwoToClean(id);//2号线到洗桶处
  3354. LEightrobotJobId.Add(id);
  3355. //Thread.Sleep(500);
  3356. if (LineToCleanCarryTaskErrorCodeAnalysis(info, 2))
  3357. {
  3358. WritePlcData("D1250", LTwoCurrentRollerNum);//下发空桶桶号到洗桶机
  3359. globalVar.rollerLineTwo.IsEpmtyBefore = true;
  3360. globalVar.AllowNextEmptyRollerToClean = false;
  3361. }
  3362. else
  3363. {
  3364. LEightrobotJobId.Remove(id);
  3365. Thread.Sleep(5000);
  3366. }
  3367. //AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体2到清洗处
  3368. }
  3369. }
  3370. else
  3371. {
  3372. AgvFromLineTwoToClean(LTwoCurrentRollerNum);//AGV从线体1到清洗处
  3373. }
  3374. }
  3375. }
  3376. catch (Exception)
  3377. {
  3378. // throw;
  3379. }
  3380. }
  3381. else
  3382. {
  3383. if (RTrig.GetInstance("LineTwoModel").Start(Convert.ToBoolean(globalVar.rollerLineTwo.WashEmptyRollerModel)))
  3384. MessageNotify.GetInstance.ShowRunLog($"2号滚筒线切换为统一洗桶模式");
  3385. lock (Obj_Lock)
  3386. {
  3387. if (globalVar.rollerLineTwo.WashRollerArriveSignal == 1 && globalVar.AllowNextEmptyRollerToClean)//1号线空桶洗桶就位
  3388. {
  3389. //下发AGV去空桶线洗桶任务
  3390. e: string id = Guid.NewGuid().ToString("D");
  3391. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  3392. goto e;
  3393. string info = AGVHelper.GetInstance.AgvLeaveLTwoToClean(id);//2号线到洗桶处
  3394. LEightrobotJobId.Add(id);
  3395. //Thread.Sleep(500);
  3396. if (LineToCleanCarryTaskErrorCodeAnalysis(info, 2))
  3397. {
  3398. globalVar.AllowNextEmptyRollerToClean = false;
  3399. }
  3400. else
  3401. {
  3402. LEightrobotJobId.Remove(id);
  3403. Thread.Sleep(5000);
  3404. }
  3405. }
  3406. else
  3407. {
  3408. AgvFromLineTwoToClean();//AGV从线体1到清洗处
  3409. }
  3410. }
  3411. }
  3412. }
  3413. }
  3414. /// <summary>
  3415. /// 线体3到清洗台
  3416. /// </summary>
  3417. private void AgvFromLineThreeToCleanPlate()
  3418. {
  3419. //线体3到清洗台
  3420. if (AlarmHelper<AlarmInfo>.GetInstance("3号滚筒线故障").LThreeRollerTrouble == 0)//输送线无故障
  3421. {
  3422. if (TTrig.GetInstance("LineThreeModel").Start(Convert.ToBoolean(globalVar.rollerLineThree.WashEmptyRollerModel)))
  3423. {
  3424. MessageNotify.GetInstance.ShowRunLog($"3号滚筒线切换为普通洗桶模式");
  3425. }
  3426. if (globalVar.rollerLineThree.WashEmptyRollerModel == 0)
  3427. {
  3428. try
  3429. {
  3430. lock (Obj_Lock)
  3431. {
  3432. if (!globalVar.rollerLineThree.IsEpmtyBefore && globalVar.rollerLineThree.CanRun && globalVar.AllowNextEmptyRollerToClean && globalVar.rollerLineThree.EmptyRollerNums.Count > 0)
  3433. {
  3434. var res = LThreeInputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineThree.StationEight);
  3435. if ((globalVar.rollerLineThree.StationEight != 0 && globalVar.rollerLineThree.EmptyRollerNums.Contains(globalVar.rollerLineThree.StationEight) && LThreeInputMaterialQuene.Count > 0 && globalVar.rollerLineThree.StationEight != LThreeInputMaterialQuene.ElementAt(0).materialType.MaterialLoc) || (res == null && globalVar.rollerLineThree.StationEight != 0 && globalVar.rollerLineThree.EmptyRollerNums.Contains(globalVar.rollerLineThree.StationEight)))//工位8上面有桶且不是配方上的原料桶,即空桶
  3436. {
  3437. LThreeCurrentRollerNum = globalVar.rollerLineThree.StationEight;
  3438. //下发AGV去空桶线洗桶任务
  3439. e: string id = Guid.NewGuid().ToString("D");
  3440. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  3441. goto e;
  3442. string info = AGVHelper.GetInstance.AgvLeaveLThreeToClean(id);//3号线到洗桶处
  3443. LNinerobotJobId.Add(id);
  3444. //Thread.Sleep(500);
  3445. if (LineToCleanCarryTaskErrorCodeAnalysis(info, 3))//呼叫成功
  3446. {
  3447. WritePlcData("D1250", LThreeCurrentRollerNum);//下发空桶桶号到洗桶机
  3448. globalVar.rollerLineThree.IsEpmtyBefore = true;
  3449. globalVar.AllowNextEmptyRollerToClean = false;
  3450. }
  3451. else//呼叫失败
  3452. {
  3453. LNinerobotJobId.Remove(id);
  3454. Thread.Sleep(5000);
  3455. }
  3456. //AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处
  3457. }
  3458. }
  3459. else
  3460. {
  3461. AgvFromLineThreeToClean(LThreeCurrentRollerNum);//AGV从线体3到清洗处
  3462. }
  3463. }
  3464. }
  3465. catch (Exception)
  3466. {
  3467. // throw;
  3468. }
  3469. }
  3470. else
  3471. {
  3472. if (RTrig.GetInstance("LineThreeModel").Start(Convert.ToBoolean(globalVar.rollerLineThree.WashEmptyRollerModel)))
  3473. MessageNotify.GetInstance.ShowRunLog($"3号滚筒线切换为统一洗桶模式");
  3474. lock (Obj_Lock)
  3475. {
  3476. if (globalVar.rollerLineThree.WashRollerArriveSignal == 1 && globalVar.AllowNextEmptyRollerToClean)//1号线空桶洗桶就位
  3477. {
  3478. //下发AGV去空桶线洗桶任务
  3479. e: string id = Guid.NewGuid().ToString("D");
  3480. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  3481. goto e;
  3482. string info = AGVHelper.GetInstance.AgvLeaveLThreeToClean(id);//3号线到洗桶处
  3483. LNinerobotJobId.Add(id);
  3484. //Thread.Sleep(500);
  3485. if (LineToCleanCarryTaskErrorCodeAnalysis(info, 3))//呼叫成功
  3486. {
  3487. globalVar.rollerLineThree.IsEpmtyBefore = true;
  3488. globalVar.AllowNextEmptyRollerToClean = false;
  3489. }
  3490. else//呼叫失败
  3491. {
  3492. LNinerobotJobId.Remove(id);
  3493. Thread.Sleep(5000);
  3494. }
  3495. }
  3496. else
  3497. {
  3498. AgvFromLineThreeToClean();//AGV从线体3到清洗处
  3499. }
  3500. }
  3501. }
  3502. }
  3503. }
  3504. /// <summary>
  3505. /// AGV从线体1到达清洗台下料位置
  3506. /// </summary>
  3507. private void AgvArriveCleanPlateFromLineOne()
  3508. {
  3509. if (globalVar.rollerLineOne.agvArriveCleanUnLoad || globalVar.LineSevenRobotTaskError)
  3510. {
  3511. globalVar.rollerLineOne.agvArriveCleanUnLoad = false;
  3512. MessageNotify.GetInstance.ShowRunLog("空桶从线体1到达清洗位置,准备卸桶");
  3513. erp: if (AlarmHelper<AlarmInfo>.GetInstance("洗桶机进筒未运行").CleanEnterRollerRunning == 0)
  3514. {
  3515. globalVar.LineSevenRobotTaskError = false;//AGV故障信号复位
  3516. //plc交互
  3517. WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC
  3518. }
  3519. else//有故障
  3520. {
  3521. while (AlarmHelper<AlarmInfo>.GetInstance("洗桶机进筒未运行").CleanEnterRollerRunning == 1)
  3522. {
  3523. Thread.Sleep(1000);
  3524. if (globalVar.ExitLineOneTask)
  3525. return;
  3526. }
  3527. MessageNotify.GetInstance.ShowRunLog("清洗台空桶进桶滚筒重新运行!!");
  3528. goto erp;
  3529. }
  3530. }
  3531. }
  3532. /// <summary>
  3533. /// AGV从线体2到达清洗台下料位置
  3534. /// </summary>
  3535. private void AgvArriveCleanPlateFromLineTwo()
  3536. {
  3537. if (globalVar.rollerLineTwo.agvArriveCleanUnLoad || globalVar.LineEightRobotTaskError)
  3538. {
  3539. globalVar.rollerLineTwo.agvArriveCleanUnLoad = false;
  3540. MessageNotify.GetInstance.ShowRunLog("空桶从线体2到达清洗位置,准备卸桶");
  3541. erp: if (AlarmHelper<AlarmInfo>.GetInstance("洗桶机进筒未运行").CleanEnterRollerRunning == 0)
  3542. {
  3543. globalVar.LineEightRobotTaskError = false;//AGV故障信号复位
  3544. //plc交互
  3545. WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC
  3546. }
  3547. else//有故障
  3548. {
  3549. while (AlarmHelper<AlarmInfo>.GetInstance("洗桶机进筒未运行").CleanEnterRollerRunning == 1)
  3550. {
  3551. Thread.Sleep(1000);
  3552. if (globalVar.ExitLineTwoTask)
  3553. return;
  3554. }
  3555. MessageNotify.GetInstance.ShowRunLog("清洗台空桶进桶滚筒重新运行!!");
  3556. goto erp;
  3557. }
  3558. }
  3559. }
  3560. /// <summary>
  3561. /// AGV从线体3到达清洗台下料位置
  3562. /// </summary>
  3563. private void AgvArriveCleanPlateFromLineThree()
  3564. {
  3565. if (globalVar.rollerLineThree.agvArriveCleanUnLoad || globalVar.LineNineRobotTaskError)
  3566. {
  3567. globalVar.rollerLineThree.agvArriveCleanUnLoad = false;
  3568. MessageNotify.GetInstance.ShowRunLog("空桶从线体3到达清洗位置,准备卸桶");
  3569. erp: if (AlarmHelper<AlarmInfo>.GetInstance("洗桶机进筒未运行").CleanEnterRollerRunning == 0)
  3570. {
  3571. globalVar.LineNineRobotTaskError = false;//AGV故障信号复位
  3572. //plc交互
  3573. WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC
  3574. }
  3575. else//有故障
  3576. {
  3577. while (AlarmHelper<AlarmInfo>.GetInstance("洗桶机进筒未运行").CleanEnterRollerRunning == 1)
  3578. {
  3579. Thread.Sleep(1000);
  3580. if (globalVar.ExitLineThreeTask)
  3581. return;
  3582. }
  3583. MessageNotify.GetInstance.ShowRunLog("清洗台空桶进桶滚筒重新运行!!");
  3584. goto erp;
  3585. }
  3586. ////plc交互
  3587. //WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC
  3588. //if (globalVar.CleadBarrelEnterSingle == 0)
  3589. //{
  3590. // MessageLog.GetInstance.ShowRunLog("警告:清洗台空桶下料就位信号已发送,进桶滚筒未运行!!");
  3591. //}
  3592. }
  3593. }
  3594. /// <summary>
  3595. /// 呼叫Agv从清洗台运洗好的空桶到四号线体
  3596. /// </summary>
  3597. public void CallAgvToLineFour()
  3598. {
  3599. if (RTrig.GetInstance("呼叫AGV").Start(Convert.ToBoolean(globalVar.CleanComplete)))
  3600. {
  3601. globalVar.AllowNextEmptyRollerToClean = true;//AGV到滚筒线搬运空桶的允许标志
  3602. e: string id = Guid.NewGuid().ToString("D");
  3603. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  3604. goto e;
  3605. string info = AGVHelper.GetInstance.AgvFromCleanToLineFourUnLoadRoller(id);
  3606. LTenrobotJobId.Add(id);
  3607. //Thread.Sleep(500);
  3608. MessageNotify.GetInstance.ShowRunLog("清洗台呼叫AGV取桶");
  3609. if (!CleanToLineCarryTaskErrorCodeAnalysis(info, 4))
  3610. {
  3611. LTenrobotJobId.Remove(id);
  3612. MessageNotify.GetInstance.ShowRunLog("清洗台呼叫AGV取桶失败");
  3613. }
  3614. }
  3615. }
  3616. /// <summary>
  3617. /// 3号滚筒线数据下发 2022/7/4 新增
  3618. /// </summary>
  3619. /// <exception cref="NotImplementedException"></exception>
  3620. private void LThreeRecipeDataToPlc()
  3621. {
  3622. if (LThreeOutputMaterialQuene.Count == 0 && LThreeInputMaterialQuene.Count == 0 && !LThreeErrorRecipe)
  3623. {
  3624. globalVar.rollerLineThree.RecipeComMidSingle = 1;
  3625. if (globalVar.LThreeCurrentRecipeName != string.Empty)
  3626. {
  3627. MessageNotify.GetInstance.ShowRunLog($"【3】号滚筒线【{globalVar.LThreeCurrentRecipeName}】 配方所有料桶已送达炒锅");
  3628. // ResetPotData(3);
  3629. WritePlcData("D2103", 0);
  3630. WritePlcData("D1103", 0);//复位开始执行指令
  3631. PlcLineThreeRecipeDataReset();
  3632. if (globalVar.LThreeFryPotSerial == 3)
  3633. {
  3634. FryPotMonitorManage.GetInstance.fryThree.TotalProduct++;
  3635. using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryThree.txt", false, Encoding.UTF8))
  3636. {
  3637. txtWriter.WriteLine(DateTime.Now.ToShortDateString());
  3638. txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryThree.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy);//炒锅1产量以及总油量记录
  3639. }
  3640. //Sqlite<PotThreeStatus>.GetInstance.Base.Add(new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
  3641. //Sqlite<PotThreeStatus>.GetInstance.Save();//保存数据
  3642. }
  3643. globalVar.LThreeCurrentRecipeName = string.Empty;
  3644. // Task.Run(() => { Thread.Sleep(1500); fryThreeRecipe = string.Empty; });
  3645. }
  3646. }
  3647. if (RTrig.GetInstance("炒锅3配方完成").Start(Convert.ToBoolean(globalVar.fryPotThree.RecipeCompleteSingle)))
  3648. {
  3649. ResetPotData(3);
  3650. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.workflows.Add(new WorkflowModel { id = globalVar.LThreeCurrentCookingStep + 1, Name = "配方制作完成!", isBool = IsBool.Yes }); }));
  3651. ActionManage.GetInstance.Send("炒锅工艺流程更新", 3);
  3652. MessageNotify.GetInstance.ShowRunLog("炒锅3配方制作完成");
  3653. AgvViewModel.GetInstance().Set启动或停止炒锅(3, IsRun.Stop);
  3654. Task.Run(() => { Thread.Sleep(1500); fryThreeRecipe = string.Empty; });
  3655. }
  3656. if (LThreeRecipeQuene.Count > 0 && LThreeOutputMaterialQuene.Count == 0 && LThreeInputMaterialQuene.Count == 0 && globalVar.rollerLineThree.RecipeComMidSingle == 1 && globalVar.rollerLineThree.WashEmptyRollerModel == 0)//后续添加其它限制条件
  3657. {
  3658. if (globalVar.fryPotThree.RecipeCompleteSingle == 1 || globalVar.fryPotThree.ProcessStep == 0)
  3659. {
  3660. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.goodsName = string.Empty; }));
  3661. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.workflows = new ObservableCollection<WorkflowModel>(); }));
  3662. AgvViewModel.GetInstance().Set启动或停止炒锅(3, IsRun.Stop);
  3663. ResetPotData(3);
  3664. WritePlcData("D2103", 0);
  3665. WritePlcData("D1103", 0);//复位开始执行指令
  3666. //清空配方数据队列
  3667. PlcLineThreeRecipeDataReset();//PLC复位
  3668. Thread.Sleep(800);
  3669. if (LThreeRecipeQuene.TryDequeue(out NewRecipeModel result))
  3670. {
  3671. potThreeCurrentRecipe = result;
  3672. LThreeErrorRecipe = false;
  3673. int headNum = result.materialCollection[0].MaterialLoc / 100;
  3674. globalVar.LThreeMaterialNum = result.materialCollection.Count;
  3675. globalVar.LThreeFryPotSerial = headNum;
  3676. globalVar.LThreeCurrentRecipeName = result.RecipeName;
  3677. AgvViewModel.GetInstance().Set滚筒线上数量(3, globalVar.LThreeMaterialNum.ToString());
  3678. MessageNotify.GetInstance.ShowUserLog($"【3】号滚筒线开始制作【{result.RecipeName}】 配方");
  3679. fryThreeRecipe = result.RecipeName;//炒锅状态开始记录
  3680. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.goodsName = result.RecipeName; }));
  3681. for (int i = 0; i < result.materialCollection.Count; i++) //遍历单个配方中所有物料
  3682. {
  3683. if (result.materialCollection[i].MaterialLoc % 100 == i + 1 && result.materialCollection[i].MaterialLoc / 100 == headNum && headNum == 3)
  3684. {
  3685. //将配方中原料加入新的队列
  3686. LThreeInputMaterialQuene.Enqueue(new MaterialInfo()
  3687. {
  3688. materialType = result.materialCollection[i],
  3689. materialId = result.RecipeId
  3690. });
  3691. RollerThreeDataWrite(i, result.materialCollection[i].MaterialLoc, (ushort)(result.materialCollection[i].MaterialWeight + RollerNetweight), result.materialCollection[i].MaterialOffset * 10);//3号滚筒线桶号以及重量数据、偏差量下发
  3692. }
  3693. else
  3694. {
  3695. MessageNotify.GetInstance.ShowRunLog($"【3】号滚筒线配方桶号配置错误,取消【{result.RecipeName}】配方制作");
  3696. MessageNotify.GetInstance.ShowUserLog($"【3】号滚筒线配方桶号配置错误,取消【{result.RecipeName}】配方制作");
  3697. LThreeInputMaterialQuene.Clear();
  3698. LThreeRecipeQuene.Clear();
  3699. LThreeErrorRecipe = true;
  3700. return;
  3701. }
  3702. }
  3703. #region 炒股用油量记录
  3704. try
  3705. {
  3706. if (result.FlowProcess.fpModels.Count > 0)
  3707. {
  3708. FryPotMonitorManage.GetInstance.fryThree.OilCapacity = result.FlowProcess.fpModels.FirstOrDefault(p => p.FryMaterialNum == (Json<FlowProcessNames>.Data.NameId.FirstOrDefault(s => s.Value == 1)).Key)?.FryWeight;
  3709. FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy += FryPotMonitorManage.GetInstance.fryThree.OilCapacity;
  3710. FryPotRecipeSetDown(headNum, result);//炒锅工艺数据下发
  3711. }
  3712. else
  3713. {
  3714. MessageNotify.GetInstance.ShowUserLog($"3号滚筒线【{result.RecipeName}】配方未制定炒锅工艺,已取消");
  3715. LThreeRecipeQuene.Clear();
  3716. LThreeInputMaterialQuene.Clear();
  3717. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"当前配方未指定炒锅工艺,配方取消制作"); }));
  3718. return;
  3719. }
  3720. }
  3721. catch (Exception)
  3722. {
  3723. LThreeRecipeQuene.Clear();
  3724. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"炒锅工艺异常,配方下发失败"); }));
  3725. return;
  3726. //throw;
  3727. }
  3728. #endregion
  3729. DeviceOperate.GetInstance.WritePlcData("D1043", (ushort)result.materialCollection.Count);//发送3号滚筒线工序数据
  3730. // globalVar.rollerLineThree.RecipeComMidSingle = 0;
  3731. WritePlcData("D1103", 1);//配方开始执行命令
  3732. globalVar.rollerLineThree.LowSignalJude = true;
  3733. globalVar.LThreeCurrentCookingStep = 0;
  3734. PotThreestep = 0;
  3735. if (LThreeRecipeQuene.Count > 0)
  3736. LThreeRecipeQuene.Clear();
  3737. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); }));
  3738. }
  3739. }
  3740. else
  3741. {
  3742. LThreeRecipeQuene.Clear();
  3743. MessageNotify.GetInstance.ShowUserLog("提示:3号滚筒线配方完成前禁止再次下发订单");
  3744. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"3号滚筒线配方完成前禁止再次下发订单"); }));
  3745. }
  3746. }
  3747. else if (globalVar.rollerLineThree.WashEmptyRollerModel == 1 && LThreeRecipeQuene.Count > 0)
  3748. {
  3749. MessageNotify.GetInstance.ShowUserLog("提示:3号滚筒线处于集中洗桶模式,无法下发配方");
  3750. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"3号滚筒线处于集中洗桶模式,无法下发配方"); }));
  3751. LThreeRecipeQuene.Clear();
  3752. }
  3753. else if(LThreeRecipeQuene.Count > 0)
  3754. {
  3755. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"配方下发失败"); }));
  3756. LThreeRecipeQuene.Clear();
  3757. }
  3758. }
  3759. /// <summary>
  3760. /// 2号滚筒线数据下发 2022/7/4 新增
  3761. /// </summary>
  3762. /// <exception cref="NotImplementedException"></exception>
  3763. private void LTwoRecipeDataToPlc()
  3764. {
  3765. if (LTwoOutputMaterialQuene.Count == 0 && LTwoInputMaterialQuene.Count == 0 && !LTwoErrorRecipe)
  3766. {
  3767. globalVar.rollerLineTwo.RecipeComMidSingle = 1;
  3768. if (globalVar.LTwoCurrentRecipeName != string.Empty)
  3769. {
  3770. MessageNotify.GetInstance.ShowRunLog($"【2】号滚筒线【{globalVar.LTwoCurrentRecipeName}】 配方所有料桶已送达炒锅");
  3771. // ResetPotData(globalVar.LTwoFryPotSerial);
  3772. WritePlcData("D2102", 0);
  3773. WritePlcData("D1102", 0);//复位开始执行指令
  3774. PlcLineTwoRecipeDataReset();
  3775. if (globalVar.LTwoFryPotSerial == 2)
  3776. {
  3777. FryPotMonitorManage.GetInstance.fryTwo.TotalProduct++;
  3778. using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryTwo.txt", false, Encoding.UTF8))
  3779. {
  3780. txtWriter.WriteLine(DateTime.Now.ToShortDateString());
  3781. txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryTwo.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy);//炒锅1产量以及总油量记录
  3782. }
  3783. //Sqlite<PotTwoStatus>.GetInstance.Base.Add(new PotTwoStatus { Temperature = FryPotMonitorManage.GetInstance.fryTwo.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryTwo.HotPower, Speed = FryPotMonitorManage.GetInstance.fryTwo.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
  3784. //Sqlite<PotTwoStatus>.GetInstance.Save();//保存数据
  3785. }
  3786. if (globalVar.LTwoFryPotSerial == 5)
  3787. {
  3788. FryPotMonitorManage.GetInstance.fryFive.TotalProduct++;
  3789. using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryFive.txt", false, Encoding.UTF8))
  3790. {
  3791. txtWriter.WriteLine(DateTime.Now.ToShortDateString());
  3792. txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryFive.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy);//炒锅1产量以及总油量记录
  3793. }
  3794. //Sqlite<PotFiveStatus>.GetInstance.Base.Add(new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFive.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
  3795. //Sqlite<PotFiveStatus>.GetInstance.Save();//保存数据
  3796. }
  3797. globalVar.LTwoCurrentRecipeName = string.Empty;
  3798. // Task.Run(() => { Thread.Sleep(1500); fryTwoRecipe = string.Empty; fryFiveRecipe = string.Empty; });
  3799. }
  3800. }
  3801. if (RTrig.GetInstance("炒锅2配方完成").Start(Convert.ToBoolean(globalVar.fryPotTwo.RecipeCompleteSingle)))
  3802. {
  3803. ResetPotData(2);
  3804. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_2.workflows.Add(new WorkflowModel { id = globalVar.LTwoCurrentCookingStep + 1, Name = "配方制作完成!", isBool = IsBool.Yes }); }));
  3805. ActionManage.GetInstance.Send("炒锅工艺流程更新", 2);
  3806. MessageNotify.GetInstance.ShowRunLog("炒锅2配方制作完成");
  3807. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LTwoFryPotSerial, IsRun.Stop);
  3808. Task.Run(() => { Thread.Sleep(1500); fryTwoRecipe = string.Empty; });
  3809. }
  3810. if (RTrig.GetInstance("炒锅5配方完成").Start(Convert.ToBoolean(globalVar.fryPotFive.RecipeCompleteSingle)))
  3811. {
  3812. ResetPotData(5);
  3813. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_5.workflows.Add(new WorkflowModel { id = globalVar.LFiveCurrentCookingStep + 1, Name = "配方制作完成!", isBool = IsBool.Yes }); }));
  3814. ActionManage.GetInstance.Send("炒锅工艺流程更新", 5);
  3815. MessageNotify.GetInstance.ShowRunLog("炒锅5配方制作完成");
  3816. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LTwoFryPotSerial, IsRun.Stop);
  3817. Task.Run(() => { Thread.Sleep(1500); fryFiveRecipe = string.Empty; });
  3818. }
  3819. if (LTwoRecipeQuene.Count > 0 && LTwoOutputMaterialQuene.Count == 0 && LTwoInputMaterialQuene.Count == 0 && globalVar.rollerLineTwo.RecipeComMidSingle == 1 && globalVar.rollerLineTwo.WashEmptyRollerModel == 0)//后续添加其它限制条件
  3820. {
  3821. if ((LTwoRecipeQuene.ElementAt(0).materialCollection[0].MaterialLoc / 100 == 2 && globalVar.fryPotTwo.RecipeCompleteSingle == 1) || (LTwoRecipeQuene.ElementAt(0).materialCollection[0].MaterialLoc / 100 == 5 && globalVar.fryPotFive.RecipeCompleteSingle == 1) || (LTwoRecipeQuene.ElementAt(0).materialCollection[0].MaterialLoc / 100 != globalVar.LTwoFryPotSerial && globalVar.LTwoFryPotSerial == 2 && globalVar.fryPotFive.ProcessStep == 0) || (LTwoRecipeQuene.ElementAt(0).materialCollection[0].MaterialLoc / 100 != globalVar.LTwoFryPotSerial && globalVar.LTwoFryPotSerial == 5 && globalVar.fryPotTwo.ProcessStep == 0) || (globalVar.LTwoFryPotSerial == 0 && globalVar.fryPotTwo.ProcessStep == 0 && globalVar.fryPotFive.ProcessStep == 0) || (LTwoRecipeQuene.ElementAt(0).materialCollection[0].MaterialLoc / 100 == globalVar.LTwoFryPotSerial && globalVar.LTwoFryPotSerial == 5 && globalVar.fryPotFive.ProcessStep == 0) || (LTwoRecipeQuene.ElementAt(0).materialCollection[0].MaterialLoc / 100 == globalVar.LTwoFryPotSerial && globalVar.LTwoFryPotSerial == 2 && globalVar.fryPotTwo.ProcessStep == 0))
  3822. {
  3823. if (globalVar.LTwoFryPotSerial == 2)
  3824. {
  3825. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_2.goodsName = string.Empty; }));
  3826. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_2.workflows = new ObservableCollection<WorkflowModel>(); }));
  3827. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LTwoFryPotSerial, IsRun.Stop);
  3828. Task.Run(() => { Thread.Sleep(1500); fryTwoRecipe = string.Empty; });
  3829. }
  3830. if (globalVar.LTwoFryPotSerial == 5)
  3831. {
  3832. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_5.goodsName = string.Empty; }));
  3833. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_5.workflows = new ObservableCollection<WorkflowModel>(); }));
  3834. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LTwoFryPotSerial, IsRun.Stop);
  3835. Task.Run(() => { Thread.Sleep(1500); fryFiveRecipe = string.Empty; });
  3836. }
  3837. //if (globalVar.LTwoCurrentRecipeName != string.Empty)
  3838. // MessageLog.GetInstance.ShowUserLog($"【2】号滚筒线【{globalVar.LTwoCurrentRecipeName}】 配方制作完成");
  3839. WritePlcData("D2102", 0);
  3840. WritePlcData("D1102", 0);//复位开始执行指令
  3841. //清空配方数据队列
  3842. PlcLineTwoRecipeDataReset();//PLC复位
  3843. if (LTwoRecipeQuene.TryDequeue(out NewRecipeModel result))
  3844. {
  3845. LTwoErrorRecipe = false;
  3846. int headNum = result.materialCollection[0].MaterialLoc / 100;
  3847. globalVar.LTwoMaterialNum = result.materialCollection.Count;
  3848. globalVar.LTwoFryPotSerial = headNum;
  3849. globalVar.LTwoCurrentRecipeName = result.RecipeName;
  3850. AgvViewModel.GetInstance().Set滚筒线上数量(2, globalVar.LTwoMaterialNum.ToString());
  3851. MessageNotify.GetInstance.ShowUserLog($"【2】号滚筒线开始制作【{result.RecipeName}】 配方");
  3852. if (headNum == 2)//炒锅2
  3853. {
  3854. potTwoCurrentRecipe = result;
  3855. globalVar.LTwoCurrentCookingStep = 0;
  3856. PotTwostep = 0;
  3857. fryTwoRecipe = result.RecipeName;//炒锅状态开始记录
  3858. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_2.goodsName = result.RecipeName; }));
  3859. }
  3860. else//炒锅5
  3861. {
  3862. potFiveCurrentRecipe = result;
  3863. PotFivestep = 0;
  3864. globalVar.LFiveCurrentCookingStep = 0;
  3865. fryFiveRecipe = result.RecipeName;//炒锅状态开始记录
  3866. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_5.goodsName = result.RecipeName; }));
  3867. }
  3868. ResetPotData(globalVar.LTwoFryPotSerial);
  3869. Thread.Sleep(800);
  3870. for (int i = 0; i < result.materialCollection.Count; i++) //遍历单个配方中所有物料
  3871. {
  3872. if (result.materialCollection[i].MaterialLoc % 100 == i + 1 && result.materialCollection[i].MaterialLoc / 100 == headNum && (headNum == 2 || headNum == 5))
  3873. {
  3874. //将配方中原料加入新的队列
  3875. LTwoInputMaterialQuene.Enqueue(new MaterialInfo()
  3876. {
  3877. materialType = result.materialCollection[i],
  3878. materialId = result.RecipeId
  3879. });
  3880. RollerTwoDataWrite(i, result.materialCollection[i].MaterialLoc, (ushort)(result.materialCollection[i].MaterialWeight + RollerNetweight), result.materialCollection[i].MaterialOffset*10);//2号滚筒线桶号以及重量、偏差量数据下发
  3881. }
  3882. else
  3883. {
  3884. MessageNotify.GetInstance.ShowRunLog($"【2】号滚筒线配方桶号配置错误,取消【{result.RecipeName}】配方制作");
  3885. MessageNotify.GetInstance.ShowUserLog($"【2】号滚筒线配方桶号配置错误,取消【{result.RecipeName}】配方制作");
  3886. LTwoInputMaterialQuene.Clear();
  3887. LTwoRecipeQuene.Clear();
  3888. LTwoErrorRecipe = true;
  3889. return;
  3890. }
  3891. }
  3892. #region 炒股用油量记录
  3893. if (headNum == 2)
  3894. {
  3895. try
  3896. {
  3897. if (result.FlowProcess.fpModels.Count > 0)
  3898. {
  3899. FryPotMonitorManage.GetInstance.fryTwo.OilCapacity = result.FlowProcess.fpModels.FirstOrDefault(p => p.FryMaterialNum == (Json<FlowProcessNames>.Data.NameId.FirstOrDefault(s => s.Value == 1)).Key)?.FryWeight;
  3900. FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy += FryPotMonitorManage.GetInstance.fryTwo.OilCapacity;
  3901. FryPotRecipeSetDown(headNum, result);//炒锅工艺下发
  3902. }
  3903. else
  3904. {
  3905. MessageNotify.GetInstance.ShowUserLog($"2号滚筒线【{result.RecipeName}】配方未制定炒锅工艺,已取消");
  3906. LTwoRecipeQuene.Clear();
  3907. LTwoInputMaterialQuene.Clear();
  3908. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"当前配方未指定炒锅工艺,配方取消制作"); }));
  3909. return;
  3910. }
  3911. }
  3912. catch (Exception)
  3913. {
  3914. LTwoRecipeQuene.Clear();
  3915. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"炒锅工艺异常,配方下发失败"); }));
  3916. return;
  3917. // throw;
  3918. }
  3919. }
  3920. else
  3921. {
  3922. try
  3923. {
  3924. if (result.FlowProcess.fpModels.Count > 0)
  3925. {
  3926. FryPotMonitorManage.GetInstance.fryFive.OilCapacity = result.FlowProcess.fpModels.FirstOrDefault(p => p.FryMaterialNum == (Json<FlowProcessNames>.Data.NameId.FirstOrDefault(s => s.Value == 1)).Key)?.FryWeight;
  3927. FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy += FryPotMonitorManage.GetInstance.fryFive.OilCapacity;
  3928. FryPotRecipeSetDown(headNum, result);//炒锅工艺下发
  3929. }
  3930. else
  3931. {
  3932. MessageNotify.GetInstance.ShowUserLog($"2号滚筒线【{result.RecipeName}】配方未制定炒锅工艺,已取消");
  3933. LTwoRecipeQuene.Clear();
  3934. LTwoInputMaterialQuene.Clear();
  3935. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"当前配方未指定炒锅工艺,配方取消制作"); }));
  3936. return;
  3937. }
  3938. }
  3939. catch (Exception)
  3940. {
  3941. LTwoRecipeQuene.Clear();
  3942. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"炒锅工艺异常,配方下发失败"); }));
  3943. return;
  3944. // throw;
  3945. }
  3946. }
  3947. #endregion
  3948. DeviceOperate.GetInstance.WritePlcData("D1026", (ushort)result.materialCollection.Count);//发送2号滚筒线工序数据
  3949. //globalVar.rollerLineTwo.RecipeComMidSingle = 0;
  3950. WritePlcData("D1102", 1);//配方开始执行命令
  3951. globalVar.rollerLineTwo.LowSignalJude = true;
  3952. if (LTwoRecipeQuene.Count > 0)
  3953. LTwoRecipeQuene.Clear();
  3954. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); }));
  3955. }
  3956. }
  3957. else
  3958. {
  3959. LTwoRecipeQuene.Clear();
  3960. MessageNotify.GetInstance.ShowUserLog("提示:2号滚筒线配方完成前禁止再次下发订单");
  3961. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"2号滚筒线配方完成前禁止再次下发订单"); }));
  3962. }
  3963. }
  3964. else if (globalVar.rollerLineTwo.WashEmptyRollerModel == 1 && LTwoRecipeQuene.Count > 0)
  3965. {
  3966. MessageNotify.GetInstance.ShowUserLog("提示:2号滚筒线处于集中洗桶模式,无法下发配方");
  3967. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"2号滚筒线处于集中洗桶模式,无法下发配方"); }));
  3968. LTwoRecipeQuene.Clear();
  3969. }
  3970. else if(LTwoRecipeQuene.Count > 0)
  3971. {
  3972. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"配方下发失败"); }));
  3973. LTwoRecipeQuene.Clear();
  3974. }
  3975. }
  3976. /// <summary>
  3977. /// 1号滚筒线数据下发 2022/7/4 新增
  3978. /// </summary>
  3979. private void LOneRecipeDataToPlc()
  3980. {
  3981. if (OutputMaterialQuene.Count == 0 && InputMaterialQuene.Count == 0 && !ErrorRecipe)
  3982. {
  3983. globalVar.rollerLineOne.RecipeComMidSingle = 1;
  3984. if (globalVar.LOneCurrentRecipeName != string.Empty)
  3985. {
  3986. MessageNotify.GetInstance.ShowRunLog($"【1】号滚筒线【{globalVar.LOneCurrentRecipeName}】 配方所有料桶已送达炒锅");
  3987. // ResetPotData(globalVar.LOneFryPotSerial);
  3988. WritePlcData("D2101", 0);
  3989. WritePlcData("D1101", 0);//复位开始执行指令
  3990. PlcLineOneRecipeDataReset();
  3991. if (globalVar.LOneFryPotSerial == 1)
  3992. {
  3993. FryPotMonitorManage.GetInstance.fryOne.TotalProduct++;
  3994. using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryOne.txt", false, Encoding.UTF8))
  3995. {
  3996. txtWriter.WriteLine(DateTime.Now.ToShortDateString());
  3997. txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryOne.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy);//炒锅1产量以及总油量记录
  3998. }
  3999. //Sqlite<PotOneStatus>.GetInstance.Base.Add(new PotOneStatus { Temperature = FryPotMonitorManage.GetInstance.fryOne.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryOne.HotPower, Speed = FryPotMonitorManage.GetInstance.fryOne.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryOne.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryOne.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
  4000. //Sqlite<PotOneStatus>.GetInstance.Save();//保存数据
  4001. }
  4002. if (globalVar.LOneFryPotSerial == 4)
  4003. {
  4004. FryPotMonitorManage.GetInstance.fryFour.TotalProduct++;
  4005. using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryFour.txt", false, Encoding.UTF8))
  4006. {
  4007. txtWriter.WriteLine(DateTime.Now.ToShortDateString());
  4008. txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryFour.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy);//炒锅1产量以及总油量记录
  4009. }
  4010. //Sqlite<PotFourStatus>.GetInstance.Base.Add(new PotFourStatus { Temperature = FryPotMonitorManage.GetInstance.fryFour.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFour.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFour.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFour.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFour.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
  4011. //Sqlite<PotFourStatus>.GetInstance.Save();//保存数据
  4012. }
  4013. globalVar.LOneCurrentRecipeName = string.Empty;
  4014. // Task.Run(() => { Thread.Sleep(1500); fryOneRecipe = string.Empty; fryFourRecipe = string.Empty; });
  4015. }
  4016. }
  4017. if (RTrig.GetInstance("炒锅1配方完成").Start(Convert.ToBoolean(globalVar.fryPotOne.RecipeCompleteSingle)))
  4018. {
  4019. ResetPotData(1);
  4020. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_1.workflows.Add(new WorkflowModel { id = globalVar.LOneCurrentCookingStep + 1, Name = "配方制作完成!", isBool = IsBool.Yes }); }));
  4021. ActionManage.GetInstance.Send("炒锅工艺流程更新", 1);
  4022. MessageNotify.GetInstance.ShowRunLog("炒锅1配方制作完成");
  4023. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LOneFryPotSerial, IsRun.Stop);
  4024. Task.Run(() => { Thread.Sleep(1500); fryOneRecipe = string.Empty; });
  4025. }
  4026. if (RTrig.GetInstance("炒锅4配方完成").Start(Convert.ToBoolean(globalVar.fryPotFour.RecipeCompleteSingle)))
  4027. {
  4028. ResetPotData(4);
  4029. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.workflows.Add(new WorkflowModel { id = globalVar.LFourCurrentCookingStep + 1, Name = "配方制作完成!", isBool = IsBool.Yes }); }));
  4030. ActionManage.GetInstance.Send("炒锅工艺流程更新", 4);
  4031. MessageNotify.GetInstance.ShowRunLog("炒锅4配方制作完成");
  4032. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LOneFryPotSerial, IsRun.Stop);
  4033. Task.Run(() => { Thread.Sleep(1500); fryFourRecipe = string.Empty; });
  4034. }
  4035. if (RecipeQuene.Count > 0 && OutputMaterialQuene.Count == 0 && InputMaterialQuene.Count == 0 && globalVar.rollerLineOne.RecipeComMidSingle == 1 && globalVar.rollerLineOne.WashEmptyRollerModel == 0)//后续添加其它限制条件
  4036. {
  4037. if ((RecipeQuene.ElementAt(0).materialCollection[0].MaterialLoc / 100 == 1 && globalVar.fryPotOne.RecipeCompleteSingle == 1) || (RecipeQuene.ElementAt(0).materialCollection[0].MaterialLoc / 100 == 4 && globalVar.fryPotFour.RecipeCompleteSingle == 1) || (RecipeQuene.ElementAt(0).materialCollection[0].MaterialLoc / 100 != globalVar.LOneFryPotSerial && globalVar.LOneFryPotSerial == 1 && globalVar.fryPotFour.ProcessStep == 0) || (RecipeQuene.ElementAt(0).materialCollection[0].MaterialLoc / 100 != globalVar.LOneFryPotSerial && globalVar.LOneFryPotSerial == 4 && globalVar.fryPotOne.ProcessStep == 0) || (globalVar.LOneFryPotSerial == 0 && globalVar.fryPotOne.ProcessStep == 0 && globalVar.fryPotFour.ProcessStep == 0) || (RecipeQuene.ElementAt(0).materialCollection[0].MaterialLoc / 100 == globalVar.LOneFryPotSerial && globalVar.LOneFryPotSerial == 4 && globalVar.fryPotFour.ProcessStep == 0) || (RecipeQuene.ElementAt(0).materialCollection[0].MaterialLoc / 100 == globalVar.LOneFryPotSerial && globalVar.LOneFryPotSerial == 1 && globalVar.fryPotOne.ProcessStep == 0)) //炒锅空闲才能下配方
  4038. {
  4039. if (globalVar.LOneFryPotSerial == 1)
  4040. {
  4041. globalVar.LOneCurrentCookingStep = 0;
  4042. PotOnestep = 0;
  4043. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_1.goodsName = string.Empty; }));
  4044. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_1.workflows = new ObservableCollection<WorkflowModel>(); }));
  4045. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LOneFryPotSerial, IsRun.Stop);
  4046. Task.Run(() => { Thread.Sleep(1500); fryOneRecipe = string.Empty; });
  4047. }
  4048. if (globalVar.LOneFryPotSerial == 4)
  4049. {
  4050. globalVar.LFourCurrentCookingStep = 0;
  4051. PotFourstep = 0;
  4052. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.goodsName = string.Empty; }));
  4053. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.workflows = new ObservableCollection<WorkflowModel>(); }));
  4054. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LOneFryPotSerial, IsRun.Stop);
  4055. Task.Run(() => { Thread.Sleep(1500); fryFourRecipe = string.Empty; });
  4056. }
  4057. WritePlcData("D2101", 0);
  4058. WritePlcData("D1101", 0);//复位开始执行指令
  4059. //清空配方数据队列
  4060. PlcLineOneRecipeDataReset();//PLC复位
  4061. if (RecipeQuene.TryDequeue(out NewRecipeModel result))
  4062. {
  4063. ErrorRecipe = false;
  4064. int headNum = result.materialCollection[0].MaterialLoc / 100;
  4065. globalVar.LOneMaterialNum = result.materialCollection.Count;
  4066. globalVar.LOneFryPotSerial = headNum;
  4067. globalVar.LOneCurrentRecipeName = result.RecipeName;
  4068. AgvViewModel.GetInstance().Set滚筒线上数量(1, globalVar.LOneMaterialNum.ToString());
  4069. MessageNotify.GetInstance.ShowUserLog($"【1】号滚筒线开始制作【{result.RecipeName}】 配方");
  4070. if (headNum == 1)//炒锅1
  4071. {
  4072. potOneCurrentRecipe = result;
  4073. fryOneRecipe = result.RecipeName;//炒锅状态开始记录
  4074. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_1.goodsName = result.RecipeName; }));
  4075. }
  4076. else//炒锅4
  4077. {
  4078. potFourCurrentRecipe = result;
  4079. fryFourRecipe = result.RecipeName;//炒锅状态开始记录
  4080. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.goodsName = result.RecipeName; }));
  4081. }
  4082. ResetPotData(globalVar.LOneFryPotSerial);
  4083. Thread.Sleep(800);
  4084. for (int i = 0; i < result.materialCollection.Count; i++) //遍历单个配方中所有物料
  4085. {
  4086. if (result.materialCollection.Count <= 8 && result.materialCollection[i].MaterialLoc % 100 == i + 1 && result.materialCollection[i].MaterialLoc / 100 == headNum && (headNum == 1 || headNum == 4))
  4087. {
  4088. //将配方中原料加入新的队列
  4089. InputMaterialQuene.Enqueue(new MaterialInfo()
  4090. {
  4091. materialType = result.materialCollection[i],
  4092. materialId = result.RecipeId
  4093. });
  4094. RollerOneDataWrite(i, result.materialCollection[i].MaterialLoc, (ushort)(result.materialCollection[i].MaterialWeight + RollerNetweight), result.materialCollection[i].MaterialOffset*10);//1号滚筒线桶号以及重量、偏差量数据下发
  4095. }
  4096. else
  4097. {
  4098. MessageNotify.GetInstance.ShowRunLog($"【1】号滚筒线配方桶号配置错误,取消【{result.RecipeName}】配方制作");
  4099. MessageNotify.GetInstance.ShowUserLog($"【1】号滚筒线配方桶号配置错误,取消【{result.RecipeName}】配方制作");
  4100. InputMaterialQuene.Clear();
  4101. RecipeQuene.Clear();
  4102. ErrorRecipe = true;
  4103. return;
  4104. }
  4105. }
  4106. #region 炒股用油量记录及工艺下发
  4107. if (headNum == 1)
  4108. {
  4109. try
  4110. {
  4111. if (result.FlowProcess.fpModels.Count > 0)
  4112. {
  4113. FryPotMonitorManage.GetInstance.fryOne.OilCapacity = result.FlowProcess.fpModels.FirstOrDefault(p => p.FryMaterialNum == (Json<FlowProcessNames>.Data.NameId.FirstOrDefault(s => s.Value == 1)).Key)?.FryWeight;
  4114. FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy += FryPotMonitorManage.GetInstance.fryOne.OilCapacity;
  4115. FryPotRecipeSetDown(headNum, result);//炒锅工艺下发
  4116. }
  4117. else
  4118. {
  4119. MessageNotify.GetInstance.ShowUserLog($"1号滚筒线【{result.RecipeName}】配方未制定炒锅工艺,已取消");
  4120. RecipeQuene.Clear();
  4121. InputMaterialQuene.Clear();
  4122. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"当前配方未指定炒锅工艺,配方取消制作"); }));
  4123. return;
  4124. }
  4125. }
  4126. catch (Exception)
  4127. {
  4128. RecipeQuene.Clear();
  4129. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"炒股工艺异常,配方下发失败"); }));
  4130. return;
  4131. // throw;
  4132. }
  4133. }
  4134. else
  4135. {
  4136. try
  4137. {
  4138. if (result.FlowProcess.fpModels.Count > 0)
  4139. {
  4140. FryPotMonitorManage.GetInstance.fryFour.OilCapacity = result.FlowProcess.fpModels.FirstOrDefault(p => p.FryMaterialNum == (Json<FlowProcessNames>.Data.NameId.FirstOrDefault(s => s.Value == 1)).Key)?.FryWeight;
  4141. FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy += FryPotMonitorManage.GetInstance.fryFour.OilCapacity;
  4142. FryPotRecipeSetDown(headNum, result);//炒锅工艺下发
  4143. }
  4144. else
  4145. {
  4146. MessageNotify.GetInstance.ShowUserLog($"1号滚筒线【{result.RecipeName}】配方未制定炒锅工艺,已取消");
  4147. RecipeQuene.Clear();
  4148. InputMaterialQuene.Clear();
  4149. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"当前配方未指定炒锅工艺,配方取消制作"); }));
  4150. return;
  4151. }
  4152. }
  4153. catch (Exception)
  4154. {
  4155. RecipeQuene.Clear();
  4156. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"炒锅工艺异常,配方下发失败"); }));
  4157. return;
  4158. //throw;
  4159. }
  4160. }
  4161. #endregion
  4162. DeviceOperate.GetInstance.WritePlcData("D1009", (ushort)result.materialCollection.Count);//发送1号滚筒线工序数据
  4163. WritePlcData("D1101", 1);//线体1配方开始执行命令
  4164. globalVar.rollerLineOne.LowSignalJude = true;
  4165. if (RecipeQuene.Count > 0)
  4166. RecipeQuene.Clear();
  4167. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); }));
  4168. }
  4169. }
  4170. else
  4171. {
  4172. RecipeQuene.Clear();
  4173. MessageNotify.GetInstance.ShowUserLog("提示:1号滚筒线配方完成前禁止再次下发订单");
  4174. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"1号滚筒线配方完成前禁止再次下发订单"); }));
  4175. }
  4176. }
  4177. else if (globalVar.rollerLineOne.WashEmptyRollerModel == 1 && RecipeQuene.Count > 0)
  4178. {
  4179. MessageNotify.GetInstance.ShowUserLog("提示:1号滚筒线处于集中洗桶模式,无法下发配方");
  4180. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"1号滚筒线处于集中洗桶模式,无法下发配方"); }));
  4181. RecipeQuene.Clear();
  4182. }
  4183. else if (RecipeQuene.Count>0)
  4184. {
  4185. Application.Current.Dispatcher.Invoke(new Action(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "提示", $"配方下发失败"); }));
  4186. RecipeQuene.Clear();
  4187. }
  4188. }
  4189. /// <summary>
  4190. /// 线体1配方执行等待下位确认
  4191. /// </summary>
  4192. public void LineOneRecipeExecuteConfirm()
  4193. {
  4194. if (globalVar.rollerLineOne.RecipeComMidSingle == 1 && globalVar.rollerLineOne.LowSignalJude)
  4195. {
  4196. if (globalVar.rollerLineOne.ExcuteIsConfirm == 1) //收到下位执行信号
  4197. {
  4198. WritePlcData("D2101", 0);
  4199. globalVar.rollerLineOne.NextStart = true;
  4200. globalVar.rollerLineOne.RecipeComMidSingle = 0;//配方完成的中转信号置0
  4201. globalVar.rollerLineOne.LowSignalJude = false;
  4202. }
  4203. else if (globalVar.rollerLineOne.ExcuteIsConfirm == 2) //收到下位取消执行命令
  4204. {
  4205. RecipeQuene.Clear();
  4206. OutputMaterialQuene.Clear();
  4207. globalVar.rollerLineOne.NextStart = false;
  4208. ResetPotData(globalVar.LOneFryPotSerial);
  4209. WritePlcData("D2101", 0);
  4210. WritePlcData("D1101", 0);//复位开始执行指令
  4211. //清空配方数据队列
  4212. PlcLineOneRecipeDataReset();//PLC复位
  4213. InputMaterialQuene.Clear();
  4214. MessageNotify.GetInstance.ShowRunLog($"下位机操作员取消【1】号线体【{globalVar.LOneCurrentRecipeName}】配方的制作");
  4215. MessageNotify.GetInstance.ShowRunLog($"1号滚筒线所有配方已清除");
  4216. MessageNotify.GetInstance.ShowUserLog($"下位机操作员取消【1】号线体【{globalVar.LOneCurrentRecipeName}】配方的制作");
  4217. MessageNotify.GetInstance.ShowUserLog($"1号滚筒线所有配方已清除");
  4218. globalVar.LOneCurrentRecipeName = string.Empty;
  4219. globalVar.rollerLineOne.LowSignalJude = false;
  4220. }
  4221. else //未收到下位执行信号
  4222. {
  4223. globalVar.rollerLineOne.NextStart = false;
  4224. }
  4225. }
  4226. }
  4227. /// <summary>
  4228. /// 线体2配方执行等待下位确认
  4229. /// </summary>
  4230. public void LineTwoRecipeExecuteConfirm()
  4231. {
  4232. if (globalVar.rollerLineTwo.RecipeComMidSingle == 1 && globalVar.rollerLineTwo.LowSignalJude)
  4233. {
  4234. if (globalVar.rollerLineTwo.ExcuteIsConfirm == 1) //收到下位执行信号
  4235. {
  4236. WritePlcData("D2102", 0);
  4237. globalVar.rollerLineTwo.NextStart = true;
  4238. globalVar.rollerLineTwo.RecipeComMidSingle = 0;//配方完成的中转信号置0
  4239. globalVar.rollerLineTwo.LowSignalJude = false;
  4240. }
  4241. else if (globalVar.rollerLineTwo.ExcuteIsConfirm == 2) //收到下位取消执行命令
  4242. {
  4243. LTwoRecipeQuene.Clear();
  4244. LTwoOutputMaterialQuene.Clear();
  4245. globalVar.rollerLineTwo.NextStart = false;
  4246. ResetPotData(globalVar.LTwoFryPotSerial);
  4247. WritePlcData("D2102", 0);
  4248. WritePlcData("D1102", 0);//复位开始执行指令
  4249. //清空配方数据队列
  4250. PlcLineTwoRecipeDataReset();//PLC复位
  4251. LTwoInputMaterialQuene.Clear();
  4252. MessageNotify.GetInstance.ShowRunLog($"下位机操作员取消【2】号线体【{globalVar.LTwoCurrentRecipeName}】配方的制作");
  4253. MessageNotify.GetInstance.ShowRunLog($"2号滚筒线所有配方已清除");
  4254. MessageNotify.GetInstance.ShowUserLog($"下位机操作员取消【2】号线体【{globalVar.LTwoCurrentRecipeName}】配方的制作");
  4255. MessageNotify.GetInstance.ShowUserLog($"2号滚筒线所有配方已清除");
  4256. globalVar.LTwoCurrentRecipeName = string.Empty;
  4257. globalVar.rollerLineTwo.LowSignalJude = false;
  4258. }
  4259. else //未收到下位执行信号
  4260. {
  4261. globalVar.rollerLineTwo.NextStart = false;
  4262. }
  4263. }
  4264. }
  4265. /// <summary>
  4266. /// 线体3配方执行等待下位确认
  4267. /// </summary>
  4268. public void LineThreeRecipeExecuteConfirm()
  4269. {
  4270. if (globalVar.rollerLineThree.RecipeComMidSingle == 1 && globalVar.rollerLineThree.LowSignalJude)
  4271. {
  4272. if (globalVar.rollerLineThree.ExcuteIsConfirm == 1) //收到下位执行信号
  4273. {
  4274. WritePlcData("D2103", 0);
  4275. globalVar.rollerLineThree.NextStart = true;
  4276. globalVar.rollerLineThree.RecipeComMidSingle = 0;//配方完成的中转信号置0
  4277. globalVar.rollerLineThree.LowSignalJude = false;
  4278. }
  4279. else if (globalVar.rollerLineThree.ExcuteIsConfirm == 2) //收到下位取消执行命令
  4280. {
  4281. LThreeRecipeQuene.Clear();
  4282. LThreeOutputMaterialQuene.Clear();
  4283. globalVar.rollerLineThree.NextStart = false;
  4284. ResetPotData(globalVar.LThreeFryPotSerial);
  4285. WritePlcData("D2103", 0);
  4286. WritePlcData("D1103", 0);//复位开始执行指令
  4287. //清空配方数据队列
  4288. PlcLineThreeRecipeDataReset();//PLC复位
  4289. LThreeInputMaterialQuene.Clear();
  4290. MessageNotify.GetInstance.ShowRunLog($"下位机操作员取消【3】号线体【{globalVar.LThreeCurrentRecipeName}】配方的制作");
  4291. MessageNotify.GetInstance.ShowRunLog($"3号滚筒线所有配方已清除");
  4292. MessageNotify.GetInstance.ShowUserLog($"下位机操作员取消【3】号线体【{globalVar.LThreeCurrentRecipeName}】配方的制作");
  4293. MessageNotify.GetInstance.ShowUserLog($"3号滚筒线所有配方已清除");
  4294. globalVar.LThreeCurrentRecipeName = string.Empty;
  4295. globalVar.rollerLineThree.LowSignalJude = false;
  4296. }
  4297. else //未收到下位执行信号
  4298. {
  4299. globalVar.rollerLineThree.NextStart = false;
  4300. }
  4301. }
  4302. }
  4303. /// <summary>
  4304. /// AGV到配方线体1装桶以及出料到炒锅
  4305. /// </summary>
  4306. public void LOneLoadRoller()
  4307. {
  4308. if (InputMaterialQuene.Count > 0 && globalVar.rollerLineOne.NextStart)
  4309. {
  4310. AgvToLineOneLoadRoller();
  4311. AgvFromLineOneToFryPot();//AGV到1号线体装桶
  4312. }
  4313. AgvLineOneLoadRollerCom();
  4314. }
  4315. /// <summary>
  4316. /// 判断agv在1号线体是否上料完成,作为线体空桶能否开始运输的条件
  4317. /// </summary>
  4318. /// <exception cref="NotImplementedException"></exception>
  4319. private void AgvLineOneLoadRollerCom()
  4320. {
  4321. if ((globalVar.agvLineOneLoadCom || globalVar.LineOneRobotTaskError)&& globalVar.AgvToFryPot)
  4322. {
  4323. if (globalVar.LineOneRobotTaskError)
  4324. DeviceOperate.GetInstance.WritePlcData("D1052", 0);//就位信号复位
  4325. globalVar.rollerLineOne.CanRun = true;
  4326. globalVar.agvLineOneLoadCom = false;
  4327. MessageNotify.GetInstance.ShowRunLog("AGV在【1】号滚筒线装桶完成");
  4328. }
  4329. }
  4330. /// <summary>
  4331. /// AGV到配方线体2装桶以及出料到炒锅
  4332. /// </summary>
  4333. public void LTwoAgvLoadRoller()
  4334. {
  4335. if (LTwoInputMaterialQuene.Count > 0 && globalVar.rollerLineTwo.NextStart)
  4336. {
  4337. AgvToLineTwoLoadRoller();
  4338. AgvFromLineTwoToFryPot();//AGV到2号线体装桶
  4339. }
  4340. AgvLineTwoLoadRollerCom();
  4341. }
  4342. /// <summary>
  4343. /// 判断agv在2号线体是否上料完成,作为线体空桶能否开始运输的条件
  4344. /// </summary>
  4345. private void AgvLineTwoLoadRollerCom()
  4346. {
  4347. if ((globalVar.agvLineTwoLoadCom || globalVar.LineTwoRobotTaskError)&&globalVar.LTwoAgvToFryPot)
  4348. {
  4349. if (globalVar.LineTwoRobotTaskError)
  4350. DeviceOperate.GetInstance.WritePlcData("D1053", 0);
  4351. globalVar.rollerLineTwo.CanRun = true;
  4352. globalVar.agvLineTwoLoadCom = false;
  4353. MessageNotify.GetInstance.ShowRunLog("AGV在【2】号滚筒线装桶完成");
  4354. }
  4355. }
  4356. /// <summary>
  4357. /// AGV到配方线体3装桶以及出料到炒锅
  4358. /// </summary>
  4359. public void LThreeAgvLoadRoller()
  4360. {
  4361. if (LThreeInputMaterialQuene.Count > 0 && globalVar.rollerLineThree.NextStart)
  4362. {
  4363. AgvToLineThreeLoadRoller();
  4364. AgvFromLineThreeToFryPot();//AGV到2号线体装桶
  4365. }
  4366. AgvLineThreeLoadRollerCom();
  4367. }
  4368. /// <summary>
  4369. /// 判断agv在1号线体是否上料完成,作为线体空桶能否开始运输的条件
  4370. /// </summary>
  4371. private void AgvLineThreeLoadRollerCom()
  4372. {
  4373. if ((globalVar.agvLineThreeLoadCom || globalVar.LineThreeRobotTaskError)&&globalVar.LThreeAgvToFryPot)
  4374. {
  4375. if (globalVar.LineThreeRobotTaskError)
  4376. DeviceOperate.GetInstance.WritePlcData("D1054", 0);
  4377. globalVar.rollerLineThree.CanRun = true;
  4378. globalVar.agvLineThreeLoadCom = false;
  4379. MessageNotify.GetInstance.ShowRunLog("AGV在【3】号滚筒线装桶完成");
  4380. }
  4381. }
  4382. /// <summary>
  4383. /// AGV从炒锅送料位置到倒料过程处理
  4384. /// </summary>
  4385. //public void FryPotInputMaterial()
  4386. //{
  4387. // if (OutputMaterialQuene.Count > 0 && !globalVar.InOrOutputLock)
  4388. // {
  4389. // while (!agvArriveUnLoad)//等待agv到达炒锅位置
  4390. // {
  4391. // Thread.Sleep(5);
  4392. // if (globalVar.ExitMainTask)
  4393. // return;
  4394. // }
  4395. // AgvArriveFryPotSingleSetDown();
  4396. // FryPotRollerTroubleCheck();
  4397. // if (FryPotAlarm == 1)//炒锅滚筒无故障
  4398. // {
  4399. // //炒锅滚筒进料运行到位处理
  4400. // FryPotInputMaterialRollerOperate();
  4401. // globalVar.InOrOutputLock = true;
  4402. // }
  4403. // }
  4404. //}
  4405. /// <summary>
  4406. /// 线体1的AGV从炒锅送料位置到倒料过程处理
  4407. /// </summary>
  4408. public void LOneFryPotInputMaterial()
  4409. {
  4410. if (OutputMaterialQuene.Count > 0 && (globalVar.agvArriveUnLoad || globalVar.LineOneRobotTaskError) && globalVar.AgvToFryPot && !globalVar.PotOneInputMaterialArrive)
  4411. {
  4412. //if (globalVar.LOneFryPotSerial == 1)
  4413. //{
  4414. // AgvViewModel.GetInstance().Set小车运动(1, CartMotionTrajectory.yc_1_1);
  4415. //}
  4416. //else if (globalVar.LOneFryPotSerial == 4)
  4417. //{
  4418. // AgvViewModel.GetInstance().Set小车运动(1, CartMotionTrajectory.yc_1_4);
  4419. //}
  4420. MessageNotify.GetInstance.ShowRunLog($"AGV到达【{globalVar.LOneFryPotSerial}】号炒锅下料位置");
  4421. AgvArriveFryPotOneOrFourSingleSetDown();
  4422. globalVar.agvArriveUnLoad = false;
  4423. globalVar.PotOneInputMaterialArrive = true;
  4424. globalVar.LineOneRobotTaskError = false;//AGV故障信号复位
  4425. FryPotOneRollerTroubleCheck();
  4426. }
  4427. }
  4428. public void LOneFallMaterial()
  4429. {
  4430. if (!globalVar.InOrOutputLock && ((globalVar.fryPotOne.InputMaterialArrivedSingle == 1 && globalVar.LOneFryPotSerial == 1) || (globalVar.fryPotFour.InputMaterialArrivedSingle == 1 && globalVar.LOneFryPotSerial == 4)) && globalVar.PotOneInputMaterialArrive && OutputMaterialQuene.Count > 0 && !globalVar.PotOneOutputRollerArrive)
  4431. {
  4432. //FryPotOneRollerTroubleCheck();
  4433. if ((FryPotAlarm == 1 && globalVar.LOneFryPotSerial == 1) || (FryPotFourAlarm == 1 && globalVar.LOneFryPotSerial == 4))//炒锅滚筒无故障
  4434. {
  4435. if (globalVar.LOneFryPotSerial == 1)
  4436. {
  4437. DeviceOperate.GetInstance.WritePlcData("D1055", 0);
  4438. //Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_1.workflows.Add(new WorkflowModel { id = globalVar.LOneCurrentCookingStep, Name = OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc.ToString(), isBool = IsBool.Yes }); }));
  4439. }
  4440. else
  4441. {
  4442. DeviceOperate.GetInstance.WritePlcData("D1058", 0);
  4443. // Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.workflows.Add(new WorkflowModel { id = globalVar.LFourCurrentCookingStep, Name = OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc.ToString(), isBool = IsBool.Yes }); }));
  4444. }
  4445. //炒锅滚筒进料运行到位处理
  4446. FryPotOneOrFourInputMaterialRollerOperate();
  4447. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LOneFryPotSerial, IsRun.Start);
  4448. FryPotOneRollerTroubleCheck();
  4449. globalVar.InOrOutputLock = true;
  4450. globalVar.PotOneOutputRollerArrive = true;
  4451. }
  4452. }
  4453. }
  4454. /// <summary>
  4455. /// 线体2的AGV从炒锅送料位置到倒料过程处理
  4456. /// </summary>
  4457. public void LTwoFryPotInputMaterial()
  4458. {
  4459. if (LTwoOutputMaterialQuene.Count > 0 && (globalVar.LTwoagvArriveUnLoad || globalVar.LineTwoRobotTaskError) && globalVar.LTwoAgvToFryPot && !globalVar.LTwoPotInputMaterialArrive)
  4460. {
  4461. //if (globalVar.LTwoFryPotSerial == 2)
  4462. //{
  4463. // AgvViewModel.GetInstance().Set小车运动(2, CartMotionTrajectory.yc_2_2);
  4464. //}
  4465. //else if (globalVar.LTwoFryPotSerial == 5)
  4466. //{
  4467. // AgvViewModel.GetInstance().Set小车运动(2, CartMotionTrajectory.yc_2_5);
  4468. //}
  4469. MessageNotify.GetInstance.ShowRunLog($"AGV到达【{globalVar.LTwoFryPotSerial}】号炒锅下料位置");
  4470. AgvArriveFryPotTwoOrFiveSingleSetDown();
  4471. globalVar.LTwoagvArriveUnLoad = false;
  4472. globalVar.LTwoPotInputMaterialArrive = true;
  4473. globalVar.LineTwoRobotTaskError = false;//agv故障信号复位
  4474. FryPotTwoRollerTroubleCheck();
  4475. }
  4476. }
  4477. public void LTwoFallMaterial()
  4478. {
  4479. if (!globalVar.LTwoInOrOutputLock && ((globalVar.fryPotTwo.InputMaterialArrivedSingle == 1 && globalVar.LTwoFryPotSerial == 2) || (globalVar.fryPotFive.InputMaterialArrivedSingle == 1 && globalVar.LTwoFryPotSerial == 5) && globalVar.LTwoPotInputMaterialArrive && LTwoOutputMaterialQuene.Count > 0 && !globalVar.LTwoPotOutputRollerArrive))
  4480. {
  4481. //if (globalVar.LTwoFryPotSerial == 2)
  4482. //{
  4483. // Sqlite<PotTwoStatus>.GetInstance.Base.Add(new PotTwoStatus { Temperature = FryPotMonitorManage.GetInstance.fryTwo.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryTwo.HotPower, Speed = FryPotMonitorManage.GetInstance.fryTwo.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
  4484. // Sqlite<PotTwoStatus>.GetInstance.Save();//保存数据
  4485. //}
  4486. //else
  4487. //{
  4488. // Sqlite<PotFiveStatus>.GetInstance.Base.Add(new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFive.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
  4489. // Sqlite<PotFiveStatus>.GetInstance.Save();//保存数据
  4490. //}
  4491. if ((FryPotTwoAlarm == 1 && globalVar.LTwoFryPotSerial == 2) || (FryPotFiveAlarm == 1 && globalVar.LTwoFryPotSerial == 5))//炒锅滚筒无故障
  4492. {
  4493. if (globalVar.LTwoFryPotSerial == 2)
  4494. {
  4495. DeviceOperate.GetInstance.WritePlcData("D1056", 0);
  4496. //Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_2.workflows.Add(new WorkflowModel { id = globalVar.LTwoCurrentCookingStep, Name = LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc.ToString(), isBool = IsBool.Yes }); }));
  4497. }
  4498. else
  4499. {
  4500. DeviceOperate.GetInstance.WritePlcData("D1059", 0);
  4501. //Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_5.workflows.Add(new WorkflowModel { id = globalVar.LFiveCurrentCookingStep, Name = LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc.ToString(), isBool = IsBool.Yes }); }));
  4502. }
  4503. //炒锅滚筒进料运行到位处理
  4504. FryPotTwoOrFiveInputMaterialRollerOperate();
  4505. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LTwoFryPotSerial, IsRun.Start);
  4506. FryPotTwoRollerTroubleCheck();
  4507. globalVar.LTwoInOrOutputLock = true;
  4508. globalVar.LTwoPotOutputRollerArrive = true;
  4509. }
  4510. }
  4511. }
  4512. /// <summary>
  4513. /// 线体3的AGV从炒锅送料位置到倒料过程处理
  4514. /// </summary>
  4515. public void LThreeFryPotInputMaterial()
  4516. {
  4517. if (LThreeOutputMaterialQuene.Count > 0 && (globalVar.LThreeagvArriveUnLoad || globalVar.LineThreeRobotTaskError) && globalVar.LThreeAgvToFryPot && !globalVar.LThreePotInputMaterialArrive)
  4518. {
  4519. // AgvViewModel.GetInstance().Set小车运动(3, CartMotionTrajectory.yc_3_3);
  4520. MessageNotify.GetInstance.ShowRunLog("AGV到达【3】号炒锅下料位置");
  4521. AgvArriveFryPotThreeSingleSetDown();
  4522. globalVar.LThreeagvArriveUnLoad = false;
  4523. globalVar.LThreePotInputMaterialArrive = true;
  4524. globalVar.LineThreeRobotTaskError = false;//agv故障信号复位
  4525. FryPotThreeRollerTroubleCheck();
  4526. }
  4527. }
  4528. public void LThreeFallMaterial()
  4529. {
  4530. if (!globalVar.LThreeInOrOutputLock && globalVar.fryPotThree.InputMaterialArrivedSingle == 1 && globalVar.LThreePotInputMaterialArrive && LThreeOutputMaterialQuene.Count > 0 && !globalVar.LThreePotOutputRollerArrive)
  4531. {
  4532. //Sqlite<PotThreeStatus>.GetInstance.Base.Add(new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据
  4533. //Sqlite<PotThreeStatus>.GetInstance.Save();//保存数据
  4534. if (FryPotThreeAlarm == 1)//炒锅滚筒无故障
  4535. {
  4536. DeviceOperate.GetInstance.WritePlcData("D1057", 0);
  4537. //Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.workflows.Add(new WorkflowModel { id = globalVar.LThreeCurrentCookingStep, Name = LThreeOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc.ToString(), isBool = IsBool.Yes }); }));
  4538. //炒锅滚筒进料运行到位处理
  4539. FryPotThreeInputMaterialRollerOperate();
  4540. AgvViewModel.GetInstance().Set启动或停止炒锅(3, IsRun.Start);
  4541. FryPotThreeRollerTroubleCheck();
  4542. globalVar.LThreeInOrOutputLock = true;
  4543. globalVar.LThreePotOutputRollerArrive = true;
  4544. }
  4545. }
  4546. }
  4547. /// <summary>
  4548. /// 炒锅出桶
  4549. /// </summary>
  4550. //public void FryPotOutputMaterial()
  4551. //{
  4552. // if (OutputMaterialQuene.Count > 0 && globalVar.InOrOutputLock)
  4553. // {
  4554. // AgvFromFryPotToClean();//上游下发搬运任务给AGV
  4555. // while (!agvArriveUpLoad)//等待agv到达炒锅位置
  4556. // {
  4557. // Thread.Sleep(5);
  4558. // if (globalVar.ExitMainTask)
  4559. // return;
  4560. // }
  4561. // agvArriveUpLoad = false;
  4562. // AgvArriveFryPotOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号
  4563. // FryPotRollerTroubleCheck();
  4564. // if (FryPotAlarm == 1)//无故障
  4565. // {
  4566. // FryPotOutEmpetyRollerOperate();
  4567. // if (OutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料
  4568. // {
  4569. // while (!agvFryPotEmptyRollerArrive)//等待AGV拿到出桶空桶
  4570. // {
  4571. // Thread.Sleep(5);agvFryPotEmptyRollerArrive
  4572. // if (globalVar.ExitMainTask)
  4573. // return;
  4574. // }
  4575. // //AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅
  4576. // globalVar.AllowAgvToLineLoadRoller = true;
  4577. // globalVar.InOrOutputLock = false;
  4578. // }
  4579. // }
  4580. // }
  4581. //}
  4582. /// <summary>
  4583. /// 线体1对应炒锅出桶
  4584. /// </summary>
  4585. public void LOneFryPotOutputMaterial()
  4586. {
  4587. if (((globalVar.fryPotOne.EmptyBarrelArrivedSingle == 1 && globalVar.LOneFryPotSerial == 1) || (globalVar.fryPotFour.EmptyBarrelArrivedSingle == 1 && globalVar.LOneFryPotSerial == 4)) && OutputMaterialQuene.Count > 0 && globalVar.InOrOutputLock && globalVar.PotOneOutputRollerArrive && !globalVar.AgvArrivePot)
  4588. {
  4589. //上游下发搬运任务给AGV
  4590. if (AgvFromFryPotOneOrFourToClean())
  4591. {
  4592. globalVar.AgvArrivePot = true;
  4593. }
  4594. else
  4595. {
  4596. Thread.Sleep(5000);
  4597. }
  4598. }
  4599. }
  4600. public void LOneEmptyOperate()
  4601. {
  4602. if ((globalVar.agvArriveUpLoad || globalVar.LineFourRobotTaskError) && OutputMaterialQuene.Count > 0 && globalVar.AgvArrivePot)
  4603. {
  4604. if (globalVar.agvFryPotEmptyRollerArrive || globalVar.LineFourRobotTaskError)//炒锅上料完成
  4605. {
  4606. if (globalVar.LineFourRobotTaskError)
  4607. {
  4608. if (globalVar.LOneFryPotSerial == 1)
  4609. {
  4610. DeviceOperate.GetInstance.WritePlcData("D1060", 0);
  4611. }
  4612. else
  4613. {
  4614. DeviceOperate.GetInstance.WritePlcData("D1063", 0);
  4615. }
  4616. }
  4617. FryPotOneOrFourOutEmpetyRollerOperate();
  4618. if (OutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料
  4619. {
  4620. //AgvViewModel.GetInstance().Set小车是否承载物品(1, IsBool.OnllYes);
  4621. //if (globalVar.LOneFryPotSerial == 1)
  4622. //{
  4623. // AgvViewModel.GetInstance().Set小车运动(1, CartMotionTrajectory.hs_1);
  4624. //}
  4625. //else if (globalVar.LOneFryPotSerial == 4)
  4626. //{
  4627. // AgvViewModel.GetInstance().Set小车运动(1, CartMotionTrajectory.hs_4);
  4628. //}
  4629. globalVar.agvArriveUpLoad = false;
  4630. globalVar.agvFryPotEmptyRollerArrive = false;
  4631. globalVar.InOrOutputLock = false;
  4632. MessageNotify.GetInstance.ShowRunLog($"AGV在【{globalVar.LOneFryPotSerial}】号炒锅将空桶回收到4号滚筒线");
  4633. //AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅
  4634. globalVar.AllowAgvToLineLoadRoller = true;
  4635. globalVar.LoadRoller = false;
  4636. globalVar.AgvToFryPot = false;
  4637. globalVar.PotOneInputMaterialArrive = false;
  4638. globalVar.PotOneOutputRollerArrive = false;
  4639. globalVar.AgvArrivePot = false;
  4640. }
  4641. }
  4642. //}
  4643. }
  4644. }
  4645. /// <summary>
  4646. /// 线体2对应炒锅出桶
  4647. /// </summary>
  4648. public void LTwoFryPotOutputMaterial()
  4649. {
  4650. if (LTwoOutputMaterialQuene.Count > 0 && globalVar.LTwoInOrOutputLock && ((globalVar.fryPotTwo.EmptyBarrelArrivedSingle == 1 && globalVar.LTwoFryPotSerial == 2) || (globalVar.fryPotFive.EmptyBarrelArrivedSingle == 1 && globalVar.LTwoFryPotSerial == 5)) && globalVar.LTwoPotOutputRollerArrive && !globalVar.LTwoAgvArrivePot)
  4651. {
  4652. //上游下发搬运任务给AGV
  4653. if (AgvFromFryPotTwoOrFiveToClean())
  4654. {
  4655. globalVar.LTwoAgvArrivePot = true;
  4656. }
  4657. else
  4658. {
  4659. Thread.Sleep(5000);
  4660. }
  4661. }
  4662. }
  4663. public void LTwoEmptyOperate()
  4664. {
  4665. if ((globalVar.agvArriveLTwoUpLoad || globalVar.LineFiveRobotTaskError) && LTwoOutputMaterialQuene.Count > 0 && globalVar.LTwoAgvArrivePot)
  4666. {
  4667. //if (FryPotTwoAlarm == 1 || FryPotFiveAlarm == 1)//无故障
  4668. //{
  4669. if (globalVar.LTwoagvFryPotEmptyRollerArrive || globalVar.LineFiveRobotTaskError)
  4670. {
  4671. if (globalVar.LineFiveRobotTaskError)
  4672. {
  4673. if (globalVar.LTwoFryPotSerial == 2)
  4674. {
  4675. DeviceOperate.GetInstance.WritePlcData("D1061", 0);
  4676. }
  4677. else
  4678. {
  4679. DeviceOperate.GetInstance.WritePlcData("D1064", 0);
  4680. }
  4681. }
  4682. FryPotTwoOrFiveOutEmpetyRollerOperate();
  4683. if (LTwoOutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料
  4684. {
  4685. //AgvViewModel.GetInstance().Set小车是否承载物品(2, IsBool.OnllYes);
  4686. //if (globalVar.LTwoFryPotSerial == 2)
  4687. //{
  4688. // AgvViewModel.GetInstance().Set小车运动(2, CartMotionTrajectory.hs_2);
  4689. //}
  4690. //else if (globalVar.LTwoFryPotSerial == 5)
  4691. //{
  4692. // AgvViewModel.GetInstance().Set小车运动(2, CartMotionTrajectory.hs_5);
  4693. //}
  4694. globalVar.agvArriveLTwoUpLoad = false;
  4695. globalVar.LTwoagvFryPotEmptyRollerArrive = false;
  4696. globalVar.LTwoInOrOutputLock = false;
  4697. MessageNotify.GetInstance.ShowRunLog($"AGV在【{globalVar.LTwoFryPotSerial}】号炒锅将空桶回收到4号滚筒线");
  4698. //AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅
  4699. globalVar.AllowAgvToLineTwoLoadRoller = true;
  4700. globalVar.LTwoLoadRoller = false;
  4701. globalVar.LTwoAgvToFryPot = false;
  4702. globalVar.LTwoPotInputMaterialArrive = false;
  4703. globalVar.LTwoPotOutputRollerArrive = false;
  4704. globalVar.LTwoAgvArrivePot = false;
  4705. }
  4706. }
  4707. //}
  4708. }
  4709. }
  4710. /// <summary>
  4711. /// 线体3对应炒锅出桶
  4712. /// </summary>
  4713. public void LThreeFryPotOutputMaterial()
  4714. {
  4715. if (LThreeOutputMaterialQuene.Count > 0 && globalVar.LThreeInOrOutputLock && globalVar.fryPotThree.EmptyBarrelArrivedSingle == 1 && globalVar.LThreePotOutputRollerArrive && !globalVar.LThreeAgvArrivePot)
  4716. {
  4717. //上游下发搬运任务给AGV
  4718. if (AgvFromFryPotThreeToClean())
  4719. {
  4720. globalVar.LThreeAgvArrivePot = true;
  4721. }
  4722. else
  4723. {
  4724. Thread.Sleep(5000);
  4725. }
  4726. }
  4727. }
  4728. public void LThreeEmptyOperate()
  4729. {
  4730. if ((globalVar.agvArriveLThreeUpLoad || globalVar.LineSixRobotTaskError) && LThreeOutputMaterialQuene.Count > 0 && globalVar.LThreeAgvArrivePot)
  4731. {
  4732. //if (FryPotThreeAlarm == 1)//无故障
  4733. //{
  4734. if (globalVar.LThreeagvFryPotEmptyRollerArrive || globalVar.LineSixRobotTaskError)
  4735. {
  4736. if (globalVar.LineSixRobotTaskError)
  4737. DeviceOperate.GetInstance.WritePlcData("D1062", 0);
  4738. //FryPotThreeOutEmpetyRollerOperate();
  4739. MessageNotify.GetInstance.ShowRunLog($"炒锅【3】原料:【{LThreeOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】空桶上料完成");
  4740. if (LThreeOutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料
  4741. {
  4742. //AgvViewModel.GetInstance().Set小车是否承载物品(3, IsBool.OnllYes);
  4743. //AgvViewModel.GetInstance().Set小车运动(3, CartMotionTrajectory.hs_3);
  4744. globalVar.agvArriveLThreeUpLoad = false;
  4745. globalVar.LThreeagvFryPotEmptyRollerArrive = false;
  4746. globalVar.LThreeInOrOutputLock = false;
  4747. MessageNotify.GetInstance.ShowRunLog($"AGV在【{globalVar.LThreeFryPotSerial}】号炒锅将空桶回收到4号滚筒线");
  4748. //AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅
  4749. globalVar.AllowAgvToLineThreeLoadRoller = true;
  4750. globalVar.LThreeLoadRoller = false;
  4751. globalVar.LThreeAgvToFryPot = false;
  4752. globalVar.LThreePotInputMaterialArrive = false;
  4753. globalVar.LThreePotOutputRollerArrive = false;
  4754. globalVar.LThreeAgvArrivePot = false;
  4755. }
  4756. }
  4757. // }
  4758. }
  4759. }
  4760. /// <summary>
  4761. /// 清洗台到4号线体下料
  4762. /// </summary>
  4763. public void EmptyRollerToLinFourFromClean()
  4764. {
  4765. if (globalVar.agvArriveLineFour || globalVar.LineTenRobotTaskError)//agv到达线体4下料位置
  4766. {
  4767. if (globalVar.LineTenRobotTaskError)
  4768. DeviceOperate.GetInstance.WritePlcData("D1066", 0);
  4769. globalVar.agvArriveLineFour = false;
  4770. globalVar.LineTenRobotTaskError = false;//AGV故障信号复位
  4771. //线体四信号交互
  4772. WritePlcData("D1067", 1);//AGV空桶回桶就位信号下发PLC
  4773. MessageNotify.GetInstance.ShowRunLog("AGV从清洗台到达【4】号回收线体,准备卸桶");
  4774. // MessageLog.GetInstance.ShowRunLog("卸桶完成");
  4775. }
  4776. }
  4777. public void EmptyRollerToLinFourFromPot()
  4778. {
  4779. if (globalVar.rollerLineOne.agvArriveLineFour || globalVar.LineFourRobotTaskError)//agv到达线体4下料位置
  4780. {
  4781. globalVar.rollerLineOne.agvArriveLineFour = false;
  4782. //线体四信号交互
  4783. WritePlcData("D1067", 1);//AGV空桶回桶就位信号下发PLC
  4784. globalVar.LineFourRobotTaskError = false;//AGV故障信号复位
  4785. MessageNotify.GetInstance.ShowRunLog($"AGV从【{globalVar.LOneFryPotSerial}】号炒锅到达【4】号回收线体,准备卸桶");
  4786. // MessageLog.GetInstance.ShowRunLog("卸桶完成");
  4787. }
  4788. if (globalVar.rollerLineTwo.agvArriveLineFour || globalVar.LineFiveRobotTaskError)//agv到达线体4下料位置
  4789. {
  4790. globalVar.rollerLineTwo.agvArriveLineFour = false;
  4791. //线体四信号交互
  4792. WritePlcData("D1067", 1);//AGV空桶回桶就位信号下发PLC
  4793. globalVar.LineFiveRobotTaskError = false;//AGV故障信号复位
  4794. MessageNotify.GetInstance.ShowRunLog($"AGV从【{globalVar.LTwoFryPotSerial}】炒锅到达【4】号回收线体,准备卸桶");
  4795. // MessageLog.GetInstance.ShowRunLog("卸桶完成");
  4796. }
  4797. if (globalVar.rollerLineThree.agvArriveLineFour || globalVar.LineSixRobotTaskError)//agv到达线体4下料位置
  4798. {
  4799. globalVar.rollerLineThree.agvArriveLineFour = false;
  4800. //线体四信号交互
  4801. WritePlcData("D1067", 1);//AGV空桶回桶就位信号下发PLC
  4802. globalVar.LineSixRobotTaskError = false;//AGV故障信号复位
  4803. MessageNotify.GetInstance.ShowRunLog("AGV从3号炒锅到达【4】号回收线体,准备卸桶");
  4804. // MessageLog.GetInstance.ShowRunLog("卸桶完成");
  4805. }
  4806. }
  4807. ///// <summary>
  4808. ///// 线体1对应炒锅到4号线体下料
  4809. ///// </summary>
  4810. //public void EmptyRollerToLinFourFromLineOne()
  4811. //{
  4812. // if (globalVar.rollerLineOne.agvArriveLineFour)//agv到达线体4下料位置
  4813. // {
  4814. // globalVar.rollerLineOne.agvArriveLineFour = false;
  4815. // //线体四信号交互
  4816. // WritePlcData("D1067", 1);//AGV空桶回桶就位信号下发PLC
  4817. // MessageLog.GetInstance.ShowRunLog("AGV从1号线体对应炒锅到达【4】号回收线体,准备卸桶");
  4818. // // MessageLog.GetInstance.ShowRunLog("卸桶完成");
  4819. // }
  4820. //}
  4821. ///// <summary>
  4822. /////线体2对应炒锅到4号线体下料
  4823. ///// </summary>
  4824. //public void EmptyRollerToLinFourFromLineTwo()
  4825. //{
  4826. // if (globalVar.rollerLineTwo.agvArriveLineFour)//agv到达线体4下料位置
  4827. // {
  4828. // globalVar.rollerLineTwo.agvArriveLineFour = false;
  4829. // //线体四信号交互
  4830. // WritePlcData("D1067", 1);//AGV空桶回桶就位信号下发PLC
  4831. // MessageLog.GetInstance.ShowRunLog("AGV从2号线体对应炒锅到达【4】号回收线体,准备卸桶");
  4832. // // MessageLog.GetInstance.ShowRunLog("卸桶完成");
  4833. // }
  4834. //}
  4835. ///// <summary>
  4836. ///// 线体3对应炒锅到4号线体下料
  4837. ///// </summary>
  4838. //public void EmptyRollerToLinFourFromLineThree()
  4839. //{
  4840. // if (globalVar.rollerLineThree.agvArriveLineFour)//agv到达线体4下料位置
  4841. // {
  4842. // globalVar.rollerLineThree.agvArriveLineFour = false;
  4843. // //线体四信号交互
  4844. // WritePlcData("D1067", 1);//AGV空桶回桶就位信号下发PLC
  4845. // MessageLog.GetInstance.ShowRunLog("AGV从3号炒锅到达【4】号回收线体,准备卸桶");
  4846. // // MessageLog.GetInstance.ShowRunLog("卸桶完成");
  4847. // }
  4848. //}
  4849. /// <summary>
  4850. /// 炒锅1,4滚筒进料运行到位处理
  4851. /// </summary>
  4852. public void FryPotOneOrFourInputMaterialRollerOperate()
  4853. {
  4854. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  4855. {
  4856. case 1:
  4857. //while (globalVar.fryPotOne.InputMaterialArrivedSingle == 0)
  4858. //{
  4859. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  4860. // return;
  4861. //}
  4862. MessageNotify.GetInstance.ShowRunLog($"炒锅【1】:【{OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】号桶已到进料位置,准备倒料"); break;
  4863. case 4:
  4864. //while (globalVar.fryPotFour.InputMaterialArrivedSingle == 0)
  4865. //{
  4866. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  4867. // return;
  4868. //}
  4869. MessageNotify.GetInstance.ShowRunLog($"炒锅【4】:【{OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】号桶已到进料位置,准备倒料"); break;
  4870. }
  4871. }
  4872. /// <summary>
  4873. /// 炒锅2,5滚筒进料运行到位处理
  4874. /// </summary>
  4875. public void FryPotTwoOrFiveInputMaterialRollerOperate()
  4876. {
  4877. switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  4878. {
  4879. case 2:
  4880. //while (globalVar.fryPotTwo.InputMaterialArrivedSingle == 0)
  4881. //{
  4882. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  4883. // return;
  4884. //}
  4885. MessageNotify.GetInstance.ShowRunLog($"炒锅【2】:【{LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】号桶已到进料位置,准备倒料"); break;
  4886. case 5:
  4887. //while (globalVar.fryPotFive.InputMaterialArrivedSingle == 0)
  4888. //{
  4889. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  4890. // return;
  4891. //}
  4892. MessageNotify.GetInstance.ShowRunLog($"炒锅【5】:【{LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】号桶已到进料位置,准备倒料"); break;
  4893. }
  4894. }
  4895. public void FryPotThreeInputMaterialRollerOperate()
  4896. {
  4897. //while (globalVar.fryPotThree.InputMaterialArrivedSingle == 0)
  4898. //{
  4899. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  4900. // return;
  4901. //}
  4902. MessageNotify.GetInstance.ShowRunLog($"炒锅【3】:【{LThreeOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】号桶已到进料位置,准备倒料");
  4903. }
  4904. /// <summary>
  4905. /// 炒锅滚筒空桶出桶处理
  4906. /// </summary>
  4907. //public void FryPotOutEmpetyRollerOperate(ConcurrentQueue<MaterialInfo> queue)
  4908. //{
  4909. // switch (queue.ElementAt(0).materialType.MaterialLoc / 100)
  4910. // {
  4911. // case 1:
  4912. // while (globalVar.fryPotOne.EmptyBarrelArrivedSingle == 0)
  4913. // {
  4914. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  4915. // return;
  4916. // }
  4917. // MessageLog.GetInstance.ShowRunLog($"炒锅【1】原料:【{queue.ElementAt(0).materialType.MaterialName}】空桶到达出桶位置,正在出桶"); break;
  4918. // case 2:
  4919. // while (globalVar.fryPotTwo.EmptyBarrelArrivedSingle == 0)
  4920. // {
  4921. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  4922. // return;
  4923. // }
  4924. // MessageLog.GetInstance.ShowRunLog($"炒锅【2】原料:【{queue.ElementAt(0).materialType.MaterialName}】空桶到达出桶位置,正在出桶"); break;
  4925. // case 3:
  4926. // while (globalVar.fryPotThree.EmptyBarrelArrivedSingle == 0)
  4927. // {
  4928. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  4929. // return;
  4930. // }
  4931. // MessageLog.GetInstance.ShowRunLog($"炒锅【3】原料:【{queue.ElementAt(0).materialType.MaterialName}】空桶到达出桶位置,正在出桶"); break;
  4932. // case 4:
  4933. // while (globalVar.fryPotFour.EmptyBarrelArrivedSingle == 0)
  4934. // {
  4935. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  4936. // return;
  4937. // }
  4938. // MessageLog.GetInstance.ShowRunLog($"炒锅【4】原料:【{queue.ElementAt(0).materialType.MaterialName}】空桶到达出桶位置,正在出桶"); break;
  4939. // case 5:
  4940. // while (globalVar.fryPotFive.EmptyBarrelArrivedSingle == 0)
  4941. // {
  4942. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  4943. // return;
  4944. // }
  4945. // MessageLog.GetInstance.ShowRunLog($"炒锅【5】原料:【{queue.ElementAt(0).materialType.MaterialName}】空桶到达出桶位置,正在出桶"); break;
  4946. // }
  4947. //}
  4948. /// <summary>
  4949. /// 炒锅1,4滚筒空桶出桶处理
  4950. /// </summary>
  4951. public void FryPotOneOrFourOutEmpetyRollerOperate()
  4952. {
  4953. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  4954. {
  4955. case 1:
  4956. //while (globalVar.fryPotOne.EmptyBarrelArrivedSingle == 0)
  4957. //{
  4958. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  4959. // return;
  4960. //}
  4961. MessageNotify.GetInstance.ShowRunLog($"炒锅【1】原料:【{OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】空桶上料完成"); break;
  4962. case 4:
  4963. //while (globalVar.fryPotFour.EmptyBarrelArrivedSingle == 0)
  4964. //{
  4965. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  4966. // return;
  4967. //}
  4968. MessageNotify.GetInstance.ShowRunLog($"炒锅【4】原料:【{OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】空桶上料完成"); break;
  4969. }
  4970. }
  4971. /// <summary>
  4972. /// 炒锅2,5滚筒空桶出桶处理
  4973. /// </summary>
  4974. public void FryPotTwoOrFiveOutEmpetyRollerOperate()
  4975. {
  4976. switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  4977. {
  4978. case 2:
  4979. //while (globalVar.fryPotTwo.EmptyBarrelArrivedSingle == 0)
  4980. //{
  4981. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  4982. // return;
  4983. //}
  4984. MessageNotify.GetInstance.ShowRunLog($"炒锅【2】原料:【{LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】空桶上料完成"); break;
  4985. case 5:
  4986. //while (globalVar.fryPotFive.EmptyBarrelArrivedSingle == 0)
  4987. //{
  4988. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  4989. // return;
  4990. //}
  4991. MessageNotify.GetInstance.ShowRunLog($"炒锅【5】原料:【{LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】空桶上料完成"); break;
  4992. }
  4993. }
  4994. /// <summary>
  4995. /// 炒锅3滚筒空桶出桶处理
  4996. /// </summary>
  4997. public void FryPotThreeOutEmpetyRollerOperate()
  4998. {
  4999. //while (globalVar.fryPotThree.EmptyBarrelArrivedSingle == 0)
  5000. //{
  5001. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  5002. // return;
  5003. //}
  5004. MessageNotify.GetInstance.ShowRunLog($"炒锅【3】原料:【{LThreeOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】空桶上料完成");
  5005. }
  5006. /// <summary>
  5007. /// 发送agv送料就位信号至PLC(线体到炒锅)
  5008. /// </summary>
  5009. public void AgvArriveFryPotSingleSetDown(ConcurrentQueue<MaterialInfo> queue)
  5010. {
  5011. switch (queue.ElementAt(0).materialType.MaterialLoc / 100)
  5012. {
  5013. case 1: DeviceOperate.GetInstance.WritePlcData("D1055", 1); break;//agv到炒锅1送料就位信号
  5014. case 2: DeviceOperate.GetInstance.WritePlcData("D1056", 1); break;//agv到炒锅2送料就位信号
  5015. case 3: DeviceOperate.GetInstance.WritePlcData("D1057", 1); break;//agv到炒锅3送料就位信号
  5016. case 4: DeviceOperate.GetInstance.WritePlcData("D1058", 1); break;//agv到炒锅4送料就位信号
  5017. case 5: DeviceOperate.GetInstance.WritePlcData("D1059", 1); break;//agv到炒锅5送料就位信号
  5018. }
  5019. }
  5020. /// <summary>
  5021. /// 发送agv送料就位信号至PLC(线体1到炒锅)
  5022. /// </summary>
  5023. public void AgvArriveFryPotOneOrFourSingleSetDown()
  5024. {
  5025. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  5026. {
  5027. case 1: DeviceOperate.GetInstance.WritePlcData("D1055", 1); break;//agv到炒锅1送料就位信号
  5028. case 4: DeviceOperate.GetInstance.WritePlcData("D1058", 1); break;//agv到炒锅4送料就位信号
  5029. }
  5030. }
  5031. /// <summary>
  5032. /// 发送agv送料就位信号至PLC(线体2到炒锅)
  5033. /// </summary>
  5034. public void AgvArriveFryPotTwoOrFiveSingleSetDown()
  5035. {
  5036. switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  5037. {
  5038. case 2: DeviceOperate.GetInstance.WritePlcData("D1056", 1); break;//agv到炒锅2送料就位信号
  5039. case 5: DeviceOperate.GetInstance.WritePlcData("D1059", 1); break;//agv到炒锅5送料就位信号
  5040. }
  5041. }
  5042. /// <summary>
  5043. /// 发送agv送料就位信号至PLC(线体3到炒锅)
  5044. /// </summary>
  5045. public void AgvArriveFryPotThreeSingleSetDown()
  5046. {
  5047. DeviceOperate.GetInstance.WritePlcData("D1057", 1); //agv到炒锅3送料就位信号
  5048. }
  5049. /// <summary>
  5050. /// 发送agv回桶就位信号至PLC
  5051. /// </summary>
  5052. public void AgvArriveFryPotOutEmptyRollerSingleSetDown(ConcurrentQueue<MaterialInfo> queue)
  5053. {
  5054. switch (queue.ElementAt(0).materialType.MaterialLoc / 100)
  5055. {
  5056. case 1: DeviceOperate.GetInstance.WritePlcData("D1060", 1); break;//agv到炒锅1送料就位信号
  5057. case 2: DeviceOperate.GetInstance.WritePlcData("D1061", 1); break;//agv到炒锅2送料就位信号
  5058. case 3: DeviceOperate.GetInstance.WritePlcData("D1062", 1); break;//agv到炒锅3送料就位信号
  5059. case 4: DeviceOperate.GetInstance.WritePlcData("D1063", 1); break;//agv到炒锅4送料就位信号
  5060. case 5: DeviceOperate.GetInstance.WritePlcData("D1064", 1); break;//agv到炒锅5送料就位信号
  5061. }
  5062. }
  5063. public void AgvArriveFryPotOneOrFourOutEmptyRollerSingleSetDown()
  5064. {
  5065. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  5066. {
  5067. case 1: DeviceOperate.GetInstance.WritePlcData("D1060", 1); break;//agv到炒锅1送料就位信号
  5068. case 4: DeviceOperate.GetInstance.WritePlcData("D1063", 1); break;//agv到炒锅4送料就位信号
  5069. }
  5070. }
  5071. public void AgvArriveFryPotTwoOrFiveOutEmptyRollerSingleSetDown()
  5072. {
  5073. switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  5074. {
  5075. case 2: DeviceOperate.GetInstance.WritePlcData("D1061", 1); break;//agv到炒锅2送料就位信号
  5076. case 5: DeviceOperate.GetInstance.WritePlcData("D1064", 1); break;//agv到炒锅5送料就位信号
  5077. }
  5078. }
  5079. public void AgvArriveFryPotThreeOutEmptyRollerSingleSetDown()
  5080. {
  5081. DeviceOperate.GetInstance.WritePlcData("D1062", 1);//agv到炒锅3送料就位信号
  5082. }
  5083. ///// <summary>
  5084. ///// AGV离开炒锅运送空桶任务
  5085. ///// </summary>
  5086. //public void AgvFromFryPotToClean(ConcurrentQueue<MaterialInfo> queue)
  5087. //{
  5088. // switch (queue.ElementAt(0).materialType.MaterialLoc / 100)
  5089. // {
  5090. // case 1:
  5091. // erp: string id = Guid.NewGuid().ToString("D");//上游唯一ID
  5092. // if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId)
  5093. // {
  5094. // goto erp;
  5095. // }
  5096. // string info = AGVHelper.GetInstance.AgvLeaveFryPotOne(id);
  5097. // LOnerobotJobId = id;
  5098. // FryCarryTaskErrorCodeAnalysis(info, 1); break;
  5099. // case 2:
  5100. // erp1: string id1 = Guid.NewGuid().ToString("D");//上游唯一ID
  5101. // if (id1 == LTworobotJobId)
  5102. // {
  5103. // goto erp1;
  5104. // }
  5105. // string info1 = AGVHelper.GetInstance.AgvLeaveFryPotTwo(id1);
  5106. // LTworobotJobId = id1;
  5107. // FryCarryTaskErrorCodeAnalysis(info1, 2); break;
  5108. // case 3:
  5109. // erp2: string id2 = Guid.NewGuid().ToString("D");//上游唯一ID
  5110. // if (id2 == LThreerobotJobId)
  5111. // {
  5112. // goto erp2;
  5113. // }
  5114. // string info2 = AGVHelper.GetInstance.AgvLeaveFryPotThree(id2);
  5115. // LThreerobotJobId = id2;
  5116. // FryCarryTaskErrorCodeAnalysis(info2, 3); break;
  5117. // case 4:
  5118. // erp3: string id3 = Guid.NewGuid().ToString("D");//上游唯一ID
  5119. // if (id3 == LOnerobotJobId)
  5120. // {
  5121. // goto erp3;
  5122. // }
  5123. // string info3 = AGVHelper.GetInstance.AgvLeaveFryPotFour(id3);
  5124. // LOnerobotJobId = id3;
  5125. // FryCarryTaskErrorCodeAnalysis(info3, 4); break;
  5126. // case 5:
  5127. // erp4: string id4 = Guid.NewGuid().ToString("D");//上游唯一ID
  5128. // if (id4 == LTworobotJobId)
  5129. // {
  5130. // goto erp4;
  5131. // }
  5132. // string info4 = AGVHelper.GetInstance.AgvLeaveFryPotFive(id4);
  5133. // LTworobotJobId = id4;
  5134. // FryCarryTaskErrorCodeAnalysis(info4, 5); break;
  5135. // }
  5136. //}
  5137. /// <summary>
  5138. /// AGV离开炒锅1,4运送空桶任务
  5139. /// </summary>
  5140. public bool AgvFromFryPotOneOrFourToClean()
  5141. {
  5142. bool result = true;
  5143. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  5144. {
  5145. case 1:
  5146. erp: string id = Guid.NewGuid().ToString("D");//上游唯一ID
  5147. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  5148. {
  5149. goto erp;
  5150. }
  5151. MessageNotify.GetInstance.ShowRunLog("AGV执行【1】号炒锅空桶回收任务");
  5152. string info = AGVHelper.GetInstance.AgvLeaveFryPotOne(id);
  5153. LFourrobotJobId = id;
  5154. if (!FryCarryTaskErrorCodeAnalysis(info, 1))
  5155. {
  5156. id = String.Empty;
  5157. result = false;
  5158. }
  5159. break;
  5160. case 4:
  5161. erp3: string id3 = Guid.NewGuid().ToString("D");//上游唯一ID
  5162. if (id3 == LOnerobotJobId || id3 == LTworobotJobId || id3 == LThreerobotJobId || id3 == LFourrobotJobId || id3 == LFiverobotJobId || id3 == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id3) != null || LEightrobotJobId.FirstOrDefault(p => p == id3) != null || LNinerobotJobId.FirstOrDefault(p => p == id3) != null || LTenrobotJobId.FirstOrDefault(p => p == id3) != null)
  5163. {
  5164. goto erp3;
  5165. }
  5166. MessageNotify.GetInstance.ShowRunLog("AGV执行【4】号炒锅空桶回收任务");
  5167. string info3 = AGVHelper.GetInstance.AgvLeaveFryPotFour(id3);
  5168. LFourrobotJobId = id3;
  5169. if (!FryCarryTaskErrorCodeAnalysis(info3, 4))
  5170. {
  5171. id3 = String.Empty;
  5172. result = false;
  5173. }
  5174. break;
  5175. }
  5176. return result;
  5177. }
  5178. /// <summary>
  5179. /// AGV离开炒锅2,5运送空桶任务
  5180. /// </summary>
  5181. public bool AgvFromFryPotTwoOrFiveToClean()
  5182. {
  5183. bool result = true;
  5184. switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  5185. {
  5186. case 2:
  5187. erp1: string id1 = Guid.NewGuid().ToString("D");//上游唯一ID
  5188. if (id1 == LOnerobotJobId || id1 == LTworobotJobId || id1 == LThreerobotJobId || id1 == LFourrobotJobId || id1 == LFiverobotJobId || id1 == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id1) != null || LEightrobotJobId.FirstOrDefault(p => p == id1) != null || LNinerobotJobId.FirstOrDefault(p => p == id1) != null || LTenrobotJobId.FirstOrDefault(p => p == id1) != null)
  5189. {
  5190. goto erp1;
  5191. }
  5192. MessageNotify.GetInstance.ShowRunLog("AGV执行【2】号炒锅空桶回收任务");
  5193. string info1 = AGVHelper.GetInstance.AgvLeaveFryPotTwo(id1);
  5194. LFiverobotJobId = id1;
  5195. if (!FryCarryTaskErrorCodeAnalysis(info1, 2))
  5196. {
  5197. id1 = String.Empty;
  5198. result = false;
  5199. }
  5200. break;
  5201. case 5:
  5202. erp4: string id4 = Guid.NewGuid().ToString("D");//上游唯一ID
  5203. if (id4 == LOnerobotJobId || id4 == LTworobotJobId || id4 == LThreerobotJobId || id4 == LFourrobotJobId || id4 == LFiverobotJobId || id4 == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id4) != null || LEightrobotJobId.FirstOrDefault(p => p == id4) != null || LNinerobotJobId.FirstOrDefault(p => p == id4) != null || LTenrobotJobId.FirstOrDefault(p => p == id4) != null)
  5204. {
  5205. goto erp4;
  5206. }
  5207. MessageNotify.GetInstance.ShowRunLog("AGV执行【5】号炒锅空桶回收任务");
  5208. string info4 = AGVHelper.GetInstance.AgvLeaveFryPotFive(id4);
  5209. LFiverobotJobId = id4;
  5210. if (!FryCarryTaskErrorCodeAnalysis(info4, 5))
  5211. {
  5212. id4 = String.Empty;
  5213. result = false;
  5214. }
  5215. break;
  5216. }
  5217. return result;
  5218. }
  5219. /// <summary>
  5220. /// AGV离开炒锅3运送空桶任务
  5221. /// </summary>
  5222. public bool AgvFromFryPotThreeToClean()
  5223. {
  5224. bool result = true;
  5225. erp2: string id2 = Guid.NewGuid().ToString("D");//上游唯一ID
  5226. if (id2 == LOnerobotJobId || id2 == LTworobotJobId || id2 == LThreerobotJobId || id2 == LFourrobotJobId || id2 == LFiverobotJobId || id2 == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id2) != null || LEightrobotJobId.FirstOrDefault(p => p == id2) != null || LNinerobotJobId.FirstOrDefault(p => p == id2) != null || LTenrobotJobId.FirstOrDefault(p => p == id2) != null)
  5227. {
  5228. goto erp2;
  5229. }
  5230. MessageNotify.GetInstance.ShowRunLog("AGV执行【3】号炒锅空桶回收任务");
  5231. string info2 = AGVHelper.GetInstance.AgvLeaveFryPotThree(id2);
  5232. LSixrobotJobId = id2;
  5233. if (!FryCarryTaskErrorCodeAnalysis(info2, 3))
  5234. {
  5235. id2 = string.Empty;
  5236. result = false;
  5237. }
  5238. return result;
  5239. }
  5240. /// <summary>
  5241. /// 处理agv从线体1到送料到炒锅的条件
  5242. /// </summary>
  5243. /// <param name="lineAlarm"></param>
  5244. public void AgvFromLineOneToFryPot()
  5245. {
  5246. erp: if (AlarmHelper<AlarmInfo>.GetInstance("1号滚筒线故障").LOneRollerTrouble == 0)
  5247. {
  5248. if ((globalVar.agvArriveUpLoad || globalVar.LineOneRobotTaskError) && globalVar.LoadRoller && globalVar.rollerLineOne.StationEight == InputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.AgvToFryPot)//无故障
  5249. {
  5250. MessageNotify.GetInstance.ShowRunLog("AGV到达【1】号滚筒线装桶位置");
  5251. AgvArriveLineSingelSetDown(InputMaterialQuene);
  5252. if (InputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
  5253. {
  5254. MessageNotify.GetInstance.ShowRunLog($"AGV正在装载{materialInfo.materialType.MaterialLoc}号料桶");
  5255. //if (materialInfo.materialType.MaterialLoc / 100 == 1)
  5256. //{
  5257. // globalVar.LOneCurrentCookingStep++;
  5258. //}
  5259. //else
  5260. //{
  5261. // globalVar.LFourCurrentCookingStep++;
  5262. //}
  5263. OutputMaterialQuene.Enqueue(materialInfo);
  5264. globalVar.agvArriveUpLoad = false;
  5265. globalVar.AgvToFryPot = true;
  5266. //原料到位,agv到位,agv自行运料到炒锅
  5267. }
  5268. }
  5269. }
  5270. else//有故障
  5271. {
  5272. while (AlarmHelper<AlarmInfo>.GetInstance("1号滚筒线故障").LOneRollerTrouble == 1)
  5273. {
  5274. Thread.Sleep(1000);
  5275. if (globalVar.ExitLineOneTask)
  5276. return;
  5277. }
  5278. MessageNotify.GetInstance.ShowRunLog("线体【1】滚筒故障解除,继续运行");
  5279. //lineAlarm = 1;
  5280. goto erp;
  5281. }
  5282. }
  5283. /// <summary>
  5284. /// Agv从1号线体运空桶到清洗处
  5285. /// </summary>
  5286. public void AgvFromLineOneToClean(ushort emptyRollerNum = 0)
  5287. {
  5288. erp: if (AlarmHelper<AlarmInfo>.GetInstance("1号滚筒线故障").LOneRollerTrouble == 0)//无故障
  5289. {
  5290. if (globalVar.agvArriveLineOneLoadEmptyRoller)//agv到达上料位置
  5291. {
  5292. MessageNotify.GetInstance.ShowRunLog("AGV到达【1】号滚筒线装桶位置");
  5293. DeviceOperate.GetInstance.WritePlcData("D1052", 1);//agv到达线体1上料位置信号下发plc
  5294. if (emptyRollerNum != 0)
  5295. MessageNotify.GetInstance.ShowRunLog($"AGV正在装载【{emptyRollerNum}】号空料桶");
  5296. globalVar.agvArriveLineOneLoadEmptyRoller = false;
  5297. //原料到位,agv到位,agv自行运料到清洗处
  5298. }
  5299. if (globalVar.agvArriveLineOneLoadCom || globalVar.LineSevenRobotTaskError)//上料完成
  5300. {
  5301. if (globalVar.LineSevenRobotTaskError)
  5302. DeviceOperate.GetInstance.WritePlcData("D1052", 0);
  5303. if (emptyRollerNum != 0)
  5304. globalVar.rollerLineOne.EmptyRollerNums.Remove(emptyRollerNum);
  5305. globalVar.agvArriveLineOneLoadCom = false;
  5306. globalVar.rollerLineOne.IsEpmtyBefore = false;
  5307. if (emptyRollerNum != 0)
  5308. MessageNotify.GetInstance.ShowRunLog($"AGV在【1】号线体完成【{emptyRollerNum}】号空料桶装载");
  5309. }
  5310. }
  5311. else//有故障
  5312. {
  5313. while (AlarmHelper<AlarmInfo>.GetInstance("1号滚筒线故障").LOneRollerTrouble == 1)
  5314. {
  5315. Thread.Sleep(1000);
  5316. if (globalVar.ExitLineOneTask)
  5317. return;
  5318. }
  5319. MessageNotify.GetInstance.ShowRunLog("线体【1】滚筒故障解除,继续运行");
  5320. //lineAlarm = 1;
  5321. goto erp;
  5322. }
  5323. }
  5324. /// <summary>
  5325. /// 处理agv从线体2到送料到炒锅的条件
  5326. /// </summary>
  5327. /// <param name="lineAlarm"></param>
  5328. public void AgvFromLineTwoToFryPot()
  5329. {
  5330. erp: if (AlarmHelper<AlarmInfo>.GetInstance("2号滚筒线故障").LTwoRollerTrouble == 0)//无故障
  5331. {
  5332. if ((globalVar.agvArriveLTwoUpLoad || globalVar.LineTwoRobotTaskError) && globalVar.LTwoLoadRoller && globalVar.rollerLineTwo.StationEight == LTwoInputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.LTwoAgvToFryPot)//无故障
  5333. {
  5334. MessageNotify.GetInstance.ShowRunLog("AGV到达【2】号滚筒线装桶位置");
  5335. AgvArriveLineSingelSetDown(LTwoInputMaterialQuene);
  5336. if (LTwoInputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
  5337. {
  5338. MessageNotify.GetInstance.ShowRunLog($"AGV正在装载{materialInfo.materialType.MaterialLoc}号料桶");
  5339. //if (materialInfo.materialType.MaterialLoc / 100 == 2)
  5340. //{
  5341. // globalVar.LTwoCurrentCookingStep++;
  5342. //}
  5343. //else
  5344. //{
  5345. // globalVar.LFiveCurrentCookingStep++;
  5346. //}
  5347. LTwoOutputMaterialQuene.Enqueue(materialInfo);
  5348. globalVar.agvArriveLTwoUpLoad = false;
  5349. globalVar.LTwoAgvToFryPot = true;
  5350. //原料到位,agv到位,agv自行运料到炒锅
  5351. }
  5352. }
  5353. }
  5354. else//有故障
  5355. {
  5356. while (AlarmHelper<AlarmInfo>.GetInstance("2号滚筒线故障").LTwoRollerTrouble == 1)
  5357. {
  5358. Thread.Sleep(1000);
  5359. if (globalVar.ExitLineTwoTask)
  5360. return;
  5361. }
  5362. MessageNotify.GetInstance.ShowRunLog("线体【2】滚筒故障解除,继续运行");
  5363. // lineAlarm = 1;
  5364. goto erp;
  5365. }
  5366. }
  5367. /// <summary>
  5368. /// Agv从2号线体运空桶到清洗处
  5369. /// </summary>
  5370. public void AgvFromLineTwoToClean(ushort emptyRollerNum = 0)
  5371. {
  5372. erp: if (AlarmHelper<AlarmInfo>.GetInstance("2号滚筒线故障").LTwoRollerTrouble == 0)//无故障
  5373. {
  5374. if (globalVar.agvArriveLineTwoLoadEmptyRoller)//agv到达上料位置
  5375. {
  5376. MessageNotify.GetInstance.ShowRunLog("AGV到达【2】号滚筒线装桶位置");
  5377. DeviceOperate.GetInstance.WritePlcData("D1053", 1);//agv到达线体2上料位置信号下发plc
  5378. if (emptyRollerNum != 0)
  5379. MessageNotify.GetInstance.ShowRunLog($"AGV正在装载【{emptyRollerNum}】号空料桶");
  5380. globalVar.agvArriveLineTwoLoadEmptyRoller = false;
  5381. //原料到位,agv到位,agv自行运料到清洗处
  5382. }
  5383. if (globalVar.agvArriveLineTwoLoadCom || globalVar.LineEightRobotTaskError)//上料完成
  5384. {
  5385. if (globalVar.LineEightRobotTaskError)
  5386. DeviceOperate.GetInstance.WritePlcData("D1053", 0);
  5387. if (emptyRollerNum != 0)
  5388. globalVar.rollerLineTwo.EmptyRollerNums.Remove(emptyRollerNum);
  5389. globalVar.agvArriveLineTwoLoadCom = false;
  5390. globalVar.rollerLineTwo.IsEpmtyBefore = false;
  5391. if (emptyRollerNum != 0)
  5392. MessageNotify.GetInstance.ShowRunLog($"AGV在【2】号线体完成【{emptyRollerNum}】号空料桶装载");
  5393. }
  5394. }
  5395. else//有故障
  5396. {
  5397. while (AlarmHelper<AlarmInfo>.GetInstance("2号滚筒线故障").LTwoRollerTrouble == 1)
  5398. {
  5399. Thread.Sleep(1000);
  5400. if (globalVar.ExitLineTwoTask)
  5401. return;
  5402. }
  5403. MessageNotify.GetInstance.ShowRunLog("线体【2】滚筒故障解除,继续运行");
  5404. //lineAlarm = 1;
  5405. goto erp;
  5406. }
  5407. }
  5408. /// <summary>
  5409. /// 处理agv从线体3到送料到炒锅的条件
  5410. /// </summary>
  5411. /// <param name="lineAlarm"></param>
  5412. public void AgvFromLineThreeToFryPot()
  5413. {
  5414. erp: if (AlarmHelper<AlarmInfo>.GetInstance("3号滚筒线故障").LThreeRollerTrouble == 0)//无故障
  5415. {
  5416. if ((globalVar.agvArriveLThreeUpLoad || globalVar.LineThreeRobotTaskError) && globalVar.LThreeLoadRoller && globalVar.rollerLineThree.StationEight == LThreeInputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.LThreeAgvToFryPot)//无故障
  5417. {
  5418. MessageNotify.GetInstance.ShowRunLog("AGV到达【3】号滚筒线装桶位置");
  5419. AgvArriveLineSingelSetDown(LThreeInputMaterialQuene);
  5420. if (LThreeInputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
  5421. {
  5422. MessageNotify.GetInstance.ShowRunLog($"AGV正在装载{materialInfo.materialType.MaterialLoc}号料桶");
  5423. // globalVar.LThreeCurrentCookingStep++;
  5424. LThreeOutputMaterialQuene.Enqueue(materialInfo);
  5425. globalVar.agvArriveLThreeUpLoad = false;
  5426. globalVar.LThreeAgvToFryPot = true;
  5427. //原料到位,agv到位,agv自行运料到炒锅
  5428. }
  5429. }
  5430. }
  5431. else //有故障
  5432. {
  5433. while (AlarmHelper<AlarmInfo>.GetInstance("3号滚筒线故障").LThreeRollerTrouble == 1)
  5434. {
  5435. Thread.Sleep(1000);
  5436. if (globalVar.ExitLineThreeTask)
  5437. return;
  5438. }
  5439. MessageNotify.GetInstance.ShowRunLog("线体【3】滚筒故障解除,继续运行");
  5440. // lineAlarm = 1;
  5441. goto erp;
  5442. }
  5443. }
  5444. /// <summary>
  5445. /// Agv从3号线体运空桶到清洗处
  5446. /// </summary>
  5447. public void AgvFromLineThreeToClean(ushort emptyRollerNum = 0)
  5448. {
  5449. erp: if (AlarmHelper<AlarmInfo>.GetInstance("3号滚筒线故障").LThreeRollerTrouble == 0)//无故障
  5450. {
  5451. if (globalVar.agvArriveLineThreeLoadEmptyRoller)//agv到达上料位置
  5452. {
  5453. MessageNotify.GetInstance.ShowRunLog("AGV到达【3】号滚筒线装桶位置");
  5454. DeviceOperate.GetInstance.WritePlcData("D1054", 1);//agv到达线体3上料位置信号下发plc
  5455. if (emptyRollerNum != 0)
  5456. MessageNotify.GetInstance.ShowRunLog($"AGV正在装载【{emptyRollerNum}】号空料桶");
  5457. globalVar.agvArriveLineThreeLoadEmptyRoller = false;
  5458. // globalVar.rollerLineThree.IsEpmtyBefore = false;
  5459. //原料到位,agv到位,agv自行运料到清洗处
  5460. }
  5461. if (globalVar.agvArriveLineThreeLoadCom || globalVar.LineNineRobotTaskError)//上料完成
  5462. {
  5463. if (globalVar.LineNineRobotTaskError)
  5464. DeviceOperate.GetInstance.WritePlcData("D1054", 0);
  5465. if (emptyRollerNum != 0)
  5466. globalVar.rollerLineThree.EmptyRollerNums.Remove(emptyRollerNum);
  5467. globalVar.agvArriveLineThreeLoadCom = false;
  5468. globalVar.rollerLineThree.IsEpmtyBefore = false;
  5469. if (emptyRollerNum != 0)
  5470. MessageNotify.GetInstance.ShowRunLog($"AGV在【3】号线体完成【{emptyRollerNum}】号空料桶装载");
  5471. }
  5472. }
  5473. else//有故障
  5474. {
  5475. while (AlarmHelper<AlarmInfo>.GetInstance("3号滚筒线故障").LThreeRollerTrouble == 1)
  5476. {
  5477. Thread.Sleep(1000);
  5478. if (globalVar.ExitLineThreeTask)
  5479. return;
  5480. }
  5481. MessageNotify.GetInstance.ShowRunLog("线体【3】滚筒故障解除,继续运行");
  5482. //lineAlarm = 1;
  5483. goto erp;
  5484. }
  5485. }
  5486. /// <summary>
  5487. /// 线体到炒锅搬运任务错误码分析
  5488. /// </summary>
  5489. /// <param name="errorCode"></param>
  5490. /// <param name="num"></param>
  5491. public bool LineCarryTaskErrorCodeAnalysis(string errorCode, int num)
  5492. {
  5493. if (errorCode == "SUCCESS")
  5494. {
  5495. MessageNotify.GetInstance.ShowRunLog($"AGV去{num}号滚筒线装桶");
  5496. return true;
  5497. }
  5498. else if (errorCode == "Analysis Error")
  5499. {
  5500. MessageNotify.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线API调用失败,请检查请求报文");
  5501. return false;
  5502. }
  5503. else
  5504. {
  5505. MessageNotify.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线失败,错误码:{errorCode}");
  5506. return false;
  5507. }
  5508. }
  5509. /// <summary>
  5510. /// 线体到清洗台搬运任务错误码分析
  5511. /// </summary>
  5512. /// <param name="errorCode"></param>
  5513. /// <param name="num"></param>
  5514. public bool LineToCleanCarryTaskErrorCodeAnalysis(string errorCode, int num)
  5515. {
  5516. if (errorCode == "SUCCESS")
  5517. {
  5518. MessageNotify.GetInstance.ShowRunLog($"AGV去{num}号滚筒线装空桶");
  5519. return true;
  5520. }
  5521. else if (errorCode == "Analysis Error")
  5522. {
  5523. MessageNotify.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线API调用失败,请检查请求报文");
  5524. return false;
  5525. }
  5526. else
  5527. {
  5528. MessageNotify.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线失败,错误码:{errorCode}");
  5529. return false;
  5530. }
  5531. }
  5532. /// <summary>
  5533. /// 清洗台到线体搬运任务错误码分析
  5534. /// </summary>
  5535. /// <param name="errorCode"></param>
  5536. /// <param name="num"></param>
  5537. public bool CleanToLineCarryTaskErrorCodeAnalysis(string errorCode, int num)
  5538. {
  5539. if (errorCode == "SUCCESS")
  5540. {
  5541. MessageNotify.GetInstance.ShowRunLog($"AGV从清洗台到{num}号滚筒线卸桶");
  5542. return true;
  5543. }
  5544. else if (errorCode == "Analysis Error")
  5545. {
  5546. MessageNotify.GetInstance.ShowRunLog($"提示:AGV从清洗台到{num}号滚筒线API调用失败,请检查请求报文");
  5547. return false;
  5548. }
  5549. else
  5550. {
  5551. MessageNotify.GetInstance.ShowRunLog($"提示:AGV从清洗台到{num}号滚筒线失败,错误码:{errorCode}");
  5552. return false;
  5553. }
  5554. }
  5555. /// <summary>
  5556. /// 炒锅搬运任务错误码分析
  5557. /// </summary>
  5558. /// <param name="errorCode"></param>
  5559. /// <param name="num"></param>
  5560. public bool FryCarryTaskErrorCodeAnalysis(string errorCode, int num)
  5561. {
  5562. if (errorCode == "SUCCESS")
  5563. {
  5564. MessageNotify.GetInstance.ShowRunLog($"AGV去{num}号炒锅");
  5565. return true;
  5566. }
  5567. else if (errorCode == "Analysis Error")
  5568. {
  5569. MessageNotify.GetInstance.ShowRunLog($"提示:AGV去{num}号炒锅接口调用失败,请检查");
  5570. return false;
  5571. }
  5572. else
  5573. {
  5574. MessageNotify.GetInstance.ShowRunLog($"提示:AGV去{num}号炒锅失败,错误码:{errorCode}");
  5575. return false;
  5576. }
  5577. }
  5578. public void AgvToLineOneLoadRoller()
  5579. {
  5580. if (AlarmHelper<AlarmInfo>.GetInstance("1号滚筒线故障").LOneRollerTrouble == 0)//输送线无故障
  5581. {
  5582. if (InputMaterialQuene.Count > 0 && globalVar.AllowAgvToLineLoadRoller && !globalVar.LoadRoller)
  5583. {
  5584. if (globalVar.rollerLineOne.StationEight == InputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.rollerLineOne.IsEpmtyBefore)//工位8上面是配方料桶
  5585. {
  5586. globalVar.rollerLineOne.CanRun = false;
  5587. e: string id = Guid.NewGuid().ToString("D");//32位
  5588. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  5589. goto e;
  5590. string info;
  5591. if (globalVar.LOneFryPotSerial == 1)
  5592. {
  5593. if (InputMaterialQuene.ElementAt(0).materialType.IsCommonMaterial)
  5594. info = AGVHelper.GetInstance.AgvToLineOneLoadRoller(id,2);
  5595. else
  5596. info = AGVHelper.GetInstance.AgvToLineOneLoadRoller(id);
  5597. }
  5598. else
  5599. {
  5600. if (InputMaterialQuene.ElementAt(0).materialType.IsCommonMaterial)
  5601. info = AGVHelper.GetInstance.AgvFromLineOneToFryFourLoadRoller(id,2);
  5602. else
  5603. info = AGVHelper.GetInstance.AgvFromLineOneToFryFourLoadRoller(id);
  5604. }
  5605. LOnerobotJobId = id;
  5606. if (LineCarryTaskErrorCodeAnalysis(info, 1))
  5607. {
  5608. globalVar.AllowAgvToLineLoadRoller = false;
  5609. globalVar.LoadRoller = true;
  5610. }
  5611. else
  5612. {
  5613. Thread.Sleep(5000);
  5614. }
  5615. }
  5616. //else if (globalVar.rollerLineOne.StationEight != InputMaterialQuene.ElementAt(0).materialType.MaterialLoc)
  5617. //{
  5618. // globalVar.rollerLineOne.CanRun = true;
  5619. //}
  5620. //else // 工位8上面不是配方料桶或没有桶时
  5621. //{
  5622. // if (!globalVar.rollerLineOne.IsEpmtyBefore)
  5623. // {
  5624. // var res = InputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineOne.StationEight);
  5625. // if (res == null && globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0))//工位8上面有桶且不是配方上的原料桶且工位8的桶号和plc上报的桶号一致,即空桶
  5626. // {
  5627. // //下发AGV去空桶线洗桶任务
  5628. // e: string id = Guid.NewGuid().ToString("D");
  5629. // if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId)
  5630. // goto e;
  5631. // string info = AGVHelper.GetInstance.AgvLeaveLOneToClean(id);//1号线到洗桶处
  5632. // LFourrobotJobId = id;
  5633. // Thread.Sleep(500);
  5634. // LineToCleanCarryTaskErrorCodeAnalysis(info, 1);
  5635. // globalVar.rollerLineOne.IsEpmtyBefore = true;
  5636. // AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
  5637. // }
  5638. // }
  5639. // else
  5640. // {
  5641. // AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
  5642. // }
  5643. //}
  5644. }
  5645. }
  5646. //else
  5647. //{
  5648. // MessageLog.GetInstance.ShowRunLog("警告:滚筒输送线体【1】故障!!!");
  5649. // // lineAlarm = -1;
  5650. //}
  5651. //// lineAlarm = 1;
  5652. }
  5653. public void AgvToLineTwoLoadRoller()
  5654. {
  5655. if (AlarmHelper<AlarmInfo>.GetInstance("2号滚筒线故障").LTwoRollerTrouble == 0)//输送线无故障
  5656. {
  5657. if (LTwoInputMaterialQuene.Count > 0 && globalVar.AllowAgvToLineTwoLoadRoller && !globalVar.LTwoLoadRoller)
  5658. {
  5659. if (globalVar.rollerLineTwo.StationEight == LTwoInputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.rollerLineTwo.IsEpmtyBefore)//工位8上面是配方料桶
  5660. {
  5661. globalVar.rollerLineTwo.CanRun = false;
  5662. e: string id = Guid.NewGuid().ToString("D");
  5663. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  5664. goto e;
  5665. string info;
  5666. if (globalVar.LTwoFryPotSerial == 2)
  5667. {
  5668. if (LTwoInputMaterialQuene.ElementAt(0).materialType.IsCommonMaterial)
  5669. info = AGVHelper.GetInstance.AgvToLineTwoLoadRoller(id, 2);
  5670. else
  5671. info = AGVHelper.GetInstance.AgvToLineTwoLoadRoller(id);
  5672. }
  5673. else
  5674. {
  5675. if (LTwoInputMaterialQuene.ElementAt(0).materialType.IsCommonMaterial)
  5676. info = AGVHelper.GetInstance.AgvFromLineTwoToFryFiveLoadRoller(id,2);
  5677. else
  5678. info = AGVHelper.GetInstance.AgvFromLineTwoToFryFiveLoadRoller(id);
  5679. }
  5680. LTworobotJobId = id;
  5681. //Thread.Sleep(500);
  5682. if (LineCarryTaskErrorCodeAnalysis(info, 2))
  5683. {
  5684. globalVar.LTwoLoadRoller = true;
  5685. globalVar.AllowAgvToLineTwoLoadRoller = false;
  5686. }
  5687. else
  5688. {
  5689. Thread.Sleep(5000);
  5690. }
  5691. }
  5692. //else if (globalVar.rollerLineTwo.StationEight != LTwoInputMaterialQuene.ElementAt(0).materialType.MaterialLoc)
  5693. //{
  5694. // globalVar.rollerLineTwo.CanRun = true;
  5695. //}
  5696. }
  5697. //else// 工位8上面不是配方料桶或没有桶时
  5698. //{
  5699. // if (!globalVar.rollerLineTwo.IsEpmtyBefore)
  5700. // {
  5701. // var res = LTwoInputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineTwo.StationEight);
  5702. // if (res == null && globalVar.rollerLineTwo.StationEight != 0 && globalVar.rollerLineTwo.StationEight == globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0))//工位8上面有桶且不是配方上的原料桶,即空桶
  5703. // {
  5704. // //下发AGV去空桶线洗桶任务
  5705. // e: string id = Guid.NewGuid().ToString("D");
  5706. // if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId)
  5707. // goto e;
  5708. // string info = AGVHelper.GetInstance.AgvLeaveLTwoToClean(id);//2号线到洗桶处
  5709. // LFiverobotJobId = id;
  5710. // Thread.Sleep(500);
  5711. // LineToCleanCarryTaskErrorCodeAnalysis(info, 2);
  5712. // globalVar.rollerLineTwo.IsEpmtyBefore = true;
  5713. // AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体2到清洗处
  5714. // }
  5715. // }
  5716. // else
  5717. // {
  5718. // AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
  5719. // }
  5720. //}
  5721. }
  5722. }
  5723. public void AgvToLineThreeLoadRoller()
  5724. {
  5725. if (AlarmHelper<AlarmInfo>.GetInstance("3号滚筒线故障").LThreeRollerTrouble == 0)//输送线无故障
  5726. {
  5727. if (LThreeInputMaterialQuene.Count > 0 && globalVar.AllowAgvToLineThreeLoadRoller && !globalVar.LThreeLoadRoller)
  5728. {
  5729. if (globalVar.rollerLineThree.StationEight == LThreeInputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.rollerLineThree.IsEpmtyBefore)//工位8上面是配方料桶
  5730. {
  5731. globalVar.rollerLineThree.CanRun = false;
  5732. e: string id = Guid.NewGuid().ToString("D");
  5733. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null)
  5734. goto e;
  5735. string info = string.Empty;
  5736. if (LThreeInputMaterialQuene.ElementAt(0).materialType.IsCommonMaterial)
  5737. info = AGVHelper.GetInstance.AgvToLineThreeLoadRoller(id,2);
  5738. else
  5739. info = AGVHelper.GetInstance.AgvToLineThreeLoadRoller(id);
  5740. LThreerobotJobId = id;
  5741. //Thread.Sleep(500);
  5742. if (LineCarryTaskErrorCodeAnalysis(info, 3))
  5743. {
  5744. globalVar.LThreeLoadRoller = true;
  5745. globalVar.AllowAgvToLineThreeLoadRoller = false;
  5746. }
  5747. else
  5748. {
  5749. Thread.Sleep(5000);
  5750. }
  5751. }
  5752. //else if (globalVar.rollerLineThree.StationEight != LThreeInputMaterialQuene.ElementAt(0).materialType.MaterialLoc)
  5753. //{
  5754. // globalVar.rollerLineThree.CanRun = true;
  5755. //}
  5756. //else // 工位8上面不是配方料桶或没有桶时
  5757. //{
  5758. // if (!globalVar.rollerLineThree.IsEpmtyBefore)
  5759. // {
  5760. // var res = LThreeInputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineThree.StationEight);
  5761. // if (res == null && globalVar.rollerLineThree.StationEight != 0 && globalVar.rollerLineThree.StationEight == globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0))//工位8上面有桶且不是配方上的原料桶,即空桶
  5762. // {
  5763. // //下发AGV去空桶线洗桶任务
  5764. // e: string id = Guid.NewGuid().ToString("D");
  5765. // if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId)
  5766. // goto e;
  5767. // string info = AGVHelper.GetInstance.AgvLeaveLThreeToClean(id);//3号线到洗桶处
  5768. // LSixrobotJobId = id;
  5769. // Thread.Sleep(500);
  5770. // LineToCleanCarryTaskErrorCodeAnalysis(info, 3);
  5771. // globalVar.rollerLineThree.IsEpmtyBefore = true;
  5772. // AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处
  5773. // }
  5774. // }
  5775. // else
  5776. // {
  5777. // AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处
  5778. // }
  5779. //}
  5780. }
  5781. }
  5782. //if (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 0)//输送线无故障
  5783. //{
  5784. // if (LThreeInputMaterialQuene.Count > 0)
  5785. // {
  5786. // while (!globalVar.AllowAgvToLineThreeLoadRoller || globalVar.rollerLineThree.OutMaterialingSingle == 0) //后续考虑是否用while
  5787. // {
  5788. // Thread.Sleep(5);
  5789. // if (globalVar.ExitMainTask)
  5790. // return;
  5791. // }
  5792. // g: string id = Guid.NewGuid().ToString();
  5793. // if (id == LThreerobotJobId)
  5794. // goto g;
  5795. // string info = AGVHelper.GetInstance.AgvToLineThreeLoadRoller(id);
  5796. // // MessageLog.GetInstance.ShowRunLog("AGV去【3】号滚筒线装桶");
  5797. // LThreerobotJobId = id;
  5798. // Thread.Sleep(500);
  5799. // LineCarryTaskErrorCodeAnalysis(info, 3);
  5800. // }
  5801. //}
  5802. //else
  5803. //{
  5804. // MessageLog.GetInstance.ShowRunLog("警告:滚筒输送线体【3】故障!!!");
  5805. // // lineAlarm = -1;
  5806. //}
  5807. }
  5808. /// <summary>
  5809. /// 1号线体数据下发
  5810. /// </summary>
  5811. /// <param name="count"></param>
  5812. /// <param name="materialLoc"></param>
  5813. /// <param name="materialWeight"></param>
  5814. public void RollerOneDataWrite(int count, ushort materialLoc, ushort materialWeight, float materialOffset)
  5815. {
  5816. switch (count)
  5817. {
  5818. case 0:
  5819. DeviceOperate.GetInstance.WritePlcData("D1001", materialLoc);//桶1位置
  5820. DeviceOperate.GetInstance.WritePlcData("D1010", materialWeight);//桶1重量
  5821. DeviceOperate.GetInstance.WriteRealPlcData("D1200", materialOffset);//桶重1量偏差
  5822. break;
  5823. case 1:
  5824. DeviceOperate.GetInstance.WritePlcData("D1002", materialLoc);//桶2位置
  5825. DeviceOperate.GetInstance.WritePlcData("D1011", materialWeight);//桶2重量
  5826. DeviceOperate.GetInstance.WriteRealPlcData("D1202", materialOffset);//桶2重量偏差
  5827. break;
  5828. case 2:
  5829. DeviceOperate.GetInstance.WritePlcData("D1003", materialLoc);//桶3位置
  5830. DeviceOperate.GetInstance.WritePlcData("D1012", materialWeight);//桶3重量
  5831. DeviceOperate.GetInstance.WriteRealPlcData("D1204", materialOffset);//桶3重量偏差
  5832. break;
  5833. case 3:
  5834. DeviceOperate.GetInstance.WritePlcData("D1004", materialLoc);//桶4位置
  5835. DeviceOperate.GetInstance.WritePlcData("D1013", materialWeight);//桶4重量
  5836. DeviceOperate.GetInstance.WriteRealPlcData("D1206", materialOffset);//桶4重量偏差
  5837. break;
  5838. case 4:
  5839. DeviceOperate.GetInstance.WritePlcData("D1005", materialLoc);//桶5位置
  5840. DeviceOperate.GetInstance.WritePlcData("D1014", materialWeight);//桶5重量
  5841. DeviceOperate.GetInstance.WriteRealPlcData("D1208", materialOffset);//桶5重量偏差
  5842. break;
  5843. case 5:
  5844. DeviceOperate.GetInstance.WritePlcData("D1006", materialLoc);//桶6位置
  5845. DeviceOperate.GetInstance.WritePlcData("D1015", materialWeight);//桶6重量
  5846. DeviceOperate.GetInstance.WriteRealPlcData("D1210", materialOffset);//桶6重量偏差
  5847. break;
  5848. case 6:
  5849. DeviceOperate.GetInstance.WritePlcData("D1007", materialLoc);//桶7位置
  5850. DeviceOperate.GetInstance.WritePlcData("D1016", materialWeight);//桶7重量
  5851. DeviceOperate.GetInstance.WriteRealPlcData("D1212", materialOffset);//桶7重量偏差
  5852. break;
  5853. case 7:
  5854. DeviceOperate.GetInstance.WritePlcData("D1008", materialLoc);//桶8位置
  5855. DeviceOperate.GetInstance.WritePlcData("D1017", materialWeight);//桶8重量
  5856. DeviceOperate.GetInstance.WriteRealPlcData("D1214", materialOffset);//桶8重量偏差
  5857. break;
  5858. }
  5859. }
  5860. /// <summary>
  5861. /// 2号线体数据下发
  5862. /// </summary>
  5863. /// <param name="count"></param>
  5864. /// <param name="materialLoc"></param>
  5865. /// <param name="materialWeight"></param>
  5866. public void RollerTwoDataWrite(int count, ushort materialLoc, ushort materialWeight, float materialOffset)
  5867. {
  5868. switch (count)
  5869. {
  5870. case 0:
  5871. DeviceOperate.GetInstance.WritePlcData("D1018", materialLoc);//桶1位置
  5872. DeviceOperate.GetInstance.WritePlcData("D1027", materialWeight);//桶2重量
  5873. DeviceOperate.GetInstance.WriteRealPlcData("D1216", materialOffset);//桶重1量偏差
  5874. break;
  5875. case 1:
  5876. DeviceOperate.GetInstance.WritePlcData("D1019", materialLoc);//桶2位置
  5877. DeviceOperate.GetInstance.WritePlcData("D1028", materialWeight);//桶2重量
  5878. DeviceOperate.GetInstance.WriteRealPlcData("D1218", materialOffset);//桶重2量偏差
  5879. break;
  5880. case 2:
  5881. DeviceOperate.GetInstance.WritePlcData("D1020", materialLoc);//桶3位置
  5882. DeviceOperate.GetInstance.WritePlcData("D1029", materialWeight);//桶3重量
  5883. DeviceOperate.GetInstance.WriteRealPlcData("D1220", materialOffset);//桶重3量偏差
  5884. break;
  5885. case 3:
  5886. DeviceOperate.GetInstance.WritePlcData("D1021", materialLoc);//桶4位置
  5887. DeviceOperate.GetInstance.WritePlcData("D1030", materialWeight);//桶4重量
  5888. DeviceOperate.GetInstance.WriteRealPlcData("D1222", materialOffset);//桶重4量偏差
  5889. break;
  5890. case 4:
  5891. DeviceOperate.GetInstance.WritePlcData("D1022", materialLoc);//桶5位置
  5892. DeviceOperate.GetInstance.WritePlcData("D1031", materialWeight);//桶5重量
  5893. DeviceOperate.GetInstance.WriteRealPlcData("D1224", materialOffset);//桶重5量偏差
  5894. break;
  5895. case 5:
  5896. DeviceOperate.GetInstance.WritePlcData("D1023", materialLoc);//桶6位置
  5897. DeviceOperate.GetInstance.WritePlcData("D1032", materialWeight);//桶6重量
  5898. DeviceOperate.GetInstance.WriteRealPlcData("D1226", materialOffset);//桶重6量偏差
  5899. break;
  5900. case 6:
  5901. DeviceOperate.GetInstance.WritePlcData("D1024", materialLoc);//桶7位置
  5902. DeviceOperate.GetInstance.WritePlcData("D1033", materialWeight);//桶7重量
  5903. DeviceOperate.GetInstance.WriteRealPlcData("D1228", materialOffset);//桶重7量偏差
  5904. break;
  5905. case 7:
  5906. DeviceOperate.GetInstance.WritePlcData("D1025", materialLoc);//桶8位置
  5907. DeviceOperate.GetInstance.WritePlcData("D1034", materialWeight);//桶8重量
  5908. DeviceOperate.GetInstance.WriteRealPlcData("D1230", materialOffset);//桶重8量偏差
  5909. break;
  5910. }
  5911. }
  5912. /// <summary>
  5913. /// 3号线体数据下发
  5914. /// </summary>
  5915. /// <param name="count"></param>
  5916. /// <param name="materialLoc"></param>
  5917. /// <param name="materialWeight"></param>
  5918. public void RollerThreeDataWrite(int count, ushort materialLoc, ushort materialWeight, float materialOffset)
  5919. {
  5920. switch (count)
  5921. {
  5922. case 0:
  5923. DeviceOperate.GetInstance.WritePlcData("D1035", materialLoc);//桶1位置
  5924. DeviceOperate.GetInstance.WritePlcData("D1044", materialWeight);//桶1重量
  5925. DeviceOperate.GetInstance.WriteRealPlcData("D1232", materialOffset);//桶重1量偏差
  5926. break;
  5927. case 1:
  5928. DeviceOperate.GetInstance.WritePlcData("D1036", materialLoc);//桶2位置
  5929. DeviceOperate.GetInstance.WritePlcData("D1045", materialWeight);//桶2重量
  5930. DeviceOperate.GetInstance.WriteRealPlcData("D1234", materialOffset);//桶重2量偏差
  5931. break;
  5932. case 2:
  5933. DeviceOperate.GetInstance.WritePlcData("D1037", materialLoc);//桶3位置
  5934. DeviceOperate.GetInstance.WritePlcData("D1046", materialWeight);//桶3重量
  5935. DeviceOperate.GetInstance.WriteRealPlcData("D1236", materialOffset);//桶重3量偏差
  5936. break;
  5937. case 3:
  5938. DeviceOperate.GetInstance.WritePlcData("D1038", materialLoc);//桶4位置
  5939. DeviceOperate.GetInstance.WritePlcData("D1047", materialWeight);//桶4重量
  5940. DeviceOperate.GetInstance.WriteRealPlcData("D1238", materialOffset);//桶重4量偏差
  5941. break;
  5942. case 4:
  5943. DeviceOperate.GetInstance.WritePlcData("D1039", materialLoc);//桶5位置
  5944. DeviceOperate.GetInstance.WritePlcData("D1048", materialWeight);//桶5重量
  5945. DeviceOperate.GetInstance.WriteRealPlcData("D1240", materialOffset);//桶重5量偏差
  5946. break;
  5947. case 5:
  5948. DeviceOperate.GetInstance.WritePlcData("D1040", materialLoc);//桶6位置
  5949. DeviceOperate.GetInstance.WritePlcData("D1049", materialWeight);//桶6重量
  5950. DeviceOperate.GetInstance.WriteRealPlcData("D1242", materialOffset);//桶重6量偏差
  5951. break;
  5952. case 6:
  5953. DeviceOperate.GetInstance.WritePlcData("D1041", materialLoc);//桶7位置
  5954. DeviceOperate.GetInstance.WritePlcData("D1050", materialWeight);//桶7重量
  5955. DeviceOperate.GetInstance.WriteRealPlcData("D1244", materialOffset);//桶重7量偏差
  5956. break;
  5957. case 7:
  5958. DeviceOperate.GetInstance.WritePlcData("D1042", materialLoc);//桶8位置
  5959. DeviceOperate.GetInstance.WritePlcData("D1051", materialWeight);//桶8重量
  5960. DeviceOperate.GetInstance.WriteRealPlcData("D1246", materialOffset);//桶重8量偏差
  5961. break;
  5962. }
  5963. }
  5964. /// <summary>
  5965. /// AGV线体进料就位信号下发至PLC
  5966. /// </summary>
  5967. public void AgvArriveLineSingelSetDown(ConcurrentQueue<MaterialInfo> queue)
  5968. {
  5969. switch (queue.ElementAt(0).materialType.MaterialLoc / 100)
  5970. {
  5971. case 1:
  5972. case 4: DeviceOperate.GetInstance.WritePlcData("D1052", 1); break;//AGV进料就位信号1
  5973. case 2:
  5974. case 5: DeviceOperate.GetInstance.WritePlcData("D1053", 1); break;//AGV进料就位信号2
  5975. case 3: DeviceOperate.GetInstance.WritePlcData("D1054", 1); break;//AGV进料就位信号3
  5976. }
  5977. }
  5978. /// <summary>
  5979. /// 炒锅滚筒信号检测
  5980. /// </summary>
  5981. //public void FryPotRollerTroubleCheck()
  5982. //{
  5983. // FryPotAlarm = 0;
  5984. // FryPotTwoAlarm = 0;
  5985. // FryPotThreeAlarm = 0;
  5986. // FryPotFourAlarm = 0;
  5987. // FryPotFiveAlarm = 0;
  5988. // switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  5989. // {
  5990. // case 1:
  5991. // if (AlarmHelper<AlarmInfo>.Alarm.FryPotOneRollerTrouble == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotOneRollerTrouble == 1)
  5992. // {
  5993. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  5994. // return;
  5995. // }
  5996. // MessageLog.GetInstance.ShowRunLog("炒锅【1】输送滚筒故障解除,继续运行");
  5997. // FryPotAlarm = 1; break;
  5998. // case 2:
  5999. // if (AlarmHelper<AlarmInfo>.Alarm.FryPotTwoRollerTrouble == 1) { FryPotTwoAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【2】输送滚筒发生故障"); } else { FryPotTwoAlarm = 1; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotTwoRollerTrouble == 1)
  6000. // {
  6001. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  6002. // return;
  6003. // }
  6004. // MessageLog.GetInstance.ShowRunLog("炒锅【2】输送滚筒故障解除,继续运行");
  6005. // FryPotTwoAlarm = 1; break;
  6006. // case 3:
  6007. // if (AlarmHelper<AlarmInfo>.Alarm.FryPotThreeRollerTrouble == 1) { FryPotThreeAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【3】输送滚筒发生故障"); } else { FryPotThreeAlarm = 1; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotThreeRollerTrouble == 1)
  6008. // {
  6009. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  6010. // return;
  6011. // }
  6012. // MessageLog.GetInstance.ShowRunLog("炒锅【3】输送滚筒故障解除,继续运行");
  6013. // FryPotThreeAlarm = 1; break;
  6014. // case 4:
  6015. // if (AlarmHelper<AlarmInfo>.Alarm.FryPotFourRollerTrouble == 1) { FryPotFourAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【4】输送滚筒发生故障"); } else { FryPotFourAlarm = 1; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotFourRollerTrouble == 1)
  6016. // {
  6017. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  6018. // return;
  6019. // }
  6020. // MessageLog.GetInstance.ShowRunLog("炒锅【4】输送滚筒故障解除,继续运行");
  6021. // FryPotFourAlarm = 1; break;
  6022. // case 5:
  6023. // if (AlarmHelper<AlarmInfo>.Alarm.FryPotFiveRollerTrouble == 1) { FryPotFiveAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【5】输送滚筒发生故障"); } else { FryPotFiveAlarm = 1; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotFiveRollerTrouble == 1)
  6024. // {
  6025. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  6026. // return;
  6027. // }
  6028. // MessageLog.GetInstance.ShowRunLog("炒锅【5】输送滚筒故障解除,继续运行");
  6029. // FryPotFiveAlarm = 1; break;
  6030. // }
  6031. //}
  6032. /// <summary>
  6033. /// 炒锅1,4滚筒信号检测
  6034. /// </summary>
  6035. public void FryPotOneRollerTroubleCheck()
  6036. {
  6037. FryPotAlarm = 0;
  6038. FryPotFourAlarm = 0;
  6039. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  6040. {
  6041. case 1:
  6042. if (AlarmHelper<AlarmInfo>.GetInstance("1号炒锅滚筒故障").FryPotOneRollerTrouble == 1)
  6043. {
  6044. FryPotAlarm = -1; MessageNotify.GetInstance.ShowRunLog("警告:炒锅【1】输送滚筒发生故障");
  6045. }
  6046. else
  6047. {
  6048. FryPotAlarm = 1; return;
  6049. }
  6050. while (AlarmHelper<AlarmInfo>.GetInstance("1号炒锅滚筒故障").FryPotOneRollerTrouble == 1)
  6051. {
  6052. Thread.Sleep(1000); if (globalVar.ExitLineOneTask)
  6053. return;
  6054. }
  6055. MessageNotify.GetInstance.ShowRunLog("炒锅【1】输送滚筒故障解除,继续运行");
  6056. FryPotAlarm = 1; break;
  6057. case 4:
  6058. if (AlarmHelper<AlarmInfo>.GetInstance("4号炒锅滚筒故障").FryPotFourRollerTrouble == 1) { FryPotFourAlarm = -1; MessageNotify.GetInstance.ShowRunLog("警告:炒锅【4】输送滚筒发生故障"); } else { FryPotFourAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.GetInstance("4号炒锅滚筒故障").FryPotFourRollerTrouble == 1)
  6059. {
  6060. Thread.Sleep(1000); if (globalVar.ExitLineOneTask)
  6061. return;
  6062. }
  6063. MessageNotify.GetInstance.ShowRunLog("炒锅【4】输送滚筒故障解除,继续运行");
  6064. FryPotFourAlarm = 1; break;
  6065. }
  6066. }
  6067. /// <summary>
  6068. /// 炒锅2,5滚筒信号检测
  6069. /// </summary>
  6070. public void FryPotTwoRollerTroubleCheck()
  6071. {
  6072. FryPotTwoAlarm = 0;
  6073. FryPotFiveAlarm = 0;
  6074. switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  6075. {
  6076. case 2:
  6077. if (AlarmHelper<AlarmInfo>.GetInstance("2号炒锅滚筒故障").FryPotTwoRollerTrouble == 1) { FryPotTwoAlarm = -1; MessageNotify.GetInstance.ShowRunLog("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotTwoAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.GetInstance("2号炒锅滚筒故障").FryPotTwoRollerTrouble == 1)
  6078. {
  6079. Thread.Sleep(1000); if (globalVar.ExitLineTwoTask)
  6080. return;
  6081. }
  6082. MessageNotify.GetInstance.ShowRunLog("炒锅【1】输送滚筒故障解除,继续运行");
  6083. FryPotTwoAlarm = 1; break;
  6084. case 5:
  6085. if (AlarmHelper<AlarmInfo>.GetInstance("5号炒锅滚筒故障").FryPotFiveRollerTrouble == 1) { FryPotFiveAlarm = -1; MessageNotify.GetInstance.ShowRunLog("警告:炒锅【4】输送滚筒发生故障"); } else { FryPotFiveAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.GetInstance("5号炒锅滚筒故障").FryPotFiveRollerTrouble == 1)
  6086. {
  6087. Thread.Sleep(1000); if (globalVar.ExitLineTwoTask)
  6088. return;
  6089. }
  6090. MessageNotify.GetInstance.ShowRunLog("炒锅【4】输送滚筒故障解除,继续运行");
  6091. FryPotFiveAlarm = 1; break;
  6092. }
  6093. }
  6094. /// <summary>
  6095. /// 炒锅3滚筒信号检测
  6096. /// </summary>
  6097. public void FryPotThreeRollerTroubleCheck()
  6098. {
  6099. FryPotThreeAlarm = 0;
  6100. if (AlarmHelper<AlarmInfo>.GetInstance("3号炒锅滚筒故障").FryPotThreeRollerTrouble == 1) { FryPotThreeAlarm = -1; MessageNotify.GetInstance.ShowRunLog("警告:炒锅【3】输送滚筒发生故障"); } else { FryPotThreeAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.GetInstance("3号炒锅滚筒故障").FryPotThreeRollerTrouble == 1)
  6101. {
  6102. Thread.Sleep(1000); if (globalVar.ExitLineThreeTask)
  6103. return;
  6104. }
  6105. MessageNotify.GetInstance.ShowRunLog("炒锅【3】输送滚筒故障解除,继续运行");
  6106. FryPotThreeAlarm = 1;
  6107. }
  6108. /// <summary>
  6109. /// PLC线体1配方数据复位功能
  6110. /// </summary>
  6111. public void PlcLineOneRecipeDataReset()
  6112. {
  6113. //复位桶号,桶重,,工序
  6114. WritePlcData("D1001", 0);
  6115. WritePlcData("D1002", 0);
  6116. WritePlcData("D1003", 0);
  6117. WritePlcData("D1004", 0);
  6118. WritePlcData("D1005", 0);
  6119. WritePlcData("D1006", 0);
  6120. WritePlcData("D1007", 0);
  6121. WritePlcData("D1008", 0);
  6122. WritePlcData("D1009", 0);
  6123. WritePlcData("D1010", 0);
  6124. WritePlcData("D1011", 0);
  6125. WritePlcData("D1012", 0);
  6126. WritePlcData("D1013", 0);
  6127. WritePlcData("D1014", 0);
  6128. WritePlcData("D1015", 0);
  6129. WritePlcData("D1016", 0);
  6130. WritePlcData("D1017", 0);
  6131. //桶偏差
  6132. DeviceOperate.GetInstance.WriteRealPlcData("D1200", 0.0F);
  6133. DeviceOperate.GetInstance.WriteRealPlcData("D1202", 0.0F);
  6134. DeviceOperate.GetInstance.WriteRealPlcData("D1204", 0.0F);
  6135. DeviceOperate.GetInstance.WriteRealPlcData("D1206", 0.0F);
  6136. DeviceOperate.GetInstance.WriteRealPlcData("D1208", 0.0F);
  6137. DeviceOperate.GetInstance.WriteRealPlcData("D1210", 0.0F);
  6138. DeviceOperate.GetInstance.WriteRealPlcData("D1212", 0.0F);
  6139. DeviceOperate.GetInstance.WriteRealPlcData("D1214", 0.0F);
  6140. }
  6141. /// <summary>
  6142. /// PLC线体2配方数据复位功能
  6143. /// </summary>
  6144. public void PlcLineTwoRecipeDataReset()
  6145. {
  6146. WritePlcData("D1018", 0);
  6147. WritePlcData("D1019", 0);
  6148. WritePlcData("D1020", 0);
  6149. WritePlcData("D1021", 0);
  6150. WritePlcData("D1022", 0);
  6151. WritePlcData("D1023", 0);
  6152. WritePlcData("D1024", 0);
  6153. WritePlcData("D1025", 0);
  6154. WritePlcData("D1026", 0);
  6155. WritePlcData("D1027", 0);
  6156. WritePlcData("D1028", 0);
  6157. WritePlcData("D1029", 0);
  6158. WritePlcData("D1030", 0);
  6159. WritePlcData("D1031", 0);
  6160. WritePlcData("D1032", 0);
  6161. WritePlcData("D1033", 0);
  6162. WritePlcData("D1034", 0);
  6163. DeviceOperate.GetInstance.WriteRealPlcData("D1216", 0.0F);
  6164. DeviceOperate.GetInstance.WriteRealPlcData("D1218", 0.0F);
  6165. DeviceOperate.GetInstance.WriteRealPlcData("D1220", 0.0F);
  6166. DeviceOperate.GetInstance.WriteRealPlcData("D1222", 0.0F);
  6167. DeviceOperate.GetInstance.WriteRealPlcData("D1224", 0.0F);
  6168. DeviceOperate.GetInstance.WriteRealPlcData("D1226", 0.0F);
  6169. DeviceOperate.GetInstance.WriteRealPlcData("D1228", 0.0F);
  6170. DeviceOperate.GetInstance.WriteRealPlcData("D1230", 0.0F);
  6171. }
  6172. /// <summary>
  6173. /// PLC线体3配方数据复位功能
  6174. /// </summary>
  6175. public void PlcLineThreeRecipeDataReset()
  6176. {
  6177. WritePlcData("D1035", 0);
  6178. WritePlcData("D1036", 0);
  6179. WritePlcData("D1037", 0);
  6180. WritePlcData("D1038", 0);
  6181. WritePlcData("D1039", 0);
  6182. WritePlcData("D1040", 0);
  6183. WritePlcData("D1041", 0);
  6184. WritePlcData("D1042", 0);
  6185. WritePlcData("D1043", 0);
  6186. WritePlcData("D1044", 0);
  6187. WritePlcData("D1045", 0);
  6188. WritePlcData("D1046", 0);
  6189. WritePlcData("D1047", 0);
  6190. WritePlcData("D1048", 0);
  6191. WritePlcData("D1049", 0);
  6192. WritePlcData("D1050", 0);
  6193. WritePlcData("D1051", 0);
  6194. DeviceOperate.GetInstance.WriteRealPlcData("D1232", 0.0F);
  6195. DeviceOperate.GetInstance.WriteRealPlcData("D1234", 0.0F);
  6196. DeviceOperate.GetInstance.WriteRealPlcData("D1236", 0.0F);
  6197. DeviceOperate.GetInstance.WriteRealPlcData("D1238", 0.0F);
  6198. DeviceOperate.GetInstance.WriteRealPlcData("D1240", 0.0F);
  6199. DeviceOperate.GetInstance.WriteRealPlcData("D1242", 0.0F);
  6200. DeviceOperate.GetInstance.WriteRealPlcData("D1244", 0.0F);
  6201. DeviceOperate.GetInstance.WriteRealPlcData("D1246", 0.0F);
  6202. }
  6203. ///// <summary>
  6204. ///// 累加重量计算
  6205. ///// </summary>
  6206. ///// <param name="collect"></param>
  6207. //public ushort SumAllTargetWeight(ObservableCollection<FlowProcessModel> collect,int length)
  6208. //{
  6209. // ushort total = 0;
  6210. // if (collect.Count >= length)
  6211. // {
  6212. // for (int i = 0; i < length; i++)
  6213. // {
  6214. // total += collect.ElementAt(i).TargeWeight;
  6215. // }
  6216. // }
  6217. // return total;
  6218. //}
  6219. /// <summary>
  6220. /// 炒锅配方下发
  6221. /// </summary>
  6222. /// <param name="PotNum"></param>
  6223. /// <param name="result"></param>
  6224. public void FryPotRecipeSetDown(int potNum, NewRecipeModel result)
  6225. {
  6226. lock (Pot_Lock)
  6227. {
  6228. Json<FlowProcessNames>.Read();
  6229. #region 炒锅工艺下发
  6230. int length = 0;
  6231. WritePotData(potNum,"D3920",Convert.ToUInt16(result.FlowProcess.targetWeightOffset*10));//目标重量偏差下发
  6232. WritePotData(potNum, "D3143", Convert.ToUInt16(result.FlowProcess.StirTime));//秘制配方搅拌时间下发
  6233. if (result.FlowProcess.fpModels.FirstOrDefault(p => p.FryMaterialNum == "清洗") != null)
  6234. {
  6235. WritePotData(potNum, "D3120", Convert.ToUInt16(result.FlowProcess.fpModels.Count - 1));//工序数量
  6236. if (result.FlowProcess.fpModels.Count < 12)
  6237. {
  6238. length = result.FlowProcess.fpModels.Count - 1;
  6239. WritePotData(potNum, "D3112", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(result.FlowProcess.fpModels.Count - 1).FryTemperature * 10));
  6240. WritePotData(potNum, "D3113", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(result.FlowProcess.fpModels.Count - 1).FryPeriodTime));
  6241. WritePotData(potNum, "D3114", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(result.FlowProcess.fpModels.Count - 1).FryWeight * 10));//炒制重量
  6242. WritePotData(potNum, "D3115", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(result.FlowProcess.fpModels.Count - 1).SmallFirePercent));
  6243. WritePotData(potNum, "D3116", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(result.FlowProcess.fpModels.Count - 1).MidFirePercent));
  6244. WritePotData(potNum, "D3117", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(result.FlowProcess.fpModels.Count - 1).BigFirePercent));
  6245. WritePotData(potNum, "D3118", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(result.FlowProcess.fpModels.Count - 1).StrongFirePercent));
  6246. WritePotData(potNum, "D3119", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(result.FlowProcess.fpModels.Count - 1).FrySpeed * 10));
  6247. WritePotData(potNum, "D4121", Convert.ToUInt16((result.FlowProcess.fpModels.ElementAt(result.FlowProcess.fpModels.Count - 1).TargeWeight*10)));//清洗目标重量
  6248. }
  6249. else
  6250. {
  6251. length = result.FlowProcess.fpModels.Count;
  6252. }
  6253. }
  6254. else//没有编辑清洗
  6255. {
  6256. length = result.FlowProcess.fpModels.Count;
  6257. WritePotData(potNum, "D3120", Convert.ToUInt16(result.FlowProcess.fpModels.Count));//工序数量
  6258. }
  6259. for (int i = 0; i < length; i++)
  6260. {
  6261. bool can = ushort.TryParse(result.FlowProcess.fpModels.ElementAt(i).FryMaterialNum, out ushort res);
  6262. //按工序下发数据
  6263. #region 工序1
  6264. if (i == 0)
  6265. {
  6266. if (can)//是桶号
  6267. {
  6268. //发送桶号对应的ID以及物料重量
  6269. switch (res % 100)
  6270. {
  6271. case 1: WritePotData(potNum, "D3001", 2); WritePotData(potNum, "D3004", Convert.ToUInt16(result.materialCollection[0].MaterialWeight * 10)); break;
  6272. case 2: WritePotData(potNum, "D3001", 3); WritePotData(potNum, "D3004", Convert.ToUInt16(result.materialCollection[1].MaterialWeight * 10)); break;
  6273. case 3: WritePotData(potNum, "D3001", 4); WritePotData(potNum, "D3004", Convert.ToUInt16(result.materialCollection[2].MaterialWeight * 10)); break;
  6274. case 4: WritePotData(potNum, "D3001", 5); WritePotData(potNum, "D3004", Convert.ToUInt16(result.materialCollection[3].MaterialWeight * 10)); break;
  6275. case 5: WritePotData(potNum, "D3001", 6); WritePotData(potNum, "D3004", Convert.ToUInt16(result.materialCollection[4].MaterialWeight * 10)); break;
  6276. case 6: WritePotData(potNum, "D3001", 7); WritePotData(potNum, "D3004", Convert.ToUInt16(result.materialCollection[5].MaterialWeight * 10)); break;
  6277. case 7: WritePotData(potNum, "D3001", 8); WritePotData(potNum, "D3004", Convert.ToUInt16(result.materialCollection[6].MaterialWeight * 10)); break;
  6278. case 8: WritePotData(potNum, "D3001", 9); WritePotData(potNum, "D3004", Convert.ToUInt16(result.materialCollection[7].MaterialWeight * 10)); break;
  6279. }
  6280. }
  6281. else
  6282. {
  6283. WritePotData(potNum, "D3001", Convert.ToUInt16(Json<FlowProcessNames>.Data.NameId[result.FlowProcess.fpModels.ElementAt(i).FryMaterialNum]));
  6284. WritePotData(potNum, "D3004", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryWeight * 10));//炒制重量
  6285. }
  6286. WritePotData(potNum, "D3002", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryTemperature * 10));
  6287. WritePotData(potNum, "D3003", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryPeriodTime));
  6288. WritePotData(potNum, "D3005", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).SmallFirePercent));
  6289. WritePotData(potNum, "D3006", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).MidFirePercent));
  6290. WritePotData(potNum, "D3007", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).BigFirePercent));
  6291. WritePotData(potNum, "D3008", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).StrongFirePercent));
  6292. WritePotData(potNum, "D3009", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FrySpeed * 10));
  6293. WritePotData(potNum, "D4011", Convert.ToUInt16((result.FlowProcess.fpModels.ElementAt(i).TargeWeight * 10)));//工序1目标重量
  6294. continue;
  6295. }
  6296. #endregion
  6297. #region 工序2
  6298. if (i == 1)
  6299. {
  6300. if (can)//是桶号
  6301. {
  6302. //发送桶号对应的ID以及物料重量
  6303. switch (res % 100)
  6304. {
  6305. case 1: WritePotData(potNum, "D3011", 2); WritePotData(potNum, "D3014", Convert.ToUInt16(result.materialCollection[0].MaterialWeight * 10)); break;
  6306. case 2: WritePotData(potNum, "D3011", 3); WritePotData(potNum, "D3014", Convert.ToUInt16(result.materialCollection[1].MaterialWeight * 10)); break;
  6307. case 3: WritePotData(potNum, "D3011", 4); WritePotData(potNum, "D3014", Convert.ToUInt16(result.materialCollection[2].MaterialWeight * 10)); break;
  6308. case 4: WritePotData(potNum, "D3011", 5); WritePotData(potNum, "D3014", Convert.ToUInt16(result.materialCollection[3].MaterialWeight * 10)); break;
  6309. case 5: WritePotData(potNum, "D3011", 6); WritePotData(potNum, "D3014", Convert.ToUInt16(result.materialCollection[4].MaterialWeight * 10)); break;
  6310. case 6: WritePotData(potNum, "D3011", 7); WritePotData(potNum, "D3014", Convert.ToUInt16(result.materialCollection[5].MaterialWeight * 10)); break;
  6311. case 7: WritePotData(potNum, "D3011", 8); WritePotData(potNum, "D3014", Convert.ToUInt16(result.materialCollection[6].MaterialWeight * 10)); break;
  6312. case 8: WritePotData(potNum, "D3011", 9); WritePotData(potNum, "D3014", Convert.ToUInt16(result.materialCollection[7].MaterialWeight * 10)); break;
  6313. }
  6314. }
  6315. else
  6316. {
  6317. WritePotData(potNum, "D3011", Convert.ToUInt16(Json<FlowProcessNames>.Data.NameId[result.FlowProcess.fpModels.ElementAt(i).FryMaterialNum]));
  6318. WritePotData(potNum, "D3014", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryWeight * 10));//炒制重量
  6319. }
  6320. WritePotData(potNum, "D3012", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryTemperature * 10));
  6321. WritePotData(potNum, "D3013", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryPeriodTime));
  6322. WritePotData(potNum, "D3015", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).SmallFirePercent));
  6323. WritePotData(potNum, "D3016", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).MidFirePercent));
  6324. WritePotData(potNum, "D3017", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).BigFirePercent));
  6325. WritePotData(potNum, "D3018", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).StrongFirePercent));
  6326. WritePotData(potNum, "D3019", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FrySpeed * 10));
  6327. WritePotData(potNum, "D4021", Convert.ToUInt16((result.FlowProcess.fpModels.ElementAt(i).TargeWeight * 10)));//工序2目标重量
  6328. continue;
  6329. }
  6330. #endregion
  6331. #region 工序3
  6332. if (i == 2)
  6333. {
  6334. if (can)//是桶号
  6335. {
  6336. //发送桶号对应的ID以及物料重量
  6337. switch (res % 100)
  6338. {
  6339. case 1: WritePotData(potNum, "D3021", 2); WritePotData(potNum, "D3024", Convert.ToUInt16(result.materialCollection[0].MaterialWeight * 10)); break;
  6340. case 2: WritePotData(potNum, "D3021", 3); WritePotData(potNum, "D3024", Convert.ToUInt16(result.materialCollection[1].MaterialWeight * 10)); break;
  6341. case 3: WritePotData(potNum, "D3021", 4); WritePotData(potNum, "D3024", Convert.ToUInt16(result.materialCollection[2].MaterialWeight * 10)); break;
  6342. case 4: WritePotData(potNum, "D3021", 5); WritePotData(potNum, "D3024", Convert.ToUInt16(result.materialCollection[3].MaterialWeight * 10)); break;
  6343. case 5: WritePotData(potNum, "D3021", 6); WritePotData(potNum, "D3024", Convert.ToUInt16(result.materialCollection[4].MaterialWeight * 10)); break;
  6344. case 6: WritePotData(potNum, "D3021", 7); WritePotData(potNum, "D3024", Convert.ToUInt16(result.materialCollection[5].MaterialWeight * 10)); break;
  6345. case 7: WritePotData(potNum, "D3021", 8); WritePotData(potNum, "D3024", Convert.ToUInt16(result.materialCollection[6].MaterialWeight * 10)); break;
  6346. case 8: WritePotData(potNum, "D3021", 9); WritePotData(potNum, "D3024", Convert.ToUInt16(result.materialCollection[7].MaterialWeight * 10)); break;
  6347. }
  6348. }
  6349. else
  6350. {
  6351. WritePotData(potNum, "D3021", Convert.ToUInt16(Json<FlowProcessNames>.Data.NameId[result.FlowProcess.fpModels.ElementAt(i).FryMaterialNum]));
  6352. WritePotData(potNum, "D3024", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryWeight * 10));//炒制重量
  6353. }
  6354. WritePotData(potNum, "D3022", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryTemperature * 10));
  6355. WritePotData(potNum, "D3023", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryPeriodTime));
  6356. WritePotData(potNum, "D3025", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).SmallFirePercent));
  6357. WritePotData(potNum, "D3026", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).MidFirePercent));
  6358. WritePotData(potNum, "D3027", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).BigFirePercent));
  6359. WritePotData(potNum, "D3028", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).StrongFirePercent));
  6360. WritePotData(potNum, "D3029", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FrySpeed * 10));
  6361. WritePotData(potNum, "D4031", Convert.ToUInt16((result.FlowProcess.fpModels.ElementAt(i).TargeWeight * 10)));//工序3目标重量
  6362. continue;
  6363. }
  6364. #endregion
  6365. #region 工序4
  6366. if (i == 3)
  6367. {
  6368. if (can)//是桶号
  6369. {
  6370. //发送桶号对应的ID以及物料重量
  6371. switch (res % 100)
  6372. {
  6373. case 1: WritePotData(potNum, "D3031", 2); WritePotData(potNum, "D3034", Convert.ToUInt16(result.materialCollection[0].MaterialWeight * 10)); break;
  6374. case 2: WritePotData(potNum, "D3031", 3); WritePotData(potNum, "D3034", Convert.ToUInt16(result.materialCollection[1].MaterialWeight * 10)); break;
  6375. case 3: WritePotData(potNum, "D3031", 4); WritePotData(potNum, "D3034", Convert.ToUInt16(result.materialCollection[2].MaterialWeight * 10)); break;
  6376. case 4: WritePotData(potNum, "D3031", 5); WritePotData(potNum, "D3034", Convert.ToUInt16(result.materialCollection[3].MaterialWeight * 10)); break;
  6377. case 5: WritePotData(potNum, "D3031", 6); WritePotData(potNum, "D3034", Convert.ToUInt16(result.materialCollection[4].MaterialWeight * 10)); break;
  6378. case 6: WritePotData(potNum, "D3031", 7); WritePotData(potNum, "D3034", Convert.ToUInt16(result.materialCollection[5].MaterialWeight * 10)); break;
  6379. case 7: WritePotData(potNum, "D3031", 8); WritePotData(potNum, "D3034", Convert.ToUInt16(result.materialCollection[6].MaterialWeight * 10)); break;
  6380. case 8: WritePotData(potNum, "D3031", 9); WritePotData(potNum, "D3034", Convert.ToUInt16(result.materialCollection[7].MaterialWeight * 10)); break;
  6381. }
  6382. }
  6383. else
  6384. {
  6385. WritePotData(potNum, "D3031", Convert.ToUInt16(Json<FlowProcessNames>.Data.NameId[result.FlowProcess.fpModels.ElementAt(i).FryMaterialNum]));
  6386. WritePotData(potNum, "D3034", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryWeight * 10));//炒制重量
  6387. }
  6388. WritePotData(potNum, "D3032", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryTemperature * 10));
  6389. WritePotData(potNum, "D3033", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryPeriodTime));
  6390. WritePotData(potNum, "D3035", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).SmallFirePercent));
  6391. WritePotData(potNum, "D3036", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).MidFirePercent));
  6392. WritePotData(potNum, "D3037", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).BigFirePercent));
  6393. WritePotData(potNum, "D3038", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).StrongFirePercent));
  6394. WritePotData(potNum, "D3039", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FrySpeed * 10));
  6395. WritePotData(potNum, "D4041", Convert.ToUInt16((result.FlowProcess.fpModels.ElementAt(i).TargeWeight * 10)));//工序4目标重量
  6396. continue;
  6397. }
  6398. #endregion
  6399. #region 工序5
  6400. if (i == 4)
  6401. {
  6402. if (can)//是桶号
  6403. {
  6404. //发送桶号对应的ID以及物料重量
  6405. switch (res % 100)
  6406. {
  6407. case 1: WritePotData(potNum, "D3041", 2); WritePotData(potNum, "D3044", Convert.ToUInt16(result.materialCollection[0].MaterialWeight * 10)); break;
  6408. case 2: WritePotData(potNum, "D3041", 3); WritePotData(potNum, "D3044", Convert.ToUInt16(result.materialCollection[1].MaterialWeight * 10)); break;
  6409. case 3: WritePotData(potNum, "D3041", 4); WritePotData(potNum, "D3044", Convert.ToUInt16(result.materialCollection[2].MaterialWeight * 10)); break;
  6410. case 4: WritePotData(potNum, "D3041", 5); WritePotData(potNum, "D3044", Convert.ToUInt16(result.materialCollection[3].MaterialWeight * 10)); break;
  6411. case 5: WritePotData(potNum, "D3041", 6); WritePotData(potNum, "D3044", Convert.ToUInt16(result.materialCollection[4].MaterialWeight * 10)); break;
  6412. case 6: WritePotData(potNum, "D3041", 7); WritePotData(potNum, "D3044", Convert.ToUInt16(result.materialCollection[5].MaterialWeight * 10)); break;
  6413. case 7: WritePotData(potNum, "D3041", 8); WritePotData(potNum, "D3044", Convert.ToUInt16(result.materialCollection[6].MaterialWeight * 10)); break;
  6414. case 8: WritePotData(potNum, "D3041", 9); WritePotData(potNum, "D3044", Convert.ToUInt16(result.materialCollection[7].MaterialWeight * 10)); break;
  6415. }
  6416. }
  6417. else
  6418. {
  6419. WritePotData(potNum, "D3041", Convert.ToUInt16(Json<FlowProcessNames>.Data.NameId[result.FlowProcess.fpModels.ElementAt(i).FryMaterialNum]));
  6420. WritePotData(potNum, "D3044", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryWeight * 10));//炒制重量
  6421. }
  6422. WritePotData(potNum, "D3042", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryTemperature * 10));
  6423. WritePotData(potNum, "D3043", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryPeriodTime));
  6424. WritePotData(potNum, "D3045", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).SmallFirePercent));
  6425. WritePotData(potNum, "D3046", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).MidFirePercent));
  6426. WritePotData(potNum, "D3047", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).BigFirePercent));
  6427. WritePotData(potNum, "D3048", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).StrongFirePercent));
  6428. WritePotData(potNum, "D3049", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FrySpeed * 10));
  6429. WritePotData(potNum, "D4051", Convert.ToUInt16((result.FlowProcess.fpModels.ElementAt(i).TargeWeight * 10)));//工序5目标重量
  6430. continue;
  6431. }
  6432. #endregion
  6433. #region 工序6
  6434. if (i == 5)
  6435. {
  6436. if (can)//是桶号
  6437. {
  6438. //发送桶号对应的ID以及物料重量
  6439. switch (res % 100)
  6440. {
  6441. case 1: WritePotData(potNum, "D3051", 2); WritePotData(potNum, "D3054", Convert.ToUInt16(result.materialCollection[0].MaterialWeight * 10)); break;
  6442. case 2: WritePotData(potNum, "D3051", 3); WritePotData(potNum, "D3054", Convert.ToUInt16(result.materialCollection[1].MaterialWeight * 10)); break;
  6443. case 3: WritePotData(potNum, "D3051", 4); WritePotData(potNum, "D3054", Convert.ToUInt16(result.materialCollection[2].MaterialWeight * 10)); break;
  6444. case 4: WritePotData(potNum, "D3051", 5); WritePotData(potNum, "D3054", Convert.ToUInt16(result.materialCollection[3].MaterialWeight * 10)); break;
  6445. case 5: WritePotData(potNum, "D3051", 6); WritePotData(potNum, "D3054", Convert.ToUInt16(result.materialCollection[4].MaterialWeight * 10)); break;
  6446. case 6: WritePotData(potNum, "D3051", 7); WritePotData(potNum, "D3054", Convert.ToUInt16(result.materialCollection[5].MaterialWeight * 10)); break;
  6447. case 7: WritePotData(potNum, "D3051", 8); WritePotData(potNum, "D3054", Convert.ToUInt16(result.materialCollection[6].MaterialWeight * 10)); break;
  6448. case 8: WritePotData(potNum, "D3051", 9); WritePotData(potNum, "D3054", Convert.ToUInt16(result.materialCollection[7].MaterialWeight * 10)); break;
  6449. }
  6450. }
  6451. else
  6452. {
  6453. WritePotData(potNum, "D3051", Convert.ToUInt16(Json<FlowProcessNames>.Data.NameId[result.FlowProcess.fpModels.ElementAt(i).FryMaterialNum]));
  6454. WritePotData(potNum, "D3054", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryWeight * 10));//炒制重量
  6455. }
  6456. WritePotData(potNum, "D3052", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryTemperature * 10));
  6457. WritePotData(potNum, "D3053", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryPeriodTime));
  6458. WritePotData(potNum, "D3055", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).SmallFirePercent));
  6459. WritePotData(potNum, "D3056", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).MidFirePercent));
  6460. WritePotData(potNum, "D3057", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).BigFirePercent));
  6461. WritePotData(potNum, "D3058", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).StrongFirePercent));
  6462. WritePotData(potNum, "D3059", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FrySpeed * 10));
  6463. WritePotData(potNum, "D4061", Convert.ToUInt16((result.FlowProcess.fpModels.ElementAt(i).TargeWeight * 10)));//工序6目标重量
  6464. continue;
  6465. }
  6466. #endregion
  6467. #region 工序7
  6468. if (i == 6)
  6469. {
  6470. if (can)//是桶号
  6471. {
  6472. //发送桶号对应的ID以及物料重量
  6473. switch (res % 100)
  6474. {
  6475. case 1: WritePotData(potNum, "D3061", 2); WritePotData(potNum, "D3064", Convert.ToUInt16(result.materialCollection[0].MaterialWeight * 10)); break;
  6476. case 2: WritePotData(potNum, "D3061", 3); WritePotData(potNum, "D3064", Convert.ToUInt16(result.materialCollection[1].MaterialWeight * 10)); break;
  6477. case 3: WritePotData(potNum, "D3061", 4); WritePotData(potNum, "D3064", Convert.ToUInt16(result.materialCollection[2].MaterialWeight * 10)); break;
  6478. case 4: WritePotData(potNum, "D3061", 5); WritePotData(potNum, "D3064", Convert.ToUInt16(result.materialCollection[3].MaterialWeight * 10)); break;
  6479. case 5: WritePotData(potNum, "D3061", 6); WritePotData(potNum, "D3064", Convert.ToUInt16(result.materialCollection[4].MaterialWeight * 10)); break;
  6480. case 6: WritePotData(potNum, "D3061", 7); WritePotData(potNum, "D3064", Convert.ToUInt16(result.materialCollection[5].MaterialWeight * 10)); break;
  6481. case 7: WritePotData(potNum, "D3061", 8); WritePotData(potNum, "D3064", Convert.ToUInt16(result.materialCollection[6].MaterialWeight * 10)); break;
  6482. case 8: WritePotData(potNum, "D3061", 9); WritePotData(potNum, "D3064", Convert.ToUInt16(result.materialCollection[7].MaterialWeight * 10)); break;
  6483. }
  6484. }
  6485. else
  6486. {
  6487. WritePotData(potNum, "D3061", Convert.ToUInt16(Json<FlowProcessNames>.Data.NameId[result.FlowProcess.fpModels.ElementAt(i).FryMaterialNum]));
  6488. WritePotData(potNum, "D3064", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryWeight * 10));//炒制重量
  6489. }
  6490. WritePotData(potNum, "D3062", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryTemperature * 10));
  6491. WritePotData(potNum, "D3063", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryPeriodTime));
  6492. WritePotData(potNum, "D3065", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).SmallFirePercent));
  6493. WritePotData(potNum, "D3066", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).MidFirePercent));
  6494. WritePotData(potNum, "D3067", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).BigFirePercent));
  6495. WritePotData(potNum, "D3068", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).StrongFirePercent));
  6496. WritePotData(potNum, "D3069", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FrySpeed * 10));
  6497. WritePotData(potNum, "D4071", Convert.ToUInt16((result.FlowProcess.fpModels.ElementAt(i).TargeWeight * 10)));//工序7目标重量
  6498. continue;
  6499. }
  6500. #endregion
  6501. #region 工序8
  6502. if (i == 7)
  6503. {
  6504. if (can)//是桶号
  6505. {
  6506. //发送桶号对应的ID以及物料重量
  6507. switch (res % 100)
  6508. {
  6509. case 1: WritePotData(potNum, "D3071", 2); WritePotData(potNum, "D3074", Convert.ToUInt16(result.materialCollection[0].MaterialWeight * 10)); break;
  6510. case 2: WritePotData(potNum, "D3071", 3); WritePotData(potNum, "D3074", Convert.ToUInt16(result.materialCollection[1].MaterialWeight * 10)); break;
  6511. case 3: WritePotData(potNum, "D3071", 4); WritePotData(potNum, "D3074", Convert.ToUInt16(result.materialCollection[2].MaterialWeight * 10)); break;
  6512. case 4: WritePotData(potNum, "D3071", 5); WritePotData(potNum, "D3074", Convert.ToUInt16(result.materialCollection[3].MaterialWeight * 10)); break;
  6513. case 5: WritePotData(potNum, "D3071", 6); WritePotData(potNum, "D3074", Convert.ToUInt16(result.materialCollection[4].MaterialWeight * 10)); break;
  6514. case 6: WritePotData(potNum, "D3071", 7); WritePotData(potNum, "D3074", Convert.ToUInt16(result.materialCollection[5].MaterialWeight * 10)); break;
  6515. case 7: WritePotData(potNum, "D3071", 8); WritePotData(potNum, "D3074", Convert.ToUInt16(result.materialCollection[6].MaterialWeight * 10)); break;
  6516. case 8: WritePotData(potNum, "D3071", 9); WritePotData(potNum, "D3074", Convert.ToUInt16(result.materialCollection[7].MaterialWeight * 10)); break;
  6517. }
  6518. }
  6519. else
  6520. {
  6521. WritePotData(potNum, "D3071", Convert.ToUInt16(Json<FlowProcessNames>.Data.NameId[result.FlowProcess.fpModels.ElementAt(i).FryMaterialNum]));
  6522. WritePotData(potNum, "D3074", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryWeight * 10));//炒制重量
  6523. }
  6524. WritePotData(potNum, "D3072", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryTemperature * 10));
  6525. WritePotData(potNum, "D3073", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryPeriodTime));
  6526. WritePotData(potNum, "D3075", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).SmallFirePercent));
  6527. WritePotData(potNum, "D3076", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).MidFirePercent));
  6528. WritePotData(potNum, "D3077", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).BigFirePercent));
  6529. WritePotData(potNum, "D3078", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).StrongFirePercent));
  6530. WritePotData(potNum, "D3079", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FrySpeed * 10));
  6531. WritePotData(potNum, "D4081", Convert.ToUInt16((result.FlowProcess.fpModels.ElementAt(i).TargeWeight * 10)));//工序8目标重量
  6532. continue;
  6533. }
  6534. #endregion
  6535. #region 工序9
  6536. if (i == 8)
  6537. {
  6538. if (can)//是桶号
  6539. {
  6540. //发送桶号对应的ID以及物料重量
  6541. switch (res % 100)
  6542. {
  6543. case 1: WritePotData(potNum, "D3081", 2); WritePotData(potNum, "D3084", Convert.ToUInt16(result.materialCollection[0].MaterialWeight * 10)); break;
  6544. case 2: WritePotData(potNum, "D3081", 3); WritePotData(potNum, "D3084", Convert.ToUInt16(result.materialCollection[1].MaterialWeight * 10)); break;
  6545. case 3: WritePotData(potNum, "D3081", 4); WritePotData(potNum, "D3084", Convert.ToUInt16(result.materialCollection[2].MaterialWeight * 10)); break;
  6546. case 4: WritePotData(potNum, "D3081", 5); WritePotData(potNum, "D3084", Convert.ToUInt16(result.materialCollection[3].MaterialWeight * 10)); break;
  6547. case 5: WritePotData(potNum, "D3081", 6); WritePotData(potNum, "D3084", Convert.ToUInt16(result.materialCollection[4].MaterialWeight * 10)); break;
  6548. case 6: WritePotData(potNum, "D3081", 7); WritePotData(potNum, "D3084", Convert.ToUInt16(result.materialCollection[5].MaterialWeight * 10)); break;
  6549. case 7: WritePotData(potNum, "D3081", 8); WritePotData(potNum, "D3084", Convert.ToUInt16(result.materialCollection[6].MaterialWeight * 10)); break;
  6550. case 8: WritePotData(potNum, "D3081", 9); WritePotData(potNum, "D3084", Convert.ToUInt16(result.materialCollection[7].MaterialWeight * 10)); break;
  6551. }
  6552. }
  6553. else
  6554. {
  6555. WritePotData(potNum, "D3081", Convert.ToUInt16(Json<FlowProcessNames>.Data.NameId[result.FlowProcess.fpModels.ElementAt(i).FryMaterialNum]));
  6556. WritePotData(potNum, "D3084", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryWeight * 10));//炒制重量
  6557. }
  6558. WritePotData(potNum, "D3082", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryTemperature * 10));
  6559. WritePotData(potNum, "D3083", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryPeriodTime));
  6560. WritePotData(potNum, "D3085", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).SmallFirePercent));
  6561. WritePotData(potNum, "D3086", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).MidFirePercent));
  6562. WritePotData(potNum, "D3087", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).BigFirePercent));
  6563. WritePotData(potNum, "D3088", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).StrongFirePercent));
  6564. WritePotData(potNum, "D3089", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FrySpeed * 10));
  6565. WritePotData(potNum, "D4091", Convert.ToUInt16((result.FlowProcess.fpModels.ElementAt(i).TargeWeight * 10)));//工序9目标重量
  6566. continue;
  6567. }
  6568. #endregion
  6569. #region 工序10
  6570. if (i == 9)
  6571. {
  6572. if (can)//是桶号
  6573. {
  6574. //发送桶号对应的ID以及物料重量
  6575. switch (res % 100)
  6576. {
  6577. case 1: WritePotData(potNum, "D3091", 2); WritePotData(potNum, "D3094", Convert.ToUInt16(result.materialCollection[0].MaterialWeight * 10)); break;
  6578. case 2: WritePotData(potNum, "D3091", 3); WritePotData(potNum, "D3094", Convert.ToUInt16(result.materialCollection[1].MaterialWeight * 10)); break;
  6579. case 3: WritePotData(potNum, "D3091", 4); WritePotData(potNum, "D3094", Convert.ToUInt16(result.materialCollection[2].MaterialWeight * 10)); break;
  6580. case 4: WritePotData(potNum, "D3091", 5); WritePotData(potNum, "D3094", Convert.ToUInt16(result.materialCollection[3].MaterialWeight * 10)); break;
  6581. case 5: WritePotData(potNum, "D3091", 6); WritePotData(potNum, "D3094", Convert.ToUInt16(result.materialCollection[4].MaterialWeight * 10)); break;
  6582. case 6: WritePotData(potNum, "D3091", 7); WritePotData(potNum, "D3094", Convert.ToUInt16(result.materialCollection[5].MaterialWeight * 10)); break;
  6583. case 7: WritePotData(potNum, "D3091", 8); WritePotData(potNum, "D3094", Convert.ToUInt16(result.materialCollection[6].MaterialWeight * 10)); break;
  6584. case 8: WritePotData(potNum, "D3091", 9); WritePotData(potNum, "D3094", Convert.ToUInt16(result.materialCollection[7].MaterialWeight * 10)); break;
  6585. }
  6586. }
  6587. else
  6588. {
  6589. WritePotData(potNum, "D3091", Convert.ToUInt16(Json<FlowProcessNames>.Data.NameId[result.FlowProcess.fpModels.ElementAt(i).FryMaterialNum]));
  6590. WritePotData(potNum, "D3094", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryWeight * 10));//炒制重量
  6591. }
  6592. WritePotData(potNum, "D3092", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryTemperature * 10));
  6593. WritePotData(potNum, "D3093", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryPeriodTime));
  6594. WritePotData(potNum, "D3095", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).SmallFirePercent));
  6595. WritePotData(potNum, "D3096", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).MidFirePercent));
  6596. WritePotData(potNum, "D3097", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).BigFirePercent));
  6597. WritePotData(potNum, "D3098", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).StrongFirePercent));
  6598. WritePotData(potNum, "D3099", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FrySpeed * 10));
  6599. WritePotData(potNum, "D4101", Convert.ToUInt16((result.FlowProcess.fpModels.ElementAt(i).TargeWeight * 10)));//工序10目标重量
  6600. continue;
  6601. }
  6602. #endregion
  6603. #region 工序11
  6604. if (i == 10)
  6605. {
  6606. if (can)//是桶号
  6607. {
  6608. //发送桶号对应的ID以及物料重量
  6609. switch (res % 100)
  6610. {
  6611. case 1: WritePotData(potNum, "D3101", 2); WritePotData(potNum, "D3104", Convert.ToUInt16(result.materialCollection[0].MaterialWeight * 10)); break;
  6612. case 2: WritePotData(potNum, "D3101", 3); WritePotData(potNum, "D3104", Convert.ToUInt16(result.materialCollection[1].MaterialWeight * 10)); break;
  6613. case 3: WritePotData(potNum, "D3101", 4); WritePotData(potNum, "D3104", Convert.ToUInt16(result.materialCollection[2].MaterialWeight * 10)); break;
  6614. case 4: WritePotData(potNum, "D3101", 5); WritePotData(potNum, "D3104", Convert.ToUInt16(result.materialCollection[3].MaterialWeight * 10)); break;
  6615. case 5: WritePotData(potNum, "D3101", 6); WritePotData(potNum, "D3104", Convert.ToUInt16(result.materialCollection[4].MaterialWeight * 10)); break;
  6616. case 6: WritePotData(potNum, "D3101", 7); WritePotData(potNum, "D3104", Convert.ToUInt16(result.materialCollection[5].MaterialWeight * 10)); break;
  6617. case 7: WritePotData(potNum, "D3101", 8); WritePotData(potNum, "D3104", Convert.ToUInt16(result.materialCollection[6].MaterialWeight * 10)); break;
  6618. case 8: WritePotData(potNum, "D3101", 9); WritePotData(potNum, "D3104", Convert.ToUInt16(result.materialCollection[7].MaterialWeight * 10)); break;
  6619. }
  6620. }
  6621. else
  6622. {
  6623. WritePotData(potNum, "D3101", Convert.ToUInt16(Json<FlowProcessNames>.Data.NameId[result.FlowProcess.fpModels.ElementAt(i).FryMaterialNum]));
  6624. WritePotData(potNum, "D3104", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryWeight * 10));//炒制重量
  6625. }
  6626. WritePotData(potNum, "D3102", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryTemperature * 10));
  6627. WritePotData(potNum, "D3103", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryPeriodTime));
  6628. WritePotData(potNum, "D3105", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).SmallFirePercent));
  6629. WritePotData(potNum, "D3106", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).MidFirePercent));
  6630. WritePotData(potNum, "D3107", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).BigFirePercent));
  6631. WritePotData(potNum, "D3108", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).StrongFirePercent));
  6632. WritePotData(potNum, "D3109", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FrySpeed * 10));
  6633. WritePotData(potNum, "D4111", Convert.ToUInt16((result.FlowProcess.fpModels.ElementAt(i).TargeWeight * 10)));//工序11目标重量
  6634. continue;
  6635. }
  6636. #endregion
  6637. #region 工序12
  6638. if (i == 11)
  6639. {
  6640. //if (can)//是桶号
  6641. //{
  6642. // //发送桶号对应的ID以及物料重量
  6643. // switch (res % 100)
  6644. // {
  6645. // case 1: WritePotData(potNum, "D3111", 2); WritePotData(potNum, "D3114", Convert.ToUInt16(result.materialCollection[0].MaterialWeight * 10)); break;
  6646. // case 2: WritePotData(potNum, "D3111", 3); WritePotData(potNum, "D3114", Convert.ToUInt16(result.materialCollection[1].MaterialWeight * 10)); break;
  6647. // case 3: WritePotData(potNum, "D3111", 4); WritePotData(potNum, "D3114", Convert.ToUInt16(result.materialCollection[2].MaterialWeight * 10)); break;
  6648. // case 4: WritePotData(potNum, "D3111", 5); WritePotData(potNum, "D3114", Convert.ToUInt16(result.materialCollection[3].MaterialWeight * 10)); break;
  6649. // case 5: WritePotData(potNum, "D3111", 6); WritePotData(potNum, "D3114", Convert.ToUInt16(result.materialCollection[4].MaterialWeight * 10)); break;
  6650. // case 6: WritePotData(potNum, "D3111", 7); WritePotData(potNum, "D3114", Convert.ToUInt16(result.materialCollection[5].MaterialWeight * 10)); break;
  6651. // case 7: WritePotData(potNum, "D3111", 8); WritePotData(potNum, "D3114", Convert.ToUInt16(result.materialCollection[6].MaterialWeight * 10)); break;
  6652. // case 8: WritePotData(potNum, "D3111", 9); WritePotData(potNum, "D3114", Convert.ToUInt16(result.materialCollection[7].MaterialWeight * 10)); break;
  6653. // }
  6654. //}
  6655. //else
  6656. //{
  6657. //}
  6658. if (result.FlowProcess.fpModels.ElementAt(i).FryMaterialNum == "清洗")
  6659. {
  6660. WritePotData(potNum, "D3112", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryTemperature * 10));
  6661. WritePotData(potNum, "D3113", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryPeriodTime));
  6662. WritePotData(potNum, "D3114", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FryWeight * 10));//炒制重量
  6663. WritePotData(potNum, "D3115", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).SmallFirePercent));
  6664. WritePotData(potNum, "D3116", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).MidFirePercent));
  6665. WritePotData(potNum, "D3117", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).BigFirePercent));
  6666. WritePotData(potNum, "D3118", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).StrongFirePercent));
  6667. WritePotData(potNum, "D3119", Convert.ToUInt16(result.FlowProcess.fpModels.ElementAt(i).FrySpeed * 10));
  6668. WritePotData(potNum, "D4121", Convert.ToUInt16((result.FlowProcess.fpModels.ElementAt(result.FlowProcess.fpModels.Count - 1).TargeWeight * 10)));//清洗目标重量
  6669. }
  6670. continue;
  6671. }
  6672. #endregion
  6673. }
  6674. #endregion
  6675. }
  6676. }
  6677. /// <summary>
  6678. /// 清除炒锅工艺数据
  6679. /// </summary>
  6680. /// <param name="PotNum"></param>
  6681. public void ResetPotData(int PotNum)
  6682. {
  6683. lock (this)
  6684. {
  6685. if (PotNum == 1 || PotNum == 2 || PotNum == 3 || PotNum == 4 || PotNum == 5)
  6686. {
  6687. for (int i = 1; i < 10; i++)
  6688. {
  6689. WritePotData(PotNum, "D300" + i, 0);
  6690. }
  6691. for (int i = 11; i < 20; i++)
  6692. {
  6693. WritePotData(PotNum, "D30" + i, 0);
  6694. }
  6695. for (int i = 21; i < 30; i++)
  6696. {
  6697. WritePotData(PotNum, "D30" + i, 0);
  6698. }
  6699. for (int i = 31; i < 40; i++)
  6700. {
  6701. WritePotData(PotNum, "D30" + i, 0);
  6702. }
  6703. for (int i = 41; i < 50; i++)
  6704. {
  6705. WritePotData(PotNum, "D30" + i, 0);
  6706. }
  6707. for (int i = 51; i < 60; i++)
  6708. {
  6709. WritePotData(PotNum, "D30" + i, 0);
  6710. }
  6711. for (int i = 61; i < 70; i++)
  6712. {
  6713. WritePotData(PotNum, "D30" + i, 0);
  6714. }
  6715. for (int i = 71; i < 80; i++)
  6716. {
  6717. WritePotData(PotNum, "D30" + i, 0);
  6718. }
  6719. for (int i = 81; i < 90; i++)
  6720. {
  6721. WritePotData(PotNum, "D30" + i, 0);
  6722. }
  6723. for (int i = 91; i < 100; i++)
  6724. {
  6725. WritePotData(PotNum, "D30" + i, 0);
  6726. }
  6727. for (int i = 101; i < 110; i++)
  6728. {
  6729. WritePotData(PotNum, "D3" + i, 0);
  6730. }
  6731. #region 目标重量清零
  6732. for (int i = 1; i < 10; i++)
  6733. {
  6734. WritePotData(PotNum, "D40" + i + "1", 0);
  6735. }
  6736. for (int i = 0; i < 3; i++)
  6737. {
  6738. WritePotData(PotNum, "D41" + i + "1", 0);
  6739. }
  6740. #endregion
  6741. WritePotData(PotNum, "D3120", 0);
  6742. WritePotData(PotNum,"D3920",0);//目标重量清零
  6743. WritePotData(PotNum, "D3143", 0);//秘制配方搅拌时间清零
  6744. }
  6745. }
  6746. }
  6747. int PotOnestep = 0;
  6748. int PotFourstep = 0;
  6749. int PotTwostep = 0;
  6750. int PotFivestep = 0;
  6751. int PotThreestep = 0;
  6752. public void LOneFryPotStepDisplay()
  6753. {
  6754. try
  6755. {
  6756. if (PotOnestep != globalVar.fryPotOne.ProcessStep && globalVar.fryPotOne.ProcessStep != 0 && potOneCurrentRecipe != null)
  6757. {
  6758. if (globalVar.fryPotOne.ProcessStep == 20)
  6759. {
  6760. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_1.workflows.Add(new WorkflowModel { id = globalVar.LOneCurrentCookingStep + 1, Name = "正在出料", isBool = IsBool.Yes }); }));
  6761. }
  6762. else
  6763. {
  6764. if (potOneCurrentRecipe.FlowProcess.fpModels.Count > 0 && globalVar.fryPotOne.ProcessStep != 12 && globalVar.fryPotOne.ProcessStep != 13)
  6765. {
  6766. try
  6767. {
  6768. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_1.workflows.Add(new WorkflowModel { id = globalVar.LOneCurrentCookingStep + 1, Name = potOneCurrentRecipe.FlowProcess.fpModels.ElementAt(globalVar.fryPotOne.ProcessStep - 1).FryMaterialNum, isBool = IsBool.Yes }); }));
  6769. }
  6770. catch (Exception)
  6771. {
  6772. //throw;
  6773. }
  6774. }
  6775. else if (globalVar.fryPotOne.ProcessStep == 12)
  6776. {
  6777. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_1.workflows.Add(new WorkflowModel { id = globalVar.LOneCurrentCookingStep + 1, Name = "清洗", isBool = IsBool.Yes }); }));
  6778. }
  6779. globalVar.LOneCurrentCookingStep++;
  6780. }
  6781. PotOnestep = globalVar.fryPotOne.ProcessStep;
  6782. }
  6783. if (PotFourstep != globalVar.fryPotFour.ProcessStep && globalVar.fryPotFour.ProcessStep != 0 && potFourCurrentRecipe != null)
  6784. {
  6785. if (globalVar.fryPotFour.ProcessStep == 20)
  6786. {
  6787. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.workflows.Add(new WorkflowModel { id = globalVar.LFourCurrentCookingStep + 1, Name = "正在出料", isBool = IsBool.Yes }); }));
  6788. }
  6789. else
  6790. {
  6791. if (potFourCurrentRecipe.FlowProcess.fpModels.Count > 0 && globalVar.fryPotFour.ProcessStep != 12 && globalVar.fryPotFour.ProcessStep != 13)
  6792. {
  6793. try
  6794. {
  6795. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.workflows.Add(new WorkflowModel { id = globalVar.LFourCurrentCookingStep + 1, Name = potFourCurrentRecipe.FlowProcess.fpModels.ElementAt(globalVar.fryPotFour.ProcessStep - 1).FryMaterialNum, isBool = IsBool.Yes }); }));
  6796. }
  6797. catch (Exception)
  6798. {
  6799. // throw;
  6800. }
  6801. }
  6802. else if (globalVar.fryPotFour.ProcessStep == 12)
  6803. {
  6804. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.workflows.Add(new WorkflowModel { id = globalVar.LFourCurrentCookingStep + 1, Name = "清洗", isBool = IsBool.Yes }); }));
  6805. }
  6806. globalVar.LFourCurrentCookingStep++;
  6807. }
  6808. PotFourstep = globalVar.fryPotFour.ProcessStep;
  6809. }
  6810. }
  6811. catch (Exception)
  6812. {
  6813. // throw;
  6814. }
  6815. }
  6816. public void LTwoFryPotStepDisplay()
  6817. {
  6818. try
  6819. {
  6820. if (PotTwostep != globalVar.fryPotTwo.ProcessStep && globalVar.fryPotTwo.ProcessStep != 0 && potTwoCurrentRecipe != null)
  6821. {
  6822. if (globalVar.fryPotTwo.ProcessStep == 20)
  6823. {
  6824. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_2.workflows.Add(new WorkflowModel { id = globalVar.LTwoCurrentCookingStep + 1, Name = "正在出料", isBool = IsBool.Yes }); }));
  6825. }
  6826. else
  6827. {
  6828. if (potTwoCurrentRecipe.FlowProcess.fpModels.Count > 0 && globalVar.fryPotTwo.ProcessStep != 12 && globalVar.fryPotTwo.ProcessStep != 13)
  6829. {
  6830. try
  6831. {
  6832. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_2.workflows.Add(new WorkflowModel { id = globalVar.LTwoCurrentCookingStep + 1, Name = potTwoCurrentRecipe.FlowProcess.fpModels.ElementAt(globalVar.fryPotTwo.ProcessStep - 1).FryMaterialNum, isBool = IsBool.Yes }); }));
  6833. }
  6834. catch (Exception)
  6835. {
  6836. //throw;
  6837. }
  6838. }
  6839. else if (globalVar.fryPotTwo.ProcessStep == 12)
  6840. {
  6841. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_2.workflows.Add(new WorkflowModel { id = globalVar.LTwoCurrentCookingStep + 1, Name = "清洗", isBool = IsBool.Yes }); }));
  6842. }
  6843. globalVar.LTwoCurrentCookingStep++;
  6844. }
  6845. PotTwostep = globalVar.fryPotTwo.ProcessStep;
  6846. }
  6847. if (PotFivestep != globalVar.fryPotFive.ProcessStep && globalVar.fryPotFive.ProcessStep != 0 && potFiveCurrentRecipe != null)
  6848. {
  6849. if (globalVar.fryPotFive.ProcessStep == 20)
  6850. {
  6851. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_5.workflows.Add(new WorkflowModel { id = globalVar.LFiveCurrentCookingStep + 1, Name = "正在出料", isBool = IsBool.Yes }); }));
  6852. globalVar.LFiveCurrentCookingStep++;
  6853. }
  6854. else
  6855. {
  6856. if (potFiveCurrentRecipe.FlowProcess.fpModels.Count > 0 && globalVar.fryPotFive.ProcessStep != 12 && globalVar.fryPotFive.ProcessStep != 13)
  6857. {
  6858. try
  6859. {
  6860. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_5.workflows.Add(new WorkflowModel { id = globalVar.LFiveCurrentCookingStep + 1, Name = potFiveCurrentRecipe.FlowProcess.fpModels.ElementAt(globalVar.fryPotFive.ProcessStep - 1).FryMaterialNum, isBool = IsBool.Yes }); }));
  6861. }
  6862. catch (Exception)
  6863. {
  6864. //throw;
  6865. }
  6866. }
  6867. else if (globalVar.fryPotFive.ProcessStep == 12)
  6868. {
  6869. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_5.workflows.Add(new WorkflowModel { id = globalVar.LFiveCurrentCookingStep + 1, Name = "清洗", isBool = IsBool.Yes }); }));
  6870. }
  6871. globalVar.LFiveCurrentCookingStep++;
  6872. }
  6873. PotFivestep = globalVar.fryPotFive.ProcessStep;
  6874. }
  6875. }
  6876. catch (Exception)
  6877. {
  6878. //throw;
  6879. }
  6880. }
  6881. public void LThreeFryPotStepDisplay()
  6882. {
  6883. try
  6884. {
  6885. if (PotThreestep != globalVar.fryPotThree.ProcessStep && globalVar.fryPotThree.ProcessStep != 0 && potThreeCurrentRecipe != null)
  6886. {
  6887. if (globalVar.fryPotThree.ProcessStep == 20)
  6888. {
  6889. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.workflows.Add(new WorkflowModel { id = globalVar.LThreeCurrentCookingStep + 1, Name = "正在出料", isBool = IsBool.Yes }); }));
  6890. }
  6891. else
  6892. {
  6893. if (potThreeCurrentRecipe.FlowProcess.fpModels.Count > 0 && globalVar.fryPotThree.ProcessStep != 12 && globalVar.fryPotThree.ProcessStep != 13)
  6894. {
  6895. try
  6896. {
  6897. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.workflows.Add(new WorkflowModel { id = globalVar.LThreeCurrentCookingStep + 1, Name = potThreeCurrentRecipe.FlowProcess.fpModels.ElementAt(globalVar.fryPotThree.ProcessStep - 1).FryMaterialNum, isBool = IsBool.Yes }); }));
  6898. }
  6899. catch (Exception)
  6900. {
  6901. //throw;
  6902. }
  6903. }
  6904. else if (globalVar.fryPotThree.ProcessStep == 12)
  6905. {
  6906. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.workflows.Add(new WorkflowModel { id = globalVar.LThreeCurrentCookingStep + 1, Name = "清洗", isBool = IsBool.Yes }); }));
  6907. }
  6908. globalVar.LThreeCurrentCookingStep++;
  6909. }
  6910. PotThreestep = globalVar.fryPotThree.ProcessStep;
  6911. }
  6912. }
  6913. catch (Exception)
  6914. {
  6915. //throw;
  6916. }
  6917. }
  6918. }
  6919. }