Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

419 linhas
14 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using HBLConsole.Interface;
  7. using HBLConsole.Communication;
  8. using System.Threading;
  9. using System.Collections.Concurrent;
  10. using HBLConsole.Model;
  11. using HBLConsole.Attributes;
  12. namespace HBLConsole.MORKD
  13. {
  14. public class GVL_MORKD : IGvl
  15. {
  16. #region 上位机到 --> PLC 控制
  17. /// <summary>
  18. /// 初始化控制
  19. /// </summary>
  20. public void InitControl()
  21. {
  22. ModbusTcpHelper.GetInstance.Write(320, WriteType.Coils, true);
  23. //await Task.Delay(1000);
  24. //ModbusTcpHelper.GetInstance.Write(320, WriteType.Coils, false);
  25. }
  26. /// <summary>
  27. /// 机器人取面启动
  28. /// </summary>
  29. /// <param name="CookNoodleLoc">煮面篮位置</param>
  30. /// /// <param name="TurntableLoc">转台位置</param>
  31. public void RBTakeNoodleStart(ushort CookNoodleLoc, ushort TurntableLoc)
  32. {
  33. ModbusTcpHelper.GetInstance.Write(101, WriteType.HoldingRegisters, CookNoodleLoc);
  34. ModbusTcpHelper.GetInstance.Write(100, WriteType.HoldingRegisters, TurntableLoc);
  35. ModbusTcpHelper.GetInstance.Write(321, WriteType.Coils, true);
  36. }
  37. /// <summary>
  38. /// 机器人出面启动
  39. /// </summary>
  40. /// <param name="OutNoodleLoc">出面位置</param>
  41. /// <param name="BowlLoc">倒面至碗位置</param>
  42. public void RBOutNoodleStart(ushort OutNoodleLoc, ushort BowlLoc)
  43. {
  44. ModbusTcpHelper.GetInstance.Write(102, WriteType.HoldingRegisters, OutNoodleLoc);
  45. ModbusTcpHelper.GetInstance.Write(103, WriteType.HoldingRegisters, BowlLoc);
  46. ModbusTcpHelper.GetInstance.Write(322, WriteType.Coils, true);
  47. }
  48. /// <summary>
  49. /// 机器人取浇头启动
  50. /// </summary>
  51. /// <param name="SoupLoc">浇头位置</param>
  52. /// <param name="CutLoc">破口位置</param>
  53. public void RBTakeSoupStart(ushort SoupLoc, ushort CutLoc)
  54. {
  55. AllowTakeSoup = true;
  56. ModbusTcpHelper.GetInstance.Write(105, WriteType.HoldingRegisters, SoupLoc);
  57. ModbusTcpHelper.GetInstance.Write(106, WriteType.HoldingRegisters, CutLoc);
  58. ModbusTcpHelper.GetInstance.Write(323, WriteType.Coils, true);
  59. }
  60. /// <summary>
  61. /// 加热完成取浇头启动
  62. /// </summary>
  63. /// <param name="SoupLoc">取浇头完成</param>
  64. /// <param name="BowlLoc">倒浇头至碗位置</param>
  65. /// <param name="OutMealLoc">放面至出餐口位置</param>
  66. public void HeatCompleteTakeSoupStart(ushort SoupLoc, ushort BowlLoc, ushort OutMealLoc)
  67. {
  68. AllowTakeSoup = true;
  69. ModbusTcpHelper.GetInstance.Write(108, WriteType.HoldingRegisters, SoupLoc);
  70. ModbusTcpHelper.GetInstance.Write(109, WriteType.HoldingRegisters, BowlLoc);
  71. ModbusTcpHelper.GetInstance.Write(110, WriteType.HoldingRegisters, OutMealLoc);
  72. ModbusTcpHelper.GetInstance.Write(324, WriteType.Coils, true);
  73. }
  74. /// <summary>
  75. /// 转台启动
  76. /// </summary>
  77. /// <param name="TurntableLoc">转台位置</param>
  78. public void TurntableStart(ushort TurntableLoc)
  79. {
  80. this.TurntableLoc = TurntableLoc;
  81. TurntableInterlock = true;
  82. TurntableLocLists.Add(TurntableLoc);
  83. ModbusTcpHelper.GetInstance.Write(100, WriteType.HoldingRegisters, TurntableLoc);
  84. ModbusTcpHelper.GetInstance.Write(325, WriteType.Coils, true);
  85. }
  86. /// <summary>
  87. /// 下碗启动
  88. /// </summary>
  89. /// <param name="AxisLoc">启动轴位置</param>
  90. /// <param name="BowlType">碗类型位置</param>
  91. public void DropBowlStart(ushort AxisLoc, ushort BowlType)
  92. {
  93. ModbusTcpHelper.GetInstance.Write(113, WriteType.HoldingRegisters, AxisLoc);
  94. ModbusTcpHelper.GetInstance.Write(114, WriteType.HoldingRegisters, BowlType);
  95. }
  96. /// <summary>
  97. /// 取面完成信号复位
  98. /// </summary>
  99. public void TakeNoodleCompleteReset()
  100. {
  101. ModbusTcpHelper.GetInstance.Write(1122, WriteType.Coils, false);
  102. }
  103. /// <summary>
  104. /// 出面完成信号复位
  105. /// </summary>
  106. public void PutNoodleTakeMealCompleteReset()
  107. {
  108. ModbusTcpHelper.GetInstance.Write(1148, WriteType.Coils, false);
  109. }
  110. /// <summary>
  111. /// 取浇头完成信号复位
  112. /// </summary>
  113. public void TakeSoupCompleteReset()
  114. {
  115. ModbusTcpHelper.GetInstance.Write(1147, WriteType.Coils, false);
  116. }
  117. #endregion
  118. #region PLC --> 上位机
  119. /// <summary>
  120. /// 初始化完成
  121. /// PLC --> M100.0
  122. /// ModbusTcp --> 1120
  123. /// </summary>
  124. [Circuit(new string[] { "允许运行", "转台控制" }, "初始化完成")]
  125. public bool InitComplete { get; set; }
  126. /// <summary>
  127. /// 转台到位
  128. /// PLC --> M100.1
  129. /// ModbusTcp --> 1121
  130. /// </summary>
  131. [Circuit("取面任务", "转台到位检测")]
  132. public bool TurntableInPlace { get; set; }
  133. /// <summary>
  134. /// 机器人取面完成
  135. /// PLC --> M100.2
  136. /// ModbusTcp --> 1122
  137. /// </summary>
  138. public bool RBTakeNoodleComplete { get; set; }
  139. /// <summary>
  140. /// 轴空闲
  141. /// PLC --> M100.3 -- M100.04
  142. /// ModbusTcp --> 1123 -- 1124
  143. /// </summary>
  144. public bool[] AxisIdle { get; set; } = new bool[2] { false, false };
  145. /// <summary>
  146. /// 轴允许倒面
  147. /// PLC --> M100.5 -- M100.06
  148. /// ModbusTcp --> 1125 -- 1126
  149. /// </summary>
  150. public bool[] AxisAllowInvertedNoodle { get; set; } = new bool[2] { false, false };
  151. /// <summary>
  152. /// 轴允许倒浇头
  153. /// PLC --> M100.7 -- M101.00
  154. /// ModbusTcp --> 1127 -- 1128
  155. /// </summary>
  156. public bool[] AxisAllowInvertedSoup { get; set; } = new bool[2] { false, false };
  157. /// <summary>
  158. /// 浇头加热完成
  159. /// PLC --> M101.1 -- M101.02
  160. /// ModbusTcp --> 1129 -- 1130
  161. /// </summary>
  162. public bool[] SoupHeatComplete { get; set; } = new bool[2] { false, false };
  163. /// <summary>
  164. /// 煮面篮空闲
  165. /// PLC --> M101.3 -- M102.0
  166. /// ModbusTcp --> 1131 -- 1136
  167. /// </summary>
  168. public bool[] CookNoodleBasketIdle { get; set; } = new bool[6] { false, false, false, false, false, false };
  169. /// <summary>
  170. /// 煮面完成
  171. /// PLC --> M102.1 -- M102.6
  172. /// ModbusTcp --> 1137 -- 1142
  173. /// </summary>
  174. public bool[] CookNoodleComplete { get; set; } = new bool[6] { false, false, false, false, false, false };
  175. /// <summary>
  176. /// 取面机器人空闲状态
  177. /// PLC --> M102.7
  178. /// ModbusTcp --> 1143
  179. /// </summary>
  180. [Circuit(new string[] { "取面任务", "出餐控制" }, "取面机器人空闲")]
  181. public bool TakeNoodleRobotIdle { get; set; }
  182. /// <summary>
  183. /// 取浇头机器人空闲状态
  184. /// PLC --> M103.0
  185. /// ModbusTcp --> 1144
  186. /// </summary>
  187. [Circuit(new string[] { "取浇头控制", "出浇头控制" }, "取浇头机器人空闲状态")]
  188. public bool TakeSoupRobotIdle { get; set; }
  189. /// <summary>
  190. /// 破口机构空闲
  191. /// PLC --> M103.1 -- M103.02
  192. /// ModbusTcp --> 1145 -- 1146
  193. /// </summary>
  194. public bool[] BreakMechanismIdle { get; set; } = new bool[2] { false, false };
  195. /// <summary>
  196. /// 取浇头完成
  197. /// PLC --> M103.3
  198. /// ModbusTcp --> 1147
  199. /// </summary>
  200. public bool TakeSoupComplete { get; set; }
  201. /// <summary>
  202. /// 放面至取餐口完成
  203. /// PLC --> M103.4
  204. /// ModbusTcp --> 1148
  205. /// </summary>
  206. public bool PutNoodleTakeMealComplete { get; set; }
  207. /// <summary>
  208. /// 设备初始化中
  209. /// PLC --> M103.5
  210. /// ModbusTcp --> 1149
  211. /// </summary>
  212. public bool Initing { get; set; }
  213. /// <summary>
  214. /// 转台位置
  215. /// PLC -> VW372
  216. /// ModbusTcp -> 286
  217. /// </summary>
  218. public ushort TurntableFeedbackloc { get; set; }
  219. #endregion
  220. #region 传感器状态
  221. /// <summary>
  222. /// 转台下限位
  223. /// PLC --> M120.0
  224. /// ModbusTcp --> 1200
  225. /// </summary>
  226. public bool TurntableLowerLimit { get; set; }
  227. /// <summary>
  228. /// 转台上限位
  229. /// PLC --> M120.1
  230. /// ModbusTcp --> 1201
  231. /// </summary>
  232. public bool TurntableUpLimit { get; set; }
  233. /// <summary>
  234. /// 浇头缺料
  235. /// PLC --> M120.2 -- M120.6
  236. /// ModbusTcp --> 1202 -- 1206
  237. /// </summary>
  238. public bool[] SoupMaterialShortage { get; set; } = new bool[5] { false, false, false, false, false };
  239. /// <summary>
  240. /// 出餐口检测
  241. /// PLC --> M120.7 -- M121.1
  242. /// ModbusTcp --> 1207 -- 1209
  243. /// </summary>
  244. public bool[] OutMealDetect { get; set; } = new bool[3] { false, false, false };
  245. /// <summary>
  246. /// 温度到达
  247. /// PLC --> M121.2
  248. /// ModbusTcp --> 1210
  249. /// </summary>
  250. public bool TemperatureReached { get; set; }
  251. #endregion
  252. #region 内部变量
  253. /// <summary>
  254. /// 允许倒浇头
  255. /// </summary>
  256. [Circuit(new string[] { "出浇头控制" }, "允许倒浇头", new bool[] { true })]
  257. public bool AllowPutSoup { get; set; }
  258. /// <summary>
  259. /// 允许取浇头
  260. /// </summary>
  261. [Circuit(new string[] { "取浇头控制", "出浇头控制" }, "允许取浇头", new bool[] { true, true })]
  262. public bool AllowTakeSoup { get; set; }
  263. /// <summary>
  264. /// 放面位置
  265. /// </summary>
  266. public int PutNoodleLoc { get; set; }
  267. /// <summary>
  268. /// 轴空闲位置
  269. /// </summary>
  270. public int AxisIdleIndex { get; set; }
  271. /// <summary>
  272. /// 轴空闲互锁位置
  273. /// </summary>
  274. public int AxisIdleLockIndex { get; set; }
  275. /// <summary>
  276. /// 转台位置
  277. /// </summary>
  278. public ushort TurntableLoc { get; set; }
  279. /// <summary>
  280. /// 机器人任务互锁信号
  281. /// </summary>
  282. [Circuit(new string[] { "取面任务", "出餐控制" }, "机器人任务互锁", new bool[] { true, false })]
  283. public bool RobotTaskInterlock { get; set; }
  284. /// <summary>
  285. /// 取碗互锁信号
  286. /// </summary>
  287. public bool TakeBowlInterlock { get; set; }
  288. /// <summary>
  289. /// 取面互锁信号
  290. /// </summary>
  291. [Circuit(new string[] { "出餐控制" }, "取面互锁信号", new bool[] { true })]
  292. public bool TakeNoodleInterlock { get; set; }
  293. /// <summary>
  294. /// 出面中
  295. /// </summary>
  296. [Circuit(new string[] { "取面任务" }, "出面中", new bool[] { true })]
  297. public bool OutNoodleing { get; set; }
  298. /// <summary>
  299. /// 允许取面
  300. /// </summary>
  301. [Circuit(new string[] { "转台控制", "取面任务" }, "允许取面", new bool[] { true, false })]
  302. public bool AllowTakeNoodle { get; set; }
  303. /// <summary>
  304. /// 转台互锁信号
  305. /// </summary>
  306. [Circuit(new string[] { "转台控制" }, "转台互锁信号", new bool[] { true })]
  307. public bool TurntableInterlock { get; set; }
  308. /// <summary>
  309. /// 轴空闲互锁
  310. /// </summary>
  311. public bool[] AxisIdleLock { get; set; } = new bool[2] { false, false };
  312. /// <summary>
  313. /// 转台位置轮询
  314. /// </summary>
  315. public List<ushort> TurntableLocLists = new List<ushort>();
  316. /// <summary>
  317. /// 允许运行
  318. /// </summary>
  319. [Circuit(new string[] { "取面任务", "取浇头控制" }, "允许运行")]
  320. public bool AllowRun { get; set; }
  321. /// <summary>
  322. /// 取面位置队列
  323. /// </summary>
  324. public ConcurrentQueue<OrderLocInfo> RBTakeNoodleTask { get; set; } = new ConcurrentQueue<OrderLocInfo>();
  325. /// <summary>
  326. /// 取浇头任务队列
  327. /// </summary>
  328. public ConcurrentQueue<OrderLocInfo> TakeSoupTask { get; set; } = new ConcurrentQueue<OrderLocInfo>();
  329. /// <summary>
  330. ///取碗任务队列
  331. /// </summary>
  332. public ConcurrentQueue<OrderLocInfo> TakeBowlTask { get; set; } = new ConcurrentQueue<OrderLocInfo>();
  333. /// <summary>
  334. /// 煮面完成任务队列
  335. /// </summary>
  336. public ConcurrentQueue<ushort> CookNoodleCompleteTask { get; set; } = new ConcurrentQueue<ushort>();
  337. #endregion
  338. #region 内部变量 --> 订单ID记录
  339. /// <summary>
  340. /// 煮面口对应的订单ID
  341. /// </summary>
  342. public string[] CookNodelId { get; set; } = new string[6] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, };
  343. /// <summary>
  344. /// 出餐口订单ID
  345. /// </summary>
  346. public string[] OutMealId { get; set; } = new string[3] { string.Empty, string.Empty, string.Empty };
  347. /// <summary>
  348. /// 轴允许倒面 id
  349. /// </summary>
  350. public string[] AxisAllowInvertedNoodleID { get; set; } = new string[2] { string.Empty, string.Empty };
  351. /// <summary>
  352. /// 轴允许倒浇头 id
  353. /// </summary>
  354. public string[] AxisAllowInvertedSoupID { get; set; } = new string[2] { string.Empty, string.Empty };
  355. /// <summary>
  356. /// 浇头加热完成 id
  357. /// </summary>
  358. public string[] SoupHeatCompleteID { get; set; } = new string[2] { string.Empty, string.Empty };
  359. #endregion
  360. }
  361. }