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

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