终端一体化运控平台
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

4134 rader
230 KiB

  1. using BPASmartClient.AGV;
  2. using BPASmartClient.AGV.Enums;
  3. using BPASmartClient.AGV.Feedback;
  4. using BPASmartClient.CustomResource.Pages.Model;
  5. using BPASmartClient.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. namespace FryPot_DosingSystem.Control
  26. {
  27. internal class DosingLogicControl
  28. {
  29. public static DosingLogicControl _instance;
  30. public static DosingLogicControl GetInstance => _instance ??= new DosingLogicControl();
  31. /// <summary>
  32. /// 滚筒线PLC数据
  33. /// </summary>
  34. public ConcurrentDictionary<string, object> PlcReadData = new ConcurrentDictionary<string, object>();
  35. public ConcurrentDictionary<string, object> FryOneData = new ConcurrentDictionary<string, object>();
  36. public ConcurrentDictionary<string, object> FryTwoData = new ConcurrentDictionary<string, object>();
  37. public ConcurrentDictionary<string, object> FryThreeData = new ConcurrentDictionary<string, object>();
  38. public ConcurrentDictionary<string, object> FryFourData = new ConcurrentDictionary<string, object>();
  39. public ConcurrentDictionary<string, object> FryFiveData = new ConcurrentDictionary<string, object>();
  40. /// <summary>
  41. /// 线体1配方队列
  42. /// </summary>
  43. public ConcurrentQueue<NewRecipeModel> RecipeQuene = new ConcurrentQueue<NewRecipeModel>();
  44. /// <summary>
  45. /// 线体2配方队列
  46. /// </summary>
  47. public ConcurrentQueue<NewRecipeModel> LTwoRecipeQuene = new ConcurrentQueue<NewRecipeModel>();
  48. /// <summary>
  49. /// 线体3配方队列
  50. /// </summary>
  51. public ConcurrentQueue<NewRecipeModel> LThreeRecipeQuene = new ConcurrentQueue<NewRecipeModel>();
  52. /// <summary>
  53. /// 线体1进料原料队列
  54. /// </summary>
  55. public ConcurrentQueue<MaterialInfo> InputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  56. /// <summary>
  57. /// 线体2进料原料队列
  58. /// </summary>
  59. public ConcurrentQueue<MaterialInfo> LTwoInputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  60. /// <summary>
  61. /// 线体3进料原料队列
  62. /// </summary>
  63. public ConcurrentQueue<MaterialInfo> LThreeInputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  64. /// <summary>
  65. /// 线体1出料原料队列
  66. /// </summary>
  67. public ConcurrentQueue<MaterialInfo> OutputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  68. /// <summary>
  69. /// 线体2出料原料队列
  70. /// </summary>
  71. public ConcurrentQueue<MaterialInfo> LTwoOutputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  72. /// <summary>
  73. /// 线体3出料原料队列
  74. /// </summary>
  75. public ConcurrentQueue<MaterialInfo> LThreeOutputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  76. /// <summary>
  77. /// 全局变量对象声明
  78. /// </summary>
  79. GlobalVariable globalVar;
  80. /// <summary>
  81. /// 线体状态对象声明
  82. /// </summary>
  83. HardWareStatusViewModel hardWareStatusModel;
  84. ///// <summary>
  85. ///// 炒锅1状态
  86. ///// </summary>
  87. //PotOneStatus fryOne;
  88. ///// <summary>
  89. ///// 炒锅2状态
  90. ///// </summary>
  91. //PotTwoStatus fryTwo;
  92. ///// <summary>
  93. ///// 炒锅3状态
  94. ///// </summary>
  95. //PotThreeStatus fryThree;
  96. ///// <summary>
  97. ///// 炒锅4状态
  98. ///// </summary>
  99. //PotFourStatus fryFour;
  100. ///// <summary>
  101. ///// 炒锅5状态
  102. ///// </summary>
  103. //PotFiveStatus fryFive;
  104. /// <summary>
  105. /// 报警信息对象声明
  106. /// </summary>
  107. #region 上位机内部变量
  108. int FryPotAlarm = 0;//炒锅1滚筒故障信号 1:无故障 -1:故障
  109. int FryPotTwoAlarm = 0;//炒锅2滚筒故障信号 1:无故障 -1:故障
  110. int FryPotThreeAlarm = 0;//炒锅3滚筒故障信号 1:无故障 -1:故障
  111. int FryPotFourAlarm = 0;//炒锅4滚筒故障信号 1:无故障 -1:故障
  112. int FryPotFiveAlarm = 0;//炒锅5滚筒故障信号 1:无故障 -1:故障
  113. int ReicpeNum = 0;//记录接收到的配方数
  114. bool ErrorRecipe;//线体1错误配方标识
  115. bool LTwoErrorRecipe;//线体2错误配方标识
  116. bool LThreeErrorRecipe;//线体3错误配方标识
  117. string fryOneRecipe = string.Empty;
  118. string fryTwoRecipe = string.Empty;
  119. string fryThreeRecipe = string.Empty;
  120. string fryFourRecipe = string.Empty;
  121. string fryFiveRecipe = string.Empty;
  122. #endregion
  123. #region agv临时变量
  124. //bool agvArriveUpLoad = false;//agv是否到达线体1上料位置
  125. //bool agvArriveLTwoUpLoad = false;//agv是否到达线体2上料位置
  126. //bool agvArriveLThreeUpLoad = false;//agv是否到达线体3上料位置
  127. //bool agvArriveUnLoad = false;//线体1 agv是否到达炒锅送料位置
  128. //bool LTwoagvArriveUnLoad = false;//线体2 agv是否到达炒锅送料位置
  129. //bool LThreeagvArriveUnLoad = false;//线体3 agv是否到达炒锅送料位置
  130. //bool agvFryPotEmptyRollerArrive = false;// 线体1的agv是否拿到炒锅空桶
  131. //bool LTwoagvFryPotEmptyRollerArrive = false; //线体2的agv是否拿到炒锅空桶
  132. //bool LThreeagvFryPotEmptyRollerArrive = false;//线体3的agv是否拿到炒锅空桶
  133. string LOnerobotJobId = string.Empty;//线体1当前上游系统任务号,全局唯一 从线体1到炒锅路径
  134. string LTworobotJobId = string.Empty;//线体2当前上游系统任务号,全局唯一 从线体2到炒锅路径
  135. string LThreerobotJobId = string.Empty;//线体3当前上游系统任务号,全局唯一 从线体3到炒锅路径
  136. string LFourrobotJobId = string.Empty;//线体4当前上游系统任务号,全局唯一 从炒锅1、4到线体4路径
  137. string LFiverobotJobId = string.Empty; //从炒锅2、5到线体4路径
  138. string LSixrobotJobId = string.Empty; //从炒锅3到线体4路径
  139. string LSevenrobotJobId = string.Empty; //从线体1到清洗台路径
  140. string LEightrobotJobId = string.Empty; //从线体2到清洗台路径
  141. string LNinerobotJobId = string.Empty; //从线体3到清洗台路径
  142. string LTenrobotJobId = string.Empty; //从清洗台到线体4路径
  143. #endregion
  144. /// <summary>
  145. /// 调试命令注册
  146. /// </summary>
  147. public void CommandRegist()
  148. {
  149. #region 线体空桶清洗及回收调试
  150. ActionManage.GetInstance.Register(new Action(() =>
  151. {
  152. globalVar.agvArriveLineOneLoadEmptyRoller = true;
  153. }), "AgvArriveLineOneEmptyRollerLoc");
  154. ActionManage.GetInstance.Register(new Action(() =>
  155. {
  156. globalVar.agvArriveLineTwoLoadEmptyRoller = true;
  157. }), "AgvArriveLineTwoEmptyRollerLoc");
  158. ActionManage.GetInstance.Register(new Action(() =>
  159. {
  160. globalVar.agvArriveLineThreeLoadEmptyRoller = true;
  161. }), "AgvArriveLineThreeEmptyRollerLoc");
  162. ActionManage.GetInstance.Register(new Action(() =>
  163. {
  164. globalVar.CleanComplete = 1;
  165. }), "CleanPlateCallAgv");
  166. ActionManage.GetInstance.Register(new Action(() =>
  167. {
  168. globalVar.agvArriveCleanUnLoad = true;//清洗台空桶下料就位
  169. }), "AgvArriveCleanPlateLoc");
  170. ActionManage.GetInstance.Register(new Action(() =>
  171. {
  172. globalVar.agvArriveCleanLoad = true;//清洗台空桶上料就位
  173. }), "AgvArriveCleanPlateLocLoad");
  174. ActionManage.GetInstance.Register(new Action(() =>
  175. {
  176. globalVar.agvArriveLineFour = true;
  177. }), "AgvArriveLineFourLoc");
  178. ActionManage.GetInstance.Register(new Action(() =>
  179. {
  180. EmptyRollerCleanTaskRestart();
  181. }), "EmptyRollerCleanTaskRestart");
  182. #endregion
  183. //接口调试
  184. ActionManage.GetInstance.Register(new Action(() =>
  185. {
  186. string id = Guid.NewGuid().ToString();
  187. string errorCode = AGVHelper._Instance.AgvToLineOneLoadRoller(id);
  188. if (errorCode == "SUCCESS")
  189. {
  190. MessageLog.GetInstance.ShowRunLog($"AGV任务下发成功");
  191. }
  192. else if (errorCode == "Analysis Error")
  193. {
  194. MessageLog.GetInstance.ShowRunLog($"提示:AGV 调用API失败,请检查请求报文");
  195. }
  196. else
  197. {
  198. MessageLog.GetInstance.ShowRunLog($"提示:AGV任务下发失败,错误码:{errorCode}");
  199. }
  200. }), "AgvDebug");
  201. ActionManage.GetInstance.Register(new Action(() =>
  202. {
  203. globalVar.agvArriveLineOneLoadCom = true;
  204. }), "AgvLineOneLoadEmptyCom");
  205. ActionManage.GetInstance.Register(new Action(() =>
  206. {
  207. globalVar.agvArriveLineTwoLoadCom = true;
  208. }), "AgvLineTwoLoadEmptyCom");
  209. ActionManage.GetInstance.Register(new Action(() =>
  210. {
  211. globalVar.agvArriveLineThreeLoadCom = true;
  212. }), "AgvLineThreeLoadEmptyCom");
  213. ActionManage.GetInstance.Register(new Action(() =>
  214. {
  215. globalVar.rollerLineOne.CanRun = true;
  216. }), "AGVLineOneLoadCom");
  217. ActionManage.GetInstance.Register(new Action(() =>
  218. {
  219. globalVar.rollerLineTwo.CanRun = true;
  220. }), "AGVLineTwoLoadCom");
  221. ActionManage.GetInstance.Register(new Action(() =>
  222. {
  223. globalVar.rollerLineThree.CanRun = true;
  224. }), "AGVLineThreeLoadCom");
  225. ActionManage.GetInstance.Register(new Action(() =>
  226. {
  227. globalVar.rollerLineOne.OutMaterialingSingle = 1;
  228. }), "RollerLineRunning");
  229. ActionManage.GetInstance.Register(new Action<object>((obj) =>
  230. {
  231. globalVar.rollerLineOne.StationEight = (ushort)obj;
  232. }), "EightWorkLoc");
  233. ActionManage.GetInstance.Register(new Action(() =>
  234. {
  235. globalVar.fryPotOne.InputMaterialArrivedSingle = 1;
  236. globalVar.fryPotFour.InputMaterialArrivedSingle = 1;
  237. }), "FryPotInputArrive");
  238. ActionManage.GetInstance.Register(new Action(() =>
  239. {
  240. globalVar.fryPotOne.EmptyBarrelArrivedSingle = 1;
  241. globalVar.fryPotFour.EmptyBarrelArrivedSingle = 1;
  242. }), "FryPotEmptyRollerArrive");
  243. ActionManage.GetInstance.Register(new Action(() =>
  244. {
  245. globalVar.agvArriveUpLoad = true;
  246. }), "AGVLOneArrive");
  247. ActionManage.GetInstance.Register(new Action(() =>
  248. {
  249. globalVar.agvArriveUnLoad = true;
  250. }), "AGVFryPotDownArrive");
  251. ActionManage.GetInstance.Register(new Action(() =>
  252. {
  253. globalVar.agvArriveUpLoad = true;
  254. }), "AGVFryPotUpArrive");
  255. ActionManage.GetInstance.Register(new Action(() =>
  256. {
  257. globalVar.agvFryPotEmptyRollerArrive = true;
  258. }), "AGVFryPotGetEmptyRoller");
  259. //滚筒线2
  260. ActionManage.GetInstance.Register(new Action(() =>
  261. {
  262. globalVar.rollerLineTwo.OutMaterialingSingle = 1;
  263. }), "RollerLineTwoRunning");
  264. ActionManage.GetInstance.Register(new Action<object>((obj) =>
  265. {
  266. globalVar.rollerLineTwo.StationEight = (ushort)obj;
  267. }), "TwoEightWorkLoc");
  268. ActionManage.GetInstance.Register(new Action(() =>
  269. {
  270. globalVar.fryPotTwo.InputMaterialArrivedSingle = 1;
  271. globalVar.fryPotFive.InputMaterialArrivedSingle = 1;
  272. }), "FryPotTwoInputArrive");
  273. ActionManage.GetInstance.Register(new Action(() =>
  274. {
  275. globalVar.fryPotTwo.EmptyBarrelArrivedSingle = 1;
  276. globalVar.fryPotFive.EmptyBarrelArrivedSingle = 1;
  277. }), "FryPotTwoEmptyRollerArrive");
  278. ActionManage.GetInstance.Register(new Action(() =>
  279. {
  280. globalVar.agvArriveLTwoUpLoad = true;
  281. }), "AGVLTwoArrive");
  282. ActionManage.GetInstance.Register(new Action(() =>
  283. {
  284. globalVar.LTwoagvArriveUnLoad = true;
  285. }), "AGVFryPotTwoDownArrive");
  286. ActionManage.GetInstance.Register(new Action(() =>
  287. {
  288. globalVar.agvArriveLTwoUpLoad = true;
  289. }), "AGVFryPotTwoUpArrive");
  290. ActionManage.GetInstance.Register(new Action(() =>
  291. {
  292. globalVar.LTwoagvFryPotEmptyRollerArrive = true;
  293. }), "AGVFryPotTwoGetEmptyRoller");
  294. //滚筒线3
  295. ActionManage.GetInstance.Register(new Action(() =>
  296. {
  297. globalVar.rollerLineThree.OutMaterialingSingle = 1;
  298. }), "RollerLineThreeRunning");
  299. ActionManage.GetInstance.Register(new Action<object>((obj) =>
  300. {
  301. globalVar.rollerLineThree.StationEight = (ushort)obj;
  302. }), "ThreeEightWorkLoc");
  303. ActionManage.GetInstance.Register(new Action(() =>
  304. {
  305. globalVar.fryPotThree.InputMaterialArrivedSingle = 1;
  306. }), "FryPotThreeInputArrive");
  307. ActionManage.GetInstance.Register(new Action(() =>
  308. {
  309. globalVar.fryPotThree.EmptyBarrelArrivedSingle = 1;
  310. }), "FryPotThreeEmptyRollerArrive");
  311. ActionManage.GetInstance.Register(new Action(() =>
  312. {
  313. globalVar.agvArriveLThreeUpLoad = true;
  314. }), "AGVLThreeArrive");
  315. ActionManage.GetInstance.Register(new Action(() =>
  316. {
  317. globalVar.LThreeagvArriveUnLoad = true;
  318. }), "AGVFryPotThreeDownArrive");
  319. ActionManage.GetInstance.Register(new Action(() =>
  320. {
  321. globalVar.agvArriveLThreeUpLoad = true;
  322. }), "AGVFryPotThreeUpArrive");
  323. ActionManage.GetInstance.Register(new Action(() =>
  324. {
  325. globalVar.LThreeagvFryPotEmptyRollerArrive = true;
  326. }), "AGVFryPotThreeGetEmptyRoller");
  327. }
  328. public DosingLogicControl()
  329. {
  330. globalVar = new GlobalVariable();
  331. //fryOne = new PotOneStatus();
  332. //fryTwo = new PotTwoStatus();
  333. //fryThree = new PotThreeStatus();
  334. //fryFour = new PotFourStatus();
  335. //fryFive = new PotFiveStatus();
  336. hardWareStatusModel = HardWareStatusViewModel.GetInstance;
  337. DateTimeJudge();
  338. FileRegClean();
  339. ActionManage.GetInstance.Register(new Action<object[]>(RecipeDataParse), "RecipeSetDown");
  340. //ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.Clear(); LTwoInputMaterialQuene.Clear(); LTwoOutputMaterialQuene.Clear(); LThreeInputMaterialQuene.Clear(); LThreeOutputMaterialQuene.Clear(); }), "ClearRecipes");
  341. ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.Clear(); }), "ClearOneRecipes");
  342. ActionManage.GetInstance.Register(new Action(() => { LTwoRecipeQuene.Clear(); LTwoInputMaterialQuene.Clear(); LTwoOutputMaterialQuene.Clear(); }), "ClearTwoRecipes");
  343. ActionManage.GetInstance.Register(new Action(() => { LThreeRecipeQuene.Clear(); LThreeInputMaterialQuene.Clear(); LThreeOutputMaterialQuene.Clear(); }), "ClearThreeRecipes");
  344. ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 1; }), "StartPlcInite");
  345. ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 0; }), "EndPlcInite");
  346. ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitLineOneTask = true; LineOneTaskRestart(); }), "LineOneTaskExit");
  347. ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitLineTwoTask = true; LineTwoTaskRestart(); }), "LineTwoTaskExit");
  348. ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitLineThreeTask = true; LineThreeTaskRestart(); }), "LineThreeTaskExit");
  349. HubHelper.GetInstance.Report = new Action<object>(AgvTaskUpReportDataAnalysis);
  350. HubHelper.GetInstance.Upstreamrequest = new Action<object>(AgvFeedBackUpReportDataAnalysis);
  351. // ResetProgram();
  352. ReadPlcData();
  353. SaveFryPotData();
  354. MainTask();
  355. CommandRegist();
  356. }
  357. /// <summary>
  358. /// 文件数据定期清理
  359. /// </summary>
  360. /// <exception cref="NotImplementedException"></exception>
  361. private void FileRegClean()
  362. {
  363. int days = 5; //清除期限
  364. string[] filesOne = Directory.GetFiles("AccessFile//DB//炒锅1状态数据");
  365. if (filesOne.Count() > 0)
  366. {
  367. foreach (var item in filesOne)
  368. {
  369. FileInfo info = new FileInfo(item);
  370. DateTime createTime = info.CreationTime;
  371. DateTime timeNow = DateTime.Now;
  372. if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days)
  373. {
  374. Directory.Delete(item);
  375. }
  376. }
  377. }
  378. string[] filesTwo = Directory.GetFiles("AccessFile//DB//炒锅2状态数据");
  379. if (filesTwo.Count() > 0)
  380. {
  381. foreach (var item in filesTwo)
  382. {
  383. FileInfo info = new FileInfo(item);
  384. DateTime createTime = info.CreationTime;
  385. DateTime timeNow = DateTime.Now;
  386. if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days)
  387. {
  388. Directory.Delete(item);
  389. }
  390. }
  391. }
  392. string[] filesThree = Directory.GetFiles("AccessFile//DB//炒锅3状态数据");
  393. if (filesThree.Count() > 0)
  394. {
  395. foreach (var item in filesThree)
  396. {
  397. FileInfo info = new FileInfo(item);
  398. DateTime createTime = info.CreationTime;
  399. DateTime timeNow = DateTime.Now;
  400. if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days)
  401. {
  402. Directory.Delete(item);
  403. }
  404. }
  405. }
  406. string[] filesFour = Directory.GetFiles("AccessFile//DB//炒锅4状态数据");
  407. if (filesFour.Count() > 0)
  408. {
  409. foreach (var item in filesFour)
  410. {
  411. FileInfo info = new FileInfo(item);
  412. DateTime createTime = info.CreationTime;
  413. DateTime timeNow = DateTime.Now;
  414. if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days)
  415. {
  416. Directory.Delete(item);
  417. }
  418. }
  419. }
  420. string[] filesFive = Directory.GetDirectories("AccessFile//DB//炒锅5状态数据");
  421. if (filesFive.Count() > 0)
  422. {
  423. foreach (var item in filesFive)
  424. {
  425. FileInfo info = new FileInfo(item);
  426. DateTime createTime = info.CreationTime;
  427. DateTime timeNow = DateTime.Now;
  428. if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days)
  429. {
  430. Directory.Delete(item);
  431. }
  432. }
  433. }
  434. }
  435. /// <summary>
  436. /// 时间差计算
  437. /// </summary>
  438. /// <param name="t">当前时间</param>
  439. /// <param name="t2">创建时间</param>
  440. /// <returns></returns>
  441. private int TimeDiff(DateTime t, DateTime t2)
  442. {
  443. long lReturn = -1;
  444. System.TimeSpan NowValue = new TimeSpan(t.Ticks);
  445. System.TimeSpan TimeValue = new TimeSpan(t2.Ticks);
  446. System.TimeSpan DateDiff = TimeSpan.Zero;
  447. try
  448. {
  449. //计算时间差
  450. //DateDiff = TimeValue.Subtract(NowValue).Duration();
  451. DateDiff = NowValue.Subtract(TimeValue);
  452. int h = DateDiff.Hours;
  453. int m = DateDiff.Minutes;
  454. return DateDiff.Days;
  455. }
  456. catch
  457. {
  458. return -1;
  459. }
  460. }
  461. /// <summary>
  462. /// 炒锅数据实时保存
  463. /// </summary>
  464. /// <exception cref="NotImplementedException"></exception>
  465. private void SaveFryPotData()
  466. {
  467. Task.Run(new Action(() =>
  468. {
  469. while (true)
  470. {
  471. FryPotDataSaveToBinaryFile(); Thread.Sleep(1000);
  472. }
  473. }));
  474. }
  475. /// <summary>
  476. /// 时间判断,数据处理
  477. /// </summary>
  478. private void DateTimeJudge()
  479. {
  480. #region sqlite数据库保存
  481. //if (Sqlite<PotOneStatus>.GetInstance.GetData().Count > 0)
  482. //{
  483. // string time1 = Sqlite<PotOneStatus>.GetInstance.GetData().Last().Time;
  484. // if (time1.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样
  485. // {
  486. // FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy = Sqlite<PotOneStatus>.GetInstance.GetData().Last().TotalOilCapactiy;
  487. // FryPotMonitorManage.GetInstance.fryOne.TotalProduct = Sqlite<PotOneStatus>.GetInstance.GetData().Last().TotalProduct;
  488. // }
  489. //}
  490. //if (Sqlite<PotTwoStatus>.GetInstance.GetData().Count > 0)
  491. //{
  492. // string time2 = Sqlite<PotTwoStatus>.GetInstance.GetData().Last().Time;
  493. // if (time2.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样
  494. // {
  495. // FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy = Sqlite<PotTwoStatus>.GetInstance.GetData().Last().TotalOilCapactiy;
  496. // FryPotMonitorManage.GetInstance.fryTwo.TotalProduct = Sqlite<PotTwoStatus>.GetInstance.GetData().Last().TotalProduct;
  497. // }
  498. //}
  499. //if (Sqlite<PotThreeStatus>.GetInstance.GetData().Count > 0)
  500. //{
  501. // string time3 = Sqlite<PotThreeStatus>.GetInstance.GetData().Last().Time;
  502. // if (time3.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样
  503. // {
  504. // FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy = Sqlite<PotThreeStatus>.GetInstance.GetData().Last().TotalOilCapactiy;
  505. // FryPotMonitorManage.GetInstance.fryThree.TotalProduct = Sqlite<PotThreeStatus>.GetInstance.GetData().Last().TotalProduct;
  506. // }
  507. //}
  508. //if (Sqlite<PotFourStatus>.GetInstance.GetData().Count > 0)
  509. //{
  510. // string time4 = Sqlite<PotFourStatus>.GetInstance.GetData().Last().Time;
  511. // if (time4.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样
  512. // {
  513. // FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy = Sqlite<PotFourStatus>.GetInstance.GetData().Last().TotalOilCapactiy;
  514. // FryPotMonitorManage.GetInstance.fryFour.TotalProduct = Sqlite<PotFourStatus>.GetInstance.GetData().Last().TotalProduct;
  515. // }
  516. //}
  517. //if (Sqlite<PotFiveStatus>.GetInstance.GetData().Count > 0)
  518. //{
  519. // string time5 = Sqlite<PotFiveStatus>.GetInstance.GetData().Last().Time;
  520. // if (time5.Equals(DateTime.Now.ToShortDateString()))//和当天时间一样
  521. // {
  522. // FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy = Sqlite<PotFiveStatus>.GetInstance.GetData().Last().TotalOilCapactiy;
  523. // FryPotMonitorManage.GetInstance.fryFive.TotalProduct = Sqlite<PotFiveStatus>.GetInstance.GetData().Last().TotalProduct;
  524. // }
  525. //}
  526. #endregion
  527. string p1 = "AccessFile//" + "Statistic//" + "FryOne.txt";
  528. string p2 = "AccessFile//" + "Statistic//" + "FryTwo.txt";
  529. string p3 = "AccessFile//" + "Statistic//" + "FryThree.txt";
  530. string p4 = "AccessFile//" + "Statistic//" + "FryFour.txt";
  531. string p5 = "AccessFile//" + "Statistic//" + "FryFive.txt";
  532. if (!Directory.Exists("AccessFile//" + "Statistic"))
  533. Directory.CreateDirectory("AccessFile//" + "Statistic");
  534. if (File.Exists(p1))
  535. {
  536. using (StreamReader sReader = new StreamReader(p1, Encoding.UTF8))
  537. {
  538. string time = sReader.ReadLine();
  539. string statistic = sReader.ReadLine();
  540. if (DateTime.Now.ToShortDateString() == time)
  541. {
  542. FryPotMonitorManage.GetInstance.fryOne.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]);
  543. FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]);
  544. }
  545. }
  546. }
  547. if (File.Exists(p2))
  548. {
  549. using (StreamReader sReader = new StreamReader(p2, Encoding.UTF8))
  550. {
  551. string time = sReader.ReadLine();
  552. string statistic = sReader.ReadLine();
  553. if (DateTime.Now.ToShortDateString() == time)
  554. {
  555. FryPotMonitorManage.GetInstance.fryTwo.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]);
  556. FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]);
  557. }
  558. }
  559. }
  560. if (File.Exists(p3))
  561. {
  562. using (StreamReader sReader = new StreamReader(p3, Encoding.UTF8))
  563. {
  564. string time = sReader.ReadLine();
  565. string statistic = sReader.ReadLine();
  566. if (DateTime.Now.ToShortDateString() == time)
  567. {
  568. FryPotMonitorManage.GetInstance.fryThree.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]);
  569. FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]);
  570. }
  571. }
  572. }
  573. if (File.Exists(p4))
  574. {
  575. using (StreamReader sReader = new StreamReader(p4, Encoding.UTF8))
  576. {
  577. string time = sReader.ReadLine();
  578. string statistic = sReader.ReadLine();
  579. if (DateTime.Now.ToShortDateString() == time)
  580. {
  581. FryPotMonitorManage.GetInstance.fryFour.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]);
  582. FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]);
  583. }
  584. }
  585. }
  586. if (File.Exists(p5))
  587. {
  588. using (StreamReader sReader = new StreamReader(p5, Encoding.UTF8))
  589. {
  590. string time = sReader.ReadLine();
  591. string statistic = sReader.ReadLine();
  592. if (DateTime.Now.ToShortDateString() == time)
  593. {
  594. FryPotMonitorManage.GetInstance.fryFive.TotalProduct = Convert.ToInt32(statistic.Split('/')[0]);
  595. FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy = Convert.ToDouble(statistic.Split('/')[1]);
  596. }
  597. }
  598. }
  599. }
  600. /// <summary>
  601. /// AGV上下料上报数据解析
  602. /// </summary>
  603. /// <param name="obj"></param>
  604. private void AgvFeedBackUpReportDataAnalysis(object obj)
  605. {
  606. //if (obj != null && obj is byte[] datas)
  607. //{
  608. //string strData = Encoding.UTF8.GetString(datas);
  609. Upstreamrequest objData = JsonConvert.DeserializeObject<Upstreamrequest>(obj.ToString());
  610. if (objData != null)
  611. {
  612. #region 线体到炒锅
  613. //线体1请求上下料
  614. if (objData.robotJobId == LOnerobotJobId && objData.command == "LOAD")//同一任务号且处于上料阶段,AGV请求上料
  615. {
  616. globalVar.agvArriveUpLoad = true;//AGV到达上料位置
  617. }
  618. if (objData.robotJobId == LOnerobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  619. {
  620. globalVar.agvArriveUnLoad = true;//AGV到达下料位置
  621. }
  622. //线体2请求上下料
  623. if (objData.robotJobId == LTworobotJobId && objData.command == "LOAD")
  624. {
  625. globalVar.agvArriveLTwoUpLoad = true;//AGV到达上料位置
  626. }
  627. if (objData.robotJobId == LTworobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  628. {
  629. globalVar.LTwoagvArriveUnLoad = true;//AGV到达下料位置
  630. }
  631. //线体3请求上下料
  632. if (objData.robotJobId == LThreerobotJobId && objData.command == "LOAD")
  633. {
  634. globalVar.agvArriveLThreeUpLoad = true;//AGV到达上料位置
  635. }
  636. if (objData.robotJobId == LThreerobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  637. {
  638. globalVar.LThreeagvArriveUnLoad = true;//AGV到达下料位置
  639. }
  640. #endregion
  641. #region 炒锅到线体4请求上下料
  642. if (objData.robotJobId == LFourrobotJobId && objData.command == "LOAD")//同一任务号且处于上料阶段,AGV请求上料
  643. {
  644. globalVar.agvArriveUpLoad = true;//AGV到达上料位置
  645. }
  646. if (objData.robotJobId == LFourrobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  647. {
  648. globalVar.agvArriveLineFour = true;//AGV到达下料位置
  649. }
  650. if (objData.robotJobId == LFiverobotJobId && objData.command == "LOAD")
  651. {
  652. globalVar.agvArriveLTwoUpLoad = true;//AGV到达上料位置
  653. }
  654. if (objData.robotJobId == LFiverobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  655. {
  656. globalVar.agvArriveLineFour = true;//AGV到达下料位置
  657. }
  658. if (objData.robotJobId == LSixrobotJobId && objData.command == "LOAD")
  659. {
  660. globalVar.agvArriveLThreeUpLoad = true;//AGV到达上料位置
  661. }
  662. if (objData.robotJobId == LSixrobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  663. {
  664. globalVar.agvArriveLineFour = true;//AGV到达下料位置
  665. }
  666. #endregion
  667. #region 线体到清洗台
  668. if (objData.robotJobId == LSevenrobotJobId && objData.command == "LOAD")//同一任务号且处于上料阶段,AGV请求上料
  669. {
  670. globalVar.agvArriveLineOneLoadEmptyRoller = true;//AGV到达上料位置
  671. }
  672. if (objData.robotJobId == LSevenrobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  673. {
  674. globalVar.agvArriveCleanUnLoad = true;//AGV到达下料位置
  675. }
  676. if (objData.robotJobId == LEightrobotJobId && objData.command == "LOAD")
  677. {
  678. globalVar.agvArriveLineTwoLoadEmptyRoller = true;//AGV到达上料位置
  679. }
  680. if (objData.robotJobId == LEightrobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  681. {
  682. globalVar.agvArriveCleanUnLoad = true;//AGV到达下料位置
  683. }
  684. if (objData.robotJobId == LSixrobotJobId && objData.command == "LOAD")
  685. {
  686. globalVar.agvArriveLineThreeLoadEmptyRoller = true;//AGV到达上料位置
  687. }
  688. if (objData.robotJobId == LSixrobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段
  689. {
  690. globalVar.agvArriveCleanUnLoad = true;//AGV到达下料位置
  691. }
  692. #endregion
  693. if (objData.robotJobId == LTenrobotJobId && objData.command == "LOAD")
  694. {
  695. globalVar.agvArriveCleanLoad = true;//agv到达清洗台下料位置
  696. }
  697. if (objData.robotJobId == LTenrobotJobId && objData.command == "UNLOAD")
  698. {
  699. globalVar.agvArriveLineFour = true;//agv到达清洗台下料位置
  700. }
  701. }
  702. }
  703. /// <summary>
  704. /// AGV搬运任务上报数据解析
  705. /// </summary>
  706. /// <param name="obj"></param>
  707. private void AgvTaskUpReportDataAnalysis(object obj)
  708. {
  709. //if (obj != null && obj is byte[] datas)
  710. //{
  711. // string strData = Encoding.UTF8.GetString(datas);
  712. AGVToUpSystem objData = JsonConvert.DeserializeObject<AGVToUpSystem>(obj.ToString());
  713. if (objData != null)
  714. {
  715. #region 线体上下料任务信息回报
  716. //线体1任务上报
  717. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LOnerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")// AGV正在上料,指线体上料
  718. {
  719. }
  720. //线体2任务上报
  721. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LTworobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")// AGV正在上料,指线体上料
  722. {
  723. //日志
  724. }
  725. //线体3任务上报
  726. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LThreerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")// AGV正在上料,指线体上料
  727. {
  728. //日志
  729. }
  730. //---------------------空桶从线体去清洗-------------------------------//
  731. //线体1任务上报
  732. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LOnerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")// AGV正在上料,指线体空桶上料
  733. {
  734. // globalVar.rollerLineOne.IsEpmtyBefore = false;
  735. }
  736. //线体2任务上报
  737. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LTworobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")// AGV正在上料,指线体空桶上料
  738. {
  739. // globalVar.rollerLineTwo.IsEpmtyBefore = false;
  740. }
  741. //线体3任务上报
  742. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LThreerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")// AGV正在上料,指线体空桶上料
  743. {
  744. // globalVar.rollerLineThree.IsEpmtyBefore = false;
  745. }
  746. //线体1任务上报
  747. if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LOnerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体上料
  748. {
  749. AgvViewModel.GetInstance().Set滚筒线上数量(1, (globalVar.LOneMaterialNum - 1).ToString());
  750. AgvViewModel.GetInstance().Set小车是否承载物品(1, IsBool.Yes);
  751. if (globalVar.LOneFryPotSerial == 1)
  752. {
  753. AgvViewModel.GetInstance().Set小车运动(1, CartMotionTrajectory.yc_1_1);
  754. }
  755. else if (globalVar.LOneFryPotSerial == 4)
  756. {
  757. AgvViewModel.GetInstance().Set小车运动(1, CartMotionTrajectory.yc_1_4);
  758. }
  759. }
  760. //线体2任务上报
  761. if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LTworobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体上料
  762. {
  763. AgvViewModel.GetInstance().Set滚筒线上数量(2, (globalVar.LTwoMaterialNum - 1).ToString());
  764. AgvViewModel.GetInstance().Set小车是否承载物品(2, IsBool.Yes);
  765. if (globalVar.LTwoFryPotSerial == 2)
  766. {
  767. AgvViewModel.GetInstance().Set小车运动(2, CartMotionTrajectory.yc_2_2);
  768. }
  769. else if (globalVar.LTwoFryPotSerial == 5)
  770. {
  771. AgvViewModel.GetInstance().Set小车运动(2, CartMotionTrajectory.yc_2_5);
  772. }
  773. }
  774. //线体3任务上报
  775. if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LThreerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体上料
  776. {
  777. AgvViewModel.GetInstance().Set滚筒线上数量(3, (globalVar.LThreeMaterialNum - 1).ToString());
  778. AgvViewModel.GetInstance().Set小车是否承载物品(3, IsBool.Yes);
  779. AgvViewModel.GetInstance().Set小车运动(3, CartMotionTrajectory.yc_3_3);
  780. }
  781. //线体1任务上报
  782. if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LSevenrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体1空桶上料
  783. {
  784. globalVar.agvArriveLineOneLoadCom = true;
  785. AgvViewModel.GetInstance().Set滚筒线上数量(1, (globalVar.LOneMaterialNum - 1).ToString());
  786. AgvViewModel.GetInstance().Set小车是否承载物品(4, IsBool.OnllYes);
  787. //到清洗处
  788. }
  789. //线体2任务上报
  790. if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LEightrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体2空桶上料
  791. {
  792. globalVar.agvArriveLineTwoLoadCom = true;
  793. AgvViewModel.GetInstance().Set滚筒线上数量(2, (globalVar.LTwoMaterialNum - 1).ToString());
  794. AgvViewModel.GetInstance().Set小车是否承载物品(4, IsBool.OnllYes);
  795. //到清洗处
  796. }
  797. //线体3任务上报
  798. if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LThreerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体3空桶上料
  799. {
  800. globalVar.agvArriveLineThreeLoadCom = true;
  801. AgvViewModel.GetInstance().Set滚筒线上数量(3, (globalVar.LThreeMaterialNum - 1).ToString());
  802. AgvViewModel.GetInstance().Set小车是否承载物品(4, IsBool.OnllYes);
  803. //到清洗处
  804. }
  805. //线体1任务上报
  806. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LOnerobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指线体下料
  807. {
  808. }
  809. //线体2任务上报
  810. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LTworobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指线体下料
  811. {
  812. }
  813. //线体3任务上报
  814. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LThreerobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指线体下料
  815. {
  816. }
  817. //线体1任务上报
  818. if (objData.state == "DONE" && objData.robotJobId == LOnerobotJobId && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指线体下料
  819. {
  820. }
  821. //线体2任务上报
  822. if (objData.state == "DONE" && objData.robotJobId == LTworobotJobId && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指线体下料
  823. {
  824. }
  825. //线体3任务上报
  826. if (objData.state == "DONE" && objData.robotJobId == LThreerobotJobId && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指线体下料
  827. {
  828. }
  829. #endregion
  830. #region 空桶上下料任务信息回报
  831. //线体1任务上报
  832. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LOnerobotJobId && objData.jobData.startPointCode == "")// AGV正在上料,指炒锅空桶上料
  833. {
  834. //日志
  835. }
  836. //线体2任务上报
  837. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LTworobotJobId && objData.jobData.startPointCode == "")// AGV正在上料,指炒锅空桶上料
  838. {
  839. //日志
  840. }
  841. //线体3任务上报
  842. if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LThreerobotJobId && objData.jobData.startPointCode == "")// AGV正在上料,指炒锅空桶上料
  843. {
  844. //日志
  845. }
  846. //线体1任务上报
  847. if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LFourrobotJobId && objData.jobData.startPointCode == "")//指定上料点上料完成,这里指炒锅空桶上料
  848. {
  849. globalVar.agvFryPotEmptyRollerArrive = true;
  850. AgvViewModel.GetInstance().Set小车是否承载物品(1, IsBool.OnllYes);
  851. if (globalVar.LOneFryPotSerial == 1)
  852. {
  853. AgvViewModel.GetInstance().Set小车运动(1, CartMotionTrajectory.hs_1);
  854. }
  855. else if (globalVar.LOneFryPotSerial == 4)
  856. {
  857. AgvViewModel.GetInstance().Set小车运动(1, CartMotionTrajectory.hs_4);
  858. }
  859. }
  860. //线体2任务上报
  861. if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LFiverobotJobId && objData.jobData.startPointCode == "")//指定上料点上料完成,这里指炒锅空桶上料
  862. {
  863. globalVar.LTwoagvFryPotEmptyRollerArrive = true;
  864. AgvViewModel.GetInstance().Set小车是否承载物品(2, IsBool.OnllYes);
  865. if (globalVar.LTwoFryPotSerial == 2)
  866. {
  867. AgvViewModel.GetInstance().Set小车运动(2, CartMotionTrajectory.hs_2);
  868. }
  869. else if (globalVar.LTwoFryPotSerial == 5)
  870. {
  871. AgvViewModel.GetInstance().Set小车运动(2, CartMotionTrajectory.hs_5);
  872. }
  873. }
  874. //线体3任务上报
  875. if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LSixrobotJobId && objData.jobData.startPointCode == "")//指定上料点上料完成,这里指炒锅空桶上料
  876. {
  877. globalVar.LThreeagvFryPotEmptyRollerArrive = true;
  878. AgvViewModel.GetInstance().Set小车是否承载物品(3, IsBool.OnllYes);
  879. AgvViewModel.GetInstance().Set小车运动(3, CartMotionTrajectory.hs_3);
  880. }
  881. //线体1任务上报
  882. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LFourrobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指炒锅空桶下料
  883. {
  884. AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
  885. AgvViewModel.GetInstance().Set小车是否承载物品(1, IsBool.No);
  886. if (globalVar.LFourRollerNum >= 8)
  887. {
  888. AgvViewModel.GetInstance().Set滚筒线上数量(4, "8");
  889. }
  890. else
  891. {
  892. AgvViewModel.GetInstance().Set滚筒线上数量(4, (globalVar.LFourRollerNum + 1).ToString());
  893. }
  894. }
  895. //线体2任务上报
  896. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LFiverobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指炒锅空桶下料
  897. {
  898. AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
  899. AgvViewModel.GetInstance().Set小车是否承载物品(2, IsBool.No);
  900. if (globalVar.LFourRollerNum >= 8)
  901. {
  902. AgvViewModel.GetInstance().Set滚筒线上数量(4, "8");
  903. }
  904. else
  905. {
  906. AgvViewModel.GetInstance().Set滚筒线上数量(4, (globalVar.LFourRollerNum + 1).ToString());
  907. }
  908. }
  909. //线体3任务上报
  910. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LSixrobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指炒锅空桶下料
  911. {
  912. AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
  913. AgvViewModel.GetInstance().Set小车是否承载物品(3, IsBool.No);
  914. if (globalVar.LFourRollerNum >= 8)
  915. {
  916. AgvViewModel.GetInstance().Set滚筒线上数量(4, "8");
  917. }
  918. else
  919. {
  920. AgvViewModel.GetInstance().Set滚筒线上数量(4, (globalVar.LFourRollerNum + 1).ToString());
  921. }
  922. }
  923. //线体1任务上报
  924. if (objData.state == "DONE" && objData.robotJobId == LFourrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指炒锅空桶下料
  925. {
  926. // globalVar.EmptyRollerUnLoadcCom = true;
  927. AgvViewModel.GetInstance().Set小车运动(1, AgvViewModel.GetInstance().GetCommandValue("hj"));
  928. AgvViewModel.GetInstance().Set小车停止(1);
  929. AgvViewModel.GetInstance().Set停车桩(1, IsBool.Yes);
  930. }
  931. //线体2任务上报
  932. if (objData.state == "DONE" && objData.robotJobId == LFiverobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指炒锅空桶下料
  933. {
  934. // globalVar.EmptyRollerUnLoadcCom = true;
  935. AgvViewModel.GetInstance().Set小车运动(2, AgvViewModel.GetInstance().GetCommandValue("hj"));
  936. AgvViewModel.GetInstance().Set小车停止(2);
  937. AgvViewModel.GetInstance().Set停车桩(2, IsBool.Yes);
  938. }
  939. //线体3任务上报
  940. if (objData.state == "DONE" && objData.robotJobId == LSixrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指炒锅空桶下料
  941. {
  942. // globalVar.EmptyRollerUnLoadcCom = true;
  943. AgvViewModel.GetInstance().Set小车运动(3, AgvViewModel.GetInstance().GetCommandValue("hj"));
  944. AgvViewModel.GetInstance().Set小车停止(3);
  945. AgvViewModel.GetInstance().Set停车桩(3, IsBool.Yes);
  946. }
  947. if (objData.state == "DONE" && objData.robotJobId == LSevenrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指从线体1到清戏台空桶下料
  948. {
  949. AgvViewModel.GetInstance().Set小车运动(4, AgvViewModel.GetInstance().GetCommandValue("hj"));
  950. AgvViewModel.GetInstance().Set小车停止(4);
  951. AgvViewModel.GetInstance().Set停车桩(4, IsBool.Yes);
  952. }
  953. if (objData.state == "DONE" && objData.robotJobId == LEightrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指从线体2到清戏台空桶下料
  954. {
  955. AgvViewModel.GetInstance().Set小车运动(4, AgvViewModel.GetInstance().GetCommandValue("hj"));
  956. AgvViewModel.GetInstance().Set小车停止(4);
  957. AgvViewModel.GetInstance().Set停车桩(4, IsBool.Yes);
  958. }
  959. if (objData.state == "DONE" && objData.robotJobId == LNinerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指从线体3到清戏台空桶下料
  960. {
  961. AgvViewModel.GetInstance().Set小车运动(4, AgvViewModel.GetInstance().GetCommandValue("hj"));
  962. AgvViewModel.GetInstance().Set小车停止(4);
  963. AgvViewModel.GetInstance().Set停车桩(4, IsBool.Yes);
  964. }
  965. if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LTenrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料位置上料完成,指清戏台空桶到上料
  966. {
  967. AgvViewModel.GetInstance().Set小车是否承载物品(4, IsBool.OnllYes);
  968. AgvViewModel.GetInstance().Set小车运动(4, CartMotionTrajectory.hs_4);//去四号空桶线
  969. }
  970. if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LTenrobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指清洗台空桶到线体4下料
  971. {
  972. AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start);
  973. AgvViewModel.GetInstance().Set小车是否承载物品(4, IsBool.No);
  974. if (globalVar.LFourRollerNum >= 8)
  975. {
  976. AgvViewModel.GetInstance().Set滚筒线上数量(4, "8");
  977. }
  978. else
  979. {
  980. AgvViewModel.GetInstance().Set滚筒线上数量(4, (globalVar.LFourRollerNum + 1).ToString());
  981. }
  982. }
  983. if (objData.state == "DONE" && objData.robotJobId == LTenrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指清戏台空桶到线体4下料
  984. {
  985. AgvViewModel.GetInstance().Set小车运动(4, AgvViewModel.GetInstance().GetCommandValue("hj"));
  986. AgvViewModel.GetInstance().Set小车停止(4);
  987. AgvViewModel.GetInstance().Set停车桩(4, IsBool.Yes);
  988. }
  989. #endregion
  990. }
  991. }
  992. /// <summary>
  993. /// 主任务重启
  994. /// </summary>
  995. private void ResetProgram()
  996. {
  997. ThreadManage.GetInstance().StartLong(new Action(() =>
  998. {
  999. if (RTrig.GetInstance("ResetProgram").Start(globalVar.PlcInite == 1))//判断是否初始化 一初始化就重启主任务
  1000. {
  1001. MessageLog.GetInstance.ShowUserLog("主任务正在重启");
  1002. ThreadManage.GetInstance().StopTask("MainViewReadPlcData", new Action(() =>
  1003. {
  1004. //ActionManage.GetInstance.CancelRegister("RecipeSetDown");
  1005. //ActionManage.GetInstance.Register(new Action<object>(RecipeDataParse), "RecipeSetDown");
  1006. // ActionManage.GetInstance.Send("ClearRecipes");
  1007. ThreadManage.GetInstance().StopTask("滚筒线1任务线程", new Action(() =>
  1008. {
  1009. ThreadManage.GetInstance().StopTask("滚筒线2任务线程", new Action(() =>
  1010. {
  1011. ThreadManage.GetInstance().StopTask("滚筒线3任务线程", new Action(() =>
  1012. {
  1013. globalVar = null;
  1014. globalVar = new GlobalVariable();
  1015. ReicpeNum = 0;
  1016. ReadPlcData();
  1017. MainTask();
  1018. MessageLog.GetInstance.ShowUserLog("主任务重启完成");
  1019. }));
  1020. }));
  1021. }));
  1022. }));
  1023. }
  1024. Thread.Sleep(10);
  1025. }), "ResetProgram");
  1026. }
  1027. public void LineOneTaskRestart()
  1028. {
  1029. ThreadManage.GetInstance().StopTask("滚筒线1任务线程", new Action(() =>
  1030. {
  1031. ActionManage.GetInstance.Send("ClearOneRecipes");
  1032. globalVar.rollerLineOne = null;
  1033. globalVar.rollerLineOne = new RollerLineOne();
  1034. globalVar.fryPotOne = null;
  1035. globalVar.fryPotOne = new FryPotOne();
  1036. globalVar.fryPotFour = null;
  1037. globalVar.fryPotFour = new FryPotFour();
  1038. globalVar.ExitLineOneTask = false;
  1039. globalVar.AllowAgvToLineLoadRoller = true;
  1040. globalVar.InOrOutputLock = false;
  1041. globalVar.LOneCurrentRecipeName = string.Empty;
  1042. globalVar.LoadRoller = false;
  1043. globalVar.AgvToFryPot = false;
  1044. globalVar.PotOneInputMaterialArrive = false;
  1045. globalVar.PotOneOutputRollerArrive = false;
  1046. globalVar.AgvArrivePot = false;
  1047. globalVar.LOneMaterialNum = 0;
  1048. globalVar.LOneFryPotSerial = 1;
  1049. globalVar.LOneCurrentCookingStep = 0;
  1050. globalVar.agvArriveUpLoad = false;
  1051. globalVar.agvArriveUnLoad = false;
  1052. globalVar.agvFryPotEmptyRollerArrive = false;
  1053. globalVar.agvLineOneLoadCom = false;
  1054. ThreadManage.GetInstance().StartLong(new Action(() => { LineOneProcessExecute(); Thread.Sleep(10); }), "滚筒线1任务线程");
  1055. MessageLog.GetInstance.ShowUserLog("滚筒线【1】任务重启成功");
  1056. }));
  1057. }
  1058. public void LineTwoTaskRestart()
  1059. {
  1060. ThreadManage.GetInstance().StopTask("滚筒线2任务线程", new Action(() =>
  1061. {
  1062. ActionManage.GetInstance.Send("ClearTwoRecipes");
  1063. globalVar.rollerLineTwo = null;
  1064. globalVar.rollerLineTwo = new RollerLineTwo();
  1065. globalVar.fryPotTwo = null;
  1066. globalVar.fryPotTwo = new FryPotTwo();
  1067. globalVar.fryPotFive = null;
  1068. globalVar.fryPotFive = new FryPotFive();
  1069. globalVar.ExitLineTwoTask = false;
  1070. globalVar.AllowAgvToLineTwoLoadRoller = true;
  1071. globalVar.LTwoInOrOutputLock = false;
  1072. globalVar.LTwoCurrentRecipeName = string.Empty;
  1073. globalVar.LTwoLoadRoller = false;
  1074. globalVar.LTwoAgvToFryPot = false;
  1075. globalVar.LTwoPotInputMaterialArrive = false;
  1076. globalVar.LTwoPotOutputRollerArrive = false;
  1077. globalVar.LTwoAgvArrivePot = false;
  1078. globalVar.LTwoMaterialNum = 0;
  1079. globalVar.LTwoFryPotSerial = 2;
  1080. globalVar.LTwoCurrentCookingStep = 0;
  1081. globalVar.agvArriveLTwoUpLoad = false;
  1082. globalVar.LTwoagvArriveUnLoad = false;
  1083. globalVar.LTwoagvFryPotEmptyRollerArrive = false;
  1084. globalVar.agvLineTwoLoadCom = false;
  1085. ThreadManage.GetInstance().StartLong(new Action(() => { LineTwoProcessExecute(); Thread.Sleep(10); }), "滚筒线2任务线程");
  1086. MessageLog.GetInstance.ShowUserLog("滚筒线【2】任务重启成功");
  1087. }));
  1088. }
  1089. public void LineThreeTaskRestart()
  1090. {
  1091. ThreadManage.GetInstance().StopTask("滚筒线3任务线程", new Action(() =>
  1092. {
  1093. ActionManage.GetInstance.Send("ClearThreeRecipes");
  1094. globalVar.rollerLineThree = null;
  1095. globalVar.rollerLineThree = new RollerLineThree();
  1096. globalVar.fryPotThree = null;
  1097. globalVar.fryPotThree = new FryPotThree();
  1098. globalVar.ExitLineThreeTask = false;
  1099. globalVar.AllowAgvToLineThreeLoadRoller = true;
  1100. globalVar.LThreeInOrOutputLock = false;
  1101. globalVar.LThreeCurrentRecipeName = string.Empty;
  1102. globalVar.LThreeLoadRoller = false;
  1103. globalVar.LThreeAgvToFryPot = false;
  1104. globalVar.LThreePotInputMaterialArrive = false;
  1105. globalVar.LThreePotOutputRollerArrive = false;
  1106. globalVar.LThreeAgvArrivePot = false;
  1107. globalVar.LThreeMaterialNum = 0;
  1108. globalVar.LThreeFryPotSerial = 3;
  1109. globalVar.LThreeCurrentCookingStep = 0;
  1110. globalVar.agvArriveLThreeUpLoad = false;
  1111. globalVar.LThreeagvArriveUnLoad = false;
  1112. globalVar.LThreeagvFryPotEmptyRollerArrive = false;
  1113. globalVar.agvLineThreeLoadCom = false;
  1114. ThreadManage.GetInstance().StartLong(new Action(() => { LineThreeProcessExecute(); Thread.Sleep(10); }), "滚筒线3任务线程");
  1115. MessageLog.GetInstance.ShowUserLog("滚筒线【3】任务重启成功");
  1116. }));
  1117. }
  1118. public void EmptyRollerCleanTaskRestart()
  1119. {
  1120. ThreadManage.GetInstance().StopTask("空桶清洗任务线程", new Action(() =>
  1121. {
  1122. globalVar.rollerLineOne.StationEight = 0;
  1123. globalVar.rollerLineOne.EmptyRollerNums.Clear();
  1124. globalVar.rollerLineOne.EmptyRollerNums.Add(108);
  1125. globalVar.rollerLineOne.IsEpmtyBefore = false;
  1126. // globalVar.rollerLineOne.CanRun = true;
  1127. globalVar.rollerLineTwo.StationEight = 0;
  1128. globalVar.rollerLineTwo.EmptyRollerNums.Clear();
  1129. globalVar.rollerLineTwo.EmptyRollerNums.Add(208);
  1130. globalVar.rollerLineTwo.IsEpmtyBefore = false;
  1131. //globalVar.rollerLineTwo.CanRun = true;
  1132. globalVar.rollerLineThree.StationEight = 0;
  1133. globalVar.rollerLineThree.EmptyRollerNums.Clear();
  1134. globalVar.rollerLineThree.EmptyRollerNums.Add(308);
  1135. globalVar.rollerLineThree.IsEpmtyBefore = false;
  1136. //globalVar.rollerLineThree.CanRun = true;
  1137. globalVar.agvArriveLineFour = false;
  1138. globalVar.agvArriveCleanLoad = false;
  1139. globalVar.agvArriveCleanUnLoad = false;
  1140. globalVar.agvArriveLineOneLoadEmptyRoller = false;
  1141. globalVar.agvArriveLineTwoLoadEmptyRoller = false;
  1142. globalVar.agvArriveLineThreeLoadEmptyRoller = false;
  1143. globalVar.agvArriveLineOneLoadCom = false;
  1144. globalVar.agvArriveLineTwoLoadCom = false;
  1145. globalVar.agvArriveLineThreeLoadCom = false;
  1146. ThreadManage.GetInstance().StartLong(new Action(() => { LineFourProcessExecute(); Thread.Sleep(10); }), "空桶清洗任务线程");
  1147. MessageLog.GetInstance.ShowUserLog("空桶清洗任务重启成功");
  1148. }));
  1149. }
  1150. /// <summary>
  1151. /// 实时获取plc数据
  1152. /// </summary>
  1153. public void ReadPlcData()
  1154. {
  1155. ThreadManage.GetInstance().StartLong(new Action(() =>
  1156. {
  1157. GetAddressData("D2001", new Action<ushort[]>((data) =>
  1158. {
  1159. globalVar.rollerLineOne.StationOne = data[0];
  1160. globalVar.rollerLineOne.StationTwo = data[1];
  1161. globalVar.rollerLineOne.StationThree = data[2];
  1162. globalVar.rollerLineOne.StationFour = data[3];
  1163. globalVar.rollerLineOne.StationFive = data[4];
  1164. globalVar.rollerLineOne.StationSix = data[5];
  1165. globalVar.rollerLineOne.StationSeven = data[6];
  1166. globalVar.rollerLineOne.StationEight = data[7];
  1167. }));
  1168. GetAddressData("D2011", new Action<ushort[]>((data) =>
  1169. {
  1170. globalVar.rollerLineTwo.StationOne = data[0];
  1171. globalVar.rollerLineTwo.StationTwo = data[1];
  1172. globalVar.rollerLineTwo.StationThree = data[2];
  1173. globalVar.rollerLineTwo.StationFour = data[3];
  1174. globalVar.rollerLineTwo.StationFive = data[4];
  1175. globalVar.rollerLineTwo.StationSix = data[5];
  1176. globalVar.rollerLineTwo.StationSeven = data[6];
  1177. globalVar.rollerLineTwo.StationEight = data[7];
  1178. }));
  1179. GetAddressData("D2021", new Action<ushort[]>((data) =>
  1180. {
  1181. globalVar.rollerLineThree.StationOne = data[0];
  1182. globalVar.rollerLineThree.StationTwo = data[1];
  1183. globalVar.rollerLineThree.StationThree = data[2];
  1184. globalVar.rollerLineThree.StationFour = data[3];
  1185. globalVar.rollerLineThree.StationFive = data[4];
  1186. globalVar.rollerLineThree.StationSix = data[5];
  1187. globalVar.rollerLineThree.StationSeven = data[6];
  1188. globalVar.rollerLineThree.StationEight = data[7];
  1189. }));
  1190. GetAddressData("D2031", new Action<ushort[]>((data) =>
  1191. {
  1192. globalVar.rollerLineOne.OutMaterialingSingle = data[3];
  1193. globalVar.rollerLineTwo.OutMaterialingSingle = data[4];
  1194. globalVar.rollerLineThree.OutMaterialingSingle = data[5];
  1195. //globalVar.rollerLineOne.OutMaterialingTroubleSingle = data[6];
  1196. //globalVar.rollerLineTwo.OutMaterialingTroubleSingle = data[7];
  1197. //globalVar.rollerLineThree.OutMaterialingTroubleSingle = data[8];
  1198. AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble = data[6];
  1199. AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble = data[7];
  1200. AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble = data[8];
  1201. }));
  1202. GetAddressData("D2040", new Action<ushort[]>((data) =>
  1203. {
  1204. globalVar.fryPotOne.InputMaterialRollerRunningSingle = data[0];
  1205. globalVar.fryPotTwo.InputMaterialRollerRunningSingle = data[1];
  1206. globalVar.fryPotThree.InputMaterialRollerRunningSingle = data[2];
  1207. globalVar.fryPotFour.InputMaterialRollerRunningSingle = data[3];
  1208. globalVar.fryPotFive.InputMaterialRollerRunningSingle = data[4];
  1209. }));
  1210. GetAddressData("D2045", new Action<ushort[]>((data) =>
  1211. {
  1212. globalVar.fryPotOne.InputMaterialArrivedSingle = data[0];
  1213. globalVar.fryPotTwo.InputMaterialArrivedSingle = data[1];
  1214. globalVar.fryPotThree.InputMaterialArrivedSingle = data[2];
  1215. globalVar.fryPotFour.InputMaterialArrivedSingle = data[3];
  1216. globalVar.fryPotFive.InputMaterialArrivedSingle = data[4];
  1217. }));
  1218. GetAddressData("D2050", new Action<ushort[]>((data) =>
  1219. {
  1220. globalVar.fryPotOne.EmptyBarrelArrivedSingle = data[0];
  1221. globalVar.fryPotTwo.EmptyBarrelArrivedSingle = data[1];
  1222. globalVar.fryPotThree.EmptyBarrelArrivedSingle = data[2];
  1223. globalVar.fryPotFour.EmptyBarrelArrivedSingle = data[3];
  1224. globalVar.fryPotFive.EmptyBarrelArrivedSingle = data[4];
  1225. }));
  1226. GetAddressData("D2065", new Action<ushort[]>((data) =>
  1227. {
  1228. globalVar.fryPotOne.EmptyBarrelRollerRunningSingle = data[0];
  1229. globalVar.fryPotTwo.EmptyBarrelRollerRunningSingle = data[1];
  1230. globalVar.fryPotThree.EmptyBarrelRollerRunningSingle = data[2];
  1231. globalVar.fryPotFour.EmptyBarrelRollerRunningSingle = data[3];
  1232. globalVar.fryPotFive.EmptyBarrelRollerRunningSingle = data[4];
  1233. }));
  1234. GetAddressData("D2070", new Action<ushort[]>((data) =>
  1235. {
  1236. //globalVar.fryPotOne.RollerTroubleSingle = data[0];
  1237. //globalVar.fryPotTwo.RollerTroubleSingle = data[1];
  1238. //globalVar.fryPotThree.RollerTroubleSingle = data[2];
  1239. //globalVar.fryPotFour.RollerTroubleSingle = data[3];
  1240. //globalVar.fryPotFive.RollerTroubleSingle = data[4];
  1241. AlarmHelper<AlarmInfo>.Alarm.FryPotOneRollerTrouble = data[0];
  1242. AlarmHelper<AlarmInfo>.Alarm.FryPotTwoRollerTrouble = data[1];
  1243. AlarmHelper<AlarmInfo>.Alarm.FryPotThreeRollerTrouble = data[2];
  1244. AlarmHelper<AlarmInfo>.Alarm.FryPotFourRollerTrouble = data[3];
  1245. AlarmHelper<AlarmInfo>.Alarm.FryPotFiveRollerTrouble = data[4];
  1246. }));
  1247. GetAddressData("D2078", new Action<ushort[]>(data =>
  1248. {
  1249. globalVar.rollerLineOne.RecipeCompleteSingle = data[0];
  1250. globalVar.rollerLineTwo.RecipeCompleteSingle = data[1];
  1251. globalVar.rollerLineThree.RecipeCompleteSingle = data[2];
  1252. }));
  1253. GetAddressData("D2075", new Action<ushort[]>(data =>
  1254. {
  1255. globalVar.CleadBarrelEnterSingle = data[0];
  1256. }));
  1257. GetAddressData("D2077", new Action<ushort[]>(data =>
  1258. {
  1259. globalVar.CleadBarrelExitSingle = data[0];
  1260. }));
  1261. //炒锅1状态数据
  1262. GetFryOneData("D2001", new Action<ushort[]>(data =>
  1263. {
  1264. }));
  1265. //炒锅2状态数据
  1266. GetFryTwoData("D2001", new Action<ushort[]>(data =>
  1267. {
  1268. }));
  1269. //炒锅3状态数据
  1270. GetFryThreeData("D2001", new Action<ushort[]>(data =>
  1271. {
  1272. }));
  1273. //炒锅4状态数据
  1274. GetFryFourData("D2001", new Action<ushort[]>(data =>
  1275. {
  1276. }));
  1277. //炒锅5状态数据
  1278. GetFryFiveData("D2001", new Action<ushort[]>(data =>
  1279. {
  1280. }));
  1281. //线体上放空桶
  1282. if (globalVar.rollerLineOne.EmptyRollerConfirmSingle == 1 && globalVar.rollerLineOne.EmptyRollerNum != 0)
  1283. {
  1284. globalVar.rollerLineOne.EmptyRollerNums.Add(globalVar.rollerLineOne.EmptyRollerNum);
  1285. }
  1286. if (globalVar.rollerLineTwo.EmptyRollerConfirmSingle == 1 && globalVar.rollerLineTwo.EmptyRollerNum != 0)
  1287. {
  1288. globalVar.rollerLineTwo.EmptyRollerNums.Add(globalVar.rollerLineTwo.EmptyRollerNum);
  1289. }
  1290. if (globalVar.rollerLineThree.EmptyRollerConfirmSingle == 1 && globalVar.rollerLineThree.EmptyRollerNum != 0)
  1291. {
  1292. globalVar.rollerLineThree.EmptyRollerNums.Add(globalVar.rollerLineThree.EmptyRollerNum);
  1293. }
  1294. //炒锅状态数据
  1295. if (globalVar.fryPotOne.OilConfirm == 1)
  1296. {
  1297. FryPotMonitorManage.GetInstance.fryOne.OilCapacity = globalVar.fryPotOne.OilCapacity;
  1298. FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy += globalVar.fryPotOne.OilCapacity;
  1299. }
  1300. if (globalVar.fryPotTwo.OilConfirm == 1)
  1301. {
  1302. FryPotMonitorManage.GetInstance.fryTwo.OilCapacity = globalVar.fryPotTwo.OilCapacity;
  1303. FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy += globalVar.fryPotTwo.OilCapacity;
  1304. }
  1305. if (globalVar.fryPotThree.OilConfirm == 1)
  1306. {
  1307. FryPotMonitorManage.GetInstance.fryThree.OilCapacity = globalVar.fryPotThree.OilCapacity;
  1308. FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy += globalVar.fryPotThree.OilCapacity;
  1309. }
  1310. if (globalVar.fryPotFour.OilConfirm == 1)
  1311. {
  1312. FryPotMonitorManage.GetInstance.fryFour.OilCapacity = globalVar.fryPotFour.OilCapacity;
  1313. FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy += globalVar.fryPotFour.OilCapacity;
  1314. }
  1315. if (globalVar.fryPotFive.OilConfirm == 1)
  1316. {
  1317. FryPotMonitorManage.GetInstance.fryFive.OilCapacity = globalVar.fryPotFive.OilCapacity;
  1318. FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy += globalVar.fryPotFive.OilCapacity;
  1319. }
  1320. //炒锅状态实时显示
  1321. FryPotStatusDisplay();
  1322. RollerLineStatusDisplay();
  1323. Thread.Sleep(10);
  1324. }), "MainViewReadPlcData");
  1325. }
  1326. private void FryPotStatusDisplay()
  1327. {
  1328. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneTemp").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.Temperature.ToString();
  1329. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOnePower").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.HotPower.ToString();
  1330. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneSpeed").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.Speed.ToString();
  1331. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneWeight").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.FryPotWeight.ToString();
  1332. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneOil").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.OilCapacity.ToString();
  1333. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneTotalOil").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy.ToString();
  1334. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneTotalProduct").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.TotalProduct.ToString();
  1335. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoTemp").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.Temperature.ToString();
  1336. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoPower").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.HotPower.ToString();
  1337. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoSpeed").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.Speed.ToString();
  1338. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoWeight").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.FryPotWeight.ToString();
  1339. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoOil").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.OilCapacity.ToString();
  1340. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoTotalOil").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy.ToString();
  1341. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotTwoTotalProduct").CurrentValue = FryPotMonitorManage.GetInstance.fryTwo.TotalProduct.ToString();
  1342. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeTemp").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.Temperature.ToString();
  1343. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreePower").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.HotPower.ToString();
  1344. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeSpeed").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.Speed.ToString();
  1345. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeWeight").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight.ToString();
  1346. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeOil").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.OilCapacity.ToString();
  1347. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeTotalOil").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy.ToString();
  1348. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotThreeTotalProduct").CurrentValue = FryPotMonitorManage.GetInstance.fryThree.TotalProduct.ToString();
  1349. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourTemp").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.Temperature.ToString();
  1350. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourPower").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.HotPower.ToString();
  1351. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourSpeed").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.Speed.ToString();
  1352. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourWeight").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight.ToString();
  1353. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourOil").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.OilCapacity.ToString();
  1354. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourTotalOil").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy.ToString();
  1355. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFourTotalProduct").CurrentValue = FryPotMonitorManage.GetInstance.fryFour.TotalProduct.ToString();
  1356. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveTemp").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.Temperature.ToString();
  1357. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFivePower").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.HotPower.ToString();
  1358. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveSpeed").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.Speed.ToString();
  1359. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveWeight").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight.ToString();
  1360. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveOil").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.OilCapacity.ToString();
  1361. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveTotalOil").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy.ToString();
  1362. FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotFiveTotalProduct").CurrentValue = FryPotMonitorManage.GetInstance.fryFive.TotalProduct.ToString();
  1363. //FryPotMonitorManage.GetInstance.fryFive.Temperature = 10;
  1364. //FryPotMonitorManage.GetInstance.fryFive.HotPower = "9";
  1365. //FryPotMonitorManage.GetInstance.fryFive.Speed = 8;
  1366. //FryPotMonitorManage.GetInstance.fryFive.FryPotWeight=7;
  1367. //FryPotMonitorManage.GetInstance.fryFive.OilCapacity = 6;
  1368. //FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy = 5;
  1369. //FryPotMonitorManage.GetInstance.fryFive.TotalProduct = 4;
  1370. }
  1371. /// <summary>
  1372. /// 炒锅状态数据保存到二进制文件
  1373. /// </summary>
  1374. public void FryPotDataSaveToBinaryFile()
  1375. {
  1376. #region 炒锅1状态数据保存
  1377. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅1状态数据"))
  1378. {
  1379. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅1状态数据");
  1380. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString()))
  1381. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString());
  1382. if (globalVar.LOneFryPotSerial == 1 && fryOneRecipe != string.Empty)
  1383. {
  1384. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryOneRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1385. {
  1386. writeStream.Position = writeStream.Length;
  1387. PotOneStatus p1 = 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, RecipeName = fryOneRecipe, Time = DateTime.Now.ToShortDateString() };
  1388. BinaryFormatter bf = new BinaryFormatter();
  1389. bf.Serialize(writeStream, p1);
  1390. }
  1391. }
  1392. }
  1393. else
  1394. {
  1395. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString()))
  1396. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString());
  1397. if (globalVar.LOneFryPotSerial == 1 && fryOneRecipe != string.Empty)
  1398. {
  1399. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryOneRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1400. {
  1401. writeStream.Position = writeStream.Length;
  1402. PotOneStatus p1 = 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, RecipeName = fryOneRecipe, Time = DateTime.Now.ToShortDateString() };
  1403. BinaryFormatter bf = new BinaryFormatter();
  1404. bf.Serialize(writeStream, p1);
  1405. }
  1406. }
  1407. }
  1408. #endregion
  1409. #region 炒锅2状态数据保存
  1410. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅2状态数据"))
  1411. {
  1412. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅2状态数据");
  1413. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString()))
  1414. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString());
  1415. if (globalVar.LTwoFryPotSerial == 2 && fryTwoRecipe != string.Empty)
  1416. {
  1417. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryTwoRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1418. {
  1419. PotTwoStatus p1 = 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, RecipeName = fryTwoRecipe, Time = DateTime.Now.ToShortDateString() };
  1420. BinaryFormatter bf = new BinaryFormatter();
  1421. bf.Serialize(writeStream, p1);
  1422. }
  1423. }
  1424. }
  1425. else
  1426. {
  1427. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString()))
  1428. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString());
  1429. if (globalVar.LTwoFryPotSerial == 2 && fryTwoRecipe != string.Empty)
  1430. {
  1431. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryTwoRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1432. {
  1433. PotTwoStatus p1 = 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, RecipeName = fryTwoRecipe, Time = DateTime.Now.ToShortDateString() };
  1434. BinaryFormatter bf = new BinaryFormatter();
  1435. bf.Serialize(writeStream, p1);
  1436. }
  1437. }
  1438. }
  1439. #endregion
  1440. #region 炒锅3状态数据保存
  1441. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅3状态数据"))
  1442. {
  1443. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅3状态数据");
  1444. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString()))
  1445. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString());
  1446. if (globalVar.LThreeFryPotSerial == 3 && fryThreeRecipe != string.Empty)
  1447. {
  1448. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryThreeRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1449. {
  1450. PotThreeStatus p1 = 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, RecipeName = fryThreeRecipe, Time = DateTime.Now.ToShortDateString() };
  1451. BinaryFormatter bf = new BinaryFormatter();
  1452. bf.Serialize(writeStream, p1);
  1453. }
  1454. }
  1455. }
  1456. else
  1457. {
  1458. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString()))
  1459. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString());
  1460. if (globalVar.LThreeFryPotSerial == 3 && fryThreeRecipe != string.Empty)
  1461. {
  1462. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryThreeRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1463. {
  1464. PotThreeStatus p1 = 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, RecipeName = fryThreeRecipe, Time = DateTime.Now.ToShortDateString() };
  1465. BinaryFormatter bf = new BinaryFormatter();
  1466. bf.Serialize(writeStream, p1);
  1467. }
  1468. }
  1469. }
  1470. #endregion
  1471. #region 炒锅4状态数据保存
  1472. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅4状态数据"))
  1473. {
  1474. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅4状态数据");
  1475. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString()))
  1476. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString());
  1477. if (globalVar.LOneFryPotSerial == 4 && fryFourRecipe != string.Empty)
  1478. {
  1479. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryFourRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1480. {
  1481. writeStream.Position = writeStream.Length;
  1482. PotFourStatus p1 = 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, RecipeName = fryFourRecipe, Time = DateTime.Now.ToShortDateString() };
  1483. BinaryFormatter bf = new BinaryFormatter();
  1484. bf.Serialize(writeStream, p1);
  1485. }
  1486. }
  1487. }
  1488. else
  1489. {
  1490. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString()))
  1491. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString());
  1492. if (globalVar.LOneFryPotSerial == 4 && fryFourRecipe != string.Empty)
  1493. {
  1494. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryFourRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1495. {
  1496. writeStream.Position = writeStream.Length;
  1497. PotFourStatus p1 = 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, RecipeName = fryFourRecipe, Time = DateTime.Now.ToShortDateString() };
  1498. BinaryFormatter bf = new BinaryFormatter();
  1499. bf.Serialize(writeStream, p1);
  1500. }
  1501. }
  1502. }
  1503. #endregion
  1504. #region 炒锅5状态数据保存
  1505. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅5状态数据"))
  1506. {
  1507. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅5状态数据");
  1508. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString()))
  1509. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString());
  1510. if (globalVar.LTwoFryPotSerial == 5 && fryFiveRecipe != string.Empty)
  1511. {
  1512. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryFiveRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1513. {
  1514. writeStream.Position = writeStream.Length;
  1515. PotFiveStatus p1 = 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, RecipeName = fryFiveRecipe, Time = DateTime.Now.ToShortDateString() };
  1516. BinaryFormatter bf = new BinaryFormatter();
  1517. bf.Serialize(writeStream, p1);
  1518. }
  1519. }
  1520. }
  1521. else
  1522. {
  1523. if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString()))
  1524. Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString());
  1525. if (globalVar.LTwoFryPotSerial == 5 && fryFiveRecipe != string.Empty)
  1526. {
  1527. using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("hh:mm").Replace(':', '.') + fryFiveRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write))
  1528. {
  1529. writeStream.Position = writeStream.Length;
  1530. PotFiveStatus p1 = 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, RecipeName = fryFiveRecipe, Time = DateTime.Now.ToShortDateString() };
  1531. BinaryFormatter bf = new BinaryFormatter();
  1532. bf.Serialize(writeStream, p1);
  1533. }
  1534. }
  1535. }
  1536. #endregion
  1537. }
  1538. /// <summary>
  1539. /// 滚筒线运行状态显示
  1540. /// </summary>
  1541. private void RollerLineStatusDisplay()
  1542. {
  1543. hardWareStatusModel.RollerOneModel.LocOneRollerSerial = globalVar.rollerLineOne.StationOne;
  1544. hardWareStatusModel.RollerOneModel.LocTwoRollerSerial = globalVar.rollerLineOne.StationTwo;
  1545. hardWareStatusModel.RollerOneModel.LocThreeRollerSerial = globalVar.rollerLineOne.StationThree;
  1546. hardWareStatusModel.RollerOneModel.LocFourRollerSerial = globalVar.rollerLineOne.StationFour;
  1547. hardWareStatusModel.RollerOneModel.LocFiveRollerSerial = globalVar.rollerLineOne.StationFive;
  1548. hardWareStatusModel.RollerOneModel.LocSixRollerSerial = globalVar.rollerLineOne.StationSix;
  1549. hardWareStatusModel.RollerOneModel.LocSevenRollerSerial = globalVar.rollerLineOne.StationSeven;
  1550. hardWareStatusModel.RollerOneModel.LocEightRollerSerial = globalVar.rollerLineOne.StationEight;
  1551. if (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 0)
  1552. {
  1553. hardWareStatusModel.RollerOneModel.RollerAlarmState = Color.FromRgb(130, 232, 139);//无故障
  1554. }
  1555. else
  1556. {
  1557. hardWareStatusModel.RollerOneModel.RollerAlarmState = Color.FromRgb(255, 51, 153);//有故障
  1558. }
  1559. if (globalVar.rollerLineOne.OutMaterialingSingle == 1)//运行中
  1560. {
  1561. hardWareStatusModel.RollerOneModel.RollerRunState = Color.FromRgb(130, 232, 139);//运行中
  1562. }
  1563. else
  1564. {
  1565. hardWareStatusModel.RollerOneModel.RollerRunState = Color.FromRgb(84, 84, 84);//未运行
  1566. }
  1567. hardWareStatusModel.RollerTwoModel.LocOneRollerSerial = globalVar.rollerLineTwo.StationOne;
  1568. hardWareStatusModel.RollerTwoModel.LocTwoRollerSerial = globalVar.rollerLineTwo.StationTwo;
  1569. hardWareStatusModel.RollerTwoModel.LocThreeRollerSerial = globalVar.rollerLineTwo.StationThree;
  1570. hardWareStatusModel.RollerTwoModel.LocFourRollerSerial = globalVar.rollerLineTwo.StationFour;
  1571. hardWareStatusModel.RollerTwoModel.LocFiveRollerSerial = globalVar.rollerLineTwo.StationFive;
  1572. hardWareStatusModel.RollerTwoModel.LocSixRollerSerial = globalVar.rollerLineTwo.StationSix;
  1573. hardWareStatusModel.RollerTwoModel.LocSevenRollerSerial = globalVar.rollerLineTwo.StationSeven;
  1574. hardWareStatusModel.RollerTwoModel.LocEightRollerSerial = globalVar.rollerLineTwo.StationEight;
  1575. if (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 0)
  1576. {
  1577. hardWareStatusModel.RollerTwoModel.RollerAlarmState = Color.FromRgb(130, 232, 139);//无故障
  1578. }
  1579. else
  1580. {
  1581. hardWareStatusModel.RollerTwoModel.RollerAlarmState = Color.FromRgb(255, 51, 153);//有故障
  1582. }
  1583. if (globalVar.rollerLineTwo.OutMaterialingSingle == 1)//运行中
  1584. {
  1585. hardWareStatusModel.RollerTwoModel.RollerRunState = Color.FromRgb(130, 232, 139);//运行中
  1586. }
  1587. else
  1588. {
  1589. hardWareStatusModel.RollerTwoModel.RollerRunState = Color.FromRgb(84, 84, 84);//未运行
  1590. }
  1591. hardWareStatusModel.RollerThreeModel.LocOneRollerSerial = globalVar.rollerLineThree.StationOne;
  1592. hardWareStatusModel.RollerThreeModel.LocTwoRollerSerial = globalVar.rollerLineThree.StationTwo;
  1593. hardWareStatusModel.RollerThreeModel.LocThreeRollerSerial = globalVar.rollerLineThree.StationThree;
  1594. hardWareStatusModel.RollerThreeModel.LocFourRollerSerial = globalVar.rollerLineThree.StationFour;
  1595. hardWareStatusModel.RollerThreeModel.LocFiveRollerSerial = globalVar.rollerLineThree.StationFive;
  1596. hardWareStatusModel.RollerThreeModel.LocSixRollerSerial = globalVar.rollerLineThree.StationSix;
  1597. hardWareStatusModel.RollerThreeModel.LocSevenRollerSerial = globalVar.rollerLineThree.StationSeven;
  1598. hardWareStatusModel.RollerThreeModel.LocEightRollerSerial = globalVar.rollerLineThree.StationEight;
  1599. if (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 0)
  1600. {
  1601. hardWareStatusModel.RollerThreeModel.RollerAlarmState = Color.FromRgb(130, 232, 139);//无故障
  1602. }
  1603. else
  1604. {
  1605. hardWareStatusModel.RollerThreeModel.RollerAlarmState = Color.FromRgb(255, 51, 153);//有故障
  1606. }
  1607. if (globalVar.rollerLineThree.OutMaterialingSingle == 1)//运行中
  1608. {
  1609. hardWareStatusModel.RollerThreeModel.RollerRunState = Color.FromRgb(130, 232, 139);//运行中
  1610. }
  1611. else
  1612. {
  1613. hardWareStatusModel.RollerThreeModel.RollerRunState = Color.FromRgb(84, 84, 84);//未运行
  1614. }
  1615. //滚筒线4
  1616. }
  1617. /// <summary>
  1618. /// 返回滚筒线PLC指定地址指定长度的数据
  1619. /// </summary>
  1620. /// <param name="address"></param>
  1621. /// <returns></returns>
  1622. public void GetAddressData(string address, Action<ushort[]> action)
  1623. {
  1624. PlcReadData = DeviceOperate.GetInstance.GetAllData();
  1625. if (PlcReadData.ContainsKey(address))
  1626. {
  1627. action((ushort[])(PlcReadData[address]));
  1628. }
  1629. }
  1630. public void GetFryOneData(string address, Action<ushort[]> action)
  1631. {
  1632. FryOneData = DeviceOperate.GetInstance.GetFryOneData();
  1633. if (FryOneData.ContainsKey(address))
  1634. {
  1635. action((ushort[])(FryOneData[address]));
  1636. }
  1637. }
  1638. public void GetFryTwoData(string address, Action<ushort[]> action)
  1639. {
  1640. FryTwoData = DeviceOperate.GetInstance.GetFryTwoData();
  1641. if (FryTwoData.ContainsKey(address))
  1642. {
  1643. action((ushort[])(FryTwoData[address]));
  1644. }
  1645. }
  1646. public void GetFryThreeData(string address, Action<ushort[]> action)
  1647. {
  1648. FryThreeData = DeviceOperate.GetInstance.GetFryThreeData();
  1649. if (FryThreeData.ContainsKey(address))
  1650. {
  1651. action((ushort[])(FryThreeData[address]));
  1652. }
  1653. }
  1654. public void GetFryFourData(string address, Action<ushort[]> action)
  1655. {
  1656. FryFourData = DeviceOperate.GetInstance.GetFryFourData();
  1657. if (FryFourData.ContainsKey(address))
  1658. {
  1659. action((ushort[])(FryFourData[address]));
  1660. }
  1661. }
  1662. public void GetFryFiveData(string address, Action<ushort[]> action)
  1663. {
  1664. FryFiveData = DeviceOperate.GetInstance.GetFryFiveData();
  1665. if (FryFiveData.ContainsKey(address))
  1666. {
  1667. action((ushort[])(FryFiveData[address]));
  1668. }
  1669. }
  1670. /// <summary>
  1671. /// 写Plc数据
  1672. /// </summary>
  1673. /// <param name="address"></param>
  1674. /// <param name="Value"></param>
  1675. public void WritePlcData(string address, ushort Value)
  1676. {
  1677. DeviceOperate.GetInstance.WritePlcData(address, Value);
  1678. }
  1679. /// <summary>
  1680. /// 初始化任务
  1681. /// </summary>
  1682. //public void IniteTask()
  1683. //{
  1684. // ThreadManage.GetInstance().StartLong(new Action(() =>
  1685. // {
  1686. // MainTask();
  1687. // }), "MainTask");
  1688. //}
  1689. /// <summary>
  1690. /// 配方数据接收
  1691. /// </summary>
  1692. public void RecipeDataParse(object obj)
  1693. {
  1694. Task.Run(new Action(() =>
  1695. {
  1696. if (obj != null && obj is NewRecipeModel[] recipes)
  1697. {
  1698. ReicpeNum = ReicpeNum + recipes.Length;
  1699. MessageLog.GetInstance.ShowUserLog($"新接收到{recipes.Length}个配方,总共{ReicpeNum}个配方");
  1700. for (int i = 0; i < recipes.Length; i++)
  1701. {
  1702. int? res = recipes[i].materialCollection.ElementAt(0).MaterialLoc / 100;
  1703. if (res != null)
  1704. {
  1705. switch (res)
  1706. {
  1707. case 1:
  1708. case 4: RecipeQuene.Enqueue(recipes[i]); break;
  1709. case 3: LThreeRecipeQuene.Enqueue(recipes[i]); break;
  1710. case 2:
  1711. case 5: LTwoRecipeQuene.Enqueue(recipes[i]); break;
  1712. }
  1713. }
  1714. }
  1715. }
  1716. }));
  1717. }
  1718. /// <summary>
  1719. /// 开启主任务
  1720. /// </summary>
  1721. public void MainTask()
  1722. {
  1723. ////RecipeDataToPlc();
  1724. //LOneRecipeDataToPlc();
  1725. //LTwoRecipeDataToPlc();
  1726. //LThreeRecipeDataToPlc();
  1727. ////AgvLoadRoller();
  1728. //LOneLoadRoller();
  1729. //LTwoAgvLoadRoller();
  1730. //LThreeAgvLoadRoller();
  1731. //// FryPotInputMaterial();
  1732. //LOneFryPotInputMaterial();
  1733. //LTwoFryPotInputMaterial();
  1734. //LThreeFryPotInputMaterial();
  1735. ////FryPotOutputMaterial();
  1736. //LOneFryPotOutputMaterial();
  1737. //LTwoFryPotOutputMaterial();
  1738. //LThreeFryPotOutputMaterial();
  1739. ThreadManage.GetInstance().StartLong(new Action(() => { LineOneProcessExecute(); Thread.Sleep(10); }), "滚筒线1任务线程");
  1740. ThreadManage.GetInstance().StartLong(new Action(() => { LineTwoProcessExecute(); Thread.Sleep(10); }), "滚筒线2任务线程");
  1741. ThreadManage.GetInstance().StartLong(new Action(() => { LineThreeProcessExecute(); Thread.Sleep(10); }), "滚筒线3任务线程");
  1742. ThreadManage.GetInstance().StartLong(new Action(() => { LineFourProcessExecute(); Thread.Sleep(10); }), "空桶清洗任务线程");
  1743. }
  1744. /// <summary>
  1745. /// 线体1的执行流程
  1746. /// </summary>
  1747. public void LineOneProcessExecute()
  1748. {
  1749. //if (!globalVar.LOneTaskLock)
  1750. //{
  1751. // globalVar.LOneTaskLock = true;
  1752. LOneRecipeDataToPlc();
  1753. LOneLoadRoller();
  1754. LOneFryPotInputMaterial();
  1755. LOneFallMaterial();
  1756. LOneFryPotOutputMaterial();
  1757. LOneEmptyOperate();
  1758. // globalVar.LOneTaskLock = false;
  1759. //}
  1760. }
  1761. /// <summary>
  1762. /// 线体2的执行流程
  1763. /// </summary>
  1764. public void LineTwoProcessExecute()
  1765. {
  1766. //if (!globalVar.LTwoTaskLock)
  1767. //{
  1768. // globalVar.LTwoTaskLock = true;
  1769. LTwoRecipeDataToPlc();
  1770. LTwoAgvLoadRoller();
  1771. LTwoFryPotInputMaterial();
  1772. LTwoFallMaterial();
  1773. LTwoFryPotOutputMaterial();
  1774. LTwoEmptyOperate();
  1775. // globalVar.LTwoTaskLock = false;
  1776. //}
  1777. }
  1778. /// <summary>
  1779. /// 线体3的执行流程
  1780. /// </summary>
  1781. public void LineThreeProcessExecute()
  1782. {
  1783. //if (!globalVar.LThreeTaskLock)
  1784. //{
  1785. // globalVar.LThreeTaskLock = true;
  1786. LThreeRecipeDataToPlc();
  1787. LThreeAgvLoadRoller();
  1788. LThreeFryPotInputMaterial();
  1789. LThreeFallMaterial();
  1790. LThreeFryPotOutputMaterial();
  1791. LThreeEmptyOperate();
  1792. // globalVar.LThreeTaskLock = false;
  1793. //}
  1794. }
  1795. private void LineFourProcessExecute()
  1796. {
  1797. //
  1798. AgvFromLineToCleanPlate();
  1799. AgvArriveCleanPlate();
  1800. CallAgvToLineFour();
  1801. CleanPlateUpLoad();
  1802. EmptyRollerToLinFour();
  1803. }
  1804. private void CleanPlateUpLoad()
  1805. {
  1806. if (globalVar.agvArriveCleanLoad)
  1807. {
  1808. globalVar.agvArriveCleanLoad = false;
  1809. MessageLog.GetInstance.ShowRunLog("清洗台空桶装载完成");
  1810. }
  1811. }
  1812. /// <summary>
  1813. /// 线体到清洗台
  1814. /// </summary>
  1815. private void AgvFromLineToCleanPlate()
  1816. {
  1817. if (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 0)//输送线无故障
  1818. {
  1819. //线体1到清洗台
  1820. if (!globalVar.rollerLineOne.IsEpmtyBefore && globalVar.rollerLineOne.CanRun)
  1821. {
  1822. var res = InputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineOne.StationEight);
  1823. if ((globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.EmptyRollerNums.Count > 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0) && InputMaterialQuene.Count > 0 && globalVar.rollerLineOne.StationEight != InputMaterialQuene.ElementAt(0).materialType.MaterialLoc) || (res == null && globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.EmptyRollerNums.Count > 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0)))//工位8上面有桶且不是配方上的原料桶且工位8的桶号和plc上报的桶号一致,即空桶
  1824. {
  1825. //下发AGV去空桶线洗桶任务
  1826. e: string id = Guid.NewGuid().ToString("N");
  1827. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId)
  1828. goto e;
  1829. string info = AGVHelper.GetInstance.AgvLeaveLOneToClean(id);//1号线到洗桶处
  1830. LFourrobotJobId = id;
  1831. Thread.Sleep(500);
  1832. LineToCleanCarryTaskErrorCodeAnalysis(info, 1);
  1833. globalVar.rollerLineOne.IsEpmtyBefore = true;
  1834. //globalVar.rollerLineOne.CanRun = false;
  1835. AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
  1836. }
  1837. }
  1838. else
  1839. {
  1840. AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
  1841. }
  1842. }
  1843. // 线体2到清洗台
  1844. if (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 0)//输送线无故障
  1845. {
  1846. if (!globalVar.rollerLineTwo.IsEpmtyBefore && globalVar.rollerLineTwo.CanRun)
  1847. {
  1848. var res = LTwoInputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineTwo.StationEight);
  1849. if ((globalVar.rollerLineTwo.StationEight != 0 && globalVar.rollerLineTwo.EmptyRollerNums.Count > 0 && globalVar.rollerLineTwo.StationEight == globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0) && LTwoInputMaterialQuene.Count > 0 && globalVar.rollerLineTwo.StationEight != LTwoInputMaterialQuene.ElementAt(0).materialType.MaterialLoc) || (res == null && globalVar.rollerLineTwo.StationEight != 0 && globalVar.rollerLineTwo.EmptyRollerNums.Count > 0 && globalVar.rollerLineTwo.StationEight == globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0)))//工位8上面有桶且不是配方上的原料桶,即空桶
  1850. {
  1851. //下发AGV去空桶线洗桶任务
  1852. e: string id = Guid.NewGuid().ToString("N");
  1853. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId)
  1854. goto e;
  1855. string info = AGVHelper.GetInstance.AgvLeaveLTwoToClean(id);//2号线到洗桶处
  1856. LFiverobotJobId = id;
  1857. Thread.Sleep(500);
  1858. LineToCleanCarryTaskErrorCodeAnalysis(info, 2);
  1859. globalVar.rollerLineTwo.IsEpmtyBefore = true;
  1860. // globalVar.rollerLineTwo.CanRun = false;
  1861. AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体2到清洗处
  1862. }
  1863. }
  1864. else
  1865. {
  1866. AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
  1867. }
  1868. }
  1869. //线体3到清洗台
  1870. if (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 0)//输送线无故障
  1871. {
  1872. if (!globalVar.rollerLineThree.IsEpmtyBefore && globalVar.rollerLineThree.CanRun)
  1873. {
  1874. var res = LThreeInputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineThree.StationEight);
  1875. if ((globalVar.rollerLineThree.StationEight != 0 && globalVar.rollerLineThree.EmptyRollerNums.Count > 0 && globalVar.rollerLineThree.StationEight == globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0) && LThreeInputMaterialQuene.Count > 0 && globalVar.rollerLineThree.StationEight != LThreeInputMaterialQuene.ElementAt(0).materialType.MaterialLoc) || (res == null && globalVar.rollerLineThree.StationEight != 0 && globalVar.rollerLineThree.EmptyRollerNums.Count > 0 && globalVar.rollerLineThree.StationEight == globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0)))//工位8上面有桶且不是配方上的原料桶,即空桶
  1876. {
  1877. //下发AGV去空桶线洗桶任务
  1878. e: string id = Guid.NewGuid().ToString("N");
  1879. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId)
  1880. goto e;
  1881. string info = AGVHelper.GetInstance.AgvLeaveLThreeToClean(id);//3号线到洗桶处
  1882. LSixrobotJobId = id;
  1883. Thread.Sleep(500);
  1884. LineToCleanCarryTaskErrorCodeAnalysis(info, 3);
  1885. globalVar.rollerLineThree.IsEpmtyBefore = true;
  1886. //globalVar.rollerLineThree.CanRun = false;
  1887. AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处
  1888. }
  1889. }
  1890. else
  1891. {
  1892. AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处
  1893. }
  1894. }
  1895. }
  1896. /// <summary>
  1897. /// AGV到达清洗台下料位置
  1898. /// </summary>
  1899. private void AgvArriveCleanPlate()
  1900. {
  1901. if (globalVar.agvArriveCleanUnLoad)
  1902. {
  1903. globalVar.agvArriveCleanUnLoad = false;
  1904. MessageLog.GetInstance.ShowRunLog("空桶到达清洗位置,准备卸桶");
  1905. MessageLog.GetInstance.ShowRunLog("卸桶完成");
  1906. //plc交互
  1907. }
  1908. }
  1909. /// <summary>
  1910. /// 呼叫Agv从清洗台运洗好的空桶到四号线体
  1911. /// </summary>
  1912. public void CallAgvToLineFour()
  1913. {
  1914. if (globalVar.CleanComplete == 1)
  1915. {
  1916. //是否需要手动给PLC置位??
  1917. globalVar.CleanComplete = 0;
  1918. e: string id = Guid.NewGuid().ToString("N");
  1919. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId)
  1920. goto e;
  1921. string info = AGVHelper.GetInstance.AgvFromCleanToLineFourUnLoadRoller(id);
  1922. LTenrobotJobId = id;
  1923. Thread.Sleep(500);
  1924. MessageLog.GetInstance.ShowRunLog("清洗台呼叫AGV取桶");
  1925. CleanToLineCarryTaskErrorCodeAnalysis(info, 4);
  1926. }
  1927. }
  1928. /// <summary>
  1929. /// 3号滚筒线数据下发 2022/7/4 新增
  1930. /// </summary>
  1931. /// <exception cref="NotImplementedException"></exception>
  1932. private void LThreeRecipeDataToPlc()
  1933. {
  1934. if (LThreeOutputMaterialQuene.Count == 0 && LThreeInputMaterialQuene.Count == 0 && !LThreeErrorRecipe)
  1935. {
  1936. if (globalVar.LThreeCurrentRecipeName != string.Empty)
  1937. {
  1938. MessageLog.GetInstance.ShowUserLog($"【3】号滚筒线【{globalVar.LThreeCurrentRecipeName}】 配方制作完成");
  1939. if (globalVar.LThreeFryPotSerial == 3)
  1940. {
  1941. FryPotMonitorManage.GetInstance.fryThree.TotalProduct++;
  1942. using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryThree.txt", false, Encoding.UTF8))
  1943. {
  1944. txtWriter.WriteLine(DateTime.Now.ToShortDateString());
  1945. txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryThree.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy);//炒锅1产量以及总油量记录
  1946. }
  1947. //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() });//向表中新增数据
  1948. //Sqlite<PotThreeStatus>.GetInstance.Save();//保存数据
  1949. }
  1950. globalVar.LThreeCurrentRecipeName = string.Empty;
  1951. Task.Run(() => { Thread.Sleep(1500); fryThreeRecipe = string.Empty; });
  1952. }
  1953. }
  1954. if (LThreeRecipeQuene.Count > 0 && LThreeOutputMaterialQuene.Count == 0 && LThreeInputMaterialQuene.Count == 0)//后续添加其它限制条件
  1955. {
  1956. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.goodsName = string.Empty; }));
  1957. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.workflows = new ObservableCollection<WorkflowModel>(); }));
  1958. AgvViewModel.GetInstance().Set启动或停止炒锅(3, IsRun.Stop);
  1959. //if (globalVar.LThreeCurrentRecipeName != string.Empty)
  1960. // MessageLog.GetInstance.ShowUserLog($"【3】号滚筒线【{globalVar.LThreeCurrentRecipeName}】 配方制作完成");
  1961. if (LThreeRecipeQuene.TryDequeue(out NewRecipeModel result))
  1962. {
  1963. LThreeErrorRecipe = false;
  1964. int headNum = result.materialCollection[0].MaterialLoc / 100;
  1965. globalVar.LThreeMaterialNum = result.materialCollection.Count;
  1966. globalVar.LThreeFryPotSerial = headNum;
  1967. globalVar.LThreeCurrentRecipeName = result.RecipeName;
  1968. AgvViewModel.GetInstance().Set滚筒线上数量(3, globalVar.LThreeMaterialNum.ToString());
  1969. MessageLog.GetInstance.ShowUserLog($"【3】号滚筒线开始制作【{result.RecipeName}】 配方");
  1970. for (int i = 0; i < result.materialCollection.Count; i++) //遍历单个配方中所有物料
  1971. {
  1972. if (result.materialCollection[i].MaterialLoc % 100 == i + 1 && result.materialCollection[i].MaterialLoc / 100 == headNum && headNum == 3)
  1973. {
  1974. fryThreeRecipe = result.RecipeName;//炒锅状态开始记录
  1975. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.goodsName = result.RecipeName; }));
  1976. //将配方中原料加入新的队列
  1977. LThreeInputMaterialQuene.Enqueue(new MaterialInfo()
  1978. {
  1979. materialType = result.materialCollection[i],
  1980. materialId = result.RecipeId
  1981. });
  1982. RollerThreeDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight);//3号滚筒线桶号以及重量数据下发
  1983. }
  1984. else
  1985. {
  1986. MessageLog.GetInstance.ShowRunLog($"【3】号滚筒线配方桶号配置错误,取消【{result.RecipeName}】配方制作");
  1987. MessageLog.GetInstance.ShowUserLog($"【3】号滚筒线配方桶号配置错误,取消【{result.RecipeName}】配方制作");
  1988. LThreeInputMaterialQuene.Clear();
  1989. LThreeErrorRecipe = true;
  1990. return;
  1991. }
  1992. }
  1993. DeviceOperate.GetInstance.WritePlcData("D1043", (ushort)result.materialCollection.Count);//发送3号滚筒线工序数据
  1994. //AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LThreeFryPotSerial, IsRun.Stop);
  1995. }
  1996. }
  1997. }
  1998. /// <summary>
  1999. /// 2号滚筒线数据下发 2022/7/4 新增
  2000. /// </summary>
  2001. /// <exception cref="NotImplementedException"></exception>
  2002. private void LTwoRecipeDataToPlc()
  2003. {
  2004. if (LTwoOutputMaterialQuene.Count == 0 && LTwoInputMaterialQuene.Count == 0 && !LTwoErrorRecipe)
  2005. {
  2006. if (globalVar.LTwoCurrentRecipeName != string.Empty)
  2007. {
  2008. MessageLog.GetInstance.ShowUserLog($"【2】号滚筒线【{globalVar.LTwoCurrentRecipeName}】 配方制作完成");
  2009. if (globalVar.LTwoFryPotSerial == 2)
  2010. {
  2011. FryPotMonitorManage.GetInstance.fryTwo.TotalProduct++;
  2012. using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryTwo.txt", false, Encoding.UTF8))
  2013. {
  2014. txtWriter.WriteLine(DateTime.Now.ToShortDateString());
  2015. txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryTwo.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryTwo.TotalOilCapactiy);//炒锅1产量以及总油量记录
  2016. }
  2017. //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() });//向表中新增数据
  2018. //Sqlite<PotTwoStatus>.GetInstance.Save();//保存数据
  2019. }
  2020. if (globalVar.LTwoFryPotSerial == 5)
  2021. {
  2022. FryPotMonitorManage.GetInstance.fryFive.TotalProduct++;
  2023. using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryFive.txt", false, Encoding.UTF8))
  2024. {
  2025. txtWriter.WriteLine(DateTime.Now.ToShortDateString());
  2026. txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryFive.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy);//炒锅1产量以及总油量记录
  2027. }
  2028. //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() });//向表中新增数据
  2029. //Sqlite<PotFiveStatus>.GetInstance.Save();//保存数据
  2030. }
  2031. globalVar.LTwoCurrentRecipeName = string.Empty;
  2032. Task.Run(() => { Thread.Sleep(2000); fryTwoRecipe = string.Empty; fryFiveRecipe = string.Empty; });
  2033. }
  2034. }
  2035. if (LTwoRecipeQuene.Count > 0 && LTwoOutputMaterialQuene.Count == 0 && LTwoInputMaterialQuene.Count == 0)//后续添加其它限制条件
  2036. {
  2037. if (globalVar.LTwoFryPotSerial == 2)
  2038. {
  2039. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_2.goodsName = string.Empty; }));
  2040. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_2.workflows = new ObservableCollection<WorkflowModel>(); }));
  2041. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LTwoFryPotSerial, IsRun.Stop);
  2042. }
  2043. if (globalVar.LTwoFryPotSerial == 5)
  2044. {
  2045. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_5.goodsName = string.Empty; }));
  2046. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_5.workflows = new ObservableCollection<WorkflowModel>(); }));
  2047. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LTwoFryPotSerial, IsRun.Stop);
  2048. }
  2049. //if (globalVar.LTwoCurrentRecipeName != string.Empty)
  2050. // MessageLog.GetInstance.ShowUserLog($"【2】号滚筒线【{globalVar.LTwoCurrentRecipeName}】 配方制作完成");
  2051. if (LTwoRecipeQuene.TryDequeue(out NewRecipeModel result))
  2052. {
  2053. LTwoErrorRecipe = false;
  2054. int headNum = result.materialCollection[0].MaterialLoc / 100;
  2055. globalVar.LTwoMaterialNum = result.materialCollection.Count;
  2056. globalVar.LTwoFryPotSerial = headNum;
  2057. globalVar.LTwoCurrentRecipeName = result.RecipeName;
  2058. AgvViewModel.GetInstance().Set滚筒线上数量(2, globalVar.LTwoMaterialNum.ToString());
  2059. MessageLog.GetInstance.ShowUserLog($"【2】号滚筒线开始制作【{result.RecipeName}】 配方");
  2060. for (int i = 0; i < result.materialCollection.Count; i++) //遍历单个配方中所有物料
  2061. {
  2062. if (result.materialCollection[i].MaterialLoc % 100 == i + 1 && result.materialCollection[i].MaterialLoc / 100 == headNum && (headNum == 2 || headNum == 5))
  2063. {
  2064. if (headNum == 1)//炒锅2
  2065. {
  2066. fryTwoRecipe = result.RecipeName;//炒锅状态开始记录
  2067. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_2.goodsName = result.RecipeName; }));
  2068. }
  2069. else//炒锅5
  2070. {
  2071. fryFiveRecipe = result.RecipeName;//炒锅状态开始记录
  2072. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_5.goodsName = result.RecipeName; }));
  2073. }
  2074. //将配方中原料加入新的队列
  2075. LTwoInputMaterialQuene.Enqueue(new MaterialInfo()
  2076. {
  2077. materialType = result.materialCollection[i],
  2078. materialId = result.RecipeId
  2079. });
  2080. RollerTwoDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight);//2号滚筒线桶号以及重量数据下发
  2081. }
  2082. else
  2083. {
  2084. MessageLog.GetInstance.ShowRunLog($"【2】号滚筒线配方桶号配置错误,取消【{result.RecipeName}】配方制作");
  2085. MessageLog.GetInstance.ShowUserLog($"【2】号滚筒线配方桶号配置错误,取消【{result.RecipeName}】配方制作");
  2086. LTwoInputMaterialQuene.Clear();
  2087. LTwoErrorRecipe = true;
  2088. return;
  2089. }
  2090. }
  2091. DeviceOperate.GetInstance.WritePlcData("D1026", (ushort)result.materialCollection.Count);//发送2号滚筒线工序数据
  2092. }
  2093. }
  2094. }
  2095. /// <summary>
  2096. /// 1号滚筒线数据下发 2022/7/4 新增
  2097. /// </summary>
  2098. private void LOneRecipeDataToPlc()
  2099. {
  2100. if (OutputMaterialQuene.Count == 0 && InputMaterialQuene.Count == 0 && !ErrorRecipe)
  2101. {
  2102. if (globalVar.LOneCurrentRecipeName != string.Empty)
  2103. {
  2104. MessageLog.GetInstance.ShowUserLog($"【1】号滚筒线【{globalVar.LOneCurrentRecipeName}】 配方制作完成");
  2105. if (globalVar.LOneFryPotSerial == 1)
  2106. {
  2107. FryPotMonitorManage.GetInstance.fryOne.TotalProduct++;
  2108. using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryOne.txt", false, Encoding.UTF8))
  2109. {
  2110. txtWriter.WriteLine(DateTime.Now.ToShortDateString());
  2111. txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryOne.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryOne.TotalOilCapactiy);//炒锅1产量以及总油量记录
  2112. }
  2113. //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() });//向表中新增数据
  2114. //Sqlite<PotOneStatus>.GetInstance.Save();//保存数据
  2115. }
  2116. if (globalVar.LOneFryPotSerial == 4)
  2117. {
  2118. FryPotMonitorManage.GetInstance.fryFour.TotalProduct++;
  2119. using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryFour.txt", false, Encoding.UTF8))
  2120. {
  2121. txtWriter.WriteLine(DateTime.Now.ToShortDateString());
  2122. txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryFour.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy);//炒锅1产量以及总油量记录
  2123. }
  2124. //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() });//向表中新增数据
  2125. //Sqlite<PotFourStatus>.GetInstance.Save();//保存数据
  2126. }
  2127. globalVar.LOneCurrentRecipeName = string.Empty;
  2128. Task.Run(() => { Thread.Sleep(1500); fryOneRecipe = string.Empty; fryFourRecipe = string.Empty; });
  2129. }
  2130. }
  2131. if (RecipeQuene.Count > 0 && OutputMaterialQuene.Count == 0 && InputMaterialQuene.Count == 0)//后续添加其它限制条件
  2132. {
  2133. if (globalVar.LOneFryPotSerial == 1)
  2134. {
  2135. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_1.goodsName = string.Empty; }));
  2136. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_1.workflows = new ObservableCollection<WorkflowModel>(); }));
  2137. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LOneFryPotSerial, IsRun.Stop);
  2138. }
  2139. if (globalVar.LOneFryPotSerial == 4)
  2140. {
  2141. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.goodsName = string.Empty; }));
  2142. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.workflows = new ObservableCollection<WorkflowModel>(); }));
  2143. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LOneFryPotSerial, IsRun.Stop);
  2144. }
  2145. if (RecipeQuene.TryDequeue(out NewRecipeModel result))
  2146. {
  2147. ErrorRecipe = false;
  2148. int headNum = result.materialCollection[0].MaterialLoc / 100;
  2149. globalVar.LOneMaterialNum = result.materialCollection.Count;
  2150. globalVar.LOneFryPotSerial = headNum;
  2151. globalVar.LOneCurrentRecipeName = result.RecipeName;
  2152. AgvViewModel.GetInstance().Set滚筒线上数量(1, globalVar.LOneMaterialNum.ToString());
  2153. MessageLog.GetInstance.ShowUserLog($"【1】号滚筒线开始制作【{result.RecipeName}】 配方");
  2154. for (int i = 0; i < result.materialCollection.Count; i++) //遍历单个配方中所有物料
  2155. {
  2156. if (result.materialCollection.Count <= 8 && result.materialCollection[i].MaterialLoc % 100 == i + 1 && result.materialCollection[i].MaterialLoc / 100 == headNum && (headNum == 1 || headNum == 4))
  2157. {
  2158. if (headNum == 1)//炒锅1
  2159. {
  2160. fryOneRecipe = result.RecipeName;//炒锅状态开始记录
  2161. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_1.goodsName = result.RecipeName; }));
  2162. }
  2163. else//炒锅4
  2164. {
  2165. fryFourRecipe = result.RecipeName;//炒锅状态开始记录
  2166. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.goodsName = result.RecipeName; }));
  2167. }
  2168. //将配方中原料加入新的队列
  2169. InputMaterialQuene.Enqueue(new MaterialInfo()
  2170. {
  2171. materialType = result.materialCollection[i],
  2172. materialId = result.RecipeId
  2173. });
  2174. RollerOneDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight);//1号滚筒线桶号以及重量数据下发
  2175. }
  2176. else
  2177. {
  2178. MessageLog.GetInstance.ShowRunLog($"【1】号滚筒线配方桶号配置错误,取消【{result.RecipeName}】配方制作");
  2179. MessageLog.GetInstance.ShowUserLog($"【1】号滚筒线配方桶号配置错误,取消【{result.RecipeName}】配方制作");
  2180. InputMaterialQuene.Clear();
  2181. ErrorRecipe = true;
  2182. return;
  2183. }
  2184. }
  2185. DeviceOperate.GetInstance.WritePlcData("D1009", (ushort)result.materialCollection.Count);//发送1号滚筒线工序数据
  2186. }
  2187. }
  2188. }
  2189. /// <summary>
  2190. /// 数据下发PLC
  2191. /// </summary>
  2192. //public void RecipeDataToPlc()
  2193. //{
  2194. // if (RecipeQuene.Count > 0 && OutputMaterialQuene.Count == 0 && InputMaterialQuene.Count == 0)//后续添加其它限制条件
  2195. // {
  2196. // //NewRecipeModel newRecipe = new NewRecipeModel();
  2197. // //MaterialType material = new MaterialType();
  2198. // if (RecipeQuene.TryDequeue(out NewRecipeModel result))
  2199. // {
  2200. // //newRecipe = result;
  2201. // MessageLog.GetInstance.ShowRunLog($"开始制作【{result.RecipeName}】 配方");
  2202. // //for (int k = 0; k < newRecipe.materialCollection.Count - 1; k++)
  2203. // //{
  2204. // // for (int j = 0; j < newRecipe.materialCollection.Count - 1 - k; j++)
  2205. // // {
  2206. // // if (newRecipe.materialCollection[j].MaterialLoc > newRecipe.materialCollection[j + 1].MaterialLoc)
  2207. // // {
  2208. // // material = newRecipe.materialCollection[j];
  2209. // // // newRecipe.materialCollection[j] = null;
  2210. // // newRecipe.materialCollection[j] = newRecipe.materialCollection[j + 1];
  2211. // // // newRecipe.materialCollection[j + 1] = null;
  2212. // // newRecipe.materialCollection[j + 1] = material;
  2213. // // }
  2214. // // }
  2215. // //}
  2216. // for (int i = 0; i < result.materialCollection.Count; i++) //遍历单个配方中所有物料
  2217. // {
  2218. // //将配方中原料加入新的队列
  2219. // InputMaterialQuene.Enqueue(new MaterialInfo()
  2220. // {
  2221. // materialType = result.materialCollection[i],
  2222. // materialId = result.RecipeId
  2223. // });
  2224. // ushort n = result.materialCollection[i].MaterialLoc;
  2225. // switch (n / 100)
  2226. // {
  2227. // case 1:
  2228. // case 4: RollerOneDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight); break;//1号滚筒线桶号以及重量数据下发
  2229. // case 2:
  2230. // case 5: RollerTwoDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight); break;//2号滚筒线桶号以及重量数据下发
  2231. // case 3: RollerThreeDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight); break;//3号滚筒线桶号以及重量数据下发
  2232. // }
  2233. // }
  2234. // switch (result.materialCollection[0].MaterialLoc / 100)
  2235. // {
  2236. // case 1:
  2237. // DeviceOperate.GetInstance.WritePlcData("D1009", (ushort)result.materialCollection.Count); break;//发送1号滚筒线工序数据
  2238. // case 2:
  2239. // DeviceOperate.GetInstance.WritePlcData("D1026", (ushort)result.materialCollection.Count); break;//发送2号滚筒线工序数据
  2240. // case 3:
  2241. // DeviceOperate.GetInstance.WritePlcData("D1043", (ushort)result.materialCollection.Count); break;//发送3号滚筒线工序数据
  2242. // }
  2243. // }
  2244. // }
  2245. //}
  2246. /// <summary>
  2247. /// AGV到配方线体1装桶以及出料到炒锅
  2248. /// </summary>
  2249. //public void AgvLoadRoller()
  2250. //{
  2251. // //lineAlarm = 0;
  2252. // if (InputMaterialQuene.Count > 0)
  2253. // {
  2254. // switch (InputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  2255. // {
  2256. // case 1:
  2257. // case 4: AgvToLineOneLoadRoller(); AgvFromLineOneToFryPot(); break;//AGV到1号线体装桶
  2258. // case 2:
  2259. // case 5: AgvToLineTwoLoadRoller(); AgvFromLineTwoToFryPot(); break;//AGV到2号线体装桶
  2260. // case 3: AgvToLineThreeLoadRoller(); AgvFromLineThreeToFryPot(); break;//AGV到3号线体装桶
  2261. // }
  2262. // }
  2263. //}
  2264. /// <summary>
  2265. /// AGV到配方线体1装桶以及出料到炒锅
  2266. /// </summary>
  2267. public void LOneLoadRoller()
  2268. {
  2269. if (InputMaterialQuene.Count > 0)
  2270. {
  2271. AgvToLineOneLoadRoller();
  2272. AgvFromLineOneToFryPot();//AGV到1号线体装桶
  2273. AgvLineOneLoadRollerCom();
  2274. }
  2275. }
  2276. /// <summary>
  2277. /// 判断agv在1号线体是否上料完成,作为线体空桶能否开始运输的条件
  2278. /// </summary>
  2279. /// <exception cref="NotImplementedException"></exception>
  2280. private void AgvLineOneLoadRollerCom()
  2281. {
  2282. if (globalVar.agvLineOneLoadCom)
  2283. {
  2284. globalVar.rollerLineOne.CanRun = true;
  2285. globalVar.agvLineOneLoadCom = false;
  2286. MessageLog.GetInstance.ShowRunLog("AGV在【1】号滚筒线装桶完成");
  2287. }
  2288. }
  2289. /// <summary>
  2290. /// AGV到配方线体2装桶以及出料到炒锅
  2291. /// </summary>
  2292. public void LTwoAgvLoadRoller()
  2293. {
  2294. if (LTwoInputMaterialQuene.Count > 0)
  2295. {
  2296. AgvToLineTwoLoadRoller();
  2297. AgvFromLineTwoToFryPot();//AGV到2号线体装桶
  2298. AgvLineTwoLoadRollerCom();
  2299. }
  2300. }
  2301. /// <summary>
  2302. /// 判断agv在1号线体是否上料完成,作为线体空桶能否开始运输的条件
  2303. /// </summary>
  2304. private void AgvLineTwoLoadRollerCom()
  2305. {
  2306. if (globalVar.agvLineTwoLoadCom)
  2307. {
  2308. globalVar.rollerLineTwo.CanRun = true;
  2309. globalVar.agvLineTwoLoadCom = false;
  2310. MessageLog.GetInstance.ShowRunLog("AGV在【2】号滚筒线装桶完成");
  2311. }
  2312. }
  2313. /// <summary>
  2314. /// AGV到配方线体3装桶以及出料到炒锅
  2315. /// </summary>
  2316. public void LThreeAgvLoadRoller()
  2317. {
  2318. if (LThreeInputMaterialQuene.Count > 0)
  2319. {
  2320. AgvToLineThreeLoadRoller();
  2321. AgvFromLineThreeToFryPot();//AGV到2号线体装桶
  2322. AgvLineThreeLoadRollerCom();
  2323. }
  2324. }
  2325. /// <summary>
  2326. /// 判断agv在1号线体是否上料完成,作为线体空桶能否开始运输的条件
  2327. /// </summary>
  2328. private void AgvLineThreeLoadRollerCom()
  2329. {
  2330. if (globalVar.agvLineThreeLoadCom)
  2331. {
  2332. globalVar.rollerLineThree.CanRun = true;
  2333. globalVar.agvLineThreeLoadCom = false;
  2334. MessageLog.GetInstance.ShowRunLog("AGV在【3】号滚筒线装桶完成");
  2335. }
  2336. }
  2337. /// <summary>
  2338. /// AGV从炒锅送料位置到倒料过程处理
  2339. /// </summary>
  2340. //public void FryPotInputMaterial()
  2341. //{
  2342. // if (OutputMaterialQuene.Count > 0 && !globalVar.InOrOutputLock)
  2343. // {
  2344. // while (!agvArriveUnLoad)//等待agv到达炒锅位置
  2345. // {
  2346. // Thread.Sleep(5);
  2347. // if (globalVar.ExitMainTask)
  2348. // return;
  2349. // }
  2350. // AgvArriveFryPotSingleSetDown();
  2351. // FryPotRollerTroubleCheck();
  2352. // if (FryPotAlarm == 1)//炒锅滚筒无故障
  2353. // {
  2354. // //炒锅滚筒进料运行到位处理
  2355. // FryPotInputMaterialRollerOperate();
  2356. // globalVar.InOrOutputLock = true;
  2357. // }
  2358. // }
  2359. //}
  2360. /// <summary>
  2361. /// 线体1的AGV从炒锅送料位置到倒料过程处理
  2362. /// </summary>
  2363. public void LOneFryPotInputMaterial()
  2364. {
  2365. if (OutputMaterialQuene.Count > 0 && globalVar.agvArriveUnLoad && globalVar.AgvToFryPot && !globalVar.PotOneInputMaterialArrive)
  2366. {
  2367. //if (globalVar.LOneFryPotSerial == 1)
  2368. //{
  2369. // AgvViewModel.GetInstance().Set小车运动(1, CartMotionTrajectory.yc_1_1);
  2370. //}
  2371. //else if (globalVar.LOneFryPotSerial == 4)
  2372. //{
  2373. // AgvViewModel.GetInstance().Set小车运动(1, CartMotionTrajectory.yc_1_4);
  2374. //}
  2375. MessageLog.GetInstance.ShowRunLog($"AGV到达【{globalVar.LOneFryPotSerial}】号炒锅下料位置");
  2376. AgvArriveFryPotOneOrFourSingleSetDown();
  2377. globalVar.agvArriveUnLoad = false;
  2378. globalVar.PotOneInputMaterialArrive = true;
  2379. }
  2380. }
  2381. public void LOneFallMaterial()
  2382. {
  2383. if (!globalVar.InOrOutputLock && (globalVar.fryPotOne.InputMaterialArrivedSingle == 1 || globalVar.fryPotFour.InputMaterialArrivedSingle == 1) && globalVar.PotOneInputMaterialArrive && OutputMaterialQuene.Count > 0 && !globalVar.PotOneOutputRollerArrive)
  2384. {
  2385. //if (globalVar.LOneFryPotSerial == 1)
  2386. //{
  2387. // 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() });//向表中新增数据
  2388. // Sqlite<PotOneStatus>.GetInstance.Save();//保存数据
  2389. //}
  2390. //else
  2391. //{
  2392. // 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() });//向表中新增数据
  2393. // Sqlite<PotFourStatus>.GetInstance.Save();//保存数据
  2394. //}
  2395. FryPotOneRollerTroubleCheck();
  2396. if (FryPotAlarm == 1 || FryPotFourAlarm == 1)//炒锅滚筒无故障
  2397. {
  2398. if (globalVar.LOneFryPotSerial == 1)
  2399. {
  2400. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_1.workflows.Add(new WorkflowModel { id = globalVar.LOneCurrentCookingStep, Name = OutputMaterialQuene.ElementAt(0).materialType.MaterialName, isBool = IsBool.Yes }); }));
  2401. }
  2402. else
  2403. {
  2404. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.workflows.Add(new WorkflowModel { id = globalVar.LOneCurrentCookingStep, Name = OutputMaterialQuene.ElementAt(0).materialType.MaterialName, isBool = IsBool.Yes }); }));
  2405. }
  2406. AgvViewModel.GetInstance().Set小车是否承载物品(1, IsBool.No);
  2407. //炒锅滚筒进料运行到位处理
  2408. FryPotOneOrFourInputMaterialRollerOperate();
  2409. AgvFromFryPotOneOrFourToClean();//上游下发搬运任务给AGV
  2410. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LOneFryPotSerial, IsRun.Start);
  2411. globalVar.InOrOutputLock = true;
  2412. globalVar.PotOneOutputRollerArrive = true;
  2413. }
  2414. }
  2415. }
  2416. /// <summary>
  2417. /// 线体2的AGV从炒锅送料位置到倒料过程处理
  2418. /// </summary>
  2419. public void LTwoFryPotInputMaterial()
  2420. {
  2421. if (LTwoOutputMaterialQuene.Count > 0 && globalVar.LTwoagvArriveUnLoad && globalVar.LTwoAgvToFryPot && !globalVar.LTwoPotInputMaterialArrive)
  2422. {
  2423. //if (globalVar.LTwoFryPotSerial == 2)
  2424. //{
  2425. // AgvViewModel.GetInstance().Set小车运动(2, CartMotionTrajectory.yc_2_2);
  2426. //}
  2427. //else if (globalVar.LTwoFryPotSerial == 5)
  2428. //{
  2429. // AgvViewModel.GetInstance().Set小车运动(2, CartMotionTrajectory.yc_2_5);
  2430. //}
  2431. MessageLog.GetInstance.ShowRunLog($"AGV到达【{globalVar.LTwoFryPotSerial}】号炒锅下料位置");
  2432. AgvArriveFryPotTwoOrFiveSingleSetDown();
  2433. globalVar.LTwoagvArriveUnLoad = false;
  2434. globalVar.LTwoPotInputMaterialArrive = true;
  2435. }
  2436. }
  2437. public void LTwoFallMaterial()
  2438. {
  2439. if (!globalVar.LTwoInOrOutputLock && (globalVar.fryPotTwo.InputMaterialArrivedSingle == 1 || globalVar.fryPotFive.InputMaterialArrivedSingle == 1) && globalVar.LTwoPotInputMaterialArrive && LTwoOutputMaterialQuene.Count > 0 && !globalVar.LTwoPotOutputRollerArrive)
  2440. {
  2441. //if (globalVar.LTwoFryPotSerial == 2)
  2442. //{
  2443. // 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() });//向表中新增数据
  2444. // Sqlite<PotTwoStatus>.GetInstance.Save();//保存数据
  2445. //}
  2446. //else
  2447. //{
  2448. // 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() });//向表中新增数据
  2449. // Sqlite<PotFiveStatus>.GetInstance.Save();//保存数据
  2450. //}
  2451. FryPotTwoRollerTroubleCheck();
  2452. if (FryPotTwoAlarm == 1 || FryPotFiveAlarm == 1)//炒锅滚筒无故障
  2453. {
  2454. if (globalVar.LTwoFryPotSerial == 2)
  2455. {
  2456. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_2.workflows.Add(new WorkflowModel { id = globalVar.LTwoCurrentCookingStep, Name = LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialName, isBool = IsBool.Yes }); }));
  2457. }
  2458. else
  2459. {
  2460. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_5.workflows.Add(new WorkflowModel { id = globalVar.LTwoCurrentCookingStep, Name = LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialName, isBool = IsBool.Yes }); }));
  2461. }
  2462. AgvViewModel.GetInstance().Set小车是否承载物品(2, IsBool.No);
  2463. //炒锅滚筒进料运行到位处理
  2464. FryPotTwoOrFiveInputMaterialRollerOperate();
  2465. AgvFromFryPotTwoOrFiveToClean();//上游下发搬运任务给AGV
  2466. AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LTwoFryPotSerial, IsRun.Start);
  2467. globalVar.LTwoInOrOutputLock = true;
  2468. globalVar.LTwoPotOutputRollerArrive = true;
  2469. }
  2470. }
  2471. }
  2472. /// <summary>
  2473. /// 线体3的AGV从炒锅送料位置到倒料过程处理
  2474. /// </summary>
  2475. public void LThreeFryPotInputMaterial()
  2476. {
  2477. if (LThreeOutputMaterialQuene.Count > 0 && globalVar.LThreeagvArriveUnLoad && globalVar.LThreeAgvToFryPot && !globalVar.LThreePotInputMaterialArrive)
  2478. {
  2479. // AgvViewModel.GetInstance().Set小车运动(3, CartMotionTrajectory.yc_3_3);
  2480. MessageLog.GetInstance.ShowRunLog("AGV到达【3】号炒锅下料位置");
  2481. AgvArriveFryPotThreeSingleSetDown();
  2482. globalVar.LThreeagvArriveUnLoad = false;
  2483. globalVar.LThreePotInputMaterialArrive = true;
  2484. }
  2485. }
  2486. public void LThreeFallMaterial()
  2487. {
  2488. if (!globalVar.LThreeInOrOutputLock && globalVar.fryPotThree.InputMaterialArrivedSingle == 1 && globalVar.LThreePotInputMaterialArrive && LThreeOutputMaterialQuene.Count > 0 && !globalVar.LThreePotOutputRollerArrive)
  2489. {
  2490. //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() });//向表中新增数据
  2491. //Sqlite<PotThreeStatus>.GetInstance.Save();//保存数据
  2492. FryPotThreeRollerTroubleCheck();
  2493. if (FryPotThreeAlarm == 1)//炒锅滚筒无故障
  2494. {
  2495. Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.workflows.Add(new WorkflowModel { id = globalVar.LThreeCurrentCookingStep, Name = LThreeOutputMaterialQuene.ElementAt(0).materialType.MaterialName, isBool = IsBool.Yes }); }));
  2496. AgvViewModel.GetInstance().Set小车是否承载物品(3, IsBool.No);
  2497. //炒锅滚筒进料运行到位处理
  2498. FryPotThreeInputMaterialRollerOperate();
  2499. AgvFromFryPotThreeToClean();//上游下发搬运任务给AGV
  2500. AgvViewModel.GetInstance().Set启动或停止炒锅(3, IsRun.Start);
  2501. globalVar.LThreeInOrOutputLock = true;
  2502. globalVar.LThreePotOutputRollerArrive = true;
  2503. }
  2504. }
  2505. }
  2506. /// <summary>
  2507. /// 炒锅出桶
  2508. /// </summary>
  2509. //public void FryPotOutputMaterial()
  2510. //{
  2511. // if (OutputMaterialQuene.Count > 0 && globalVar.InOrOutputLock)
  2512. // {
  2513. // AgvFromFryPotToClean();//上游下发搬运任务给AGV
  2514. // while (!agvArriveUpLoad)//等待agv到达炒锅位置
  2515. // {
  2516. // Thread.Sleep(5);
  2517. // if (globalVar.ExitMainTask)
  2518. // return;
  2519. // }
  2520. // agvArriveUpLoad = false;
  2521. // AgvArriveFryPotOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号
  2522. // FryPotRollerTroubleCheck();
  2523. // if (FryPotAlarm == 1)//无故障
  2524. // {
  2525. // FryPotOutEmpetyRollerOperate();
  2526. // if (OutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料
  2527. // {
  2528. // while (!agvFryPotEmptyRollerArrive)//等待AGV拿到出桶空桶
  2529. // {
  2530. // Thread.Sleep(5);
  2531. // if (globalVar.ExitMainTask)
  2532. // return;
  2533. // }
  2534. // //AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅
  2535. // globalVar.AllowAgvToLineLoadRoller = true;
  2536. // globalVar.InOrOutputLock = false;
  2537. // }
  2538. // }
  2539. // }
  2540. //}
  2541. /// <summary>
  2542. /// 线体1对应炒锅出桶
  2543. /// </summary>
  2544. public void LOneFryPotOutputMaterial()
  2545. {
  2546. if (OutputMaterialQuene.Count > 0 && globalVar.InOrOutputLock && globalVar.agvArriveUpLoad && globalVar.PotOneOutputRollerArrive && !globalVar.AgvArrivePot)
  2547. {
  2548. MessageLog.GetInstance.ShowRunLog($"AGV到达【{globalVar.LOneFryPotSerial}】号炒锅空桶上料位置");
  2549. AgvArriveFryPotOneOrFourOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号
  2550. globalVar.agvArriveUpLoad = false;
  2551. globalVar.AgvArrivePot = true;
  2552. }
  2553. }
  2554. public void LOneEmptyOperate()
  2555. {
  2556. if ((globalVar.fryPotOne.EmptyBarrelArrivedSingle == 1 || globalVar.fryPotFour.EmptyBarrelArrivedSingle == 1) && OutputMaterialQuene.Count > 0 && globalVar.AgvArrivePot)
  2557. {
  2558. FryPotOneRollerTroubleCheck();
  2559. if (FryPotAlarm == 1 || FryPotFourAlarm == 1)//无故障
  2560. {
  2561. if (globalVar.agvFryPotEmptyRollerArrive)
  2562. {
  2563. FryPotOneOrFourOutEmpetyRollerOperate();
  2564. if (OutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料
  2565. {
  2566. //AgvViewModel.GetInstance().Set小车是否承载物品(1, IsBool.OnllYes);
  2567. //if (globalVar.LOneFryPotSerial == 1)
  2568. //{
  2569. // AgvViewModel.GetInstance().Set小车运动(1, CartMotionTrajectory.hs_1);
  2570. //}
  2571. //else if (globalVar.LOneFryPotSerial == 4)
  2572. //{
  2573. // AgvViewModel.GetInstance().Set小车运动(1, CartMotionTrajectory.hs_4);
  2574. //}
  2575. globalVar.agvFryPotEmptyRollerArrive = false;
  2576. globalVar.InOrOutputLock = false;
  2577. globalVar.LOneMaterialNum--;
  2578. MessageLog.GetInstance.ShowRunLog($"AGV在【{globalVar.LOneFryPotSerial}】号炒锅将空桶回收到4号滚筒线");
  2579. //AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅
  2580. globalVar.AllowAgvToLineLoadRoller = true;
  2581. globalVar.LoadRoller = false;
  2582. globalVar.AgvToFryPot = false;
  2583. globalVar.PotOneInputMaterialArrive = false;
  2584. globalVar.PotOneOutputRollerArrive = false;
  2585. globalVar.AgvArrivePot = false;
  2586. }
  2587. }
  2588. }
  2589. }
  2590. }
  2591. /// <summary>
  2592. /// 线体2对应炒锅出桶
  2593. /// </summary>
  2594. public void LTwoFryPotOutputMaterial()
  2595. {
  2596. if (LTwoOutputMaterialQuene.Count > 0 && globalVar.LTwoInOrOutputLock && globalVar.agvArriveLTwoUpLoad && globalVar.LTwoPotOutputRollerArrive && !globalVar.LTwoAgvArrivePot)
  2597. {
  2598. MessageLog.GetInstance.ShowRunLog($"AGV到达【{globalVar.LTwoFryPotSerial}】号炒锅空桶上料位置");
  2599. AgvArriveFryPotTwoOrFiveOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号
  2600. globalVar.agvArriveLTwoUpLoad = false;
  2601. globalVar.LTwoAgvArrivePot = true;
  2602. }
  2603. }
  2604. public void LTwoEmptyOperate()
  2605. {
  2606. if ((globalVar.fryPotTwo.EmptyBarrelArrivedSingle == 1 || globalVar.fryPotFive.EmptyBarrelArrivedSingle == 1) && LTwoOutputMaterialQuene.Count > 0 && globalVar.LTwoAgvArrivePot)
  2607. {
  2608. FryPotTwoRollerTroubleCheck();
  2609. if (FryPotTwoAlarm == 1 || FryPotFiveAlarm == 1)//无故障
  2610. {
  2611. if (globalVar.LTwoagvFryPotEmptyRollerArrive)
  2612. {
  2613. FryPotTwoOrFiveOutEmpetyRollerOperate();
  2614. if (LTwoOutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料
  2615. {
  2616. //AgvViewModel.GetInstance().Set小车是否承载物品(2, IsBool.OnllYes);
  2617. //if (globalVar.LTwoFryPotSerial == 2)
  2618. //{
  2619. // AgvViewModel.GetInstance().Set小车运动(2, CartMotionTrajectory.hs_2);
  2620. //}
  2621. //else if (globalVar.LTwoFryPotSerial == 5)
  2622. //{
  2623. // AgvViewModel.GetInstance().Set小车运动(2, CartMotionTrajectory.hs_5);
  2624. //}
  2625. globalVar.LTwoagvFryPotEmptyRollerArrive = false;
  2626. globalVar.LTwoInOrOutputLock = false;
  2627. globalVar.LTwoMaterialNum--;
  2628. MessageLog.GetInstance.ShowRunLog($"AGV在【{globalVar.LTwoFryPotSerial}】号炒锅将空桶回收到4号滚筒线");
  2629. //AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅
  2630. globalVar.AllowAgvToLineTwoLoadRoller = true;
  2631. globalVar.LTwoLoadRoller = false;
  2632. globalVar.LTwoAgvToFryPot = false;
  2633. globalVar.LTwoPotInputMaterialArrive = false;
  2634. globalVar.LTwoPotOutputRollerArrive = false;
  2635. globalVar.LTwoAgvArrivePot = false;
  2636. }
  2637. }
  2638. }
  2639. }
  2640. }
  2641. /// <summary>
  2642. /// 线体3对应炒锅出桶
  2643. /// </summary>
  2644. public void LThreeFryPotOutputMaterial()
  2645. {
  2646. if (LThreeOutputMaterialQuene.Count > 0 && globalVar.LThreeInOrOutputLock && globalVar.agvArriveLThreeUpLoad && globalVar.LThreePotOutputRollerArrive && !globalVar.LThreeAgvArrivePot)
  2647. {
  2648. MessageLog.GetInstance.ShowRunLog($"AGV到达【{globalVar.LThreeFryPotSerial}】号炒锅空桶上料位置");
  2649. AgvArriveFryPotThreeOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号
  2650. globalVar.agvArriveLThreeUpLoad = false;
  2651. globalVar.LThreeAgvArrivePot = true;
  2652. }
  2653. }
  2654. public void LThreeEmptyOperate()
  2655. {
  2656. if (globalVar.fryPotThree.EmptyBarrelArrivedSingle == 1 && LThreeOutputMaterialQuene.Count > 0 && globalVar.LThreeAgvArrivePot)
  2657. {
  2658. FryPotThreeRollerTroubleCheck();
  2659. if (FryPotThreeAlarm == 1)//无故障
  2660. {
  2661. if (globalVar.LThreeagvFryPotEmptyRollerArrive)
  2662. {
  2663. FryPotThreeOutEmpetyRollerOperate();
  2664. if (LThreeOutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料
  2665. {
  2666. //AgvViewModel.GetInstance().Set小车是否承载物品(3, IsBool.OnllYes);
  2667. //AgvViewModel.GetInstance().Set小车运动(3, CartMotionTrajectory.hs_3);
  2668. globalVar.LThreeagvFryPotEmptyRollerArrive = false;
  2669. globalVar.LThreeInOrOutputLock = false;
  2670. globalVar.LThreeMaterialNum--;
  2671. MessageLog.GetInstance.ShowRunLog($"AGV在【{globalVar.LThreeFryPotSerial}】号炒锅将空桶回收到4号滚筒线");
  2672. //AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅
  2673. globalVar.AllowAgvToLineThreeLoadRoller = true;
  2674. globalVar.LThreeLoadRoller = false;
  2675. globalVar.LThreeAgvToFryPot = false;
  2676. globalVar.LThreePotInputMaterialArrive = false;
  2677. globalVar.LThreePotOutputRollerArrive = false;
  2678. globalVar.LThreeAgvArrivePot = false;
  2679. }
  2680. }
  2681. }
  2682. }
  2683. }
  2684. /// <summary>
  2685. /// 4号线体下料
  2686. /// </summary>
  2687. public void EmptyRollerToLinFour()
  2688. {
  2689. if (globalVar.agvArriveLineFour)//agv到达线体4下料位置
  2690. {
  2691. globalVar.agvArriveLineFour = false;
  2692. //线体四信号交互
  2693. MessageLog.GetInstance.ShowRunLog("AGV到达【4】号回收线体,准备卸桶");
  2694. MessageLog.GetInstance.ShowRunLog("卸桶完成");
  2695. }
  2696. }
  2697. ///// <summary>
  2698. ///// 2号线体对应空桶清洗
  2699. ///// </summary>
  2700. //public void LTwoEmptyRollerToLineFour()
  2701. //{
  2702. // if (globalVar.LTwoEmptyRollerUnLoadcCom)//agv在4号线体下料完成
  2703. // {
  2704. // globalVar.AllowAgvToLineTwoLoadRoller = true;
  2705. // globalVar.LTwoLoadRoller = false;
  2706. // globalVar.LTwoAgvToFryPot = false;
  2707. // globalVar.LTwoPotInputMaterialArrive = false;
  2708. // globalVar.LTwoPotOutputRollerArrive = false;
  2709. // globalVar.LTwoAgvArrivePot = false;
  2710. // }
  2711. //}
  2712. ///// <summary>
  2713. ///// 3号线体对应空桶清洗
  2714. ///// </summary>
  2715. //public void LThreeEmptyRollerToLinFour()
  2716. //{
  2717. // if (globalVar.LThreeEmptyRollerUnLoadcCom)//agv在4号线体下料完成
  2718. // {
  2719. // globalVar.AllowAgvToLineThreeLoadRoller = true;
  2720. // globalVar.LThreeLoadRoller = false;
  2721. // globalVar.LThreeAgvToFryPot = false;
  2722. // globalVar.LThreePotInputMaterialArrive = false;
  2723. // globalVar.LThreePotOutputRollerArrive = false;
  2724. // globalVar.LThreeAgvArrivePot = false;
  2725. // }
  2726. //}
  2727. /// <summary>
  2728. /// 炒锅滚筒进料运行到位处理
  2729. /// </summary>
  2730. //public void FryPotInputMaterialRollerOperate(ConcurrentQueue<MaterialInfo> queue)
  2731. //{
  2732. // switch (queue.ElementAt(0).materialType.MaterialLoc / 100)
  2733. // {
  2734. // case 1:
  2735. // while (globalVar.fryPotOne.InputMaterialArrivedSingle == 0)
  2736. // {
  2737. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2738. // return;
  2739. // }
  2740. // MessageLog.GetInstance.ShowRunLog($"炒锅【1】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
  2741. // case 2:
  2742. // while (globalVar.fryPotTwo.InputMaterialArrivedSingle == 0)
  2743. // {
  2744. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2745. // return;
  2746. // }
  2747. // MessageLog.GetInstance.ShowRunLog($"炒锅【2】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
  2748. // case 3:
  2749. // while (globalVar.fryPotThree.InputMaterialArrivedSingle == 0)
  2750. // {
  2751. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2752. // return;
  2753. // }
  2754. // MessageLog.GetInstance.ShowRunLog($"炒锅【3】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
  2755. // case 4:
  2756. // while (globalVar.fryPotFour.InputMaterialArrivedSingle == 0)
  2757. // {
  2758. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2759. // return;
  2760. // }
  2761. // MessageLog.GetInstance.ShowRunLog($"炒锅【4】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
  2762. // case 5:
  2763. // while (globalVar.fryPotFive.InputMaterialArrivedSingle == 0)
  2764. // {
  2765. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2766. // return;
  2767. // }
  2768. // MessageLog.GetInstance.ShowRunLog($"炒锅【5】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
  2769. // }
  2770. //}
  2771. /// <summary>
  2772. /// 炒锅1,4滚筒进料运行到位处理
  2773. /// </summary>
  2774. public void FryPotOneOrFourInputMaterialRollerOperate()
  2775. {
  2776. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  2777. {
  2778. case 1:
  2779. //while (globalVar.fryPotOne.InputMaterialArrivedSingle == 0)
  2780. //{
  2781. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2782. // return;
  2783. //}
  2784. MessageLog.GetInstance.ShowRunLog($"炒锅【1】:【{OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】号桶已到进料位置,准备倒料"); break;
  2785. case 4:
  2786. //while (globalVar.fryPotFour.InputMaterialArrivedSingle == 0)
  2787. //{
  2788. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2789. // return;
  2790. //}
  2791. MessageLog.GetInstance.ShowRunLog($"炒锅【4】:【{OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】号桶已到进料位置,准备倒料"); break;
  2792. }
  2793. }
  2794. /// <summary>
  2795. /// 炒锅2,5滚筒进料运行到位处理
  2796. /// </summary>
  2797. public void FryPotTwoOrFiveInputMaterialRollerOperate()
  2798. {
  2799. switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  2800. {
  2801. case 2:
  2802. //while (globalVar.fryPotTwo.InputMaterialArrivedSingle == 0)
  2803. //{
  2804. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2805. // return;
  2806. //}
  2807. MessageLog.GetInstance.ShowRunLog($"炒锅【2】:【{LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】号桶已到进料位置,准备倒料"); break;
  2808. case 5:
  2809. //while (globalVar.fryPotFive.InputMaterialArrivedSingle == 0)
  2810. //{
  2811. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2812. // return;
  2813. //}
  2814. MessageLog.GetInstance.ShowRunLog($"炒锅【5】:【{LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】号桶已到进料位置,准备倒料"); break;
  2815. }
  2816. }
  2817. public void FryPotThreeInputMaterialRollerOperate()
  2818. {
  2819. //while (globalVar.fryPotThree.InputMaterialArrivedSingle == 0)
  2820. //{
  2821. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2822. // return;
  2823. //}
  2824. MessageLog.GetInstance.ShowRunLog($"炒锅【3】:【{LThreeOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc}】号桶已到进料位置,准备倒料");
  2825. }
  2826. /// <summary>
  2827. /// 炒锅滚筒空桶出桶处理
  2828. /// </summary>
  2829. //public void FryPotOutEmpetyRollerOperate(ConcurrentQueue<MaterialInfo> queue)
  2830. //{
  2831. // switch (queue.ElementAt(0).materialType.MaterialLoc / 100)
  2832. // {
  2833. // case 1:
  2834. // while (globalVar.fryPotOne.EmptyBarrelArrivedSingle == 0)
  2835. // {
  2836. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2837. // return;
  2838. // }
  2839. // MessageLog.GetInstance.ShowRunLog($"炒锅【1】原料:【{queue.ElementAt(0).materialType.MaterialName}】空桶到达出桶位置,正在出桶"); break;
  2840. // case 2:
  2841. // while (globalVar.fryPotTwo.EmptyBarrelArrivedSingle == 0)
  2842. // {
  2843. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2844. // return;
  2845. // }
  2846. // MessageLog.GetInstance.ShowRunLog($"炒锅【2】原料:【{queue.ElementAt(0).materialType.MaterialName}】空桶到达出桶位置,正在出桶"); break;
  2847. // case 3:
  2848. // while (globalVar.fryPotThree.EmptyBarrelArrivedSingle == 0)
  2849. // {
  2850. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2851. // return;
  2852. // }
  2853. // MessageLog.GetInstance.ShowRunLog($"炒锅【3】原料:【{queue.ElementAt(0).materialType.MaterialName}】空桶到达出桶位置,正在出桶"); break;
  2854. // case 4:
  2855. // while (globalVar.fryPotFour.EmptyBarrelArrivedSingle == 0)
  2856. // {
  2857. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2858. // return;
  2859. // }
  2860. // MessageLog.GetInstance.ShowRunLog($"炒锅【4】原料:【{queue.ElementAt(0).materialType.MaterialName}】空桶到达出桶位置,正在出桶"); break;
  2861. // case 5:
  2862. // while (globalVar.fryPotFive.EmptyBarrelArrivedSingle == 0)
  2863. // {
  2864. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2865. // return;
  2866. // }
  2867. // MessageLog.GetInstance.ShowRunLog($"炒锅【5】原料:【{queue.ElementAt(0).materialType.MaterialName}】空桶到达出桶位置,正在出桶"); break;
  2868. // }
  2869. //}
  2870. /// <summary>
  2871. /// 炒锅1,4滚筒空桶出桶处理
  2872. /// </summary>
  2873. public void FryPotOneOrFourOutEmpetyRollerOperate()
  2874. {
  2875. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  2876. {
  2877. case 1:
  2878. //while (globalVar.fryPotOne.EmptyBarrelArrivedSingle == 0)
  2879. //{
  2880. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2881. // return;
  2882. //}
  2883. MessageLog.GetInstance.ShowRunLog($"炒锅【1】原料:【{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}】空桶上料完成"); break;
  2884. case 4:
  2885. //while (globalVar.fryPotFour.EmptyBarrelArrivedSingle == 0)
  2886. //{
  2887. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2888. // return;
  2889. //}
  2890. MessageLog.GetInstance.ShowRunLog($"炒锅【4】原料:【{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}】空桶上料完成"); break;
  2891. }
  2892. }
  2893. /// <summary>
  2894. /// 炒锅2,5滚筒空桶出桶处理
  2895. /// </summary>
  2896. public void FryPotTwoOrFiveOutEmpetyRollerOperate()
  2897. {
  2898. switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  2899. {
  2900. case 2:
  2901. //while (globalVar.fryPotTwo.EmptyBarrelArrivedSingle == 0)
  2902. //{
  2903. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2904. // return;
  2905. //}
  2906. MessageLog.GetInstance.ShowRunLog($"炒锅【2】原料:【{LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialName}】空桶上料完成"); break;
  2907. case 5:
  2908. //while (globalVar.fryPotFive.EmptyBarrelArrivedSingle == 0)
  2909. //{
  2910. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2911. // return;
  2912. //}
  2913. MessageLog.GetInstance.ShowRunLog($"炒锅【5】原料:【{LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialName}】空桶上料完成"); break;
  2914. }
  2915. }
  2916. /// <summary>
  2917. /// 炒锅3滚筒空桶出桶处理
  2918. /// </summary>
  2919. public void FryPotThreeOutEmpetyRollerOperate()
  2920. {
  2921. //while (globalVar.fryPotThree.EmptyBarrelArrivedSingle == 0)
  2922. //{
  2923. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  2924. // return;
  2925. //}
  2926. MessageLog.GetInstance.ShowRunLog($"炒锅【3】原料:【{LThreeOutputMaterialQuene.ElementAt(0).materialType.MaterialName}】空桶上料完成");
  2927. }
  2928. /// <summary>
  2929. /// 发送agv送料就位信号至PLC(线体到炒锅)
  2930. /// </summary>
  2931. public void AgvArriveFryPotSingleSetDown(ConcurrentQueue<MaterialInfo> queue)
  2932. {
  2933. switch (queue.ElementAt(0).materialType.MaterialLoc / 100)
  2934. {
  2935. case 1: DeviceOperate.GetInstance.WritePlcData("D1055", 1); break;//agv到炒锅1送料就位信号
  2936. case 2: DeviceOperate.GetInstance.WritePlcData("D1056", 1); break;//agv到炒锅2送料就位信号
  2937. case 3: DeviceOperate.GetInstance.WritePlcData("D1057", 1); break;//agv到炒锅3送料就位信号
  2938. case 4: DeviceOperate.GetInstance.WritePlcData("D1058", 1); break;//agv到炒锅4送料就位信号
  2939. case 5: DeviceOperate.GetInstance.WritePlcData("D1059", 1); break;//agv到炒锅5送料就位信号
  2940. }
  2941. }
  2942. /// <summary>
  2943. /// 发送agv送料就位信号至PLC(线体1到炒锅)
  2944. /// </summary>
  2945. public void AgvArriveFryPotOneOrFourSingleSetDown()
  2946. {
  2947. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  2948. {
  2949. case 1: DeviceOperate.GetInstance.WritePlcData("D1055", 1); break;//agv到炒锅1送料就位信号
  2950. case 4: DeviceOperate.GetInstance.WritePlcData("D1058", 1); break;//agv到炒锅4送料就位信号
  2951. }
  2952. }
  2953. /// <summary>
  2954. /// 发送agv送料就位信号至PLC(线体2到炒锅)
  2955. /// </summary>
  2956. public void AgvArriveFryPotTwoOrFiveSingleSetDown()
  2957. {
  2958. switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  2959. {
  2960. case 2: DeviceOperate.GetInstance.WritePlcData("D1056", 1); break;//agv到炒锅2送料就位信号
  2961. case 5: DeviceOperate.GetInstance.WritePlcData("D1059", 1); break;//agv到炒锅5送料就位信号
  2962. }
  2963. }
  2964. /// <summary>
  2965. /// 发送agv送料就位信号至PLC(线体3到炒锅)
  2966. /// </summary>
  2967. public void AgvArriveFryPotThreeSingleSetDown()
  2968. {
  2969. DeviceOperate.GetInstance.WritePlcData("D1057", 1); //agv到炒锅3送料就位信号
  2970. }
  2971. /// <summary>
  2972. /// 发送agv回桶就位信号至PLC
  2973. /// </summary>
  2974. public void AgvArriveFryPotOutEmptyRollerSingleSetDown(ConcurrentQueue<MaterialInfo> queue)
  2975. {
  2976. switch (queue.ElementAt(0).materialType.MaterialLoc / 100)
  2977. {
  2978. case 1: DeviceOperate.GetInstance.WritePlcData("D1060", 1); break;//agv到炒锅1送料就位信号
  2979. case 2: DeviceOperate.GetInstance.WritePlcData("D1061", 1); break;//agv到炒锅2送料就位信号
  2980. case 3: DeviceOperate.GetInstance.WritePlcData("D1062", 1); break;//agv到炒锅3送料就位信号
  2981. case 4: DeviceOperate.GetInstance.WritePlcData("D1063", 1); break;//agv到炒锅4送料就位信号
  2982. case 5: DeviceOperate.GetInstance.WritePlcData("D1064", 1); break;//agv到炒锅5送料就位信号
  2983. }
  2984. }
  2985. public void AgvArriveFryPotOneOrFourOutEmptyRollerSingleSetDown()
  2986. {
  2987. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  2988. {
  2989. case 1: DeviceOperate.GetInstance.WritePlcData("D1060", 1); break;//agv到炒锅1送料就位信号
  2990. case 4: DeviceOperate.GetInstance.WritePlcData("D1063", 1); break;//agv到炒锅4送料就位信号
  2991. }
  2992. }
  2993. public void AgvArriveFryPotTwoOrFiveOutEmptyRollerSingleSetDown()
  2994. {
  2995. switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  2996. {
  2997. case 2: DeviceOperate.GetInstance.WritePlcData("D1061", 1); break;//agv到炒锅2送料就位信号
  2998. case 5: DeviceOperate.GetInstance.WritePlcData("D1064", 1); break;//agv到炒锅5送料就位信号
  2999. }
  3000. }
  3001. public void AgvArriveFryPotThreeOutEmptyRollerSingleSetDown()
  3002. {
  3003. DeviceOperate.GetInstance.WritePlcData("D1062", 1);//agv到炒锅3送料就位信号
  3004. }
  3005. ///// <summary>
  3006. ///// AGV离开炒锅运送空桶任务
  3007. ///// </summary>
  3008. //public void AgvFromFryPotToClean(ConcurrentQueue<MaterialInfo> queue)
  3009. //{
  3010. // switch (queue.ElementAt(0).materialType.MaterialLoc / 100)
  3011. // {
  3012. // case 1:
  3013. // erp: string id = Guid.NewGuid().ToString("N");//上游唯一ID
  3014. // if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId)
  3015. // {
  3016. // goto erp;
  3017. // }
  3018. // string info = AGVHelper.GetInstance.AgvLeaveFryPotOne(id);
  3019. // LOnerobotJobId = id;
  3020. // FryCarryTaskErrorCodeAnalysis(info, 1); break;
  3021. // case 2:
  3022. // erp1: string id1 = Guid.NewGuid().ToString("N");//上游唯一ID
  3023. // if (id1 == LTworobotJobId)
  3024. // {
  3025. // goto erp1;
  3026. // }
  3027. // string info1 = AGVHelper.GetInstance.AgvLeaveFryPotTwo(id1);
  3028. // LTworobotJobId = id1;
  3029. // FryCarryTaskErrorCodeAnalysis(info1, 2); break;
  3030. // case 3:
  3031. // erp2: string id2 = Guid.NewGuid().ToString("N");//上游唯一ID
  3032. // if (id2 == LThreerobotJobId)
  3033. // {
  3034. // goto erp2;
  3035. // }
  3036. // string info2 = AGVHelper.GetInstance.AgvLeaveFryPotThree(id2);
  3037. // LThreerobotJobId = id2;
  3038. // FryCarryTaskErrorCodeAnalysis(info2, 3); break;
  3039. // case 4:
  3040. // erp3: string id3 = Guid.NewGuid().ToString("N");//上游唯一ID
  3041. // if (id3 == LOnerobotJobId)
  3042. // {
  3043. // goto erp3;
  3044. // }
  3045. // string info3 = AGVHelper.GetInstance.AgvLeaveFryPotFour(id3);
  3046. // LOnerobotJobId = id3;
  3047. // FryCarryTaskErrorCodeAnalysis(info3, 4); break;
  3048. // case 5:
  3049. // erp4: string id4 = Guid.NewGuid().ToString("N");//上游唯一ID
  3050. // if (id4 == LTworobotJobId)
  3051. // {
  3052. // goto erp4;
  3053. // }
  3054. // string info4 = AGVHelper.GetInstance.AgvLeaveFryPotFive(id4);
  3055. // LTworobotJobId = id4;
  3056. // FryCarryTaskErrorCodeAnalysis(info4, 5); break;
  3057. // }
  3058. //}
  3059. /// <summary>
  3060. /// AGV离开炒锅1,4运送空桶任务
  3061. /// </summary>
  3062. public void AgvFromFryPotOneOrFourToClean()
  3063. {
  3064. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  3065. {
  3066. case 1:
  3067. erp: string id = Guid.NewGuid().ToString("N");//上游唯一ID
  3068. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId)
  3069. {
  3070. goto erp;
  3071. }
  3072. MessageLog.GetInstance.ShowRunLog("AGV执行【1】号炒锅空桶回收任务");
  3073. string info = AGVHelper.GetInstance.AgvLeaveFryPotOne(id);
  3074. LFourrobotJobId = id;
  3075. FryCarryTaskErrorCodeAnalysis(info, 1); break;
  3076. case 4:
  3077. erp3: string id3 = Guid.NewGuid().ToString("N");//上游唯一ID
  3078. if (id3 == LOnerobotJobId || id3 == LTworobotJobId || id3 == LThreerobotJobId || id3 == LFourrobotJobId || id3 == LFiverobotJobId || id3 == LSixrobotJobId || id3 == LSevenrobotJobId || id3 == LEightrobotJobId || id3 == LNinerobotJobId || id3 == LTenrobotJobId)
  3079. {
  3080. goto erp3;
  3081. }
  3082. MessageLog.GetInstance.ShowRunLog("AGV执行【4】号炒锅空桶回收任务");
  3083. string info3 = AGVHelper.GetInstance.AgvLeaveFryPotFour(id3);
  3084. LFourrobotJobId = id3;
  3085. FryCarryTaskErrorCodeAnalysis(info3, 4); break;
  3086. }
  3087. }
  3088. /// <summary>
  3089. /// AGV离开炒锅2,5运送空桶任务
  3090. /// </summary>
  3091. public void AgvFromFryPotTwoOrFiveToClean()
  3092. {
  3093. switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  3094. {
  3095. case 2:
  3096. erp1: string id1 = Guid.NewGuid().ToString("N");//上游唯一ID
  3097. if (id1 == LOnerobotJobId || id1 == LTworobotJobId || id1 == LThreerobotJobId || id1 == LFourrobotJobId || id1 == LFiverobotJobId || id1 == LSixrobotJobId || id1 == LSevenrobotJobId || id1 == LEightrobotJobId || id1 == LNinerobotJobId || id1 == LTenrobotJobId)
  3098. {
  3099. goto erp1;
  3100. }
  3101. MessageLog.GetInstance.ShowRunLog("AGV执行【2】号炒锅空桶回收任务");
  3102. string info1 = AGVHelper.GetInstance.AgvLeaveFryPotTwo(id1);
  3103. LFiverobotJobId = id1;
  3104. FryCarryTaskErrorCodeAnalysis(info1, 2); break;
  3105. case 5:
  3106. erp4: string id4 = Guid.NewGuid().ToString("N");//上游唯一ID
  3107. if (id4 == LOnerobotJobId || id4 == LTworobotJobId || id4 == LThreerobotJobId || id4 == LFourrobotJobId || id4 == LFiverobotJobId || id4 == LSixrobotJobId || id4 == LSevenrobotJobId || id4 == LEightrobotJobId || id4 == LNinerobotJobId || id4 == LTenrobotJobId)
  3108. {
  3109. goto erp4;
  3110. }
  3111. MessageLog.GetInstance.ShowRunLog("AGV执行【5】号炒锅空桶回收任务");
  3112. string info4 = AGVHelper.GetInstance.AgvLeaveFryPotFive(id4);
  3113. LFiverobotJobId = id4;
  3114. FryCarryTaskErrorCodeAnalysis(info4, 5); break;
  3115. }
  3116. }
  3117. /// <summary>
  3118. /// AGV离开炒锅3运送空桶任务
  3119. /// </summary>
  3120. public void AgvFromFryPotThreeToClean()
  3121. {
  3122. erp2: string id2 = Guid.NewGuid().ToString("N");//上游唯一ID
  3123. if (id2 == LOnerobotJobId || id2 == LTworobotJobId || id2 == LThreerobotJobId || id2 == LFourrobotJobId || id2 == LFiverobotJobId || id2 == LSixrobotJobId || id2 == LSevenrobotJobId || id2 == LEightrobotJobId || id2 == LNinerobotJobId || id2 == LTenrobotJobId)
  3124. {
  3125. goto erp2;
  3126. }
  3127. MessageLog.GetInstance.ShowRunLog("AGV执行【3】号炒锅空桶回收任务");
  3128. string info2 = AGVHelper.GetInstance.AgvLeaveFryPotThree(id2);
  3129. LSixrobotJobId = id2;
  3130. FryCarryTaskErrorCodeAnalysis(info2, 3);
  3131. }
  3132. /// <summary>
  3133. /// 处理agv从线体1到送料到炒锅的条件
  3134. /// </summary>
  3135. /// <param name="lineAlarm"></param>
  3136. public void AgvFromLineOneToFryPot()
  3137. {
  3138. erp: if (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 0)
  3139. {
  3140. if (globalVar.agvArriveUpLoad && globalVar.LoadRoller && globalVar.rollerLineOne.StationEight == InputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.AgvToFryPot)//无故障
  3141. {
  3142. MessageLog.GetInstance.ShowRunLog("AGV到达【1】号滚筒线装桶位置");
  3143. AgvArriveLineSingelSetDown(InputMaterialQuene);
  3144. if (InputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
  3145. {
  3146. MessageLog.GetInstance.ShowRunLog($"AGV正在装载{materialInfo.materialType.MaterialLoc}号料桶");
  3147. AgvViewModel.GetInstance().Set滚筒线状态(1, IsRun.Start);
  3148. globalVar.LOneCurrentCookingStep++;
  3149. OutputMaterialQuene.Enqueue(materialInfo);
  3150. globalVar.agvArriveUpLoad = false;
  3151. globalVar.AgvToFryPot = true;
  3152. //原料到位,agv到位,agv自行运料到炒锅
  3153. }
  3154. }
  3155. }
  3156. else//有故障
  3157. {
  3158. while (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 1)
  3159. {
  3160. Thread.Sleep(5);
  3161. if (globalVar.ExitLineOneTask)
  3162. return;
  3163. }
  3164. MessageLog.GetInstance.ShowRunLog("线体【1】滚筒故障解除,继续运行");
  3165. //lineAlarm = 1;
  3166. goto erp;
  3167. }
  3168. }
  3169. /// <summary>
  3170. /// Agv从1号线体运空桶到清洗处
  3171. /// </summary>
  3172. public void AgvFromLineOneToClean(ushort emptyRollerNum)
  3173. {
  3174. erp: if (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 0)//无故障
  3175. {
  3176. if (globalVar.agvArriveLineOneLoadEmptyRoller)//agv到达上料位置
  3177. {
  3178. MessageLog.GetInstance.ShowRunLog("AGV到达【1】号滚筒线装桶位置");
  3179. DeviceOperate.GetInstance.WritePlcData("D1052", 1);//agv到达线体1上料位置信号下发plc
  3180. MessageLog.GetInstance.ShowRunLog($"AGV正在装载【{emptyRollerNum}】号空料桶");
  3181. AgvViewModel.GetInstance().Set滚筒线状态(1, IsRun.Start);
  3182. globalVar.LOneMaterialNum--;
  3183. globalVar.agvArriveLineOneLoadEmptyRoller = false;
  3184. //原料到位,agv到位,agv自行运料到清洗处
  3185. }
  3186. if (globalVar.agvArriveLineOneLoadCom)//上料完成
  3187. {
  3188. globalVar.rollerLineOne.EmptyRollerNums.RemoveAt(0);
  3189. globalVar.agvArriveLineOneLoadCom = false;
  3190. globalVar.rollerLineOne.IsEpmtyBefore = false;
  3191. MessageLog.GetInstance.ShowRunLog($"AGV在【1】号线体完成{emptyRollerNum}号空料桶装载");
  3192. }
  3193. }
  3194. else//有故障
  3195. {
  3196. while (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 1)
  3197. {
  3198. Thread.Sleep(5);
  3199. if (globalVar.ExitLineOneTask)
  3200. return;
  3201. }
  3202. MessageLog.GetInstance.ShowRunLog("线体【1】滚筒故障解除,继续运行");
  3203. //lineAlarm = 1;
  3204. goto erp;
  3205. }
  3206. }
  3207. /// <summary>
  3208. /// 处理agv从线体2到送料到炒锅的条件
  3209. /// </summary>
  3210. /// <param name="lineAlarm"></param>
  3211. public void AgvFromLineTwoToFryPot()
  3212. {
  3213. erp: if (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 0)//无故障
  3214. {
  3215. if (globalVar.agvArriveLTwoUpLoad && globalVar.LTwoLoadRoller && globalVar.rollerLineTwo.StationEight == LTwoInputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.LTwoAgvToFryPot)//无故障
  3216. {
  3217. MessageLog.GetInstance.ShowRunLog("AGV到达【2】号滚筒线装桶位置");
  3218. AgvArriveLineSingelSetDown(LTwoInputMaterialQuene);
  3219. if (LTwoInputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
  3220. {
  3221. MessageLog.GetInstance.ShowRunLog($"AGV正在装载{materialInfo.materialType.MaterialLoc}号料桶");
  3222. AgvViewModel.GetInstance().Set滚筒线状态(2, IsRun.Start);
  3223. globalVar.LTwoCurrentCookingStep++;
  3224. LTwoOutputMaterialQuene.Enqueue(materialInfo);
  3225. globalVar.agvArriveLTwoUpLoad = false;
  3226. globalVar.LTwoAgvToFryPot = true;
  3227. //原料到位,agv到位,agv自行运料到炒锅
  3228. }
  3229. }
  3230. }
  3231. else//有故障
  3232. {
  3233. while (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 1)
  3234. {
  3235. Thread.Sleep(5);
  3236. if (globalVar.ExitLineTwoTask)
  3237. return;
  3238. }
  3239. MessageLog.GetInstance.ShowRunLog("线体【2】滚筒故障解除,继续运行");
  3240. // lineAlarm = 1;
  3241. goto erp;
  3242. }
  3243. }
  3244. /// <summary>
  3245. /// Agv从2号线体运空桶到清洗处
  3246. /// </summary>
  3247. public void AgvFromLineTwoToClean(ushort emptyRollerNum)
  3248. {
  3249. erp: if (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 0)//无故障
  3250. {
  3251. if (globalVar.agvArriveLineTwoLoadEmptyRoller)//agv到达上料位置
  3252. {
  3253. MessageLog.GetInstance.ShowRunLog("AGV到达【2】号滚筒线装桶位置");
  3254. DeviceOperate.GetInstance.WritePlcData("D1053", 1);//agv到达线体2上料位置信号下发plc
  3255. MessageLog.GetInstance.ShowRunLog($"AGV正在装载【{emptyRollerNum}】号空料桶");
  3256. AgvViewModel.GetInstance().Set滚筒线状态(2, IsRun.Start);
  3257. globalVar.LTwoMaterialNum--;
  3258. globalVar.agvArriveLineTwoLoadEmptyRoller = false;
  3259. //原料到位,agv到位,agv自行运料到清洗处
  3260. }
  3261. if (globalVar.agvArriveLineTwoLoadCom)//上料完成
  3262. {
  3263. globalVar.rollerLineTwo.EmptyRollerNums.RemoveAt(0);
  3264. globalVar.agvArriveLineTwoLoadCom = false;
  3265. globalVar.rollerLineTwo.IsEpmtyBefore = false;
  3266. MessageLog.GetInstance.ShowRunLog($"AGV在【2】号线体完成【{emptyRollerNum}】号空料桶装载");
  3267. }
  3268. }
  3269. else//有故障
  3270. {
  3271. while (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 1)
  3272. {
  3273. Thread.Sleep(5);
  3274. if (globalVar.ExitLineOneTask)
  3275. return;
  3276. }
  3277. MessageLog.GetInstance.ShowRunLog("线体【2】滚筒故障解除,继续运行");
  3278. //lineAlarm = 1;
  3279. goto erp;
  3280. }
  3281. }
  3282. /// <summary>
  3283. /// 处理agv从线体3到送料到炒锅的条件
  3284. /// </summary>
  3285. /// <param name="lineAlarm"></param>
  3286. public void AgvFromLineThreeToFryPot()
  3287. {
  3288. erp: if (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 0)//无故障
  3289. {
  3290. if (globalVar.agvArriveLThreeUpLoad && globalVar.LThreeLoadRoller && globalVar.rollerLineThree.StationEight == LThreeInputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.LThreeAgvToFryPot)//无故障
  3291. {
  3292. MessageLog.GetInstance.ShowRunLog("AGV到达【3】号滚筒线装桶位置");
  3293. AgvArriveLineSingelSetDown(LThreeInputMaterialQuene);
  3294. if (LThreeInputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
  3295. {
  3296. MessageLog.GetInstance.ShowRunLog($"AGV正在装载{materialInfo.materialType.MaterialLoc}号料桶");
  3297. AgvViewModel.GetInstance().Set滚筒线状态(3, IsRun.Start);
  3298. globalVar.LThreeCurrentCookingStep++;
  3299. LThreeOutputMaterialQuene.Enqueue(materialInfo);
  3300. globalVar.agvArriveLThreeUpLoad = false;
  3301. globalVar.LThreeAgvToFryPot = true;
  3302. //原料到位,agv到位,agv自行运料到炒锅
  3303. }
  3304. }
  3305. }
  3306. else //有故障
  3307. {
  3308. while (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 1)
  3309. {
  3310. Thread.Sleep(5);
  3311. if (globalVar.ExitLineThreeTask)
  3312. return;
  3313. }
  3314. MessageLog.GetInstance.ShowRunLog("线体【3】滚筒故障解除,继续运行");
  3315. // lineAlarm = 1;
  3316. goto erp;
  3317. }
  3318. }
  3319. /// <summary>
  3320. /// Agv从3号线体运空桶到清洗处
  3321. /// </summary>
  3322. public void AgvFromLineThreeToClean(ushort emptyRollerNum)
  3323. {
  3324. erp: if (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 0)//无故障
  3325. {
  3326. if (globalVar.agvArriveLineThreeLoadEmptyRoller)//agv到达上料位置
  3327. {
  3328. MessageLog.GetInstance.ShowRunLog("AGV到达【3】号滚筒线装桶位置");
  3329. DeviceOperate.GetInstance.WritePlcData("D1054", 1);//agv到达线体3上料位置信号下发plc
  3330. MessageLog.GetInstance.ShowRunLog($"AGV正在装载【{emptyRollerNum}】号空料桶");
  3331. AgvViewModel.GetInstance().Set滚筒线状态(3, IsRun.Start);
  3332. globalVar.LThreeMaterialNum--;
  3333. globalVar.agvArriveLineThreeLoadEmptyRoller = false;
  3334. // globalVar.rollerLineThree.IsEpmtyBefore = false;
  3335. //原料到位,agv到位,agv自行运料到清洗处
  3336. }
  3337. if (globalVar.agvArriveLineThreeLoadCom)//上料完成
  3338. {
  3339. globalVar.rollerLineThree.EmptyRollerNums.RemoveAt(0);
  3340. globalVar.agvArriveLineThreeLoadCom = false;
  3341. globalVar.rollerLineThree.IsEpmtyBefore = false;
  3342. MessageLog.GetInstance.ShowRunLog($"AGV在【3】号线体完成【{emptyRollerNum}】号空料桶装载");
  3343. }
  3344. }
  3345. else//有故障
  3346. {
  3347. while (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 1)
  3348. {
  3349. Thread.Sleep(5);
  3350. if (globalVar.ExitLineOneTask)
  3351. return;
  3352. }
  3353. MessageLog.GetInstance.ShowRunLog("线体【3】滚筒故障解除,继续运行");
  3354. //lineAlarm = 1;
  3355. goto erp;
  3356. }
  3357. }
  3358. /// <summary>
  3359. /// 线体到炒锅搬运任务错误码分析
  3360. /// </summary>
  3361. /// <param name="errorCode"></param>
  3362. /// <param name="num"></param>
  3363. public void LineCarryTaskErrorCodeAnalysis(string errorCode, int num)
  3364. {
  3365. if (errorCode == "SUCCESS")
  3366. {
  3367. AgvViewModel.GetInstance().Set停车桩(num, IsBool.No);
  3368. AgvViewModel.GetInstance().Set小车是否承载物品(num, IsBool.No);
  3369. AgvViewModel.GetInstance().Set小车运动(num, AgvViewModel.GetInstance().GetCommandValue($"qc_{num}"));
  3370. MessageLog.GetInstance.ShowRunLog($"AGV去{num}号滚筒线装桶");
  3371. globalVar.AllowAgvToLineLoadRoller = false;
  3372. }
  3373. else if (errorCode == "Analysis Error")
  3374. {
  3375. MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线API调用失败,请检查请求报文");
  3376. }
  3377. else
  3378. {
  3379. MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线失败,错误码:{errorCode}");
  3380. }
  3381. }
  3382. /// <summary>
  3383. /// 线体到清洗台搬运任务错误码分析
  3384. /// </summary>
  3385. /// <param name="errorCode"></param>
  3386. /// <param name="num"></param>
  3387. public void LineToCleanCarryTaskErrorCodeAnalysis(string errorCode, int num)
  3388. {
  3389. if (errorCode == "SUCCESS")
  3390. {
  3391. AgvViewModel.GetInstance().Set停车桩(num, IsBool.No);
  3392. AgvViewModel.GetInstance().Set小车是否承载物品(num, IsBool.No);
  3393. AgvViewModel.GetInstance().Set小车运动(num, AgvViewModel.GetInstance().GetCommandValue($"qc_{num}"));
  3394. MessageLog.GetInstance.ShowRunLog($"AGV去{num}号滚筒线装桶");
  3395. }
  3396. else if (errorCode == "Analysis Error")
  3397. {
  3398. MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线API调用失败,请检查请求报文");
  3399. }
  3400. else
  3401. {
  3402. MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线失败,错误码:{errorCode}");
  3403. }
  3404. }
  3405. /// <summary>
  3406. /// 清洗台到线体搬运任务错误码分析
  3407. /// </summary>
  3408. /// <param name="errorCode"></param>
  3409. /// <param name="num"></param>
  3410. public void CleanToLineCarryTaskErrorCodeAnalysis(string errorCode, int num)
  3411. {
  3412. if (errorCode == "SUCCESS")
  3413. {
  3414. AgvViewModel.GetInstance().Set停车桩(num, IsBool.No);
  3415. AgvViewModel.GetInstance().Set小车是否承载物品(num, IsBool.No);
  3416. AgvViewModel.GetInstance().Set小车运动(num, AgvViewModel.GetInstance().GetCommandValue($"qc_{num}"));
  3417. MessageLog.GetInstance.ShowRunLog($"AGV去{num}号滚筒线卸桶");
  3418. }
  3419. else if (errorCode == "Analysis Error")
  3420. {
  3421. MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线API调用失败,请检查请求报文");
  3422. }
  3423. else
  3424. {
  3425. MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线失败,错误码:{errorCode}");
  3426. }
  3427. }
  3428. /// <summary>
  3429. /// 炒锅搬运任务错误码分析
  3430. /// </summary>
  3431. /// <param name="errorCode"></param>
  3432. /// <param name="num"></param>
  3433. public void FryCarryTaskErrorCodeAnalysis(string errorCode, int num)
  3434. {
  3435. if (errorCode == "SUCCESS")
  3436. {
  3437. MessageLog.GetInstance.ShowRunLog($"AGV离开{num}号炒锅");
  3438. }
  3439. else if (errorCode == "Analysis Error")
  3440. {
  3441. MessageLog.GetInstance.ShowRunLog($"提示:AGV离开{num}号炒锅接口调用失败,请检查");
  3442. }
  3443. else
  3444. {
  3445. MessageLog.GetInstance.ShowRunLog($"提示:AGV离开{num}号炒锅失败,错误码:{errorCode}");
  3446. }
  3447. }
  3448. public void AgvToLineOneLoadRoller()
  3449. {
  3450. if (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 0)//输送线无故障
  3451. {
  3452. if (InputMaterialQuene.Count > 0 && globalVar.AllowAgvToLineLoadRoller && globalVar.rollerLineOne.OutMaterialingSingle == 1 && !globalVar.LoadRoller)
  3453. {
  3454. if (globalVar.rollerLineOne.StationEight == InputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.rollerLineOne.IsEpmtyBefore)//工位8上面是配方料桶
  3455. {
  3456. globalVar.rollerLineOne.CanRun = false;
  3457. e: string id = Guid.NewGuid().ToString("N");
  3458. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId)
  3459. goto e;
  3460. string info = AGVHelper.GetInstance.AgvToLineOneLoadRoller(id);
  3461. LOnerobotJobId = id;
  3462. Thread.Sleep(500);
  3463. LineCarryTaskErrorCodeAnalysis(info, 1);
  3464. globalVar.LoadRoller = true;
  3465. }
  3466. //else if (globalVar.rollerLineOne.StationEight != InputMaterialQuene.ElementAt(0).materialType.MaterialLoc)
  3467. //{
  3468. // globalVar.rollerLineOne.CanRun = true;
  3469. //}
  3470. //else // 工位8上面不是配方料桶或没有桶时
  3471. //{
  3472. // if (!globalVar.rollerLineOne.IsEpmtyBefore)
  3473. // {
  3474. // var res = InputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineOne.StationEight);
  3475. // if (res == null && globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0))//工位8上面有桶且不是配方上的原料桶且工位8的桶号和plc上报的桶号一致,即空桶
  3476. // {
  3477. // //下发AGV去空桶线洗桶任务
  3478. // e: string id = Guid.NewGuid().ToString("N");
  3479. // if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId)
  3480. // goto e;
  3481. // string info = AGVHelper.GetInstance.AgvLeaveLOneToClean(id);//1号线到洗桶处
  3482. // LFourrobotJobId = id;
  3483. // Thread.Sleep(500);
  3484. // LineToCleanCarryTaskErrorCodeAnalysis(info, 1);
  3485. // globalVar.rollerLineOne.IsEpmtyBefore = true;
  3486. // AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
  3487. // }
  3488. // }
  3489. // else
  3490. // {
  3491. // AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
  3492. // }
  3493. //}
  3494. }
  3495. }
  3496. //else
  3497. //{
  3498. // MessageLog.GetInstance.ShowRunLog("警告:滚筒输送线体【1】故障!!!");
  3499. // // lineAlarm = -1;
  3500. //}
  3501. //// lineAlarm = 1;
  3502. }
  3503. public void AgvToLineTwoLoadRoller()
  3504. {
  3505. if (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 0)//输送线无故障
  3506. {
  3507. if (LTwoInputMaterialQuene.Count > 0 && globalVar.AllowAgvToLineTwoLoadRoller && globalVar.rollerLineTwo.OutMaterialingSingle == 1 && !globalVar.LTwoLoadRoller)
  3508. {
  3509. if (globalVar.rollerLineTwo.StationEight == LTwoInputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.rollerLineTwo.IsEpmtyBefore)//工位8上面是配方料桶
  3510. {
  3511. globalVar.rollerLineTwo.CanRun = false;
  3512. e: string id = Guid.NewGuid().ToString("N");
  3513. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId)
  3514. goto e;
  3515. string info = AGVHelper.GetInstance.AgvToLineTwoLoadRoller(id);
  3516. LTworobotJobId = id;
  3517. Thread.Sleep(500);
  3518. LineCarryTaskErrorCodeAnalysis(info, 2);
  3519. globalVar.LTwoLoadRoller = true;
  3520. }
  3521. //else if (globalVar.rollerLineTwo.StationEight != LTwoInputMaterialQuene.ElementAt(0).materialType.MaterialLoc)
  3522. //{
  3523. // globalVar.rollerLineTwo.CanRun = true;
  3524. //}
  3525. }
  3526. //else// 工位8上面不是配方料桶或没有桶时
  3527. //{
  3528. // if (!globalVar.rollerLineTwo.IsEpmtyBefore)
  3529. // {
  3530. // var res = LTwoInputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineTwo.StationEight);
  3531. // if (res == null && globalVar.rollerLineTwo.StationEight != 0 && globalVar.rollerLineTwo.StationEight == globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0))//工位8上面有桶且不是配方上的原料桶,即空桶
  3532. // {
  3533. // //下发AGV去空桶线洗桶任务
  3534. // e: string id = Guid.NewGuid().ToString("N");
  3535. // if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId)
  3536. // goto e;
  3537. // string info = AGVHelper.GetInstance.AgvLeaveLTwoToClean(id);//2号线到洗桶处
  3538. // LFiverobotJobId = id;
  3539. // Thread.Sleep(500);
  3540. // LineToCleanCarryTaskErrorCodeAnalysis(info, 2);
  3541. // globalVar.rollerLineTwo.IsEpmtyBefore = true;
  3542. // AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体2到清洗处
  3543. // }
  3544. // }
  3545. // else
  3546. // {
  3547. // AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处
  3548. // }
  3549. //}
  3550. }
  3551. }
  3552. public void AgvToLineThreeLoadRoller()
  3553. {
  3554. if (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 0)//输送线无故障
  3555. {
  3556. if (LThreeInputMaterialQuene.Count > 0 && globalVar.AllowAgvToLineThreeLoadRoller && globalVar.rollerLineThree.OutMaterialingSingle == 1 && !globalVar.LThreeLoadRoller)
  3557. {
  3558. if (globalVar.rollerLineThree.StationEight == LThreeInputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.rollerLineThree.IsEpmtyBefore)//工位8上面是配方料桶
  3559. {
  3560. globalVar.rollerLineThree.CanRun = false;
  3561. e: string id = Guid.NewGuid().ToString("N");
  3562. if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId)
  3563. goto e;
  3564. string info = AGVHelper.GetInstance.AgvToLineThreeLoadRoller(id);
  3565. LThreerobotJobId = id;
  3566. Thread.Sleep(500);
  3567. LineCarryTaskErrorCodeAnalysis(info, 3);
  3568. globalVar.LThreeLoadRoller = true;
  3569. }
  3570. //else if (globalVar.rollerLineThree.StationEight != LThreeInputMaterialQuene.ElementAt(0).materialType.MaterialLoc)
  3571. //{
  3572. // globalVar.rollerLineThree.CanRun = true;
  3573. //}
  3574. //else // 工位8上面不是配方料桶或没有桶时
  3575. //{
  3576. // if (!globalVar.rollerLineThree.IsEpmtyBefore)
  3577. // {
  3578. // var res = LThreeInputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineThree.StationEight);
  3579. // if (res == null && globalVar.rollerLineThree.StationEight != 0 && globalVar.rollerLineThree.StationEight == globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0))//工位8上面有桶且不是配方上的原料桶,即空桶
  3580. // {
  3581. // //下发AGV去空桶线洗桶任务
  3582. // e: string id = Guid.NewGuid().ToString("N");
  3583. // if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId)
  3584. // goto e;
  3585. // string info = AGVHelper.GetInstance.AgvLeaveLThreeToClean(id);//3号线到洗桶处
  3586. // LSixrobotJobId = id;
  3587. // Thread.Sleep(500);
  3588. // LineToCleanCarryTaskErrorCodeAnalysis(info, 3);
  3589. // globalVar.rollerLineThree.IsEpmtyBefore = true;
  3590. // AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处
  3591. // }
  3592. // }
  3593. // else
  3594. // {
  3595. // AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处
  3596. // }
  3597. //}
  3598. }
  3599. }
  3600. //if (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 0)//输送线无故障
  3601. //{
  3602. // if (LThreeInputMaterialQuene.Count > 0)
  3603. // {
  3604. // while (!globalVar.AllowAgvToLineThreeLoadRoller || globalVar.rollerLineThree.OutMaterialingSingle == 0) //后续考虑是否用while
  3605. // {
  3606. // Thread.Sleep(5);
  3607. // if (globalVar.ExitMainTask)
  3608. // return;
  3609. // }
  3610. // g: string id = Guid.NewGuid().ToString();
  3611. // if (id == LThreerobotJobId)
  3612. // goto g;
  3613. // string info = AGVHelper.GetInstance.AgvToLineThreeLoadRoller(id);
  3614. // // MessageLog.GetInstance.ShowRunLog("AGV去【3】号滚筒线装桶");
  3615. // LThreerobotJobId = id;
  3616. // Thread.Sleep(500);
  3617. // LineCarryTaskErrorCodeAnalysis(info, 3);
  3618. // }
  3619. //}
  3620. //else
  3621. //{
  3622. // MessageLog.GetInstance.ShowRunLog("警告:滚筒输送线体【3】故障!!!");
  3623. // // lineAlarm = -1;
  3624. //}
  3625. }
  3626. /// <summary>
  3627. /// 1号线体数据下发
  3628. /// </summary>
  3629. /// <param name="count"></param>
  3630. /// <param name="materialLoc"></param>
  3631. /// <param name="materialWeight"></param>
  3632. public void RollerOneDataWrite(int count, ushort materialLoc, ushort materialWeight)
  3633. {
  3634. switch (count)
  3635. {
  3636. case 0:
  3637. DeviceOperate.GetInstance.WritePlcData("D1001", materialLoc);//桶1位置
  3638. DeviceOperate.GetInstance.WritePlcData("D1010", materialWeight);//桶2重量
  3639. break;
  3640. case 1:
  3641. DeviceOperate.GetInstance.WritePlcData("D1002", materialLoc);//桶2位置
  3642. DeviceOperate.GetInstance.WritePlcData("D1011", materialWeight);//桶2重量
  3643. break;
  3644. case 2:
  3645. DeviceOperate.GetInstance.WritePlcData("D1003", materialLoc);//桶3位置
  3646. DeviceOperate.GetInstance.WritePlcData("D1012", materialWeight);//桶3重量
  3647. break;
  3648. case 3:
  3649. DeviceOperate.GetInstance.WritePlcData("D1004", materialLoc);//桶4位置
  3650. DeviceOperate.GetInstance.WritePlcData("D1013", materialWeight);//桶4重量
  3651. break;
  3652. case 4:
  3653. DeviceOperate.GetInstance.WritePlcData("D1005", materialLoc);//桶5位置
  3654. DeviceOperate.GetInstance.WritePlcData("D1014", materialWeight);//桶5重量
  3655. break;
  3656. case 5:
  3657. DeviceOperate.GetInstance.WritePlcData("D1006", materialLoc);//桶6位置
  3658. DeviceOperate.GetInstance.WritePlcData("D1015", materialWeight);//桶6重量
  3659. break;
  3660. case 6:
  3661. DeviceOperate.GetInstance.WritePlcData("D1007", materialLoc);//桶7位置
  3662. DeviceOperate.GetInstance.WritePlcData("D1016", materialWeight);//桶7重量
  3663. break;
  3664. case 7:
  3665. DeviceOperate.GetInstance.WritePlcData("D1008", materialLoc);//桶8位置
  3666. DeviceOperate.GetInstance.WritePlcData("D1017", materialWeight);//桶8重量
  3667. break;
  3668. }
  3669. }
  3670. /// <summary>
  3671. /// 2号线体数据下发
  3672. /// </summary>
  3673. /// <param name="count"></param>
  3674. /// <param name="materialLoc"></param>
  3675. /// <param name="materialWeight"></param>
  3676. public void RollerTwoDataWrite(int count, ushort materialLoc, ushort materialWeight)
  3677. {
  3678. switch (count)
  3679. {
  3680. case 0:
  3681. DeviceOperate.GetInstance.WritePlcData("D1018", materialLoc);//桶1位置
  3682. DeviceOperate.GetInstance.WritePlcData("D1027", materialWeight);//桶2重量
  3683. break;
  3684. case 1:
  3685. DeviceOperate.GetInstance.WritePlcData("D1019", materialLoc);//桶2位置
  3686. DeviceOperate.GetInstance.WritePlcData("D1028", materialWeight);//桶2重量
  3687. break;
  3688. case 2:
  3689. DeviceOperate.GetInstance.WritePlcData("D1020", materialLoc);//桶3位置
  3690. DeviceOperate.GetInstance.WritePlcData("D1029", materialWeight);//桶3重量
  3691. break;
  3692. case 3:
  3693. DeviceOperate.GetInstance.WritePlcData("D1021", materialLoc);//桶4位置
  3694. DeviceOperate.GetInstance.WritePlcData("D1030", materialWeight);//桶4重量
  3695. break;
  3696. case 4:
  3697. DeviceOperate.GetInstance.WritePlcData("D1022", materialLoc);//桶5位置
  3698. DeviceOperate.GetInstance.WritePlcData("D1031", materialWeight);//桶5重量
  3699. break;
  3700. case 5:
  3701. DeviceOperate.GetInstance.WritePlcData("D1023", materialLoc);//桶6位置
  3702. DeviceOperate.GetInstance.WritePlcData("D1032", materialWeight);//桶6重量
  3703. break;
  3704. case 6:
  3705. DeviceOperate.GetInstance.WritePlcData("D1024", materialLoc);//桶7位置
  3706. DeviceOperate.GetInstance.WritePlcData("D1033", materialWeight);//桶7重量
  3707. break;
  3708. case 7:
  3709. DeviceOperate.GetInstance.WritePlcData("D1025", materialLoc);//桶8位置
  3710. DeviceOperate.GetInstance.WritePlcData("D1034", materialWeight);//桶8重量
  3711. break;
  3712. }
  3713. }
  3714. /// <summary>
  3715. /// 3号线体数据下发
  3716. /// </summary>
  3717. /// <param name="count"></param>
  3718. /// <param name="materialLoc"></param>
  3719. /// <param name="materialWeight"></param>
  3720. public void RollerThreeDataWrite(int count, ushort materialLoc, ushort materialWeight)
  3721. {
  3722. switch (count)
  3723. {
  3724. case 0:
  3725. DeviceOperate.GetInstance.WritePlcData("D1035", materialLoc);//桶1位置
  3726. DeviceOperate.GetInstance.WritePlcData("D1044", materialWeight);//桶2重量
  3727. break;
  3728. case 1:
  3729. DeviceOperate.GetInstance.WritePlcData("D1036", materialLoc);//桶2位置
  3730. DeviceOperate.GetInstance.WritePlcData("D1045", materialWeight);//桶2重量
  3731. break;
  3732. case 2:
  3733. DeviceOperate.GetInstance.WritePlcData("D1037", materialLoc);//桶3位置
  3734. DeviceOperate.GetInstance.WritePlcData("D1046", materialWeight);//桶3重量
  3735. break;
  3736. case 3:
  3737. DeviceOperate.GetInstance.WritePlcData("D1038", materialLoc);//桶4位置
  3738. DeviceOperate.GetInstance.WritePlcData("D1047", materialWeight);//桶4重量
  3739. break;
  3740. case 4:
  3741. DeviceOperate.GetInstance.WritePlcData("D1039", materialLoc);//桶5位置
  3742. DeviceOperate.GetInstance.WritePlcData("D1048", materialWeight);//桶5重量
  3743. break;
  3744. case 5:
  3745. DeviceOperate.GetInstance.WritePlcData("D1040", materialLoc);//桶6位置
  3746. DeviceOperate.GetInstance.WritePlcData("D1049", materialWeight);//桶6重量
  3747. break;
  3748. case 6:
  3749. DeviceOperate.GetInstance.WritePlcData("D1041", materialLoc);//桶7位置
  3750. DeviceOperate.GetInstance.WritePlcData("D1050", materialWeight);//桶7重量
  3751. break;
  3752. case 7:
  3753. DeviceOperate.GetInstance.WritePlcData("D1042", materialLoc);//桶8位置
  3754. DeviceOperate.GetInstance.WritePlcData("D1051", materialWeight);//桶8重量
  3755. break;
  3756. }
  3757. }
  3758. /// <summary>
  3759. /// AGV线体进料就位信号下发至PLC
  3760. /// </summary>
  3761. public void AgvArriveLineSingelSetDown(ConcurrentQueue<MaterialInfo> queue)
  3762. {
  3763. switch (queue.ElementAt(0).materialType.MaterialLoc / 100)
  3764. {
  3765. case 1:
  3766. case 4: DeviceOperate.GetInstance.WritePlcData("D1052", 1); break;//AGV进料就位信号1
  3767. case 2:
  3768. case 5: DeviceOperate.GetInstance.WritePlcData("D1053", 1); break;//AGV进料就位信号2
  3769. case 3: DeviceOperate.GetInstance.WritePlcData("D1054", 1); break;//AGV进料就位信号3
  3770. }
  3771. }
  3772. /// <summary>
  3773. /// 炒锅滚筒信号检测
  3774. /// </summary>
  3775. //public void FryPotRollerTroubleCheck()
  3776. //{
  3777. // FryPotAlarm = 0;
  3778. // FryPotTwoAlarm = 0;
  3779. // FryPotThreeAlarm = 0;
  3780. // FryPotFourAlarm = 0;
  3781. // FryPotFiveAlarm = 0;
  3782. // switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  3783. // {
  3784. // case 1:
  3785. // if (AlarmHelper<AlarmInfo>.Alarm.FryPotOneRollerTrouble == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotOneRollerTrouble == 1)
  3786. // {
  3787. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3788. // return;
  3789. // }
  3790. // MessageLog.GetInstance.ShowRunLog("炒锅【1】输送滚筒故障解除,继续运行");
  3791. // FryPotAlarm = 1; break;
  3792. // case 2:
  3793. // if (AlarmHelper<AlarmInfo>.Alarm.FryPotTwoRollerTrouble == 1) { FryPotTwoAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【2】输送滚筒发生故障"); } else { FryPotTwoAlarm = 1; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotTwoRollerTrouble == 1)
  3794. // {
  3795. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3796. // return;
  3797. // }
  3798. // MessageLog.GetInstance.ShowRunLog("炒锅【2】输送滚筒故障解除,继续运行");
  3799. // FryPotTwoAlarm = 1; break;
  3800. // case 3:
  3801. // if (AlarmHelper<AlarmInfo>.Alarm.FryPotThreeRollerTrouble == 1) { FryPotThreeAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【3】输送滚筒发生故障"); } else { FryPotThreeAlarm = 1; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotThreeRollerTrouble == 1)
  3802. // {
  3803. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3804. // return;
  3805. // }
  3806. // MessageLog.GetInstance.ShowRunLog("炒锅【3】输送滚筒故障解除,继续运行");
  3807. // FryPotThreeAlarm = 1; break;
  3808. // case 4:
  3809. // if (AlarmHelper<AlarmInfo>.Alarm.FryPotFourRollerTrouble == 1) { FryPotFourAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【4】输送滚筒发生故障"); } else { FryPotFourAlarm = 1; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotFourRollerTrouble == 1)
  3810. // {
  3811. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3812. // return;
  3813. // }
  3814. // MessageLog.GetInstance.ShowRunLog("炒锅【4】输送滚筒故障解除,继续运行");
  3815. // FryPotFourAlarm = 1; break;
  3816. // case 5:
  3817. // if (AlarmHelper<AlarmInfo>.Alarm.FryPotFiveRollerTrouble == 1) { FryPotFiveAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【5】输送滚筒发生故障"); } else { FryPotFiveAlarm = 1; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotFiveRollerTrouble == 1)
  3818. // {
  3819. // Thread.Sleep(5); if (globalVar.ExitMainTask)
  3820. // return;
  3821. // }
  3822. // MessageLog.GetInstance.ShowRunLog("炒锅【5】输送滚筒故障解除,继续运行");
  3823. // FryPotFiveAlarm = 1; break;
  3824. // }
  3825. //}
  3826. /// <summary>
  3827. /// 炒锅1,4滚筒信号检测
  3828. /// </summary>
  3829. public void FryPotOneRollerTroubleCheck()
  3830. {
  3831. FryPotAlarm = 0;
  3832. FryPotFourAlarm = 0;
  3833. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  3834. {
  3835. case 1:
  3836. if (AlarmHelper<AlarmInfo>.Alarm.FryPotOneRollerTrouble == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotOneRollerTrouble == 1)
  3837. {
  3838. Thread.Sleep(5); if (globalVar.ExitLineOneTask)
  3839. return;
  3840. }
  3841. MessageLog.GetInstance.ShowRunLog("炒锅【1】输送滚筒故障解除,继续运行");
  3842. FryPotAlarm = 1; break;
  3843. case 4:
  3844. if (AlarmHelper<AlarmInfo>.Alarm.FryPotFourRollerTrouble == 1) { FryPotFourAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【4】输送滚筒发生故障"); } else { FryPotFourAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotFourRollerTrouble == 1)
  3845. {
  3846. Thread.Sleep(5); if (globalVar.ExitLineOneTask)
  3847. return;
  3848. }
  3849. MessageLog.GetInstance.ShowRunLog("炒锅【4】输送滚筒故障解除,继续运行");
  3850. FryPotFourAlarm = 1; break;
  3851. }
  3852. }
  3853. /// <summary>
  3854. /// 炒锅2,5滚筒信号检测
  3855. /// </summary>
  3856. public void FryPotTwoRollerTroubleCheck()
  3857. {
  3858. FryPotTwoAlarm = 0;
  3859. FryPotFiveAlarm = 0;
  3860. switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  3861. {
  3862. case 2:
  3863. if (AlarmHelper<AlarmInfo>.Alarm.FryPotTwoRollerTrouble == 1) { FryPotTwoAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotTwoAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotTwoRollerTrouble == 1)
  3864. {
  3865. Thread.Sleep(5); if (globalVar.ExitLineTwoTask)
  3866. return;
  3867. }
  3868. MessageLog.GetInstance.ShowRunLog("炒锅【1】输送滚筒故障解除,继续运行");
  3869. FryPotTwoAlarm = 1; break;
  3870. case 5:
  3871. if (AlarmHelper<AlarmInfo>.Alarm.FryPotFiveRollerTrouble == 1) { FryPotFiveAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【4】输送滚筒发生故障"); } else { FryPotFiveAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotFiveRollerTrouble == 1)
  3872. {
  3873. Thread.Sleep(5); if (globalVar.ExitLineTwoTask)
  3874. return;
  3875. }
  3876. MessageLog.GetInstance.ShowRunLog("炒锅【4】输送滚筒故障解除,继续运行");
  3877. FryPotFiveAlarm = 1; break;
  3878. }
  3879. }
  3880. /// <summary>
  3881. /// 炒锅3滚筒信号检测
  3882. /// </summary>
  3883. public void FryPotThreeRollerTroubleCheck()
  3884. {
  3885. FryPotThreeAlarm = 0;
  3886. if (AlarmHelper<AlarmInfo>.Alarm.FryPotThreeRollerTrouble == 1) { FryPotThreeAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【3】输送滚筒发生故障"); } else { FryPotThreeAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotThreeRollerTrouble == 1)
  3887. {
  3888. Thread.Sleep(5); if (globalVar.ExitLineThreeTask)
  3889. return;
  3890. }
  3891. MessageLog.GetInstance.ShowRunLog("炒锅【3】输送滚筒故障解除,继续运行");
  3892. FryPotThreeAlarm = 1;
  3893. }
  3894. }
  3895. }