终端一体化运控平台
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Control_MorkF.cs 104 KiB

2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272
  1. using BPA.Message;
  2. using BPA.Message.Enum;
  3. using BPASmartClient.Device;
  4. using BPASmartClient.EventBus;
  5. using BPASmartClient.Helper;
  6. using BPASmartClient.Message;
  7. using BPASmartClient.Model;
  8. using BPASmartClient.Model.PLC;
  9. using BPA.Models;
  10. using static BPASmartClient.EventBus.EventBus;
  11. using BPASmartClient.Model.小炒机;
  12. using BPASmartClient.MorkF.Model;
  13. namespace BPASmartClient.MorkF
  14. {
  15. public class Control_MorkF : BaseDevice
  16. {
  17. public override DeviceClientType DeviceType => DeviceClientType.MORKCS;
  18. public AutoResetEvent minorReset = new AutoResetEvent(false);
  19. public AutoResetEvent mainReset = new AutoResetEvent(false);
  20. GVL_MorkF morkF = new GVL_MorkF();//全局对象声明
  21. public StirFryBom stirFryBom = new StirFryBom();//创建获取流程的对象
  22. List<StirFryGoods> stirFryGoods = new List<StirFryGoods>();//创建商品对象
  23. List<int> resultorder = new List<int>();//调试变量
  24. /// <summary>
  25. /// 入口
  26. /// </summary>
  27. public override void DoMain()
  28. {
  29. CommandRegist();//调试
  30. ServerInit();
  31. DataParse();//数据解析
  32. DeviceProcessLogShow("MORKF 设备初始化完成");
  33. }
  34. #region 调试代码
  35. public void CommandRegist()
  36. {
  37. #region 设备控制
  38. ActionManage.GetInstance.Register(PLCInite, "InitCommand");
  39. ActionManage.GetInstance.Register(InitialData, "SimultaorOrder");
  40. #endregion
  41. ActionManage.GetInstance.Register(ShreddCabbage, "ShreddCabbage");
  42. ActionManage.GetInstance.Register(FryPork, "FryPork");
  43. ActionManage.GetInstance.Register(XingBaoGu, "XingBaoGu");
  44. #region 配料控制
  45. ActionManage.GetInstance.Register(OutMaterials, "OutMaterials");
  46. #endregion
  47. #region 炒锅1
  48. ActionManage.GetInstance.Register<Action>(AddOil, "AddOil");
  49. ActionManage.GetInstance.Register(StartFire, "StartFire");
  50. ActionManage.GetInstance.Register(StopFire, "StopFire");
  51. ActionManage.GetInstance.Register(StartStir, "StartStir");
  52. ActionManage.GetInstance.Register(StopStir, "StopStir");
  53. ActionManage.GetInstance.Register(OutFood, "OutFood");
  54. ActionManage.GetInstance.Register(StirArmGoOrigin, "StirArmGoOrigin");
  55. ActionManage.GetInstance.Register(StirArmGoWork, "StirArmGoWork");
  56. ActionManage.GetInstance.Register(HBOTGoWork, "HBOTGoWork");
  57. ActionManage.GetInstance.Register(OutMeal, "OutMeal");
  58. ActionManage.GetInstance.Register(SetFire, "SetFire");
  59. ActionManage.GetInstance.Register(SetStir, "SetStir");
  60. #endregion
  61. }
  62. /// <summary>
  63. /// 手撕包菜流程
  64. /// </summary>
  65. public void ShreddCabbage()
  66. {
  67. if (stirFryBom.StirFryActions.Count > 0)
  68. {
  69. stirFryBom.StirFryActions.Clear();
  70. }
  71. //流程
  72. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.清洗槽取锅 } });
  73. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, PotActions = new List<StirFryPotAction>() { StirFryPotAction.大火持续 }, During = 5 });
  74. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.取A料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.加油, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 6 });
  75. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.停止火力, StirFryPotAction.搅拌臂上位 } });//加A料
  76. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.取B料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 6 });
  77. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加B料
  78. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.取C料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 9 });
  79. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T8, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加C料
  80. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 30 });
  81. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
  82. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.灶取锅 } });
  83. morkF.listStirBom.Add(stirFryBom);
  84. }
  85. /// <summary>
  86. /// 盐煎肉流程
  87. /// </summary>
  88. public void FryPork()
  89. {
  90. if (stirFryBom.StirFryActions.Count > 0)
  91. {
  92. stirFryBom.StirFryActions.Clear();
  93. }
  94. //流程
  95. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.清洗槽取锅 } });
  96. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 15 });
  97. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, PotActions = new List<StirFryPotAction>() { StirFryPotAction.加油, StirFryPotAction.停止火力 }, During = 19 });
  98. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
  99. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T5, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入A料 } });
  100. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 20 });
  101. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力 }, During = 35 });
  102. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T8, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位, } });
  103. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入B料 } });
  104. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 22 });
  105. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
  106. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T12, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入C料 } });
  107. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T13, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 70 });
  108. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T14, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });
  109. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T15, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.灶取锅 } });
  110. }
  111. /// <summary>
  112. /// 酱烧杏鲍菇流程
  113. /// </summary>
  114. public void XingBaoGu()
  115. {
  116. if (stirFryBom.StirFryActions.Count > 0)
  117. {
  118. stirFryBom.StirFryActions.Clear();
  119. }
  120. //流程
  121. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T1, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.清洗槽取锅 } });
  122. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T2, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入A料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.低速旋转 }, During = 5 });
  123. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T3, PotActions = new List<StirFryPotAction>() { StirFryPotAction.加油 }, During = 12 });
  124. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T4, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加A料
  125. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入B料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 25 });
  126. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T7, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加B料
  127. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.加入C料 }, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 30 });
  128. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List<StirFryPotAction>() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } });//加C料
  129. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 55 });
  130. stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.灶取锅 } });
  131. }
  132. //出配料
  133. public void OutMaterials(object o)
  134. {
  135. if (o == null) return;
  136. if (o is List<int> ints && ints.Count == 2)
  137. {
  138. WriteControl(morkF.PassWayValue[ints[0]], ints[1]);//写入通道值
  139. Thread.Sleep(500);
  140. WriteControl(morkF.StartPassWay[ints[0]], true);//开启通道
  141. }
  142. }
  143. #region 炒锅1
  144. //加热启动
  145. public void StartFire()
  146. {
  147. WriteControl("M0.1", true);
  148. }
  149. //加热停止
  150. public void StopFire()
  151. {
  152. WriteControl("M0.1", false);
  153. }
  154. //搅拌启动
  155. public void StartStir()
  156. {
  157. WriteControl("M0.2", true);
  158. }
  159. //搅拌启停止
  160. public void StopStir()
  161. {
  162. WriteControl("M0.2", false);
  163. }
  164. //倒菜
  165. public void OutFood()
  166. {
  167. WriteControl("M0.3", true);
  168. }
  169. //搅拌臂去原点位
  170. public void StirArmGoOrigin()
  171. {
  172. WriteControl("M0.5", true);
  173. }
  174. //搅拌臂去炒制位
  175. public void StirArmGoWork()
  176. {
  177. WriteControl("M0.6", true);
  178. }
  179. //HBOT放盒子到位
  180. public void HBOTGoWork()
  181. {
  182. WriteControl("M0.7", true);
  183. }
  184. //出餐启动
  185. public void OutMeal()
  186. {
  187. WriteControl("M0.4", true);
  188. }
  189. //加热挡位设定
  190. public void SetFire(object o)
  191. {
  192. if(o == null) return;
  193. if(o is List<int> ints&&ints.Count == 1)
  194. {
  195. WriteControl("VW228",ints[0]);
  196. }
  197. }
  198. //搅拌挡位设定
  199. public void SetStir(object o)
  200. {
  201. if (o == null) return;
  202. if (o is List<int> ints && ints.Count == 1)
  203. {
  204. WriteControl("VW230", ints[0]);
  205. }
  206. }
  207. #endregion
  208. /// <summary>
  209. /// 订单初始化
  210. /// </summary>
  211. private void InitialData()
  212. {
  213. string subId = Guid.NewGuid().ToString();
  214. //单个订单
  215. //string subId = Guid.NewGuid().ToString();
  216. //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 1 } });//A料
  217. //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 2 } });//B料
  218. //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 3 } });//C料
  219. //morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId });
  220. //resultorder.AddRange(new int[] { 1, 2, 3 });
  221. for (int i = 0; i < morkF.listStirBom.Count; i++)
  222. {
  223. morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i, MaterialLoc = new List<int>() { 1 } });//A料
  224. morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i, MaterialLoc = new List<int>() { 2 } });//B料
  225. morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i, MaterialLoc = new List<int>() { 3 } });//C料
  226. morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i });
  227. //resultorder.AddRange(new int[] { 1, 2, 3 });
  228. }
  229. //多个订单
  230. //string subId = Guid.NewGuid().ToString();
  231. //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 1 } });//A料
  232. //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 2 } });//B料
  233. //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List<int>() { 3 } });//C料
  234. //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+1, MaterialLoc = new List<int>() { 1 } });//A料
  235. //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+1, MaterialLoc = new List<int>() { 2 } });//B料
  236. //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+1, MaterialLoc = new List<int>() { 3 } });//C料
  237. //morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId });
  238. //morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+1 });
  239. //resultorder.AddRange(new int[] { 1, 2, 3 });
  240. //resultorder.AddRange(new int[] { 1, 2, 3 });
  241. }
  242. #endregion
  243. public override void ResetProgram()
  244. {
  245. morkF = null;
  246. morkF = new GVL_MorkF();
  247. }
  248. /// <summary>
  249. /// PLC数据读取
  250. /// </summary>
  251. public override void ReadData()
  252. {
  253. GetStatus("M0.1", new Action<bool[]>((bools) =>
  254. {
  255. Initing = bools[0];
  256. morkF.InitialComplete = Initing;
  257. }));
  258. GetStatus("M1.0", new Action<bool[]>((bools) =>
  259. {
  260. morkF.ProvidePlateModule = bools[0];
  261. morkF.ProvidePlateComplete = bools[2];
  262. morkF.CleanModule = bools[3];
  263. morkF.CleanComplete = bools[5];
  264. }));
  265. GetStatus("M2.0", new Action<bool[]>((bools) =>
  266. {
  267. morkF.KitchenOneStatus = bools[1];
  268. morkF.KitchenSecondStatus = bools[4];
  269. morkF.FallOilComplete = bools[8];
  270. }));
  271. GetStatus("M8.0", new Action<bool[]>((bools) =>
  272. {
  273. morkF.TurnMachineUpComplete = bools[1];
  274. morkF.TurnMachineDownComplete = bools[3];
  275. }));
  276. GetStatus("M13.5", new Action<bool[]>((bools) =>
  277. {
  278. morkF.MaterialArriveComplete = bools[0];
  279. }));
  280. GetStatus("M16.0", new Action<bool[]>((bools) =>
  281. {
  282. morkF.PutPotToKitchenComlete = bools[1];
  283. morkF.TakeMaterialComplete = bools[2];
  284. morkF.FallMaterialComplete = bools[3];
  285. morkF.PlaceRinseTableComplete = bools[5];
  286. morkF.RoobotIdle = bools[6];
  287. }));
  288. }
  289. private void ServerInit()
  290. {
  291. //物料信息
  292. EventBus.EventBus.GetInstance().Subscribe<MaterialDeliveryEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  293. {
  294. if (@event == null) return;
  295. if (@event is MaterialDeliveryEvent material)
  296. {
  297. orderMaterialDelivery = material.orderMaterialDelivery;
  298. }
  299. });
  300. //配方数据信息
  301. EventBus.EventBus.GetInstance().Subscribe<RecipeBomEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
  302. {
  303. if (@event == null) return;
  304. if (@event is RecipeBomEvent recipe)
  305. {
  306. recipeBoms = recipe.recipeBoms;
  307. WriteRecipeBoms();
  308. }
  309. });
  310. //小炒流程信息
  311. EventBus.EventBus.GetInstance().Subscribe<StirFryGoodsEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callback)
  312. {
  313. if (@event == null) return;
  314. if (@event is StirFryGoodsEvent stirFry)
  315. {
  316. stirFryGoods = stirFry.stirFrymessage.stirFryGoods;
  317. MessageLog.GetInstance.Show("接收到小炒流程信息");
  318. //流程解析
  319. foreach (var item in stirFryGoods)
  320. {
  321. MessageLog.GetInstance.ShowEx($"执行菜谱{item.GoodsKey}");
  322. // morkF.listStirBom.Add(item.StirFryBomInfo);//添加订单制作流程
  323. foreach (var items in item.StirFryBomInfo.StirFryActions)
  324. {
  325. MessageLog.GetInstance.Show($"执行流程{items.Time}");
  326. foreach (var pro in items.RobotActions)
  327. {
  328. switch (pro)
  329. {
  330. case StirFryRobotAction.等待:
  331. MessageLog.GetInstance.Show($"等待");
  332. break;
  333. case StirFryRobotAction.清洗槽取锅:
  334. MessageLog.GetInstance.Show($"清洗槽取锅");
  335. break;
  336. case StirFryRobotAction.灶放锅:
  337. MessageLog.GetInstance.Show($"灶放锅");
  338. break;
  339. case StirFryRobotAction.清洗槽放锅:
  340. MessageLog.GetInstance.Show($"清洗槽放锅");
  341. break;
  342. case StirFryRobotAction.取A料:
  343. MessageLog.GetInstance.Show($"取A料");
  344. break;
  345. case StirFryRobotAction.取B料:
  346. MessageLog.GetInstance.Show($"取B料");
  347. break;
  348. case StirFryRobotAction.取C料:
  349. MessageLog.GetInstance.Show($"取C料");
  350. break;
  351. case StirFryRobotAction.加入A料:
  352. MessageLog.GetInstance.Show($"加入A料");
  353. break;
  354. case StirFryRobotAction.加入B料:
  355. MessageLog.GetInstance.Show($"加入B料");
  356. break;
  357. case StirFryRobotAction.加入C料:
  358. MessageLog.GetInstance.Show($"加入C料");
  359. break;
  360. case StirFryRobotAction.切换快速:
  361. MessageLog.GetInstance.Show($"切换快速");
  362. break;
  363. case StirFryRobotAction.切换中速:
  364. MessageLog.GetInstance.Show($"切换中速");
  365. break;
  366. case StirFryRobotAction.丢料盒:
  367. MessageLog.GetInstance.Show($"丢料盒");
  368. break;
  369. case StirFryRobotAction.倒菜:
  370. MessageLog.GetInstance.Show($"倒菜");
  371. break;
  372. case StirFryRobotAction.灶取锅:
  373. MessageLog.GetInstance.Show($"灶取锅");
  374. break;
  375. }
  376. }
  377. foreach (var pro in items.PotActions)
  378. {
  379. switch (pro)
  380. {
  381. case StirFryPotAction.NONE:
  382. break;
  383. case StirFryPotAction.加热:
  384. MessageLog.GetInstance.Show($"加热");
  385. break;
  386. case StirFryPotAction.大火t1s:
  387. MessageLog.GetInstance.Show($"大火1s");
  388. break;
  389. case StirFryPotAction.加油:
  390. MessageLog.GetInstance.Show($"加油");
  391. break;
  392. case StirFryPotAction.中火t2s:
  393. MessageLog.GetInstance.Show($"中火2s");
  394. break;
  395. case StirFryPotAction.小火持续:
  396. MessageLog.GetInstance.Show($"小火持续");
  397. break;
  398. case StirFryPotAction.中火持续:
  399. MessageLog.GetInstance.Show($"中火持续");
  400. break;
  401. case StirFryPotAction.大火持续:
  402. MessageLog.GetInstance.Show($"大火持续");
  403. break;
  404. case StirFryPotAction.停止火力:
  405. MessageLog.GetInstance.Show($"停止火力");
  406. break;
  407. case StirFryPotAction.搅拌臂上位:
  408. MessageLog.GetInstance.Show($"搅拌臂上位");
  409. break;
  410. case StirFryPotAction.搅拌臂中位:
  411. MessageLog.GetInstance.Show($"搅拌臂中位");
  412. break;
  413. case StirFryPotAction.搅拌臂下位:
  414. MessageLog.GetInstance.Show($"搅拌臂下位");
  415. break;
  416. case StirFryPotAction.低速旋转:
  417. MessageLog.GetInstance.Show($"低速旋转");
  418. break;
  419. case StirFryPotAction.快速旋转:
  420. MessageLog.GetInstance.Show($"快速旋转");
  421. break;
  422. case StirFryPotAction.停止旋转:
  423. MessageLog.GetInstance.Show($"停止旋转");
  424. break;
  425. }
  426. }
  427. }
  428. }
  429. }
  430. });
  431. }
  432. /// <summary>
  433. /// 订单状态发布
  434. /// </summary>
  435. /// <param name="subid"></param>
  436. /// <param name="oRDER_STATUS"></param>
  437. private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
  438. {
  439. EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid });
  440. }
  441. /// <summary>
  442. /// 数据解析
  443. /// </summary>
  444. private void DataParse()
  445. {
  446. EventBus.EventBus.GetInstance().Subscribe<DoOrderEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle)
  447. {
  448. if (@event == null) return;
  449. if (@event is DoOrderEvent order)
  450. {
  451. if (order.MorkOrder.GoodBatchings == null) return;
  452. OrderCount++;
  453. DeviceProcessLogShow($"接收到{OrderCount}次订单");
  454. var res = stirFryGoods?.FirstOrDefault(p => p.GoodsKey == order.MorkOrder.RecipeId);//匹配订单对应制作流程
  455. if (res != null)
  456. {
  457. morkF.listStirBom.Add(res.StirFryBomInfo);//添加订单制作流程
  458. if (morkF.TakeMaterialQueue.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
  459. {
  460. morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = order.MorkOrder.SuborderId, MaterialLoc = res.StirFryBomInfo.ALoc });
  461. morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = order.MorkOrder.SuborderId, MaterialLoc = res.StirFryBomInfo.BLoc });
  462. morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = order.MorkOrder.SuborderId, MaterialLoc = res.StirFryBomInfo.CLoc });
  463. }
  464. //foreach (var item in order.MorkOrder.GoodBatchings)
  465. //{
  466. if (morkF.TakePlateQueue.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null)
  467. {
  468. morkF.TakePlateQueue.Enqueue(new OrderLocInfo()
  469. {
  470. SuborderId = order.MorkOrder.SuborderId,
  471. });
  472. }
  473. //}
  474. }
  475. }
  476. });
  477. }
  478. //}
  479. /// <summary>
  480. /// 主任务
  481. /// </summary>
  482. public override void MainTask()
  483. {
  484. TakePlatelTask();
  485. TurntableControl();
  486. MainProcessExecute();
  487. MinorProcessExcute();
  488. SingleProcess();
  489. }
  490. //辅流程执行
  491. private void MinorProcessExcute()
  492. {
  493. if (!morkF.MinorProcessExcuteLock)
  494. {
  495. morkF.MinorProcessExcuteLock = true;
  496. Task.Run(() =>
  497. {
  498. if (morkF.MinorProcessFlag && !morkF.RoobotIdle && morkF.TakeMaterialQueue.Count > 0 && morkF.listStirBom.Count > 0 )
  499. {
  500. morkF.MinorProessStatus = true;
  501. morkF.MainProcessStatus = false;
  502. StirFryBom bom = morkF.listStirBom.ElementAt(0);
  503. morkF.listStirBom.RemoveAt(0);
  504. foreach (var res in bom.StirFryActions)
  505. {
  506. DeviceProcessLogShow($"执行流程{res.Time}");
  507. //机器人线程
  508. Task taskRobot = Task.Run(new Action(() =>
  509. {
  510. foreach (var temp in res.RobotActions)
  511. {
  512. switch (temp)
  513. {
  514. case StirFryRobotAction.清洗槽取锅:
  515. TakePotTask();//执行取锅操作
  516. break;
  517. case StirFryRobotAction.取A料:
  518. TakeBurdenATask();//执行取A料操作
  519. break;
  520. case StirFryRobotAction.取B料:
  521. TakeBurdenATask();//执行取B料操作
  522. break;
  523. case StirFryRobotAction.取C料:
  524. TakeBurdenCTask();//执行取C料操作
  525. break;
  526. case StirFryRobotAction.灶取锅:
  527. MinorProcessOutDishTask();//执行出餐操作
  528. MinorProcessCleanPotTask();//洗锅操作
  529. break;
  530. }
  531. }
  532. }));
  533. //炒锅线程操作
  534. Task taskPot = Task.Run(new Action(() =>
  535. {
  536. foreach (var temp in res.PotActions)
  537. {
  538. switch (temp)
  539. {
  540. case StirFryPotAction.NONE:
  541. break;
  542. case StirFryPotAction.大火t1s:
  543. MinorProcessKitchenAdjustGears(3);
  544. // Task.Delay(1000).Wait(); //大火加热1s//执行大火锅干操作
  545. break;
  546. case StirFryPotAction.加油:
  547. AddOil();//注油//执行加油操作
  548. break;
  549. case StirFryPotAction.中火t2s:
  550. MinorProcessKitchenAdjustGears(2);
  551. Task.Delay(2000).Wait();//执行操作
  552. break;
  553. case StirFryPotAction.小火持续:
  554. MinorProcessKitchenAdjustGears(1);
  555. break;
  556. case StirFryPotAction.中火持续:
  557. MinorProcessKitchenAdjustGears(5);
  558. break;
  559. case StirFryPotAction.大火持续:
  560. MinorProcessKitchenAdjustGears(7);
  561. break;
  562. case StirFryPotAction.停止火力:
  563. MinorProcessKitchenAdjustGears(0);//关闭灶加热
  564. break;
  565. case StirFryPotAction.搅拌臂上位:
  566. MinorProcessTurnUpStatusDetect();//执行搅拌臂上位操作
  567. break;
  568. case StirFryPotAction.搅拌臂下位:
  569. MinorProcessTurnDownStatusDetect();//执行搅拌臂下位操作
  570. break;
  571. case StirFryPotAction.低速旋转:
  572. MinorProcessTurnMachineGearsControl(1);//执行搅拌臂速度1挡操作
  573. break;
  574. case StirFryPotAction.快速旋转:
  575. MinorProcessTurnMachineGearsControl(2);//执行搅拌臂速度3挡操作
  576. break;
  577. case StirFryPotAction.停止旋转:
  578. MinorProcessTurnMachineGearsControl(0);//执行搅拌臂速度0挡操作
  579. break;
  580. }
  581. }
  582. }));
  583. Task.WhenAll(taskRobot, taskPot).Wait();//等待所有线程结束
  584. Task.Delay(res.During * 1000).Wait();//当前流程延迟
  585. if (morkF.MainProcessWait)
  586. {
  587. if (morkF.MainHasTakeMaterial)
  588. {
  589. }
  590. else
  591. {
  592. MinorProcessKitchenAdjustGears(0);//关闭灶加热
  593. //阻塞辅流程
  594. minorReset.WaitOne();
  595. //morkF.MinorProessStatus = true;
  596. //morkF.MainProcessStatus = false;
  597. }
  598. }
  599. }
  600. morkF.MinorOutMealComplete = true;
  601. }
  602. else
  603. {
  604. morkF.MinorProcessExcuteLock = false;//解除辅流程自锁
  605. }
  606. });
  607. }
  608. }
  609. //机器人,锅灶主流程执行
  610. public void MainProcessExecute()
  611. {
  612. if (!morkF.MainProcessExcuteLock)
  613. {
  614. morkF.MainProcessExcuteLock = true;
  615. Task.Run(new Action(() =>
  616. {
  617. if (!morkF.RoobotIdle && morkF.InitialComplete && morkF.TakeMaterialQueue.Count > 0 && morkF.MainProcessFlag&& morkF.listStirBom.Count > 0)
  618. {
  619. morkF.MainProcessStatus = true;
  620. morkF.MinorProessStatus = false;
  621. StirFryBom bom = morkF.listStirBom.ElementAt(0);
  622. morkF.listStirBom.RemoveAt(0);
  623. foreach (var res in bom.StirFryActions)//遍历所有流程
  624. {
  625. DeviceProcessLogShow($"执行流程{res.Time}");
  626. //机器人线程
  627. Task taskRobot = Task.Run(new Action(() =>
  628. {
  629. foreach (var temp in res.RobotActions)
  630. {
  631. switch (temp)
  632. {
  633. case StirFryRobotAction.清洗槽取锅:
  634. TakePotTask();//执行取锅操作
  635. break;
  636. case StirFryRobotAction.取A料:
  637. TakeBurdenATask();//执行取A料操作
  638. break;
  639. case StirFryRobotAction.取B料:
  640. TakeBurdenATask();//执行取B料操作
  641. break;
  642. case StirFryRobotAction.取C料:
  643. TakeBurdenCTask();//执行取C料操作
  644. break;
  645. case StirFryRobotAction.灶取锅:
  646. MainProcessOutDishTask();//执行出餐操作
  647. MainProcessCleanPotTask();//洗锅操作
  648. break;
  649. }
  650. }
  651. }));
  652. //炒锅线程操作
  653. Task taskPot = Task.Run(new Action(() =>
  654. {
  655. foreach (var temp in res.PotActions)
  656. {
  657. switch (temp)
  658. {
  659. case StirFryPotAction.NONE:
  660. break;
  661. case StirFryPotAction.大火t1s:
  662. MainProcessKitchenAdjustGears(3);
  663. // Task.Delay(1000).Wait(); //大火加热1s//执行大火锅干操作
  664. break;
  665. case StirFryPotAction.加油:
  666. AddOil();//注油//执行加油操作
  667. break;
  668. case StirFryPotAction.中火t2s:
  669. MainProcessKitchenAdjustGears(2);
  670. Task.Delay(2000).Wait();//执行操作
  671. break;
  672. case StirFryPotAction.小火持续:
  673. MainProcessKitchenAdjustGears(1);
  674. break;
  675. case StirFryPotAction.中火持续:
  676. MainProcessKitchenAdjustGears(5);
  677. break;
  678. case StirFryPotAction.大火持续:
  679. MainProcessKitchenAdjustGears(7);
  680. break;
  681. case StirFryPotAction.停止火力:
  682. MainProcessKitchenAdjustGears(0);//关闭灶加热
  683. break;
  684. case StirFryPotAction.搅拌臂上位:
  685. MainProcessTurnUpStatusDetect();//执行搅拌臂上位操作
  686. break;
  687. case StirFryPotAction.搅拌臂下位:
  688. MainProcessTurnDownStatusDetect();//执行搅拌臂下位操作
  689. break;
  690. case StirFryPotAction.低速旋转:
  691. MainProcessTurnMachineGearsControl(1);//执行搅拌臂速度1挡操作
  692. break;
  693. case StirFryPotAction.快速旋转:
  694. MainProcessTurnMachineGearsControl(2);//执行搅拌臂速度3挡操作
  695. break;
  696. case StirFryPotAction.停止旋转:
  697. MainProcessTurnMachineGearsControl(0);//执行搅拌臂速度0挡操作
  698. break;
  699. }
  700. }
  701. }));
  702. Task.WhenAll(taskRobot, taskPot).Wait();//等待所有线程结束
  703. Task.Delay(res.During * 1000).Wait();//当前流程延迟
  704. #region 两口锅逻辑
  705. //if (morkF.MinorProcessWait)
  706. //{
  707. // if (morkF.MinorHasTakeMaterial)//针对主流程准备出餐但辅流程机器人忙碌情况下,辅流程不阻塞
  708. // {
  709. // }
  710. // else
  711. // {
  712. // MainProcessKitchenAdjustGears(0);//关闭灶加热
  713. // //阻塞主流程
  714. // mainReset.WaitOne();
  715. // //morkF.MinorProessStatus = false;
  716. // //morkF.MainProcessStatus = true;
  717. // }
  718. //}
  719. #endregion
  720. }
  721. morkF.MainOutMealComplete = true;
  722. }
  723. else
  724. {
  725. morkF.MainProcessExcuteLock = false;//解除流程自锁
  726. }
  727. }));
  728. }
  729. }
  730. /// <summary>
  731. /// 信号处理
  732. /// </summary>
  733. private void SingleProcess()
  734. {
  735. //主流程出餐完成,相应变量复位
  736. if (morkF.MainOutMealComplete)
  737. {
  738. morkF.MainOutMealComplete = false;
  739. morkF.TakePlateLock = false;
  740. morkF.MainProcessExcuteLock = false;
  741. morkF.MainOrderMaterialCom = false;
  742. morkF.MainProcessWait = false;//主流程出餐完成取消辅流程线程阻塞
  743. #region 单口锅逻辑
  744. morkF.PotInPlace = false;
  745. #endregion
  746. #region 两口锅逻辑
  747. //if (morkF.MainProcessPotLoc == 1)
  748. //{
  749. // morkF.PotInPlace = false;
  750. //}
  751. //else if (morkF.MainProcessPotLoc == 2)
  752. //{
  753. // morkF.SecondPotInPlace = false;
  754. //}
  755. #endregion
  756. }
  757. //辅流程出餐完成,相应变量复位
  758. if (morkF.MinorOutMealComplete)
  759. {
  760. morkF.MinorOutMealComplete = false;
  761. morkF.TakePlateLock = false;
  762. morkF.MinorProcessExcuteLock = false;
  763. morkF.MinorOrderMaterialCom = false;
  764. morkF.MinorProcessWait = false;//辅流程出餐完成取消主流程线程阻塞
  765. if (morkF.MinorProcessPotLoc == 1)
  766. {
  767. morkF.PotInPlace = false;
  768. }
  769. else if (morkF.MinorProcessPotLoc == 2)
  770. {
  771. morkF.SecondPotInPlace = false;
  772. }
  773. }
  774. }
  775. /// <summary>
  776. /// 转台控制
  777. /// </summary>
  778. private void TurntableControl()
  779. {
  780. //模拟订单
  781. if (morkF.TakeMaterialQueue.Count > 0 && !morkF.TurnTableLock && General_Config.SimOrderAllow)
  782. {
  783. if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo info))
  784. {
  785. TurnMaterialStore(info.MaterialLoc[0]);
  786. DeviceProcessLogShow($"转台转到【{info.MaterialLoc[0]}】位置");
  787. morkF.TurnTableLock = true;
  788. }
  789. else
  790. {
  791. DeviceProcessLogShow("当前订单未找到可用的物料信息");
  792. }
  793. }
  794. //正式订单
  795. if (morkF.TakeMaterialQueue.Count > 0 && !morkF.TurnTableLock)
  796. {
  797. //var result = orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == morkF.TakeMaterialQueue.ElementAt(0).BatchingId).ToList();
  798. var materialLoc = morkF.TakeMaterialQueue.ElementAt(0).MaterialLoc;
  799. if (materialLoc.Count != 0)
  800. {
  801. TurnMaterialStore(materialLoc[0]);
  802. DeviceProcessLogShow($"转台转到【{materialLoc[0]}】位置");
  803. morkF.TurnTableLock = true; //取料完成后置false
  804. }
  805. else
  806. {
  807. DeviceProcessLogShow("当前订单未找到可用的物料信息");
  808. }
  809. }
  810. }
  811. /// <summary>
  812. /// 供盘
  813. /// </summary>
  814. /// <exception cref="NotImplementedException"></exception>
  815. private void TakePlatelTask()
  816. {
  817. if (!morkF.RoobotIdle && morkF.InitialComplete && morkF.TakePlateQueue.Count > 0 && !morkF.ProvidePlateModule && !morkF.TakePlateLock)
  818. {
  819. if (morkF.TakePlateQueue.TryDequeue(out OrderLocInfo order))
  820. {
  821. StartTakePlate();
  822. #region 两口锅逻辑
  823. //if (morkF.MainProcessStatus)
  824. // morkF.MainCurrentOrderId = order.SuborderId;
  825. //if (morkF.MinorProessStatus)
  826. // morkF.MinorCurrentOrderId = order.SuborderId;
  827. #endregion
  828. #region 单口锅逻辑
  829. morkF.CurrentOrderId = order.SuborderId;
  830. #endregion
  831. morkF.TakePlateLock = true; //订单完成后置false
  832. DeviceProcessLogShow($"订单【{order.SuborderId}】执行取碗控制");
  833. }
  834. }
  835. }
  836. /// <summary>
  837. /// 取锅到灶台
  838. /// </summary>
  839. /// <exception cref="NotImplementedException"></exception>
  840. private void TakePotTask()
  841. {
  842. while (morkF.CleanModule || morkF.KitchenOneStatus || !morkF.CleanComplete || morkF.RoobotIdle)//等待取锅条件满足
  843. {
  844. Task.Delay(5).Wait();
  845. }
  846. #region 单口锅逻辑
  847. //if (!morkF.CleanModule && !morkF.KitchenOneStatus && morkF.CleanComplete)
  848. //{
  849. //取1号锅到1号灶台
  850. TakePotToKitchen(1);
  851. WriteData("M1.5", false);//清洗模组1完成复位
  852. DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】执行取锅到灶台控制");
  853. while (!morkF.PutPotToKitchenComlete)
  854. {
  855. Task.Delay(5).Wait();
  856. }
  857. morkF.PotInPlace = true;//锅到位
  858. WriteData("M14.0", false);//机器人取锅完成复位
  859. //}
  860. #endregion
  861. #region 两口锅逻辑
  862. //while (!((!morkF.CleanModule || !morkF.SecondCleanModule) && (!morkF.KitchenOneStatus || !morkF.KitchenSecondStatus) && (morkF.CleanComplete || morkF.SecondCleanComplete)))//等待取锅条件满足
  863. //{
  864. // Task.Delay(5).Wait();
  865. //}
  866. //while (morkF.RoobotIdle)//等待机器人空闲
  867. //{
  868. // Task.Delay(5).Wait();
  869. //}
  870. //if (!morkF.CleanModule && !morkF.KitchenOneStatus && morkF.CleanComplete)
  871. //{
  872. // //取1号锅到1号灶台
  873. // TakePotToKitchen(1);
  874. // morkF.CurrentPutPotLoc = 1;
  875. // WriteData("M1.5", false);//清洗模组1完成复位
  876. // DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】执行取锅到灶台控制");
  877. //}
  878. //else if (!morkF.SecondCleanModule && !morkF.KitchenOneStatus && morkF.SecondCleanComplete)
  879. //{
  880. // //取2号锅到1号灶台
  881. // TakePotToKitchen(1);
  882. // morkF.CurrentPutPotLoc = 1;
  883. // WriteData("M2.0", false);//清洗模组2完成复位
  884. //}
  885. //if (!morkF.SecondCleanModule && !morkF.KitchenSecondStatus && morkF.SecondCleanComplete)
  886. //{
  887. // //取2号锅到2号灶台
  888. // TakePotToKitchen(2);
  889. // morkF.CurrentPutPotLoc = 2;
  890. // WriteData("M2.0", false);//清洗模组2完成复位
  891. //}
  892. //else if (!morkF.CleanModule && !morkF.KitchenSecondStatus && morkF.CleanComplete)
  893. //{
  894. // //取1号锅到2号灶台
  895. // TakePotToKitchen(2);
  896. // morkF.CurrentPutPotLoc = 2;
  897. // WriteData("M2.0", false);//清洗模组1完成复位
  898. //}
  899. //if (morkF.MainProcessStatus)
  900. //{
  901. // morkF.MainProcessPotLoc = morkF.CurrentPutPotLoc;
  902. // DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】执行取锅到灶台控制");
  903. //}
  904. //if (morkF.MinorProessStatus)
  905. //{
  906. // morkF.MinorProcessPotLoc = morkF.CurrentPutPotLoc;
  907. // DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】执行取锅到灶台控制");
  908. //}
  909. //if (morkF.CurrentPutPotLoc == 1)
  910. //{
  911. // while (!morkF.PutPotToKitchenComlete)
  912. // {
  913. // Task.Delay(5).Wait();
  914. // }
  915. // morkF.PotInPlace = true;//锅到位
  916. // WriteData("M14.0", false);//机器人取锅完成复位
  917. //}
  918. //if (morkF.CurrentPutPotLoc == 2)
  919. //{
  920. // while (!morkF.PutPotToSecondKitchenComlete)
  921. // {
  922. // Task.Delay(5).Wait();
  923. // }
  924. // morkF.SecondPotInPlace = true;
  925. // WriteData("M14.4", false);//机器人取锅完成复位
  926. //}
  927. #endregion
  928. Thread.Sleep(2000);
  929. }
  930. /// <summary>
  931. /// 写入配方数据到 PLC
  932. /// </summary>
  933. private void WriteRecipeBoms()
  934. {
  935. //List<ushort> recipeBoms = new List<ushort>();
  936. //if (this.recipeBoms == null) return;
  937. //foreach (var item in this.recipeBoms.RecipeIds)
  938. //{
  939. // foreach (var rec in item.Recipes)
  940. // {
  941. // recipeBoms.Add((ushort)rec);
  942. // }
  943. //}
  944. //if (recipeBoms.Count > 0)
  945. //{
  946. // //配方数据地址范围:VW2000 - VW2278
  947. // WriteData("VW2000", recipeBoms.ToArray());
  948. //}
  949. //else {DeviceProcessLogShow("配方数据为空"); }
  950. }
  951. /// <summary>
  952. /// 转台复位
  953. /// </summary>
  954. /// <param name="loc"></param>
  955. public void TurnReset(int loc)
  956. {
  957. switch (loc)
  958. {
  959. case 1: WriteData("M13.0", false); break;
  960. case 2: WriteData("M13.1", false); break;
  961. case 3: WriteData("M13.2", false); break;
  962. case 4: WriteData("M13.3", false); break;
  963. case 5: WriteData("M13.4", false); break;
  964. }
  965. }
  966. /// <summary>
  967. /// 取素菜A料
  968. /// </summary>
  969. private void TakeBurdenATask()
  970. {
  971. int loc = 0;
  972. #region 单口锅逻辑
  973. while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
  974. {
  975. Task.Delay(5).Wait();
  976. }
  977. if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
  978. {
  979. loc = order.MaterialLoc[0];
  980. TakeBurden();
  981. TurnReset(loc);//转台复位
  982. DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
  983. }
  984. //等待取料完成
  985. while (!morkF.TakeMaterialComplete)
  986. {
  987. Task.Delay(5).Wait();
  988. }
  989. WriteData("M14.1", false);//机器人取料完成复位
  990. #endregion
  991. #region 两口锅逻辑
  992. //if (morkF.MainProcessStatus)
  993. //{
  994. // if (morkF.MainProcessPotLoc == 1)
  995. // {
  996. // while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
  997. // {
  998. // Task.Delay(5).Wait();
  999. // }
  1000. // }
  1001. // else
  1002. // {
  1003. // while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
  1004. // {
  1005. // Task.Delay(5).Wait();
  1006. // }
  1007. // }
  1008. // if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
  1009. // {
  1010. // loc = order.MaterialLoc[0];
  1011. // TakeBurden();
  1012. // TurnReset(loc);//转台复位
  1013. // DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
  1014. // }
  1015. // //等待取料完成
  1016. // while (!morkF.TakeMaterialComplete)
  1017. // {
  1018. // Task.Delay(5).Wait();
  1019. // }
  1020. // morkF.MainOrderMaterialCom = false;
  1021. // morkF.MainHasTakeMaterial = true;
  1022. // WriteData("M14.1", false);//机器人取料完成复位
  1023. //}
  1024. //if (morkF.MinorProessStatus)
  1025. //{
  1026. // if (morkF.MinorProcessPotLoc == 1)
  1027. // {
  1028. // while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
  1029. // {
  1030. // Task.Delay(5).Wait();
  1031. // }
  1032. // }
  1033. // else
  1034. // {
  1035. // while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
  1036. // {
  1037. // Task.Delay(5).Wait();
  1038. // }
  1039. // }
  1040. // if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
  1041. // {
  1042. // loc = order.MaterialLoc[0];
  1043. // TakeBurden();
  1044. // TurnReset(loc);//转台复位
  1045. // DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
  1046. // }
  1047. // //等待取料完成
  1048. // while (!morkF.TakeMaterialComplete)
  1049. // {
  1050. // Task.Delay(5).Wait();
  1051. // }
  1052. // morkF.MinorOrderMaterialCom = false;
  1053. // morkF.MinorHasTakeMaterial = true;
  1054. // WriteData("M14.5", false);//机器人取料完成复位
  1055. //}
  1056. #endregion
  1057. morkF.TurnTableLock = false;//转台互锁解除
  1058. }
  1059. /// <summary>
  1060. /// 取素菜B料
  1061. /// </summary>
  1062. private void TakeBurdenBTask()
  1063. {
  1064. int loc = 0;
  1065. //while (morkF.RoobotIdle || (!morkF.PotInPlace && !morkF.SecondPotInPlace) || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅到位
  1066. //{
  1067. // Task.Delay(5).Wait();
  1068. //}
  1069. if (morkF.MainProcessStatus)
  1070. {
  1071. if (morkF.MainProcessPotLoc == 1)
  1072. {
  1073. while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
  1074. {
  1075. Task.Delay(5).Wait();
  1076. }
  1077. }
  1078. else
  1079. {
  1080. while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
  1081. {
  1082. Task.Delay(5).Wait();
  1083. }
  1084. }
  1085. if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
  1086. {
  1087. loc = order.MaterialLoc[0];
  1088. TakeBurden();
  1089. TurnReset(loc);//转台复位
  1090. DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
  1091. }
  1092. //等待取料完成
  1093. while (!morkF.TakeMaterialComplete)
  1094. {
  1095. Task.Delay(5).Wait();
  1096. }
  1097. morkF.MainOrderMaterialCom = false;
  1098. morkF.MainHasTakeMaterial = true;
  1099. WriteData("M14.1", false);//机器人取料完成复位
  1100. }
  1101. if (morkF.MinorProessStatus)
  1102. {
  1103. if (morkF.MinorProcessPotLoc == 1)
  1104. {
  1105. while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
  1106. {
  1107. Task.Delay(5).Wait();
  1108. }
  1109. }
  1110. else
  1111. {
  1112. while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
  1113. {
  1114. Task.Delay(5).Wait();
  1115. }
  1116. }
  1117. if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
  1118. {
  1119. loc = order.MaterialLoc[0];
  1120. TakeBurden();
  1121. TurnReset(loc);//转台复位
  1122. DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
  1123. }
  1124. //等待取料完成
  1125. while (!morkF.TakeMaterialComplete)
  1126. {
  1127. Task.Delay(5).Wait();
  1128. }
  1129. morkF.MinorOrderMaterialCom = false;
  1130. morkF.MinorHasTakeMaterial = true;
  1131. WriteData("M14.5", false);//机器人取料完成复位
  1132. }
  1133. morkF.TurnTableLock = false;//转台互锁解除
  1134. }
  1135. /// <summary>
  1136. /// 取调味品C料
  1137. /// </summary>
  1138. /// <exception cref="NotImplementedException"></exception>
  1139. private void TakeBurdenCTask()
  1140. {
  1141. #region 单口锅逻辑
  1142. int loc = 0;
  1143. while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
  1144. {
  1145. Task.Delay(5).Wait();
  1146. }
  1147. if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
  1148. {
  1149. loc = order.MaterialLoc[0];
  1150. TakeBurden();
  1151. TurnReset(loc);//转台复位
  1152. DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
  1153. }
  1154. //等待取料完成
  1155. while (!morkF.TakeMaterialComplete)
  1156. {
  1157. Task.Delay(5).Wait();
  1158. }
  1159. WriteData("M14.1", false);//机器人取料完成复位
  1160. morkF.TurnTableLock = false;//转台互锁解除
  1161. #endregion
  1162. #region 两口锅逻辑
  1163. //int loc = 0;
  1164. //if (morkF.MainProcessStatus)
  1165. //{
  1166. // if (morkF.MainProcessPotLoc == 1)
  1167. // {
  1168. // while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
  1169. // {
  1170. // Task.Delay(5).Wait();
  1171. // }
  1172. // }
  1173. // else
  1174. // {
  1175. // while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
  1176. // {
  1177. // Task.Delay(5).Wait();
  1178. // }
  1179. // }
  1180. // if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
  1181. // {
  1182. // loc = order.MaterialLoc[0];
  1183. // TakeBurden();
  1184. // TurnReset(loc);//转台复位
  1185. // DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
  1186. // }
  1187. // //等待取料完成
  1188. // while (!morkF.TakeMaterialComplete)
  1189. // {
  1190. // Task.Delay(5).Wait();
  1191. // }
  1192. // morkF.MainOrderMaterialCom = false;
  1193. // morkF.MainHasTakeMaterial = true;
  1194. // WriteData("M14.1", false);//机器人取料完成复位
  1195. //}
  1196. //if (morkF.MinorProessStatus)
  1197. //{
  1198. // if (morkF.MinorProcessPotLoc == 1)
  1199. // {
  1200. // while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅1到位
  1201. // {
  1202. // Task.Delay(5).Wait();
  1203. // }
  1204. // }
  1205. // else
  1206. // {
  1207. // while (morkF.RoobotIdle || !morkF.SecondPotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅2到位
  1208. // {
  1209. // Task.Delay(5).Wait();
  1210. // }
  1211. // }
  1212. // if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo order))
  1213. // {
  1214. // loc = order.MaterialLoc[0];
  1215. // TakeBurden();
  1216. // TurnReset(loc);//转台复位
  1217. // DeviceProcessLogShow($"订单【{order.SuborderId}】,执行到转台{loc}位置取料");
  1218. // }
  1219. // //等待取料完成
  1220. // while (!morkF.TakeMaterialComplete)
  1221. // {
  1222. // Task.Delay(5).Wait();
  1223. // }
  1224. // morkF.MinorOrderMaterialCom = false;
  1225. // morkF.MinorHasTakeMaterial = true;
  1226. // WriteData("M14.5", false);//机器人取料完成复位
  1227. //}
  1228. //morkF.TurnTableLock = false;//转台互锁解除
  1229. #endregion
  1230. }
  1231. /// <summary>
  1232. /// 主流程出餐
  1233. /// </summary>
  1234. private void MainProcessOutDishTask()
  1235. {
  1236. //while (morkF.RoobotIdle || morkF.CleanModule || !morkF.ProvidePlateComplete)//等待条件满足
  1237. //{
  1238. // Task.Delay(5).Wait();
  1239. //}
  1240. #region 单口锅逻辑
  1241. while (morkF.RoobotIdle || morkF.CleanModule || !morkF.ProvidePlateComplete)//等待条件满足
  1242. {
  1243. Task.Delay(5).Wait();
  1244. }
  1245. if (morkF.TakePlateQueue.Count == 0)
  1246. {
  1247. WriteData("M0.7", false);//无订单关闭抽风机
  1248. }
  1249. MainProcessRobotOutMeal();
  1250. WriteData("M1.2", false);//供盘复位
  1251. DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】执行取锅到清洗台控制");
  1252. #endregion
  1253. #region 两口锅逻辑
  1254. //while (morkF.RoobotIdle || (morkF.CleanModule && morkF.SecondCleanModule) || !morkF.ProvidePlateComplete)//等待条件满足
  1255. //{
  1256. // Task.Delay(5).Wait();
  1257. //}
  1258. //if (morkF.TakePlateQueue.Count == 0)
  1259. //{
  1260. // WriteData("M0.7", false);//无订单关闭抽风机
  1261. //}
  1262. //MainProcessRobotOutMeal();
  1263. //WriteData("M1.2", false);//供盘复位
  1264. //DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】执行取锅到清洗台控制");
  1265. #endregion
  1266. }
  1267. /// <summary>
  1268. /// 复流程流程出餐
  1269. /// </summary>
  1270. private void MinorProcessOutDishTask()
  1271. {
  1272. //while (morkF.RoobotIdle || morkF.CleanModule || !morkF.ProvidePlateComplete)//等待条件满足
  1273. //{
  1274. // Task.Delay(5).Wait();
  1275. //}
  1276. while (morkF.RoobotIdle || (morkF.CleanModule && morkF.SecondCleanModule) || !morkF.ProvidePlateComplete)//等待条件满足
  1277. {
  1278. Task.Delay(5).Wait();
  1279. }
  1280. if (morkF.TakePlateQueue.Count == 0)
  1281. {
  1282. WriteData("M0.7", false);//无订单关闭抽风机
  1283. }
  1284. MinorProcessRobotOutMeal();
  1285. WriteData("M1.2", false);//供盘复位
  1286. DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】执行取锅到清洗台控制");
  1287. }
  1288. /// <summary>
  1289. /// 主流程洗锅放锅
  1290. /// </summary>
  1291. private void MainProcessCleanPotTask()
  1292. {
  1293. #region 单口锅逻辑
  1294. while (!morkF.PlaceRinseTableComplete || morkF.CleanModule)
  1295. {
  1296. Task.Delay(5).Wait();
  1297. }
  1298. WriteData("M14.2", false);//机器人出餐完成复位
  1299. CleanModuleControl("Start", 1);
  1300. DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】执行清洗操作");
  1301. #endregion
  1302. #region 两口锅逻辑
  1303. //while ((!morkF.PlaceRinseTableComplete || morkF.CleanModule) && (!morkF.PlaceRinseSecondTableComplete || morkF.SecondCleanModule))
  1304. //{
  1305. // Task.Delay(5).Wait();
  1306. //}
  1307. //WriteData("M14.2", false);//机器人出餐完成复位
  1308. //if (morkF.PlaceRinseTableComplete && !morkF.CleanModule)
  1309. //{
  1310. // CleanModuleControl("Start", 1);
  1311. //}
  1312. //if (morkF.PlaceRinseSecondTableComplete && !morkF.SecondCleanModule)
  1313. //{
  1314. // CleanModuleControl("Start", 2);
  1315. //}
  1316. //DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】执行清洗操作");
  1317. //morkF.MainProcessFlag = false;
  1318. //minorReset.Set();
  1319. #endregion
  1320. //OrderChange(morkF.CurrentOrderId, ORDER_STATUS.COMPLETED_COOK);
  1321. }
  1322. /// <summary>
  1323. /// 辅流程洗锅放锅
  1324. /// </summary>
  1325. private void MinorProcessCleanPotTask()
  1326. {
  1327. while ((!morkF.PlaceRinseTableComplete || morkF.CleanModule) && (!morkF.PlaceRinseSecondTableComplete || morkF.SecondCleanModule))
  1328. {
  1329. Task.Delay(5).Wait();
  1330. }
  1331. WriteData("M14.6", false);//机器人出餐完成复位
  1332. if (morkF.PlaceRinseTableComplete && !morkF.CleanModule)
  1333. {
  1334. CleanModuleControl("Start", 1);
  1335. }
  1336. if (morkF.PlaceRinseSecondTableComplete && !morkF.SecondCleanModule)
  1337. {
  1338. CleanModuleControl("Start", 2);
  1339. }
  1340. DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】执行清洗操作");
  1341. morkF.MinorProcessFlag = false;
  1342. mainReset.Set();
  1343. //OrderChange(morkF.CurrentOrderId, ORDER_STATUS.COMPLETED_COOK);
  1344. }
  1345. /// <summary>
  1346. /// 任务复位重启
  1347. /// </summary>
  1348. //private void ResetProgram()
  1349. //{
  1350. // ThreadManage.GetInstance().StartLong(new Action(() =>
  1351. // {
  1352. // if (RTrig.GetInstance("ResetProgram").Start(morkF.DevicDataInite))
  1353. // {
  1354. // ThreadManage.GetInstance().StopTask("MainTask", new Action(() =>
  1355. // {
  1356. // ThreadManage.GetInstance().StopTask("ReadPLCData", new Action(() =>
  1357. // {
  1358. // morkF = null;
  1359. // morkF = new GVL_MorkF();
  1360. // ActionManage.GetInstance.Send("ResetProgram");
  1361. // ActionManage.GetInstance.Send("ClearOrders");
  1362. // ReadData();
  1363. // Main();
  1364. // }));
  1365. // }));
  1366. // }
  1367. // Thread.Sleep(10);
  1368. // }), "ResetProgram");
  1369. //}
  1370. /// <summary>
  1371. /// 主流程翻转机下降及状态检测
  1372. /// </summary>
  1373. public void MainProcessTurnDownStatusDetect()
  1374. {
  1375. int potLoc = MainProcessTurnMachineOrientControl("Down");
  1376. if (potLoc == 1)
  1377. {
  1378. while (!morkF.TurnMachineDownComplete)//等待翻转机下降完成
  1379. {
  1380. Task.Delay(5).Wait();
  1381. }
  1382. WriteData("M8.3", false);//下降完成复位
  1383. }
  1384. if (potLoc == 2)
  1385. {
  1386. while (!morkF.SecondTurnMachineDownComplete)//等待翻转机下降完成
  1387. {
  1388. Task.Delay(5).Wait();
  1389. }
  1390. WriteData("M8.7", false);//下降完成复位
  1391. }
  1392. DeviceProcessLogShow($"翻转机下降完成");
  1393. }
  1394. /// <summary>
  1395. /// 辅流程翻转机下降及状态检测
  1396. /// </summary>
  1397. public void MinorProcessTurnDownStatusDetect()
  1398. {
  1399. int potLoc = MinorProcessTurnMachineOrientControl("Down");
  1400. if (potLoc == 1)
  1401. {
  1402. while (!morkF.TurnMachineDownComplete)//等待翻转机下降完成
  1403. {
  1404. Task.Delay(5).Wait();
  1405. }
  1406. WriteData("M8.3", false);//下降完成复位
  1407. }
  1408. if (potLoc == 2)
  1409. {
  1410. while (!morkF.SecondTurnMachineDownComplete)//等待翻转机下降完成
  1411. {
  1412. Task.Delay(5).Wait();
  1413. }
  1414. WriteData("M8.7", false);//下降完成复位
  1415. }
  1416. DeviceProcessLogShow($"翻转机下降完成");
  1417. //if (morkF.MaterialCount == 3 && morkF.MainProcessStatus)
  1418. //{
  1419. // morkF.MainProcessWait = true;
  1420. //}
  1421. //else if (morkF.MaterialCount == 3 && morkF.MinorProessStatus)
  1422. //{
  1423. // morkF.MinorProcessWait = true;
  1424. //}
  1425. }
  1426. /// <summary>
  1427. /// 主流程翻转机上升及状态检测
  1428. /// </summary>
  1429. public void MainProcessTurnUpStatusDetect()
  1430. {
  1431. //while (morkF.RoobotIdle)//机器人忙碌
  1432. //{
  1433. // Task.Delay(5).Wait();
  1434. //}
  1435. MainProcessTurnMachineOrientControl("Top");//翻转机上升
  1436. #region 单口锅逻辑
  1437. while (!morkF.TurnMachineUpComplete)//等待翻转机上升完成以及取料完成
  1438. {
  1439. Task.Delay(5).Wait();
  1440. }
  1441. WriteData("M8.1", false);//上升完成复位
  1442. WriteData("M14.3", true);//倒料
  1443. while (!morkF.FallMaterialComplete)//等待倒料完成
  1444. {
  1445. Task.Delay(5).Wait();
  1446. }
  1447. WriteData("M14.3", false);//倒料复位
  1448. DeviceProcessLogShow($"订单【{morkF.CurrentOrderId}】,配料倒料完成");
  1449. #endregion
  1450. #region 两口锅逻辑
  1451. //if (morkF.MainProcessPotLoc == 1)
  1452. //{
  1453. // while (!morkF.TurnMachineUpComplete)//等待翻转机上升完成以及取料完成
  1454. // {
  1455. // Task.Delay(5).Wait();
  1456. // }
  1457. // WriteData("M8.1", false);//上升完成复位
  1458. // if (!morkF.MainOrderMaterialCom)
  1459. // {
  1460. // WriteData("M14.3", true);//倒料
  1461. // while (!morkF.FallMaterialComplete)//等待倒料完成
  1462. // {
  1463. // Task.Delay(5).Wait();
  1464. // }
  1465. // morkF.MaterialCount++;
  1466. // WriteData("M14.3", false);//倒料复位
  1467. // if (morkF.MaterialCount == 3)
  1468. // {
  1469. // //允许执行下一个订单流程
  1470. // morkF.MaterialCount = 0;
  1471. // morkF.MinorProcessFlag = true;
  1472. // }
  1473. // morkF.MainOrderMaterialCom = true;
  1474. // morkF.MainHasTakeMaterial = false;
  1475. // DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】,配料倒料完成");
  1476. // }
  1477. // else //辅程准备阻塞
  1478. // {
  1479. // morkF.MainProcessWait = true;
  1480. // }
  1481. //}
  1482. //if (morkF.MainProcessPotLoc == 2)
  1483. //{
  1484. // while (!morkF.SecondTurnMachineUpComplete)//等待翻转机上升完成以及取料完成
  1485. // {
  1486. // Task.Delay(5).Wait();
  1487. // }
  1488. // WriteData("M8.5", false);//上升完成复位
  1489. // if (!morkF.MainOrderMaterialCom)
  1490. // {
  1491. // WriteData("M14.7", true);//倒料
  1492. // while (!morkF.SecondFallMaterialComplete)//等待倒料完成
  1493. // {
  1494. // Task.Delay(5).Wait();
  1495. // }
  1496. // morkF.MaterialCount++;
  1497. // WriteData("M14.7", false);//倒料复位
  1498. // if (morkF.MaterialCount == 3)
  1499. // {
  1500. // //允许执行下一个订单流程
  1501. // morkF.MaterialCount = 0;
  1502. // morkF.MinorProcessFlag = true;
  1503. // }
  1504. // morkF.MainOrderMaterialCom = true;
  1505. // morkF.MainHasTakeMaterial = false;
  1506. // DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】,配料倒料完成");
  1507. // }
  1508. // else //辅流程准备阻塞
  1509. // {
  1510. // morkF.MainProcessWait = true;
  1511. // }
  1512. //}
  1513. #endregion
  1514. DeviceProcessLogShow("翻转机上升完成");
  1515. }
  1516. /// <summary>
  1517. /// 辅流程翻转机上升及状态检测
  1518. /// </summary>
  1519. public void MinorProcessTurnUpStatusDetect()
  1520. {
  1521. while (morkF.RoobotIdle)//机器人忙碌
  1522. {
  1523. Task.Delay(5).Wait();
  1524. }
  1525. MinorProcessTurnMachineOrientControl("Top");//翻转机上升
  1526. if (morkF.MinorProcessPotLoc == 1)
  1527. {
  1528. while (!morkF.TurnMachineUpComplete)//等待翻转机上升完成以及取料完成
  1529. {
  1530. Task.Delay(5).Wait();
  1531. }
  1532. WriteData("M8.1", false);//上升完成复位
  1533. if (!morkF.MinorOrderMaterialCom)
  1534. {
  1535. WriteData("M14.3", true);//倒料
  1536. while (!morkF.FallMaterialComplete)//等待倒料完成
  1537. {
  1538. Task.Delay(5).Wait();
  1539. }
  1540. morkF.MaterialCount++;
  1541. WriteData("M14.3", false);//倒料复位
  1542. if (morkF.MaterialCount == 3)
  1543. {
  1544. //允许执行下一个订单流程
  1545. morkF.MaterialCount = 0;
  1546. morkF.MainProcessFlag = true;
  1547. }
  1548. morkF.MinorOrderMaterialCom = true;
  1549. morkF.MinorHasTakeMaterial = false;
  1550. DeviceProcessLogShow($"订单【{morkF.MainCurrentOrderId}】,配料倒料完成");
  1551. }
  1552. else //主程准备阻塞
  1553. {
  1554. morkF.MinorProcessWait = true;
  1555. }
  1556. }
  1557. if (morkF.MinorProcessPotLoc == 2)
  1558. {
  1559. while (!morkF.SecondTurnMachineUpComplete)//等待翻转机上升完成以及取料完成
  1560. {
  1561. Task.Delay(5).Wait();
  1562. }
  1563. WriteData("M8.5", false);//上升完成复位
  1564. if (!morkF.MinorOrderMaterialCom)
  1565. {
  1566. WriteData("M14.7", true);//倒料
  1567. while (!morkF.SecondFallMaterialComplete)//等待倒料完成
  1568. {
  1569. Task.Delay(5).Wait();
  1570. }
  1571. morkF.MaterialCount++;
  1572. WriteData("M14.7", false);//倒料复位
  1573. if (morkF.MaterialCount == 3)
  1574. {
  1575. //允许执行下一个订单流程
  1576. morkF.MaterialCount = 0;
  1577. morkF.MainProcessFlag = true;
  1578. }
  1579. morkF.MinorOrderMaterialCom = true;
  1580. morkF.MinorHasTakeMaterial = false;
  1581. DeviceProcessLogShow($"订单【{morkF.MinorCurrentOrderId}】,配料倒料完成");
  1582. }
  1583. else //主流程准备阻塞
  1584. {
  1585. morkF.MinorProcessWait = true;
  1586. }
  1587. }
  1588. DeviceProcessLogShow("翻转机上升完成");
  1589. }
  1590. private void GetStatus(string key, Action<bool[]> action)
  1591. {
  1592. if (peripheralStatus.ContainsKey(key))
  1593. {
  1594. action((bool[])peripheralStatus[key]);//获取PLC指定地址的状态值
  1595. }
  1596. }
  1597. /// <summary>
  1598. /// 写数据
  1599. /// </summary>
  1600. /// <param name="address"></param>
  1601. /// <param name="value"></param>
  1602. private void WriteData(string address, object value)
  1603. {
  1604. EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = address, Value = value });
  1605. }
  1606. public void FirstPotGears(int number)
  1607. {
  1608. switch (number)
  1609. {
  1610. case 0:
  1611. //if (morkF.MainProcessStatus && morkF.PotInPlace)
  1612. WriteData("M4.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
  1613. //if (morkF.MinorProessStatus && morkF.SecondPotInPlace)
  1614. // WriteData("M5.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
  1615. break;
  1616. case 1:
  1617. // if (morkF.MainProcessStatus)
  1618. WriteData("M4.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
  1619. //if (morkF.MinorProessStatus)
  1620. // WriteData("M5.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
  1621. break;
  1622. case 2:
  1623. //if (morkF.MainProcessStatus)
  1624. WriteData("M4.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
  1625. //if (morkF.MinorProessStatus)
  1626. // WriteData("M5.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
  1627. break;
  1628. case 3:
  1629. //if (morkF.MainProcessStatus)
  1630. WriteData("M4.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
  1631. //if (morkF.MinorProessStatus)
  1632. // WriteData("M5.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
  1633. break;
  1634. case 4:
  1635. // if (morkF.MainProcessStatus)
  1636. WriteData("M4.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100
  1637. //if (morkF.MinorProessStatus)
  1638. // WriteData("M5.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100
  1639. break;
  1640. case 5:
  1641. if (morkF.MainProcessStatus)
  1642. WriteData("M4.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101
  1643. //if (morkF.MinorProessStatus)
  1644. // WriteData("M5.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101
  1645. break;
  1646. case 6:
  1647. // if (morkF.MainProcessStatus)
  1648. WriteData("M4.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110
  1649. //if (morkF.MinorProessStatus)
  1650. // WriteData("M5.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110
  1651. break;
  1652. case 7:
  1653. // if (morkF.MainProcessStatus)
  1654. WriteData("M4.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111
  1655. //if (morkF.MinorProessStatus)
  1656. // WriteData("M5.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111
  1657. break;
  1658. case 8:
  1659. //if (morkF.MainProcessStatus)
  1660. WriteData("M4.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000
  1661. //if (morkF.MinorProessStatus)
  1662. // WriteData("M5.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000
  1663. break;
  1664. case 9:
  1665. //if (morkF.MainProcessStatus)
  1666. WriteData("M4.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001
  1667. //if (morkF.MinorProessStatus)
  1668. // WriteData("M5.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001
  1669. break;
  1670. }
  1671. }
  1672. public void SecondPotGears(int number)
  1673. {
  1674. switch (number)
  1675. {
  1676. case 0:
  1677. //if (morkF.MainProcessStatus && morkF.PotInPlace)
  1678. WriteData("M5.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
  1679. //if (morkF.MinorProessStatus && morkF.SecondPotInPlace)
  1680. // WriteData("M5.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000
  1681. break;
  1682. case 1:
  1683. // if (morkF.MainProcessStatus)
  1684. WriteData("M5.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
  1685. //if (morkF.MinorProessStatus)
  1686. // WriteData("M5.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001
  1687. break;
  1688. case 2:
  1689. //if (morkF.MainProcessStatus)
  1690. WriteData("M5.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
  1691. //if (morkF.MinorProessStatus)
  1692. // WriteData("M5.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010
  1693. break;
  1694. case 3:
  1695. //if (morkF.MainProcessStatus)
  1696. WriteData("M5.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
  1697. //if (morkF.MinorProessStatus)
  1698. // WriteData("M5.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011
  1699. break;
  1700. case 4:
  1701. // if (morkF.MainProcessStatus)
  1702. WriteData("M5.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100
  1703. //if (morkF.MinorProessStatus)
  1704. // WriteData("M5.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100
  1705. break;
  1706. case 5:
  1707. if (morkF.MainProcessStatus)
  1708. WriteData("M5.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101
  1709. //if (morkF.MinorProessStatus)
  1710. // WriteData("M5.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101
  1711. break;
  1712. case 6:
  1713. // if (morkF.MainProcessStatus)
  1714. WriteData("M5.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110
  1715. //if (morkF.MinorProessStatus)
  1716. // WriteData("M5.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110
  1717. break;
  1718. case 7:
  1719. // if (morkF.MainProcessStatus)
  1720. WriteData("M5.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111
  1721. //if (morkF.MinorProessStatus)
  1722. // WriteData("M5.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111
  1723. break;
  1724. case 8:
  1725. //if (morkF.MainProcessStatus)
  1726. WriteData("M5.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000
  1727. //if (morkF.MinorProessStatus)
  1728. // WriteData("M5.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000
  1729. break;
  1730. case 9:
  1731. //if (morkF.MainProcessStatus)
  1732. WriteData("M5.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001
  1733. //if (morkF.MinorProessStatus)
  1734. // WriteData("M5.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001
  1735. break;
  1736. }
  1737. }
  1738. /// <summary>
  1739. /// 主流程灶台档位调节
  1740. /// </summary>
  1741. public void MainProcessKitchenAdjustGears(int number)
  1742. {
  1743. #region 单口锅逻辑
  1744. while (!morkF.PotInPlace)
  1745. {
  1746. Task.Delay(5).Wait();
  1747. }
  1748. FirstPotGears(number);
  1749. DeviceProcessLogShow($"灶台【{morkF.CurrentOrderId}】档位调节至【{number}】挡");
  1750. #endregion
  1751. #region 两口锅逻辑
  1752. //if (morkF.MainProcessPotLoc == 1)
  1753. //{
  1754. // while (!morkF.PotInPlace)
  1755. // {
  1756. // Task.Delay(5).Wait();
  1757. // }
  1758. // FirstPotGears(number);
  1759. //}
  1760. //if (morkF.MainProcessPotLoc == 2)
  1761. //{
  1762. // while (!morkF.SecondPotInPlace)
  1763. // {
  1764. // Task.Delay(5).Wait();
  1765. // }
  1766. // SecondPotGears(number);
  1767. //}
  1768. //DeviceProcessLogShow($"灶台【{morkF.MainProcessPotLoc}】档位调节至【{number}】挡");
  1769. #endregion
  1770. }
  1771. /// <summary>
  1772. /// 辅流程灶台档位调节
  1773. /// </summary>
  1774. public void MinorProcessKitchenAdjustGears(int number)
  1775. {
  1776. if (morkF.MinorProcessPotLoc == 1)
  1777. {
  1778. while (!morkF.PotInPlace)
  1779. {
  1780. Task.Delay(5).Wait();
  1781. }
  1782. FirstPotGears(number);
  1783. }
  1784. if (morkF.MinorProcessPotLoc == 2)
  1785. {
  1786. while (!morkF.SecondPotInPlace)
  1787. {
  1788. Task.Delay(5).Wait();
  1789. }
  1790. SecondPotGears(number);
  1791. }
  1792. DeviceProcessLogShow($"灶台【{morkF.MinorProcessPotLoc}】档位调节至【{number}】挡");
  1793. }
  1794. /// <summary>
  1795. /// PLC转台控制
  1796. /// </summary>
  1797. /// <param name="loc"></param>
  1798. public void TurnMaterialStore(int loc)
  1799. {
  1800. switch (loc)
  1801. {
  1802. case 1:
  1803. WriteData("M13.0", true);
  1804. break;
  1805. case 2:
  1806. WriteData("M13.1", true);
  1807. break;
  1808. case 3:
  1809. WriteData("M13.2", true);
  1810. break;
  1811. case 4:
  1812. WriteData("M13.3", true);
  1813. break;
  1814. case 5:
  1815. WriteData("M13.4", true);
  1816. break;
  1817. }
  1818. }
  1819. public void PLCInite()
  1820. {
  1821. WriteData("M0.0", true);
  1822. }
  1823. /// <summary>
  1824. /// 供盘启动
  1825. /// </summary>
  1826. public void StartTakePlate()
  1827. {
  1828. WriteData("M1.1", true);
  1829. }
  1830. /// <summary>
  1831. /// 取锅到灶台
  1832. /// </summary>
  1833. public void TakePotToKitchen(int loc)
  1834. {
  1835. if (loc == 1)
  1836. WriteData("M14.0", true);
  1837. if (loc == 2)
  1838. WriteData("M14.4", true);
  1839. }
  1840. /// <summary>
  1841. /// 主流程机器人出餐并将锅放置清洗台位置
  1842. /// </summary>
  1843. public void MainProcessRobotOutMeal()
  1844. {
  1845. #region 单口锅逻辑
  1846. WriteData("M14.2", true);//1号锅出餐
  1847. #endregion
  1848. #region 两口锅逻辑
  1849. //if (morkF.MainProcessPotLoc == 1)
  1850. //{
  1851. // WriteData("M14.2", true);//1号锅出餐
  1852. //}
  1853. //else if (morkF.MainProcessPotLoc == 2)
  1854. //{
  1855. // WriteData("M14.6", true);//2号锅出餐
  1856. //}
  1857. #endregion
  1858. }
  1859. /// <summary>
  1860. /// 复流程机器人出餐并将锅放置清洗台位置
  1861. /// </summary>
  1862. public void MinorProcessRobotOutMeal()
  1863. {
  1864. if (morkF.MinorProcessPotLoc == 1)
  1865. {
  1866. WriteData("M14.2", true);//1号锅出餐
  1867. }
  1868. else if (morkF.MinorProcessPotLoc == 2)
  1869. {
  1870. WriteData("M14.6", true);//2号锅出餐
  1871. }
  1872. }
  1873. public void OpenDraft()
  1874. {
  1875. WriteData("M0.7", true);//打开抽风机
  1876. }
  1877. /// <summary>
  1878. /// 注油
  1879. /// </summary>
  1880. public void AddOil()
  1881. {
  1882. #region 单口锅逻辑
  1883. while (!morkF.PotInPlace)
  1884. {
  1885. Task.Delay(5).Wait();
  1886. }
  1887. WriteData("M2.7", true);//加油
  1888. OpenDraft();
  1889. DeviceProcessLogShow("开始注油");
  1890. while (!morkF.FallOilComplete)
  1891. {
  1892. Task.Delay(5).Wait();
  1893. }
  1894. #endregion
  1895. #region 两口锅逻辑
  1896. //if (morkF.MainProcessStatus)
  1897. //{
  1898. // if (morkF.MainProcessPotLoc == 1)
  1899. // {
  1900. // while (!morkF.PotInPlace)
  1901. // {
  1902. // Task.Delay(5).Wait();
  1903. // }
  1904. // WriteData("M2.7", true);//加油
  1905. // OpenDraft();
  1906. // DeviceProcessLogShow("开始注油");
  1907. // while (!morkF.FallOilComplete)
  1908. // {
  1909. // Task.Delay(5).Wait();
  1910. // }
  1911. // }
  1912. // if (morkF.MainProcessPotLoc == 2)
  1913. // {
  1914. // while (!morkF.SecondPotInPlace)
  1915. // {
  1916. // Task.Delay(5).Wait();
  1917. // }
  1918. // WriteData("M3.1", true);//加油
  1919. // OpenDraft();
  1920. // DeviceProcessLogShow("开始注油");
  1921. // while (!morkF.SecondOilComplete)
  1922. // {
  1923. // Task.Delay(5).Wait();
  1924. // }
  1925. // }
  1926. //}
  1927. //if (morkF.MinorProessStatus)
  1928. //{
  1929. // if (morkF.MinorProcessPotLoc == 1)
  1930. // {
  1931. // while (!morkF.PotInPlace)
  1932. // {
  1933. // Task.Delay(5).Wait();
  1934. // }
  1935. // WriteData("M2.7", true);//加油
  1936. // OpenDraft();
  1937. // DeviceProcessLogShow("开始注油");
  1938. // while (!morkF.FallOilComplete)
  1939. // {
  1940. // Task.Delay(5).Wait();
  1941. // }
  1942. // }
  1943. // if (morkF.MinorProcessPotLoc == 2)
  1944. // {
  1945. // while (!morkF.SecondPotInPlace)
  1946. // {
  1947. // Task.Delay(5).Wait();
  1948. // }
  1949. // WriteData("M3.1", true);//加油
  1950. // OpenDraft();
  1951. // DeviceProcessLogShow("开始注油");
  1952. // while (!morkF.SecondOilComplete)
  1953. // {
  1954. // Task.Delay(5).Wait();
  1955. // }
  1956. // }
  1957. //}
  1958. #endregion
  1959. //while (!morkF.FallOilComplete || !morkF.SecondOilComplete)
  1960. //{
  1961. // Task.Delay(5).Wait();
  1962. //}
  1963. DeviceProcessLogShow("注油完成");
  1964. }
  1965. public void FirstPotTurnMachine(string orientation)
  1966. {
  1967. switch (orientation)
  1968. {
  1969. case "Top": WriteData("M8.0", true); break;
  1970. case "Down": WriteData("M8.2", true); break;
  1971. }
  1972. }
  1973. public void SecondPotTurnMachine(string orientation)
  1974. {
  1975. switch (orientation)
  1976. {
  1977. case "Top": WriteData("M8.4", true); break;
  1978. case "Down": WriteData("M8.6", true); break;
  1979. }
  1980. }
  1981. /// <summary>
  1982. /// 主流程翻转机方向控制
  1983. /// </summary>
  1984. /// <param name="orientation"></param>
  1985. public int MainProcessTurnMachineOrientControl(string orientation)
  1986. {
  1987. int potLoc = 0;
  1988. #region 单口锅逻辑
  1989. FirstPotTurnMachine(orientation);
  1990. potLoc = 1;
  1991. #endregion
  1992. #region 两口锅逻辑
  1993. //if (morkF.MainProcessPotLoc == 1)
  1994. //{
  1995. // FirstPotTurnMachine(orientation);
  1996. // potLoc = 1;
  1997. //}
  1998. //if (morkF.MainProcessPotLoc == 2)
  1999. //{
  2000. // SecondPotTurnMachine(orientation);
  2001. // potLoc = 2;
  2002. //}
  2003. #endregion
  2004. DeviceProcessLogShow($"翻转机执行{orientation}操作");
  2005. return potLoc;
  2006. }
  2007. /// <summary>
  2008. /// 辅流程翻转机方向控制
  2009. /// </summary>
  2010. /// <param name="orientation"></param>
  2011. public int MinorProcessTurnMachineOrientControl(string orientation)
  2012. {
  2013. int potLoc = 0;
  2014. if (morkF.MinorProcessPotLoc == 1)
  2015. {
  2016. FirstPotTurnMachine(orientation);
  2017. potLoc = 1;
  2018. }
  2019. if (morkF.MinorProcessPotLoc == 2)
  2020. {
  2021. SecondPotTurnMachine(orientation);
  2022. potLoc = 2;
  2023. }
  2024. DeviceProcessLogShow($"翻转机执行{orientation}操作");
  2025. return potLoc;
  2026. }
  2027. public void FirstPotTurnMachine(int gear)
  2028. {
  2029. while (!morkF.PotInPlace)
  2030. {
  2031. Task.Delay(5).Wait();
  2032. }
  2033. switch (gear)
  2034. {
  2035. case 0: WriteData("M7.0", true); Task.Delay(1000).Wait(); break;//关闭翻炒机
  2036. case 1: WriteData("M7.1", true); break;//翻炒机1挡
  2037. case 2: WriteData("M7.2", true); break;//翻炒机2挡
  2038. case 3: WriteData("M7.3", true); break;//翻炒机3挡
  2039. }
  2040. }
  2041. public void SecondPotTurnMachine(int gear)
  2042. {
  2043. while (!morkF.SecondPotInPlace)
  2044. {
  2045. Task.Delay(5).Wait();
  2046. }
  2047. switch (gear)
  2048. {
  2049. case 0: WriteData("M7.4", true); Task.Delay(1000).Wait(); break;//关闭翻炒机
  2050. case 1: WriteData("M7.5", true); break;//翻炒机1挡
  2051. case 2: WriteData("M7.6", true); break;//翻炒机2挡
  2052. case 3: WriteData("M7.7", true); break;//翻炒机3挡
  2053. }
  2054. }
  2055. /// <summary>
  2056. /// 主流程翻转机档位控制
  2057. /// </summary>
  2058. public void MainProcessTurnMachineGearsControl(int gear)
  2059. {
  2060. #region 单口锅逻辑
  2061. FirstPotTurnMachine(gear);
  2062. DeviceProcessLogShow($"炒锅【{morkF.CurrentOrderId}】翻转机档位调至{gear}挡");
  2063. #endregion
  2064. #region 两口锅逻辑
  2065. //if (morkF.MainProcessPotLoc == 1)
  2066. //{
  2067. // FirstPotTurnMachine(gear);
  2068. //}
  2069. //if (morkF.MainProcessPotLoc == 2)
  2070. //{
  2071. // SecondPotTurnMachine(gear);
  2072. //}
  2073. //DeviceProcessLogShow($"炒锅【{morkF.MainProcessPotLoc}】翻转机档位调至{gear}挡");
  2074. #endregion
  2075. }
  2076. /// <summary>
  2077. /// 辅流程翻转机档位控制
  2078. /// </summary>
  2079. public void MinorProcessTurnMachineGearsControl(int gear)
  2080. {
  2081. if (morkF.MinorProcessPotLoc == 1)
  2082. {
  2083. FirstPotTurnMachine(gear);
  2084. }
  2085. if (morkF.MinorProcessPotLoc == 2)
  2086. {
  2087. SecondPotTurnMachine(gear);
  2088. }
  2089. DeviceProcessLogShow($"炒锅【{morkF.MinorProcessPotLoc}】翻转机档位调至{gear}挡");
  2090. }
  2091. /// <summary>
  2092. /// 取A,B,C料
  2093. /// </summary>
  2094. public void TakeBurden()
  2095. {
  2096. #region 单口锅逻辑
  2097. WriteData("M14.1", true);//机器人取料至1号锅
  2098. #endregion
  2099. #region 两口锅逻辑
  2100. //if (morkF.PotInPlace)
  2101. // WriteData("M14.1", true);//机器人取料至1号锅
  2102. //if (morkF.SecondPotInPlace)
  2103. // WriteData("M14.5", true);//机器人取料至2号锅
  2104. #endregion
  2105. }
  2106. /// <summary>
  2107. /// 清洗模组1启停控制
  2108. /// </summary>
  2109. public void CleanModuleControl(string status, int loc)
  2110. {
  2111. if (loc == 1)
  2112. {
  2113. if (status == "Start")
  2114. {
  2115. WriteData("M1.4", true);
  2116. }
  2117. if (status == "Stop")
  2118. {
  2119. WriteData("M1.4", false);
  2120. }
  2121. DeviceProcessLogShow($"清洗模组1执行【{status}】操作");
  2122. }
  2123. if (loc == 2)
  2124. {
  2125. if (status == "Start")
  2126. {
  2127. WriteData("M1.7", true);
  2128. }
  2129. if (status == "Stop")
  2130. {
  2131. WriteData("M1.7", false);
  2132. }
  2133. DeviceProcessLogShow($"清洗模组2执行【{status}】操作");
  2134. }
  2135. }
  2136. public override void Stop()
  2137. {
  2138. }
  2139. public override void SimOrder()
  2140. {
  2141. }
  2142. }
  2143. }