终端一体化运控平台
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.
 
 
 

1188 lines
56 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. namespace FryPot_DosingSystem.Control
  21. {
  22. internal class DosingLogicControl
  23. {
  24. public static DosingLogicControl _instance;
  25. public static DosingLogicControl GetInstance => _instance ??= new DosingLogicControl();
  26. public ConcurrentDictionary<string, object> PlcReadData = new ConcurrentDictionary<string, object>();
  27. /// <summary>
  28. /// 配方队列
  29. /// </summary>
  30. public ConcurrentQueue<NewRecipeModel> RecipeQuene = new ConcurrentQueue<NewRecipeModel>();
  31. /// <summary>
  32. /// 进料原料队列
  33. /// </summary>
  34. public ConcurrentQueue<MaterialInfo> InputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  35. /// <summary>
  36. /// 出料原料队列
  37. /// </summary>
  38. public ConcurrentQueue<MaterialInfo> OutputMaterialQuene = new ConcurrentQueue<MaterialInfo>();
  39. /// <summary>
  40. /// 全局变量对象声明
  41. /// </summary>
  42. GlobalVariable globalVar;
  43. /// <summary>
  44. /// 线体状态对象声明
  45. /// </summary>
  46. HardWareStatusViewModel hardWareStatusModel;
  47. #region 上位机内部变量
  48. //int lineAlarm = 0;//线体故障信号 1:无故障 -1:故障
  49. int FryPotAlarm = 0;//炒锅滚筒故障信号 1:无故障 -1:故障
  50. int ReicpeNum = 0;//记录接收到的配方数
  51. #endregion
  52. #region agv临时变量
  53. bool agvArriveUpLoad = false;//agv是否到达线体装料位置
  54. bool agvArriveUnLoad = false;//agv是否到达炒锅送料位置
  55. bool agvFryPotEmptyRollerArrive = false;//agv是否拿到炒锅空桶
  56. string robotJobId = String.Empty;//当前上游系统任务号,全局唯一
  57. //List<string> robotJobIds = new List<string>();//存储当前上游系统任务号,全局唯一
  58. bool loadInteractive = false;// fasle:不需要上料交互 true:需要上料交互
  59. #endregion
  60. public DosingLogicControl()
  61. {
  62. globalVar = new GlobalVariable();
  63. hardWareStatusModel = HardWareStatusViewModel.GetInstance;
  64. ActionManage.GetInstance.Register(new Action<object>(RecipeDataParse), "RecipeSetDown");
  65. ActionManage.GetInstance.Register(new Action(() => { RecipeQuene.Clear(); InputMaterialQuene.Clear(); OutputMaterialQuene.Clear(); }), "ClearRecipes");
  66. ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 1; }), "StartPlcInite");
  67. ActionManage.GetInstance.Register(new Action(() => { globalVar.PlcInite = 0; }), "EndPlcInite");
  68. ActionManage.GetInstance.Register(new Action(() => { globalVar.ExitMainTask = true; }), "FryPotDosingMainTaskExit");
  69. HubHelper.GetInstance.Report = new Action<object>(AgvTaskUpReportDataAnalysis);
  70. HubHelper.GetInstance.Upstreamrequest = new Action<object>(AgvFeedBackUpReportDataAnalysis);
  71. ResetProgram();
  72. ReadPlcData();
  73. IniteTask();
  74. }
  75. /// <summary>
  76. /// AGV上下料上报数据解析
  77. /// </summary>
  78. /// <param name="obj"></param>
  79. private void AgvFeedBackUpReportDataAnalysis(object obj)
  80. {
  81. if (obj != null && obj is byte[] datas)
  82. {
  83. string strData = Encoding.UTF8.GetString(datas);
  84. object objData = JsonConvert.DeserializeObject(strData);
  85. if (objData != null && objData is Upstreamrequest upDownReportData)
  86. {
  87. //if (upDownReportData.body != null && upDownReportData.body is UpstreamrequestBody body)
  88. //{
  89. // if (body.robotJobId == robotJobId && body.command == "LOAD")//同一任务号且处于上料阶段
  90. // {
  91. // agvArriveUpLoad = true;//AGV到达上料位置
  92. // }
  93. // if (body.robotJobId == robotJobId && body.command == "UNLOAD")//同一任务号且处于下料阶段
  94. // {
  95. // agvArriveUnLoad = true;//AGV到达下料位置
  96. // }
  97. //}
  98. }
  99. }
  100. }
  101. /// <summary>
  102. /// AGV搬运任务上报数据解析
  103. /// </summary>
  104. /// <param name="obj"></param>
  105. private void AgvTaskUpReportDataAnalysis(object obj)
  106. {
  107. if (obj != null && obj is byte[] datas)
  108. {
  109. string strData = Encoding.UTF8.GetString(datas);
  110. object objData = JsonConvert.DeserializeObject(strData);
  111. if (objData != null && objData is AGVToUpSystem agvUpReportData)
  112. {
  113. //if (agvUpReportData.body != null && agvUpReportData.body is AGVToUpSystemBody body)
  114. //{
  115. // if (body.state == "ROLLER_LOAD_FINISH" && body.jobData.startPointCode == "")//上料完成以及到达指定上料点位
  116. // {
  117. // agvFryPotEmptyRollerArrive = true;
  118. // }
  119. //}
  120. }
  121. }
  122. }
  123. /// <summary>
  124. /// 主任务重启
  125. /// </summary>
  126. private void ResetProgram()
  127. {
  128. ThreadManage.GetInstance().StartLong(new Action(() =>
  129. {
  130. if (RTrig.GetInstance("ResetProgram").Start(globalVar.PlcInite == 1))//判断是否初始化 一初始化就重启主任务
  131. {
  132. MessageLog.GetInstance.ShowRunLog("主任务正在重启");
  133. ThreadManage.GetInstance().StopTask("MainTask", new Action(() =>
  134. {
  135. ThreadManage.GetInstance().StopTask("MainViewReadPlcData", new Action(() =>
  136. {
  137. globalVar = null;
  138. globalVar = new GlobalVariable();
  139. ReicpeNum = 0;
  140. ActionManage.GetInstance.CancelRegister("RecipeSetDown");
  141. ActionManage.GetInstance.Register(new Action<object>(RecipeDataParse), "RecipeSetDown");
  142. ActionManage.GetInstance.Send("ClearRecipes");
  143. ReadPlcData();
  144. IniteTask();
  145. MessageLog.GetInstance.ShowRunLog("主任务重启完成");
  146. }));
  147. }));
  148. }
  149. Thread.Sleep(10);
  150. }), "ResetProgram");
  151. }
  152. /// <summary>
  153. /// 实时获取plc数据
  154. /// </summary>
  155. public void ReadPlcData()
  156. {
  157. ThreadManage.GetInstance().StartLong(new Action(() =>
  158. {
  159. GetAddressData("D2001", new Action<ushort[]>((data) =>
  160. {
  161. globalVar.rollerLineOne.StationOne = data[0];
  162. globalVar.rollerLineOne.StationTwo = data[1];
  163. globalVar.rollerLineOne.StationThree = data[2];
  164. globalVar.rollerLineOne.StationFour = data[3];
  165. globalVar.rollerLineOne.StationFive = data[4];
  166. globalVar.rollerLineOne.StationSix = data[5];
  167. globalVar.rollerLineOne.StationSeven = data[6];
  168. globalVar.rollerLineOne.StationEight = data[7];
  169. }));
  170. GetAddressData("D2011", new Action<ushort[]>((data) =>
  171. {
  172. globalVar.rollerLineTwo.StationOne = data[0];
  173. globalVar.rollerLineTwo.StationTwo = data[1];
  174. globalVar.rollerLineTwo.StationThree = data[2];
  175. globalVar.rollerLineTwo.StationFour = data[3];
  176. globalVar.rollerLineTwo.StationFive = data[4];
  177. globalVar.rollerLineTwo.StationSix = data[5];
  178. globalVar.rollerLineTwo.StationSeven = data[6];
  179. globalVar.rollerLineTwo.StationEight = data[7];
  180. }));
  181. GetAddressData("D2021", new Action<ushort[]>((data) =>
  182. {
  183. globalVar.rollerLineThree.StationOne = data[0];
  184. globalVar.rollerLineThree.StationTwo = data[1];
  185. globalVar.rollerLineThree.StationThree = data[2];
  186. globalVar.rollerLineThree.StationFour = data[3];
  187. globalVar.rollerLineThree.StationFive = data[4];
  188. globalVar.rollerLineThree.StationSix = data[5];
  189. globalVar.rollerLineThree.StationSeven = data[6];
  190. globalVar.rollerLineThree.StationEight = data[7];
  191. }));
  192. GetAddressData("D2031", new Action<ushort[]>((data) =>
  193. {
  194. globalVar.rollerLineOne.OutMaterialingSingle = data[3];
  195. globalVar.rollerLineTwo.OutMaterialingSingle = data[4];
  196. globalVar.rollerLineThree.OutMaterialingSingle = data[5];
  197. globalVar.rollerLineOne.OutMaterialingTroubleSingle = data[6];
  198. globalVar.rollerLineTwo.OutMaterialingTroubleSingle = data[7];
  199. globalVar.rollerLineThree.OutMaterialingTroubleSingle = data[8];
  200. }));
  201. GetAddressData("D2040", new Action<ushort[]>((data) =>
  202. {
  203. globalVar.fryPotOne.InputMaterialRollerRunningSingle = data[0];
  204. globalVar.fryPotTwo.InputMaterialRollerRunningSingle = data[1];
  205. globalVar.fryPotThree.InputMaterialRollerRunningSingle = data[2];
  206. globalVar.fryPotFour.InputMaterialRollerRunningSingle = data[3];
  207. globalVar.fryPotFive.InputMaterialRollerRunningSingle = data[4];
  208. }));
  209. GetAddressData("D2045", new Action<ushort[]>((data) =>
  210. {
  211. globalVar.fryPotOne.InputMaterialArrivedSingle = data[0];
  212. globalVar.fryPotTwo.InputMaterialArrivedSingle = data[1];
  213. globalVar.fryPotThree.InputMaterialArrivedSingle = data[2];
  214. globalVar.fryPotFour.InputMaterialArrivedSingle = data[3];
  215. globalVar.fryPotFive.InputMaterialArrivedSingle = data[4];
  216. }));
  217. GetAddressData("D2050", new Action<ushort[]>((data) =>
  218. {
  219. globalVar.fryPotOne.EmptyBarrelArrivedSingle = data[0];
  220. globalVar.fryPotTwo.EmptyBarrelArrivedSingle = data[1];
  221. globalVar.fryPotThree.EmptyBarrelArrivedSingle = data[2];
  222. globalVar.fryPotFour.EmptyBarrelArrivedSingle = data[3];
  223. globalVar.fryPotFive.EmptyBarrelArrivedSingle = data[4];
  224. }));
  225. GetAddressData("D2065", new Action<ushort[]>((data) =>
  226. {
  227. globalVar.fryPotOne.EmptyBarrelRollerRunningSingle = data[0];
  228. globalVar.fryPotTwo.EmptyBarrelRollerRunningSingle = data[1];
  229. globalVar.fryPotThree.EmptyBarrelRollerRunningSingle = data[2];
  230. globalVar.fryPotFour.EmptyBarrelRollerRunningSingle = data[3];
  231. globalVar.fryPotFive.EmptyBarrelRollerRunningSingle = data[4];
  232. }));
  233. GetAddressData("D2070", new Action<ushort[]>((data) =>
  234. {
  235. globalVar.fryPotOne.RollerTroubleSingle = data[0];
  236. globalVar.fryPotTwo.RollerTroubleSingle = data[1];
  237. globalVar.fryPotThree.RollerTroubleSingle = data[2];
  238. globalVar.fryPotFour.RollerTroubleSingle = data[3];
  239. globalVar.fryPotFive.RollerTroubleSingle = data[4];
  240. }));
  241. GetAddressData("D2078", new Action<ushort[]>(data =>
  242. {
  243. globalVar.rollerLineOne.RecipeCompleteSingle = data[0];
  244. globalVar.rollerLineTwo.RecipeCompleteSingle = data[1];
  245. globalVar.rollerLineThree.RecipeCompleteSingle = data[2];
  246. }));
  247. GetAddressData("D2075", new Action<ushort[]>(data =>
  248. {
  249. globalVar.CleadBarrelEnterSingle = data[0];
  250. }));
  251. GetAddressData("D2077", new Action<ushort[]>(data =>
  252. {
  253. globalVar.CleadBarrelExitSingle = data[0];
  254. }));
  255. //globalVar.rollerLineOne.OutMaterialingSingle = 0;
  256. //globalVar.rollerLineOne.StationOne = 401;
  257. //globalVar.rollerLineOne.StationTwo = 402;
  258. //globalVar.rollerLineOne.OutMaterialingTroubleSingle = 1;
  259. RollerLineStatusDisplay();
  260. Thread.Sleep(10);
  261. }), "MainViewReadPlcData");
  262. }
  263. /// <summary>
  264. /// 滚筒线运行状态显示
  265. /// </summary>
  266. private void RollerLineStatusDisplay()
  267. {
  268. hardWareStatusModel.RollerOneModel.LocOneRollerSerial = globalVar.rollerLineOne.StationOne;
  269. hardWareStatusModel.RollerOneModel.LocTwoRollerSerial = globalVar.rollerLineOne.StationTwo;
  270. hardWareStatusModel.RollerOneModel.LocThreeRollerSerial = globalVar.rollerLineOne.StationThree;
  271. hardWareStatusModel.RollerOneModel.LocFourRollerSerial = globalVar.rollerLineOne.StationFour;
  272. hardWareStatusModel.RollerOneModel.LocFiveRollerSerial = globalVar.rollerLineOne.StationFive;
  273. hardWareStatusModel.RollerOneModel.LocSixRollerSerial = globalVar.rollerLineOne.StationSix;
  274. hardWareStatusModel.RollerOneModel.LocSevenRollerSerial = globalVar.rollerLineOne.StationSeven;
  275. hardWareStatusModel.RollerOneModel.LocEightRollerSerial = globalVar.rollerLineOne.StationEight;
  276. if (globalVar.rollerLineOne.OutMaterialingTroubleSingle == 0)
  277. {
  278. hardWareStatusModel.RollerOneModel.RollerAlarmState = Color.FromRgb(130, 232, 139);//无故障
  279. }
  280. else
  281. {
  282. hardWareStatusModel.RollerOneModel.RollerAlarmState = Color.FromRgb(255, 51, 153);//有故障
  283. }
  284. if (globalVar.rollerLineOne.OutMaterialingSingle == 1)//运行中
  285. {
  286. hardWareStatusModel.RollerOneModel.RollerRunState = Color.FromRgb(130, 232, 139);//运行中
  287. }
  288. else
  289. {
  290. hardWareStatusModel.RollerOneModel.RollerRunState = Color.FromRgb(84, 84, 84);//未运行
  291. }
  292. hardWareStatusModel.RollerTwoModel.LocOneRollerSerial = globalVar.rollerLineTwo.StationOne;
  293. hardWareStatusModel.RollerTwoModel.LocTwoRollerSerial = globalVar.rollerLineTwo.StationTwo;
  294. hardWareStatusModel.RollerTwoModel.LocThreeRollerSerial = globalVar.rollerLineTwo.StationThree;
  295. hardWareStatusModel.RollerTwoModel.LocFourRollerSerial = globalVar.rollerLineTwo.StationFour;
  296. hardWareStatusModel.RollerTwoModel.LocFiveRollerSerial = globalVar.rollerLineTwo.StationFive;
  297. hardWareStatusModel.RollerTwoModel.LocSixRollerSerial = globalVar.rollerLineTwo.StationSix;
  298. hardWareStatusModel.RollerTwoModel.LocSevenRollerSerial = globalVar.rollerLineTwo.StationSeven;
  299. hardWareStatusModel.RollerTwoModel.LocEightRollerSerial = globalVar.rollerLineTwo.StationEight;
  300. if (globalVar.rollerLineTwo.OutMaterialingTroubleSingle == 0)
  301. {
  302. hardWareStatusModel.RollerTwoModel.RollerAlarmState = Color.FromRgb(130, 232, 139);//无故障
  303. }
  304. else
  305. {
  306. hardWareStatusModel.RollerTwoModel.RollerAlarmState = Color.FromRgb(255, 51, 153);//有故障
  307. }
  308. if (globalVar.rollerLineTwo.OutMaterialingSingle == 1)//运行中
  309. {
  310. hardWareStatusModel.RollerTwoModel.RollerRunState = Color.FromRgb(130, 232, 139);//运行中
  311. }
  312. else
  313. {
  314. hardWareStatusModel.RollerTwoModel.RollerRunState = Color.FromRgb(84, 84, 84);//未运行
  315. }
  316. hardWareStatusModel.RollerThreeModel.LocOneRollerSerial = globalVar.rollerLineThree.StationOne;
  317. hardWareStatusModel.RollerThreeModel.LocTwoRollerSerial = globalVar.rollerLineThree.StationTwo;
  318. hardWareStatusModel.RollerThreeModel.LocThreeRollerSerial = globalVar.rollerLineThree.StationThree;
  319. hardWareStatusModel.RollerThreeModel.LocFourRollerSerial = globalVar.rollerLineThree.StationFour;
  320. hardWareStatusModel.RollerThreeModel.LocFiveRollerSerial = globalVar.rollerLineThree.StationFive;
  321. hardWareStatusModel.RollerThreeModel.LocSixRollerSerial = globalVar.rollerLineThree.StationSix;
  322. hardWareStatusModel.RollerThreeModel.LocSevenRollerSerial = globalVar.rollerLineThree.StationSeven;
  323. hardWareStatusModel.RollerThreeModel.LocEightRollerSerial = globalVar.rollerLineThree.StationEight;
  324. if (globalVar.rollerLineThree.OutMaterialingTroubleSingle == 0)
  325. {
  326. hardWareStatusModel.RollerThreeModel.RollerAlarmState = Color.FromRgb(130, 232, 139);//无故障
  327. }
  328. else
  329. {
  330. hardWareStatusModel.RollerThreeModel.RollerAlarmState = Color.FromRgb(255, 51, 153);//有故障
  331. }
  332. if (globalVar.rollerLineThree.OutMaterialingSingle == 1)//运行中
  333. {
  334. hardWareStatusModel.RollerThreeModel.RollerRunState = Color.FromRgb(130, 232, 139);//运行中
  335. }
  336. else
  337. {
  338. hardWareStatusModel.RollerThreeModel.RollerRunState = Color.FromRgb(84, 84, 84);//未运行
  339. }
  340. //滚筒线4
  341. }
  342. /// <summary>
  343. /// 返回指定地址指定长度的数据
  344. /// </summary>
  345. /// <param name="address"></param>
  346. /// <returns></returns>
  347. public void GetAddressData(string address, Action<ushort[]> action)
  348. {
  349. PlcReadData = DeviceOperate.GetInstance.GetAllData();
  350. if (PlcReadData.ContainsKey(address))
  351. {
  352. action((ushort[])(PlcReadData[address]));
  353. }
  354. }
  355. /// <summary>
  356. /// 写Plc数据
  357. /// </summary>
  358. /// <param name="address"></param>
  359. /// <param name="Value"></param>
  360. public void WritePlcData(string address, ushort Value)
  361. {
  362. DeviceOperate.GetInstance.WritePlcData(address, Value);
  363. }
  364. /// <summary>
  365. /// 初始化任务
  366. /// </summary>
  367. public void IniteTask()
  368. {
  369. ThreadManage.GetInstance().StartLong(new Action(() =>
  370. {
  371. MainTask();
  372. }), "MainTask");
  373. }
  374. /// <summary>
  375. /// 配方数据接收
  376. /// </summary>
  377. public void RecipeDataParse(object obj)
  378. {
  379. Task.Run(new Action(() =>
  380. {
  381. if (obj != null && obj is NewRecipeModel recipe)
  382. {
  383. RecipeQuene.Enqueue(recipe);
  384. ReicpeNum++;
  385. MessageLog.GetInstance.ShowRunLog($"接收到第{ReicpeNum}个配方");
  386. }
  387. }));
  388. }
  389. /// <summary>
  390. /// 开启主任务
  391. /// </summary>
  392. public void MainTask()
  393. {
  394. RecipeDataToPlc();
  395. AgvLoadRoller();
  396. FryPotInputMaterial();
  397. FryPotOutputMaterial();
  398. }
  399. /// <summary>
  400. /// 数据下发PLC
  401. /// </summary>
  402. public void RecipeDataToPlc()
  403. {
  404. if (RecipeQuene.Count > 0 && OutputMaterialQuene.Count == 0 && InputMaterialQuene.Count == 0)//后续添加其它限制条件
  405. {
  406. //NewRecipeModel newRecipe = new NewRecipeModel();
  407. MaterialType material = new MaterialType();
  408. if (RecipeQuene.TryDequeue(out NewRecipeModel result))
  409. {
  410. MessageLog.GetInstance.ShowRunLog($"开始制作【{result.RecipeName}】 配方");
  411. //for (int k = 0; k < result.materialCollection.Count-1; k++)
  412. //{
  413. // for (int j = 0; j < result.materialCollection.Count-1-k; j++)
  414. // {
  415. // if (result.materialCollection[j].MaterialLoc > result.materialCollection[j + 1].MaterialLoc)
  416. // {
  417. // material = result.materialCollection[j];
  418. // result.materialCollection[j] = result.materialCollection[j + 1];
  419. // result.materialCollection[j + 1] = material;
  420. // }
  421. // }
  422. //}
  423. for (int i = 0; i < result.materialCollection.Count; i++) //遍历单个配方中所有物料
  424. {
  425. //将配方中原料加入新的队列
  426. InputMaterialQuene.Enqueue(new MaterialInfo()
  427. {
  428. materialType = result.materialCollection[i],
  429. materialId = result.RecipeId
  430. });
  431. ushort n = result.materialCollection[i].MaterialLoc;
  432. switch (n / 100)
  433. {
  434. case 1:
  435. case 4: RollerOneDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight); break;//1号滚筒线桶号以及重量数据下发
  436. case 2:
  437. case 5: RollerTwoDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight); break;//2号滚筒线桶号以及重量数据下发
  438. case 3: RollerThreeDataWrite(i, result.materialCollection[i].MaterialLoc, result.materialCollection[i].MaterialWeight); break;//3号滚筒线桶号以及重量数据下发
  439. }
  440. }
  441. switch (result.materialCollection[0].MaterialLoc / 100)
  442. {
  443. case 1:
  444. DeviceOperate.GetInstance.WritePlcData("D1009", (ushort)result.materialCollection.Count); break;//发送1号滚筒线工序数据
  445. case 2:
  446. DeviceOperate.GetInstance.WritePlcData("D1026", (ushort)result.materialCollection.Count); break;//发送2号滚筒线工序数据
  447. case 3:
  448. DeviceOperate.GetInstance.WritePlcData("D1043", (ushort)result.materialCollection.Count); break;//发送3号滚筒线工序数据
  449. }
  450. }
  451. }
  452. }
  453. /// <summary>
  454. /// AGV到配方对应线体装桶以及出料到炒锅
  455. /// </summary>
  456. public void AgvLoadRoller()
  457. {
  458. //lineAlarm = 0;
  459. if (InputMaterialQuene.Count > 0)
  460. {
  461. switch (InputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  462. {
  463. case 1:
  464. case 4: AgvToLineOneLoadRoller(); AgvFromLineOneToFryPot(); break;//AGV到1号线体装桶
  465. case 2:
  466. case 5: AgvToLineTwoLoadRoller(); AgvFromLineTwoToFryPot(); break;//AGV到2号线体装桶
  467. case 3: AgvToLineThreeLoadRoller(); AgvFromLineThreeToFryPot(); break;//AGV到3号线体装桶
  468. }
  469. }
  470. }
  471. /// <summary>
  472. /// AGV从炒锅送料位置到倒料过程处理
  473. /// </summary>
  474. public void FryPotInputMaterial()
  475. {
  476. if (OutputMaterialQuene.Count > 0 && !globalVar.InOrOutputLock)
  477. {
  478. while (!agvArriveUnLoad)//等待agv到达炒锅位置
  479. {
  480. Thread.Sleep(5);
  481. if (globalVar.ExitMainTask)
  482. return;
  483. }
  484. AgvArriveFryPotSingleSetDown();
  485. FryPotRollerTroubleCheck();
  486. if (FryPotAlarm == 1)//炒锅滚筒无故障
  487. {
  488. //炒锅滚筒进料运行到位处理
  489. FryPotInputMaterialRollerOperate();
  490. globalVar.InOrOutputLock = true;
  491. }
  492. }
  493. }
  494. /// <summary>
  495. /// 炒锅出桶
  496. /// </summary>
  497. public void FryPotOutputMaterial()
  498. {
  499. if (OutputMaterialQuene.Count > 0 && globalVar.InOrOutputLock)
  500. {
  501. AgvFromFryPotToClean();//上游下发搬运任务给AGV
  502. while (!agvArriveUpLoad)//等待agv到达炒锅位置
  503. {
  504. Thread.Sleep(5);
  505. if (globalVar.ExitMainTask)
  506. return;
  507. }
  508. agvArriveUpLoad = false;
  509. AgvArriveFryPotOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号
  510. FryPotRollerTroubleCheck();
  511. if (FryPotAlarm == 1)//无故障
  512. {
  513. FryPotOutEmpetyRollerOperate();
  514. if (OutputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))//空桶出桶后,出料原料队列移除对应原料
  515. {
  516. while (!agvFryPotEmptyRollerArrive)//等待AGV拿到出桶空桶
  517. {
  518. Thread.Sleep(5);
  519. if (globalVar.ExitMainTask)
  520. return;
  521. }
  522. //AGV拿到空桶,让AGV运桶到指定位置,同时可以让下一个AGV从线体装料运到炒锅
  523. globalVar.AllowAgvToLineLoadRoller = true;
  524. globalVar.InOrOutputLock = false;
  525. }
  526. }
  527. }
  528. }
  529. /// <summary>
  530. /// 炒锅滚筒进料运行到位处理
  531. /// </summary>
  532. public void FryPotInputMaterialRollerOperate()
  533. {
  534. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  535. {
  536. case 1:
  537. while (globalVar.fryPotOne.InputMaterialArrivedSingle == 0)
  538. {
  539. Thread.Sleep(5); if (globalVar.ExitMainTask)
  540. return;
  541. }
  542. MessageLog.GetInstance.ShowRunLog($"炒锅【1】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
  543. case 2:
  544. while (globalVar.fryPotTwo.InputMaterialArrivedSingle == 0)
  545. {
  546. Thread.Sleep(5); if (globalVar.ExitMainTask)
  547. return;
  548. }
  549. MessageLog.GetInstance.ShowRunLog($"炒锅【2】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
  550. case 3:
  551. while (globalVar.fryPotThree.InputMaterialArrivedSingle == 0)
  552. {
  553. Thread.Sleep(5); if (globalVar.ExitMainTask)
  554. return;
  555. }
  556. MessageLog.GetInstance.ShowRunLog($"炒锅【3】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
  557. case 4:
  558. while (globalVar.fryPotFour.InputMaterialArrivedSingle == 0)
  559. {
  560. Thread.Sleep(5); if (globalVar.ExitMainTask)
  561. return;
  562. }
  563. MessageLog.GetInstance.ShowRunLog($"炒锅【4】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
  564. case 5:
  565. while (globalVar.fryPotFive.InputMaterialArrivedSingle == 0)
  566. {
  567. Thread.Sleep(5); if (globalVar.ExitMainTask)
  568. return;
  569. }
  570. MessageLog.GetInstance.ShowRunLog($"炒锅【5】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}已到进料位置,准备倒料"); break;
  571. }
  572. }
  573. /// <summary>
  574. /// 炒锅滚筒空桶出桶处理
  575. /// </summary>
  576. public void FryPotOutEmpetyRollerOperate()
  577. {
  578. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  579. {
  580. case 1:
  581. while (globalVar.fryPotOne.EmptyBarrelArrivedSingle == 0)
  582. {
  583. Thread.Sleep(5); if (globalVar.ExitMainTask)
  584. return;
  585. }
  586. MessageLog.GetInstance.ShowRunLog($"炒锅【1】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break;
  587. case 2:
  588. while (globalVar.fryPotTwo.EmptyBarrelArrivedSingle == 0)
  589. {
  590. Thread.Sleep(5); if (globalVar.ExitMainTask)
  591. return;
  592. }
  593. MessageLog.GetInstance.ShowRunLog($"炒锅【2】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break;
  594. case 3:
  595. while (globalVar.fryPotThree.EmptyBarrelArrivedSingle == 0)
  596. {
  597. Thread.Sleep(5); if (globalVar.ExitMainTask)
  598. return;
  599. }
  600. MessageLog.GetInstance.ShowRunLog($"炒锅【3】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break;
  601. case 4:
  602. while (globalVar.fryPotFour.EmptyBarrelArrivedSingle == 0)
  603. {
  604. Thread.Sleep(5); if (globalVar.ExitMainTask)
  605. return;
  606. }
  607. MessageLog.GetInstance.ShowRunLog($"炒锅【4】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break;
  608. case 5:
  609. while (globalVar.fryPotFive.EmptyBarrelArrivedSingle == 0)
  610. {
  611. Thread.Sleep(5); if (globalVar.ExitMainTask)
  612. return;
  613. }
  614. MessageLog.GetInstance.ShowRunLog($"炒锅【5】原料:{OutputMaterialQuene.ElementAt(0).materialType.MaterialName}空桶到达出桶位置,正在出桶"); break;
  615. }
  616. }
  617. /// <summary>
  618. /// 发送agv送料就位信号至PLC(线体到炒锅)
  619. /// </summary>
  620. public void AgvArriveFryPotSingleSetDown()
  621. {
  622. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  623. {
  624. case 1: DeviceOperate.GetInstance.WritePlcData("D1055", 1); break;//agv到炒锅1送料就位信号
  625. case 2: DeviceOperate.GetInstance.WritePlcData("D1056", 1); break;//agv到炒锅2送料就位信号
  626. case 3: DeviceOperate.GetInstance.WritePlcData("D1057", 1); break;//agv到炒锅3送料就位信号
  627. case 4: DeviceOperate.GetInstance.WritePlcData("D1058", 1); break;//agv到炒锅4送料就位信号
  628. case 5: DeviceOperate.GetInstance.WritePlcData("D1059", 1); break;//agv到炒锅5送料就位信号
  629. }
  630. }
  631. /// <summary>
  632. /// 发送agv回桶就位信号至PLC
  633. /// </summary>
  634. public void AgvArriveFryPotOutEmptyRollerSingleSetDown()
  635. {
  636. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  637. {
  638. case 1: DeviceOperate.GetInstance.WritePlcData("D1060", 1); break;//agv到炒锅1送料就位信号
  639. case 2: DeviceOperate.GetInstance.WritePlcData("D1061", 1); break;//agv到炒锅2送料就位信号
  640. case 3: DeviceOperate.GetInstance.WritePlcData("D1062", 1); break;//agv到炒锅3送料就位信号
  641. case 4: DeviceOperate.GetInstance.WritePlcData("D1063", 1); break;//agv到炒锅4送料就位信号
  642. case 5: DeviceOperate.GetInstance.WritePlcData("D1064", 1); break;//agv到炒锅5送料就位信号
  643. }
  644. }
  645. /// <summary>
  646. /// AGV离开炒锅运送空桶任务
  647. /// </summary>
  648. public void AgvFromFryPotToClean()
  649. {
  650. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  651. {
  652. case 1:
  653. erp: string id = Guid.NewGuid().ToString("N");//上游唯一ID
  654. if (id == robotJobId)
  655. {
  656. goto erp;
  657. }
  658. string info = AGVHelper.GetInstance.AgvLeaveFryPotOne(id);
  659. robotJobId = id;
  660. FryCarryTaskErrorCodeAnalysis(info, 1); break;
  661. case 2:
  662. erp1: string id1 = Guid.NewGuid().ToString("N");//上游唯一ID
  663. if (id1 == robotJobId)
  664. {
  665. goto erp1;
  666. }
  667. string info1 = AGVHelper.GetInstance.AgvLeaveFryPotTwo(id1);
  668. robotJobId = id1;
  669. FryCarryTaskErrorCodeAnalysis(info1, 2); break;
  670. case 3:
  671. erp2: string id2 = Guid.NewGuid().ToString("N");//上游唯一ID
  672. if (id2 == robotJobId)
  673. {
  674. goto erp2;
  675. }
  676. string info2 = AGVHelper.GetInstance.AgvLeaveFryPotThree(id2);
  677. robotJobId = id2;
  678. FryCarryTaskErrorCodeAnalysis(info2, 3); break;
  679. case 4:
  680. erp3: string id3 = Guid.NewGuid().ToString("N");//上游唯一ID
  681. if (id3 == robotJobId)
  682. {
  683. goto erp3;
  684. }
  685. string info3 = AGVHelper.GetInstance.AgvLeaveFryPotFour(id3);
  686. robotJobId = id3;
  687. FryCarryTaskErrorCodeAnalysis(info3, 4); break;
  688. case 5:
  689. erp4: string id4 = Guid.NewGuid().ToString("N");//上游唯一ID
  690. if (id4 == robotJobId)
  691. {
  692. goto erp4;
  693. }
  694. string info4 = AGVHelper.GetInstance.AgvLeaveFryPotFive(id4);
  695. robotJobId = id4;
  696. FryCarryTaskErrorCodeAnalysis(info4, 5); break;
  697. }
  698. }
  699. /// <summary>
  700. /// 处理agv从线体1到送料到炒锅的条件
  701. /// </summary>
  702. /// <param name="lineAlarm"></param>
  703. public void AgvFromLineOneToFryPot()
  704. {
  705. erp: if (globalVar.rollerLineOne.OutMaterialingTroubleSingle == 0)//无故障
  706. {
  707. while (!agvArriveUpLoad)//等待AGV到线体装料位置
  708. {
  709. Thread.Sleep(5);
  710. if (globalVar.ExitMainTask)
  711. return;
  712. }
  713. agvArriveUpLoad = false;
  714. AgvArriveLineSingelSetDown();
  715. if (InputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
  716. {
  717. while (!(globalVar.rollerLineOne.StationEight == materialInfo.materialType.MaterialLoc))//等待线体工号位8存放对应原料桶号
  718. {
  719. Thread.Sleep(5);
  720. if (globalVar.ExitMainTask)
  721. return;
  722. }
  723. OutputMaterialQuene.Enqueue(materialInfo);
  724. //原料到位,agv到位,agv自行运料到炒锅
  725. }
  726. }
  727. else//有故障
  728. {
  729. while (globalVar.rollerLineOne.OutMaterialingTroubleSingle == 1)
  730. {
  731. Thread.Sleep(50);
  732. if (globalVar.ExitMainTask)
  733. return;
  734. }
  735. MessageLog.GetInstance.ShowRunLog("线体【1】滚筒故障解除,继续运行");
  736. //lineAlarm = 1;
  737. goto erp;
  738. }
  739. }
  740. /// <summary>
  741. /// 处理agv从线体2到送料到炒锅的条件
  742. /// </summary>
  743. /// <param name="lineAlarm"></param>
  744. public void AgvFromLineTwoToFryPot()
  745. {
  746. erp: if (globalVar.rollerLineTwo.OutMaterialingTroubleSingle == 0)//无故障
  747. {
  748. while (!agvArriveUpLoad)//等待AGV到线体装料位置
  749. {
  750. Thread.Sleep(5);
  751. if (globalVar.ExitMainTask)
  752. return;
  753. }
  754. agvArriveUpLoad = false;
  755. AgvArriveLineSingelSetDown();
  756. if (InputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
  757. {
  758. while (!(globalVar.rollerLineTwo.StationEight == materialInfo.materialType.MaterialLoc))//等待线体工号位8存放对应原料桶号
  759. {
  760. Thread.Sleep(5);
  761. if (globalVar.ExitMainTask)
  762. return;
  763. }
  764. OutputMaterialQuene.Enqueue(materialInfo);
  765. //原料到位,agv到位,agv运料到炒锅
  766. }
  767. }
  768. else//有故障
  769. {
  770. while (globalVar.rollerLineTwo.OutMaterialingTroubleSingle == 1)
  771. {
  772. Thread.Sleep(50);
  773. if (globalVar.ExitMainTask)
  774. return;
  775. }
  776. MessageLog.GetInstance.ShowRunLog("线体【2】滚筒故障解除,继续运行");
  777. // lineAlarm = 1;
  778. goto erp;
  779. }
  780. }
  781. /// <summary>
  782. /// 处理agv从线体3到送料到炒锅的条件
  783. /// </summary>
  784. /// <param name="lineAlarm"></param>
  785. public void AgvFromLineThreeToFryPot()
  786. {
  787. erp: if (globalVar.rollerLineThree.OutMaterialingTroubleSingle == 0)//无故障
  788. {
  789. while (!agvArriveUpLoad)//等待AGV到线体装料位置
  790. {
  791. Thread.Sleep(5);
  792. if (globalVar.ExitMainTask)
  793. return;
  794. }
  795. agvArriveUpLoad = false;
  796. AgvArriveLineSingelSetDown();
  797. if (InputMaterialQuene.TryDequeue(out MaterialInfo materialInfo))
  798. {
  799. while (!(globalVar.rollerLineThree.StationEight == materialInfo.materialType.MaterialLoc))//等待线体工号位8存放对应原料桶号
  800. {
  801. Thread.Sleep(5);
  802. if (globalVar.ExitMainTask)
  803. return;
  804. }
  805. OutputMaterialQuene.Enqueue(materialInfo);
  806. //原料到位,agv到位,agv运料到炒锅
  807. }
  808. }
  809. else //有故障
  810. {
  811. while (globalVar.rollerLineThree.OutMaterialingTroubleSingle == 1)
  812. {
  813. Thread.Sleep(50);
  814. if (globalVar.ExitMainTask)
  815. return;
  816. }
  817. MessageLog.GetInstance.ShowRunLog("线体【3】滚筒故障解除,继续运行");
  818. // lineAlarm = 1;
  819. goto erp;
  820. }
  821. }
  822. /// <summary>
  823. /// 线体搬运任务错误码分析
  824. /// </summary>
  825. /// <param name="errorCode"></param>
  826. /// <param name="num"></param>
  827. public void LineCarryTaskErrorCodeAnalysis(string errorCode, int num)
  828. {
  829. if (errorCode == "SUCCESS")
  830. {
  831. MessageLog.GetInstance.ShowRunLog($"AGV去{num}号线体");
  832. globalVar.AllowAgvToLineLoadRoller = false;
  833. }
  834. else if (errorCode == "Analysis Error")
  835. {
  836. MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号线体接口调用失败,请检查");
  837. }
  838. else
  839. {
  840. MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号线体失败,错误码:{errorCode}");
  841. }
  842. }
  843. /// <summary>
  844. /// 炒锅搬运任务错误码分析
  845. /// </summary>
  846. /// <param name="errorCode"></param>
  847. /// <param name="num"></param>
  848. public void FryCarryTaskErrorCodeAnalysis(string errorCode, int num)
  849. {
  850. if (errorCode == "SUCCESS")
  851. {
  852. MessageLog.GetInstance.ShowRunLog($"AGV离开{num}号炒锅");
  853. }
  854. else if (errorCode == "Analysis Error")
  855. {
  856. MessageLog.GetInstance.ShowRunLog($"提示:AGV离开{num}号炒锅接口调用失败,请检查");
  857. }
  858. else
  859. {
  860. MessageLog.GetInstance.ShowRunLog($"提示:AGV离开{num}号炒锅失败,错误码:{errorCode}");
  861. }
  862. }
  863. public void AgvToLineOneLoadRoller()
  864. {
  865. if (globalVar.rollerLineOne.OutMaterialingTroubleSingle == 0)//输送线无故障
  866. {
  867. if (InputMaterialQuene.Count > 0)
  868. {
  869. while (!globalVar.AllowAgvToLineLoadRoller || globalVar.rollerLineOne.OutMaterialingSingle == 0)
  870. {
  871. Thread.Sleep(5);
  872. if (globalVar.ExitMainTask)
  873. return;
  874. }
  875. e: string id = Guid.NewGuid().ToString("N");
  876. if (id == robotJobId)
  877. goto e;
  878. string info = AGVHelper.GetInstance.AgvToLineOneLoadRoller(id);
  879. robotJobId = id;
  880. Thread.Sleep(500);
  881. LineCarryTaskErrorCodeAnalysis(info, 1);
  882. }
  883. }
  884. else
  885. {
  886. MessageLog.GetInstance.ShowRunLog("警告:滚筒输送线体【1】故障!!!");
  887. // lineAlarm = -1;
  888. }
  889. // lineAlarm = 1;
  890. }
  891. public void AgvToLineTwoLoadRoller()
  892. {
  893. if (globalVar.rollerLineTwo.OutMaterialingTroubleSingle == 0)//输送线无故障
  894. {
  895. if (InputMaterialQuene.Count > 0)
  896. {
  897. while (!globalVar.AllowAgvToLineLoadRoller || globalVar.rollerLineOne.OutMaterialingSingle == 0) //后续考虑是否用while
  898. {
  899. Thread.Sleep(5);
  900. if (globalVar.ExitMainTask)
  901. return;
  902. }
  903. p: string id = Guid.NewGuid().ToString();
  904. if (id == robotJobId)
  905. goto p;
  906. string info = AGVHelper.GetInstance.AgvToLineTwoLoadRoller(id);
  907. robotJobId = id;
  908. Thread.Sleep(500);
  909. LineCarryTaskErrorCodeAnalysis(info, 2);
  910. }
  911. }
  912. else
  913. {
  914. MessageLog.GetInstance.ShowRunLog("警告:滚筒输送线体【2】故障!!!");
  915. //lineAlarm = -1;
  916. }
  917. // lineAlarm = 1;
  918. }
  919. public void AgvToLineThreeLoadRoller()
  920. {
  921. if (globalVar.rollerLineThree.OutMaterialingTroubleSingle == 0)//输送线无故障
  922. {
  923. if (InputMaterialQuene.Count > 0)
  924. {
  925. while (!globalVar.AllowAgvToLineLoadRoller || globalVar.rollerLineOne.OutMaterialingSingle == 0) //后续考虑是否用while
  926. {
  927. Thread.Sleep(5);
  928. if (globalVar.ExitMainTask)
  929. return;
  930. }
  931. g: string id = Guid.NewGuid().ToString();
  932. if (id == robotJobId)
  933. goto g;
  934. string info = AGVHelper.GetInstance.AgvToLineThreeLoadRoller(id);
  935. robotJobId = id;
  936. Thread.Sleep(500);
  937. LineCarryTaskErrorCodeAnalysis(info, 3);
  938. }
  939. }
  940. else
  941. {
  942. MessageLog.GetInstance.ShowRunLog("警告:滚筒输送线体【3】故障!!!");
  943. // lineAlarm = -1;
  944. }
  945. // lineAlarm = 1;
  946. }
  947. /// <summary>
  948. /// 1号线体数据下发
  949. /// </summary>
  950. /// <param name="count"></param>
  951. /// <param name="materialLoc"></param>
  952. /// <param name="materialWeight"></param>
  953. public void RollerOneDataWrite(int count, ushort materialLoc, ushort materialWeight)
  954. {
  955. switch (count)
  956. {
  957. case 0:
  958. DeviceOperate.GetInstance.WritePlcData("D1001", materialLoc);//桶1位置
  959. DeviceOperate.GetInstance.WritePlcData("D1010", materialWeight);//桶2重量
  960. break;
  961. case 1:
  962. DeviceOperate.GetInstance.WritePlcData("D1002", materialLoc);//桶2位置
  963. DeviceOperate.GetInstance.WritePlcData("D1011", materialWeight);//桶2重量
  964. break;
  965. case 2:
  966. DeviceOperate.GetInstance.WritePlcData("D1003", materialLoc);//桶3位置
  967. DeviceOperate.GetInstance.WritePlcData("D1012", materialWeight);//桶3重量
  968. break;
  969. case 3:
  970. DeviceOperate.GetInstance.WritePlcData("D1004", materialLoc);//桶4位置
  971. DeviceOperate.GetInstance.WritePlcData("D1013", materialWeight);//桶4重量
  972. break;
  973. case 4:
  974. DeviceOperate.GetInstance.WritePlcData("D1005", materialLoc);//桶5位置
  975. DeviceOperate.GetInstance.WritePlcData("D1014", materialWeight);//桶5重量
  976. break;
  977. case 5:
  978. DeviceOperate.GetInstance.WritePlcData("D1006", materialLoc);//桶6位置
  979. DeviceOperate.GetInstance.WritePlcData("D1015", materialWeight);//桶6重量
  980. break;
  981. case 6:
  982. DeviceOperate.GetInstance.WritePlcData("D1007", materialLoc);//桶7位置
  983. DeviceOperate.GetInstance.WritePlcData("D1016", materialWeight);//桶7重量
  984. break;
  985. case 7:
  986. DeviceOperate.GetInstance.WritePlcData("D1008", materialLoc);//桶8位置
  987. DeviceOperate.GetInstance.WritePlcData("D1017", materialWeight);//桶8重量
  988. break;
  989. }
  990. }
  991. /// <summary>
  992. /// 2号线体数据下发
  993. /// </summary>
  994. /// <param name="count"></param>
  995. /// <param name="materialLoc"></param>
  996. /// <param name="materialWeight"></param>
  997. public void RollerTwoDataWrite(int count, ushort materialLoc, ushort materialWeight)
  998. {
  999. switch (count)
  1000. {
  1001. case 0:
  1002. DeviceOperate.GetInstance.WritePlcData("D1018", materialLoc);//桶1位置
  1003. DeviceOperate.GetInstance.WritePlcData("D1027", materialWeight);//桶2重量
  1004. break;
  1005. case 1:
  1006. DeviceOperate.GetInstance.WritePlcData("D1019", materialLoc);//桶2位置
  1007. DeviceOperate.GetInstance.WritePlcData("D1028", materialWeight);//桶2重量
  1008. break;
  1009. case 2:
  1010. DeviceOperate.GetInstance.WritePlcData("D1020", materialLoc);//桶3位置
  1011. DeviceOperate.GetInstance.WritePlcData("D1029", materialWeight);//桶3重量
  1012. break;
  1013. case 3:
  1014. DeviceOperate.GetInstance.WritePlcData("D1021", materialLoc);//桶4位置
  1015. DeviceOperate.GetInstance.WritePlcData("D1030", materialWeight);//桶4重量
  1016. break;
  1017. case 4:
  1018. DeviceOperate.GetInstance.WritePlcData("D1022", materialLoc);//桶5位置
  1019. DeviceOperate.GetInstance.WritePlcData("D1031", materialWeight);//桶5重量
  1020. break;
  1021. case 5:
  1022. DeviceOperate.GetInstance.WritePlcData("D1023", materialLoc);//桶6位置
  1023. DeviceOperate.GetInstance.WritePlcData("D1032", materialWeight);//桶6重量
  1024. break;
  1025. case 6:
  1026. DeviceOperate.GetInstance.WritePlcData("D1024", materialLoc);//桶7位置
  1027. DeviceOperate.GetInstance.WritePlcData("D1033", materialWeight);//桶7重量
  1028. break;
  1029. case 7:
  1030. DeviceOperate.GetInstance.WritePlcData("D1025", materialLoc);//桶8位置
  1031. DeviceOperate.GetInstance.WritePlcData("D1034", materialWeight);//桶8重量
  1032. break;
  1033. }
  1034. }
  1035. /// <summary>
  1036. /// 3号线体数据下发
  1037. /// </summary>
  1038. /// <param name="count"></param>
  1039. /// <param name="materialLoc"></param>
  1040. /// <param name="materialWeight"></param>
  1041. public void RollerThreeDataWrite(int count, ushort materialLoc, ushort materialWeight)
  1042. {
  1043. switch (count)
  1044. {
  1045. case 0:
  1046. DeviceOperate.GetInstance.WritePlcData("D1035", materialLoc);//桶1位置
  1047. DeviceOperate.GetInstance.WritePlcData("D1044", materialWeight);//桶2重量
  1048. break;
  1049. case 1:
  1050. DeviceOperate.GetInstance.WritePlcData("D1036", materialLoc);//桶2位置
  1051. DeviceOperate.GetInstance.WritePlcData("D1045", materialWeight);//桶2重量
  1052. break;
  1053. case 2:
  1054. DeviceOperate.GetInstance.WritePlcData("D1037", materialLoc);//桶3位置
  1055. DeviceOperate.GetInstance.WritePlcData("D1046", materialWeight);//桶3重量
  1056. break;
  1057. case 3:
  1058. DeviceOperate.GetInstance.WritePlcData("D1038", materialLoc);//桶4位置
  1059. DeviceOperate.GetInstance.WritePlcData("D1047", materialWeight);//桶4重量
  1060. break;
  1061. case 4:
  1062. DeviceOperate.GetInstance.WritePlcData("D1039", materialLoc);//桶5位置
  1063. DeviceOperate.GetInstance.WritePlcData("D1048", materialWeight);//桶5重量
  1064. break;
  1065. case 5:
  1066. DeviceOperate.GetInstance.WritePlcData("D1040", materialLoc);//桶6位置
  1067. DeviceOperate.GetInstance.WritePlcData("D1049", materialWeight);//桶6重量
  1068. break;
  1069. case 6:
  1070. DeviceOperate.GetInstance.WritePlcData("D1041", materialLoc);//桶7位置
  1071. DeviceOperate.GetInstance.WritePlcData("D1050", materialWeight);//桶7重量
  1072. break;
  1073. case 7:
  1074. DeviceOperate.GetInstance.WritePlcData("D1042", materialLoc);//桶8位置
  1075. DeviceOperate.GetInstance.WritePlcData("D1051", materialWeight);//桶8重量
  1076. break;
  1077. }
  1078. }
  1079. /// <summary>
  1080. /// AGV进料就位信号下发至PLC
  1081. /// </summary>
  1082. public void AgvArriveLineSingelSetDown()
  1083. {
  1084. switch (InputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  1085. {
  1086. case 1:
  1087. case 4: DeviceOperate.GetInstance.WritePlcData("D1052", 1); break;//AGV进料就位信号1
  1088. case 2:
  1089. case 5: DeviceOperate.GetInstance.WritePlcData("D1053", 1); break;//AGV进料就位信号2
  1090. case 3: DeviceOperate.GetInstance.WritePlcData("D1054", 1); break;//AGV进料就位信号3
  1091. }
  1092. }
  1093. /// <summary>
  1094. /// 炒锅滚筒信号检测
  1095. /// </summary>
  1096. public void FryPotRollerTroubleCheck()
  1097. {
  1098. FryPotAlarm = 0;
  1099. switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100)
  1100. {
  1101. case 1:
  1102. if (globalVar.fryPotOne.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotOne.RollerTroubleSingle == 1)
  1103. {
  1104. Thread.Sleep(50); if (globalVar.ExitMainTask)
  1105. return;
  1106. }
  1107. MessageLog.GetInstance.ShowRunLog("炒锅【1】输送滚筒故障解除,继续运行");
  1108. FryPotAlarm = 1; break;
  1109. case 2:
  1110. if (globalVar.fryPotTwo.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【2】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotTwo.RollerTroubleSingle == 1)
  1111. {
  1112. Thread.Sleep(50); if (globalVar.ExitMainTask)
  1113. return;
  1114. }
  1115. MessageLog.GetInstance.ShowRunLog("炒锅【2】输送滚筒故障解除,继续运行");
  1116. FryPotAlarm = 1; break;
  1117. case 3:
  1118. if (globalVar.fryPotThree.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【3】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotThree.RollerTroubleSingle == 1)
  1119. {
  1120. Thread.Sleep(50); if (globalVar.ExitMainTask)
  1121. return;
  1122. }
  1123. MessageLog.GetInstance.ShowRunLog("炒锅【3】输送滚筒故障解除,继续运行");
  1124. FryPotAlarm = 1; break;
  1125. case 4:
  1126. if (globalVar.fryPotFour.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【4】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotFour.RollerTroubleSingle == 1)
  1127. {
  1128. Thread.Sleep(50); if (globalVar.ExitMainTask)
  1129. return;
  1130. }
  1131. MessageLog.GetInstance.ShowRunLog("炒锅【4】输送滚筒故障解除,继续运行");
  1132. FryPotAlarm = 1; break;
  1133. case 5:
  1134. if (globalVar.fryPotFive.RollerTroubleSingle == 1) { FryPotAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【5】输送滚筒发生故障"); } else { FryPotAlarm = 1; } while (globalVar.fryPotFive.RollerTroubleSingle == 1)
  1135. {
  1136. Thread.Sleep(50); if (globalVar.ExitMainTask)
  1137. return;
  1138. }
  1139. MessageLog.GetInstance.ShowRunLog("炒锅【5】输送滚筒故障解除,继续运行");
  1140. FryPotAlarm = 1; break;
  1141. }
  1142. }
  1143. }
  1144. }