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

219 regels
6.7 KiB

  1. using BPA.Helper;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace BPASmartClient.MorkCL.Model.Control
  8. {
  9. internal class RobotSet : RobotGet
  10. {
  11. /// <summary>
  12. /// 机器人任务控制
  13. /// </summary>
  14. /// <param name="MainTask"></param>
  15. /// <param name="SubTask"></param>
  16. public void RobotTaskControl(string MainTask, EDeviceType SubTask)
  17. {
  18. if (MyModbus is null || !MyModbus.IsConnected())
  19. {
  20. return;
  21. }
  22. if (ushort.TryParse(MainTask, out ushort mainTask))
  23. if (mainTask >= 0 && mainTask <= 24)
  24. {
  25. IsIdle.Wait();
  26. MyModbus.Write("GI1".ToModbusAdd(), (ushort)SubTask);
  27. MyModbus.Write("GI0".ToModbusAdd(), mainTask);
  28. }
  29. }
  30. /// <summary>
  31. /// 入库控制
  32. /// </summary>
  33. /// <param name="Loc"></param>
  34. public void WarehousingControl(string Loc,CancellationTokenSource Cts)
  35. {
  36. if (MyModbus is null || !MyModbus.IsConnected())
  37. {
  38. return;
  39. }
  40. if (ushort.TryParse(Loc, out ushort loc))
  41. {
  42. if (loc >= 1 && loc <= 12)
  43. {
  44. IsIdle.Wait(Cts: Cts);
  45. MyModbus.Write("GI0".ToModbusAdd(), (ushort)(loc + 29));
  46. }
  47. }
  48. }
  49. /// <summary>
  50. /// 去夹爪清洗维护位。
  51. /// </summary>
  52. /// <param name="Cts"></param>
  53. public void GoCleanLoc(CancellationTokenSource Cts = null)
  54. {
  55. if (MyModbus is null || !MyModbus.IsConnected())
  56. {
  57. return;
  58. }
  59. IsIdle.Wait(Cts: Cts);
  60. MyModbus.Write("GI0".ToModbusAdd(), 45);
  61. }
  62. /// <summary>
  63. /// 发送清洗完成。
  64. /// </summary>
  65. /// <param name="Cts"></param>
  66. public bool SendCleanFinish(CancellationTokenSource Cts = null)
  67. {
  68. if (MyModbus is null || !MyModbus.IsConnected())
  69. {
  70. return false;
  71. }
  72. //IsIdle.Wait(Cts: Cts);
  73. return MyModbus.Write("GM550".ToModbusAdd(), true).IsSuccess;
  74. }
  75. /// <summary>
  76. /// 机器人到位允许倒菜到炒锅
  77. /// </summary>
  78. /// <param name="num">炒锅类型</param>
  79. public void AllowPourVegetables(EDeviceType num)
  80. {
  81. if (MyModbus is null || !MyModbus.IsConnected())
  82. {
  83. return;
  84. }
  85. switch (num)
  86. {
  87. case EDeviceType.炒锅1:
  88. MyModbus.Write("GM500".ToModbusAdd(), true);
  89. break;
  90. case EDeviceType.炒锅2:
  91. MyModbus.Write("GM501".ToModbusAdd(), true);
  92. break;
  93. case EDeviceType.压力锅:
  94. MyModbus.Write("GM502".ToModbusAdd(), true);
  95. break;
  96. default:
  97. break;
  98. }
  99. }
  100. /// <summary>
  101. /// 禁止机器人倒菜到炒锅。
  102. /// </summary>
  103. /// <param name="num">炒锅类型</param>
  104. public void DisablePourVegetables(EDeviceType num)
  105. {
  106. if (MyModbus is null || !MyModbus.IsConnected())
  107. {
  108. return;
  109. }
  110. switch (num)
  111. {
  112. case EDeviceType.炒锅1:
  113. MyModbus.Write("GM500".ToModbusAdd(), false);
  114. break;
  115. case EDeviceType.炒锅2:
  116. MyModbus.Write("GM501".ToModbusAdd(), false);
  117. break;
  118. case EDeviceType.压力锅:
  119. MyModbus.Write("GM502".ToModbusAdd(), false);
  120. break;
  121. default:
  122. break;
  123. }
  124. }
  125. /// <summary>
  126. /// 出餐减速到位
  127. /// </summary>
  128. /// <param name="num">炒锅类型</param>
  129. public void ModerateInPlace(EDeviceType num)
  130. {
  131. if (MyModbus is null || !MyModbus.IsConnected())
  132. {
  133. return;
  134. }
  135. switch (num)
  136. {
  137. case EDeviceType.炒锅1:
  138. MyModbus.Write("GM503".ToModbusAdd(), true);
  139. break;
  140. case EDeviceType.炒锅2:
  141. MyModbus.Write("GM505".ToModbusAdd(), true);
  142. break;
  143. case EDeviceType.压力锅:
  144. MyModbus.Write("GM507".ToModbusAdd(), true);
  145. break;
  146. default:
  147. break;
  148. }
  149. }
  150. /// <summary>
  151. /// 出餐倒菜完成
  152. /// </summary>
  153. /// <param name="num">炒锅类型</param>
  154. public void DiningOutComplete(EDeviceType num)
  155. {
  156. if (MyModbus is null || !MyModbus.IsConnected())
  157. {
  158. return;
  159. }
  160. switch (num)
  161. {
  162. case EDeviceType.炒锅1:
  163. MyModbus.Write("GM504".ToModbusAdd(), true);
  164. break;
  165. case EDeviceType.炒锅2:
  166. MyModbus.Write("GM506".ToModbusAdd(), true);
  167. break;
  168. case EDeviceType.压力锅:
  169. MyModbus.Write("GM508".ToModbusAdd(), true);
  170. break;
  171. default:
  172. break;
  173. }
  174. }
  175. /// <summary>
  176. /// 设置远程启动(暂停后也可以启动) M702
  177. /// </summary>
  178. public bool RobotStart
  179. {
  180. get { return MyModbus.Read<bool>("GM702".ToModbusAdd()).Content; }
  181. set { MyModbus.Write("GM702".ToModbusAdd(), value); }
  182. }
  183. /// <summary>
  184. /// 设置远程暂停 M703
  185. /// </summary>
  186. public bool RobotSuspend
  187. {
  188. get { return MyModbus.Read<bool>("GM703".ToModbusAdd()).Content; }
  189. set { MyModbus.Write("GM703".ToModbusAdd(), value); }
  190. }
  191. /// <summary>
  192. /// 设置使能 M700
  193. /// </summary>
  194. public bool RobotEnable
  195. {
  196. get { return MyModbus.Read<bool>("GM700".ToModbusAdd()).Content; }
  197. set { MyModbus.Write("GM700".ToModbusAdd(), value); }
  198. }
  199. /// <summary>
  200. /// 机器人复位
  201. /// </summary>
  202. public bool RobotReset
  203. {
  204. get { return MyModbus.Read<bool>("GM701".ToModbusAdd()).Content; }
  205. set { MyModbus.Write("GM701".ToModbusAdd(), value); }
  206. }
  207. }
  208. }