You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

395 lines
13 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 async 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. public bool InitComplete { get; set; }
  125. /// <summary>
  126. /// 转台到位
  127. /// PLC --> M100.1
  128. /// ModbusTcp --> 1121
  129. /// </summary>
  130. public bool TurntableInPlace { get; set; }
  131. /// <summary>
  132. /// 机器人取面完成
  133. /// PLC --> M100.2
  134. /// ModbusTcp --> 1122
  135. /// </summary>
  136. public bool RBTakeNoodleComplete { get; set; }
  137. /// <summary>
  138. /// 轴空闲
  139. /// PLC --> M100.3 -- M100.04
  140. /// ModbusTcp --> 1123 -- 1124
  141. /// </summary>
  142. public bool[] AxisIdle { get; set; } = new bool[2] { false, false };
  143. /// <summary>
  144. /// 轴允许倒面
  145. /// PLC --> M100.5 -- M100.06
  146. /// ModbusTcp --> 1125 -- 1126
  147. /// </summary>
  148. public bool[] AxisAllowInvertedNoodle { get; set; } = new bool[2] { false, false };
  149. /// <summary>
  150. /// 轴允许倒浇头
  151. /// PLC --> M100.7 -- M101.00
  152. /// ModbusTcp --> 1127 -- 1128
  153. /// </summary>
  154. public bool[] AxisAllowInvertedSoup { get; set; } = new bool[2] { false, false };
  155. /// <summary>
  156. /// 浇头加热完成
  157. /// PLC --> M101.1 -- M101.02
  158. /// ModbusTcp --> 1129 -- 1130
  159. /// </summary>
  160. public bool[] SoupHeatComplete { get; set; } = new bool[2] { false, false };
  161. /// <summary>
  162. /// 煮面篮空闲
  163. /// PLC --> M101.3 -- M102.0
  164. /// ModbusTcp --> 1131 -- 1136
  165. /// </summary>
  166. public bool[] CookNoodleBasketIdle { get; set; } = new bool[6] { false, false, false, false, false, false };
  167. /// <summary>
  168. /// 煮面完成
  169. /// PLC --> M102.1 -- M102.6
  170. /// ModbusTcp --> 1137 -- 1142
  171. /// </summary>
  172. public bool[] CookNoodleComplete { get; set; } = new bool[6] { false, false, false, false, false, false };
  173. /// <summary>
  174. /// 取面机器人空闲状态
  175. /// PLC --> M102.7
  176. /// ModbusTcp --> 1143
  177. /// </summary>
  178. public bool TakeNoodleRobotIdle { get; set; }
  179. /// <summary>
  180. /// 取浇头机器人空闲状态
  181. /// PLC --> M103.0
  182. /// ModbusTcp --> 1144
  183. /// </summary>
  184. public bool TakeSoupRobotIdle { get; set; }
  185. /// <summary>
  186. /// 破口机构空闲
  187. /// PLC --> M103.1 -- M103.02
  188. /// ModbusTcp --> 1145 -- 1146
  189. /// </summary>
  190. public bool[] BreakMechanismIdle { get; set; } = new bool[2] { false, false };
  191. /// <summary>
  192. /// 取浇头完成
  193. /// PLC --> M103.3
  194. /// ModbusTcp --> 1147
  195. /// </summary>
  196. public bool TakeSoupComplete { get; set; }
  197. /// <summary>
  198. /// 放面至取餐口完成
  199. /// PLC --> M103.4
  200. /// ModbusTcp --> 1148
  201. /// </summary>
  202. public bool PutNoodleTakeMealComplete { get; set; }
  203. #endregion
  204. #region 传感器状态
  205. /// <summary>
  206. /// 转台下限位
  207. /// PLC --> M120.0
  208. /// ModbusTcp --> 1200
  209. /// </summary>
  210. public bool TurntableLowerLimit { get; set; }
  211. /// <summary>
  212. /// 转台上限位
  213. /// PLC --> M120.1
  214. /// ModbusTcp --> 1201
  215. /// </summary>
  216. public bool TurntableUpLimit { get; set; }
  217. /// <summary>
  218. /// 浇头缺料
  219. /// PLC --> M120.2 -- M120.6
  220. /// ModbusTcp --> 1202 -- 1206
  221. /// </summary>
  222. public bool[] SoupMaterialShortage { get; set; } = new bool[5] { false, false, false, false, false };
  223. /// <summary>
  224. /// 出餐口检测
  225. /// PLC --> M120.7 -- M121.1
  226. /// ModbusTcp --> 1207 -- 1209
  227. /// </summary>
  228. public bool[] OutMealDetect { get; set; } = new bool[3] { false, false, false };
  229. /// <summary>
  230. /// 温度到达
  231. /// PLC --> M121.2
  232. /// ModbusTcp --> 1210
  233. /// </summary>
  234. public bool TemperatureReached { get; set; }
  235. #endregion
  236. #region 内部变量
  237. /// <summary>
  238. /// 允许倒浇头
  239. /// </summary>
  240. public bool AllowPutSoup { get; set; }
  241. /// <summary>
  242. /// 允许取浇头
  243. /// </summary>
  244. public bool AllowTakeSoup { get; set; }
  245. /// <summary>
  246. /// 放面位置
  247. /// </summary>
  248. public int PutNoodleLoc { get; set; }
  249. /// <summary>
  250. /// 轴空闲位置
  251. /// </summary>
  252. public int AxisIdleIndex { get; set; }
  253. /// <summary>
  254. /// 轴空闲互锁位置
  255. /// </summary>
  256. public int AxisIdleLockIndex { get; set; }
  257. /// <summary>
  258. /// 转台位置
  259. /// </summary>
  260. public ushort TurntableLoc { get; set; }
  261. /// <summary>
  262. /// 机器人任务互锁信号
  263. /// </summary>
  264. public bool RobotTaskInterlock { get; set; }
  265. /// <summary>
  266. /// 取碗互锁信号
  267. /// </summary>
  268. public bool TakeBowlInterlock { get; set; }
  269. /// <summary>
  270. /// 取面互锁信号
  271. /// </summary>
  272. public bool TakeNoodleInterlock { get; set; }
  273. /// <summary>
  274. /// 出面中
  275. /// </summary>
  276. public bool OutNoodleing { get; set; }
  277. /// <summary>
  278. /// 允许取面
  279. /// </summary>
  280. public bool AllowTakeNoodle { get; set; }
  281. /// <summary>
  282. /// 转台互锁信号
  283. /// </summary>
  284. public bool TurntableInterlock { get; set; }
  285. /// <summary>
  286. /// 轴空闲互锁
  287. /// </summary>
  288. public bool[] AxisIdleLock { get; set; } = new bool[2] { false, false };
  289. /// <summary>
  290. /// 转台位置轮询
  291. /// </summary>
  292. public List<ushort> TurntableLocLists = new List<ushort>();
  293. /// <summary>
  294. /// 允许运行
  295. /// </summary>
  296. public bool AllowRun { get; set; }
  297. /// <summary>
  298. /// 取面位置队列
  299. /// </summary>
  300. public ConcurrentQueue<OrderLocInfo> RBTakeNoodleTask { get; set; } = new ConcurrentQueue<OrderLocInfo>();
  301. /// <summary>
  302. /// 取浇头任务队列
  303. /// </summary>
  304. public ConcurrentQueue<OrderLocInfo> TakeSoupTask { get; set; } = new ConcurrentQueue<OrderLocInfo>();
  305. /// <summary>
  306. ///取碗任务队列
  307. /// </summary>
  308. public ConcurrentQueue<OrderLocInfo> TakeBowlTask { get; set; } = new ConcurrentQueue<OrderLocInfo>();
  309. /// <summary>
  310. /// 煮面完成任务队列
  311. /// </summary>
  312. public ConcurrentQueue<ushort> CookNoodleCompleteTask { get; set; } = new ConcurrentQueue<ushort>();
  313. #endregion
  314. #region 内部变量 --> 订单ID记录
  315. /// <summary>
  316. /// 煮面口对应的订单ID
  317. /// </summary>
  318. public string[] CookNodelId { get; set; } = new string[6] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, };
  319. /// <summary>
  320. /// 出餐口订单ID
  321. /// </summary>
  322. public string[] OutMealId { get; set; } = new string[3] { string.Empty, string.Empty, string.Empty };
  323. /// <summary>
  324. /// 轴允许倒面 id
  325. /// </summary>
  326. public string[] AxisAllowInvertedNoodleID { get; set; } = new string[2] { string.Empty, string.Empty };
  327. /// <summary>
  328. /// 轴允许倒浇头 id
  329. /// </summary>
  330. public string[] AxisAllowInvertedSoupID { get; set; } = new string[2] { string.Empty, string.Empty };
  331. /// <summary>
  332. /// 浇头加热完成 id
  333. /// </summary>
  334. public string[] SoupHeatCompleteID { get; set; } = new string[2] { string.Empty, string.Empty };
  335. #endregion
  336. }
  337. }