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.

378 lines
15 KiB

8 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Mirle.Component.API.ShuttleCarController.Models
  4. {
  5. /// <summary>
  6. /// Shuttle message extensions
  7. /// </summary>
  8. public static class WrapperMessageExtensions
  9. {
  10. /// <summary>
  11. /// Get ID 9012 shuttle car controller online response
  12. /// </summary>
  13. /// <param name="result">Online permit result</param>
  14. /// <returns>Shuttle car controller online response message</returns>
  15. public static WrapperMessage Get_ID_9012_ShuttleCOnlineResponse(bool result)
  16. {
  17. return new WrapperMessage()
  18. {
  19. ID = 12,
  20. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  21. S12 = new S12_ShuttleCOnlineResponse()
  22. {
  23. ReplyCode = result ? 0 : 1
  24. }
  25. };
  26. }
  27. /// <summary>
  28. /// Get ID 9014 Shuttle car controller offline response
  29. /// </summary>
  30. /// <param name="result">Offline permit result</param>
  31. /// <returns>Shuttle car controller offline response message</returns>
  32. public static WrapperMessage Get_ID_9014_ShuttleOfflineResponse(bool result)
  33. {
  34. return new WrapperMessage()
  35. {
  36. ID = 14,
  37. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  38. S14 = new S14_ShuttleCOfflineResponse()
  39. {
  40. ReplyCode = result ? 0 : 1
  41. }
  42. };
  43. }
  44. /// <summary>
  45. /// Get ID 9015 Datetime sync report
  46. /// </summary>
  47. /// <returns>Datetime sync report message</returns>
  48. public static WrapperMessage Get_ID_9015_DateTimeSyncReport()
  49. {
  50. return new WrapperMessage()
  51. {
  52. ID = 15,
  53. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  54. P15 = new P15_DateTimeSyncRequest()
  55. {
  56. SyncDateTime = DateTime.Now.ToString("yyyyMMddHHmmssff")
  57. }
  58. };
  59. }
  60. /// <summary>
  61. /// Get ID 9021 release repair door interlock request
  62. /// </summary>
  63. /// <param name="repairDoorID">Repair door ID</param>
  64. /// <returns>Release repair door interlock request message</returns>
  65. public static WrapperMessage Get_ID_9021_ReleaseRepairDoorInterlockRequest(string repairDoorID)
  66. {
  67. return new WrapperMessage()
  68. {
  69. ID = 21,
  70. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  71. P21 = new P21_ReleaseRepairDoorInterlockRequest()
  72. {
  73. RepairDoorID = repairDoorID
  74. }
  75. };
  76. }
  77. /// <summary>
  78. /// Get ID 9023 cancel release repair door interlock request
  79. /// </summary>
  80. /// <param name="repairDoorID">Repair door ID</param>
  81. /// <returns>Cancel release repair door interlock request message</returns>
  82. public static WrapperMessage Get_ID_9023_CancelReleaseRepairDoorInterlockRequest(string repairDoorID)
  83. {
  84. return new WrapperMessage()
  85. {
  86. ID = 23,
  87. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  88. P23 = new P23_CancelReleaseRepairDoorInterlockRequest()
  89. {
  90. RepairDoorID = repairDoorID
  91. }
  92. };
  93. }
  94. /// <summary>
  95. /// Get ID 9026 release repair door status response
  96. /// </summary>
  97. /// <param name="result">Process result</param>
  98. /// <returns>Release repair door status response message</returns>
  99. public static WrapperMessage Get_ID_9026_ReleaseRepairDoorStatusResponse(bool result)
  100. {
  101. return new WrapperMessage()
  102. {
  103. ID = 26,
  104. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  105. S26 = new S26_RepairDoorReleaseStatusResponse()
  106. {
  107. ReplyCode = result ? 0 : 1
  108. }
  109. };
  110. }
  111. /// <summary>
  112. /// Get ID 9029 repair door interlock status change report
  113. /// </summary>
  114. /// <param name="repairDoorID">Repair door ID</param>
  115. /// <param name="doorStatus">Repair door stauts</param>
  116. /// <param name="doorLockStatus">Repair door lock status</param>
  117. /// <returns>Repair door interlock status change report message</returns>
  118. public static WrapperMessage Get_ID_9029_RepariDoorInterlockStatusChangeReport(string repairDoorID, int doorStatus, int doorLockStatus)
  119. {
  120. return new WrapperMessage()
  121. {
  122. ID = 29,
  123. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  124. P29 = new P29_RepairDoorInterlockStatusChangeReport()
  125. {
  126. RepairDoorID = repairDoorID,
  127. DoorStatus = doorStatus,
  128. DoorLockStatus = doorLockStatus
  129. }
  130. };
  131. }
  132. /// <summary>
  133. /// Get ID 9032 fire door response
  134. /// </summary>
  135. /// <param name="result">Process result</param>
  136. /// <param name="doorID">Rolling door ID</param>
  137. /// <param name="doorAction">Rolling door action</param>
  138. /// <param name="crossingLock">Rolling crossing lock status</param>
  139. /// <returns>Fire door response message</returns>
  140. public static WrapperMessage Get_ID_9032_FireDoorResponse(bool result, string doorID, int doorAction, int crossingLock)
  141. {
  142. return new WrapperMessage()
  143. {
  144. ID = 32,
  145. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  146. S32 = new S32_FireDoorResponse()
  147. {
  148. ReplyCode = result ? 0 : 1,
  149. DoorID = doorID,
  150. DoorAction = doorAction,
  151. DoorLockStateCode = crossingLock
  152. }
  153. };
  154. }
  155. /// <summary>
  156. /// Get ID 9036 query fire door status response
  157. /// </summary>
  158. /// <param name="doorListStatus">Class for door list status</param>
  159. /// <returns>Query fire door status response message</returns>
  160. public static WrapperMessage Get_ID_9036_QueryFireDoorStatusResponse(List<DoorStatus> doorListStatus)
  161. {
  162. WrapperMessage wrapper_message = new WrapperMessage()
  163. {
  164. ID = 36,
  165. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  166. S36 = new S36_QueryFireDoorStatusResponse()
  167. {
  168. }
  169. };
  170. wrapper_message.S36.DoorList.Add(doorListStatus);
  171. return wrapper_message;
  172. }
  173. /// <summary>
  174. /// Get ID 9041 command request message
  175. /// </summary>
  176. /// <param name="commandID">Controller command ID</param>
  177. /// <param name="cmdType">Controller command type</param>
  178. /// <param name="priority">Task priority</param>
  179. /// <param name="source">Source position</param>
  180. /// <param name="destination">Destination position</param>
  181. /// <param name="cassetteID">Cassette ID</param>
  182. /// <param name="cassetteType">Cassette type</param>
  183. /// <param name="vehicleID">Vehicle ID</param>
  184. /// <returns>Command request message</returns>
  185. public static WrapperMessage Get_ID_9041_CommandRequest(string commandID, int cmdType, int priority,
  186. string source, string destination, string cassetteID, int cassetteType, int vehicleID = 0)
  187. {
  188. return new WrapperMessage()
  189. {
  190. ID = 41,
  191. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  192. P41 = new P41_CommandRequest()
  193. {
  194. CmdID = commandID,
  195. CmdType = cmdType,
  196. Priority = priority,
  197. Source = source,
  198. Destination = destination,
  199. CstID = cassetteID,
  200. CstType = cassetteType,
  201. VehicleID = vehicleID
  202. }
  203. };
  204. }
  205. /// <summary>
  206. /// Get ID 9043 command cancel request
  207. /// </summary>
  208. /// <param name="commandID">Controller command ID</param>
  209. /// <returns>Command cancel request message</returns>
  210. public static WrapperMessage Get_ID_9043_CommandCancelRequest(string commandID)
  211. {
  212. return new WrapperMessage()
  213. {
  214. ID = 43,
  215. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  216. P43 = new P43_CancelCommandRequest()
  217. {
  218. CmdID = commandID
  219. }
  220. };
  221. }
  222. /// <summary>
  223. /// Get ID 9045 pause request
  224. /// </summary>
  225. /// <param name="eventType">Event type</param>
  226. /// <param name="pauseType">Pause type</param>
  227. /// <returns>Pause request message</returns>
  228. public static WrapperMessage Get_ID_9045_PauseRequest(PauseEvent eventType, int pauseType)
  229. {
  230. return new WrapperMessage()
  231. {
  232. ID = 45,
  233. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  234. P45 = new P45_PauseRequest()
  235. {
  236. EventType = eventType,
  237. PauseType = pauseType
  238. }
  239. };
  240. }
  241. /// <summary>
  242. /// Get ID 9052 alarm response
  243. /// </summary>
  244. /// <param name="result">Process result</param>
  245. /// <returns>Alarm response message</returns>
  246. public static WrapperMessage Get_ID_9052_AlarmResponse(bool result)
  247. {
  248. return new WrapperMessage()
  249. {
  250. ID = 52,
  251. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  252. S52 = new S52_AlarmResponse()
  253. {
  254. ReplyCode = result ? 0 : 1
  255. }
  256. };
  257. }
  258. /// <summary>
  259. /// Get ID 9062 command status response
  260. /// </summary>
  261. /// <param name="result">Receive and check result</param>
  262. /// <param name="commandID">Controller's command ID</param>
  263. /// <param name="commandStatus">Controller's command status</param>
  264. /// <returns>Command status response message</returns>
  265. public static WrapperMessage Get_ID_9062_CommandStatusResponse(bool result, string commandID, int commandStatus)
  266. {
  267. return new WrapperMessage()
  268. {
  269. ID = 62,
  270. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  271. S62 = new S62_CommandStatusResponse()
  272. {
  273. ReplyCode = result ? 0 : 1,
  274. CmdID = commandID,
  275. CmdStatus = commandStatus
  276. }
  277. };
  278. }
  279. /// <summary>
  280. /// Get ID 9065 query all command status request
  281. /// </summary>
  282. /// <returns>Query all command status request message</returns>
  283. public static WrapperMessage Get_ID_9065_QueryAllCommandStatusRequest()
  284. {
  285. return new WrapperMessage()
  286. {
  287. ID = 65,
  288. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  289. P65 = new P65_QueryAllCOmmandStatusRequest()
  290. {
  291. }
  292. };
  293. }
  294. /// <summary>
  295. /// Get ID 9068 vehicle status response
  296. /// </summary>
  297. /// <param name="result">Process result</param>
  298. /// <returns>Vehicle status response message</returns>
  299. public static WrapperMessage Get_ID_9068_VehicleStatusResponse(bool result)
  300. {
  301. return new WrapperMessage()
  302. {
  303. ID = 68,
  304. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  305. S68 = new S68_VehicleStatusResponse()
  306. {
  307. ReplyCode = result ? 0 : 1
  308. }
  309. };
  310. }
  311. /// <summary>
  312. /// Get ID 9069 query vehicle status request
  313. /// </summary>
  314. /// <param name="queryType">Query type</param>
  315. /// <param name="vehicleID">Vehicle ID</param>
  316. /// <returns>Query vehicle status request message</returns>
  317. public static WrapperMessage Get_ID_9069_QueryVehicleStatusRequest(int queryType, int vehicleID = 0)
  318. {
  319. return new WrapperMessage()
  320. {
  321. ID = 69,
  322. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  323. P69 = new P69_QueryVehicleStatusRequest()
  324. {
  325. QueryType = queryType,
  326. VehicleID = vehicleID
  327. }
  328. };
  329. }
  330. /// <summary>
  331. /// Get ID 9083 Change layer response
  332. /// </summary>
  333. /// <param name="commandID">Shuttle car controller command ID</param>
  334. /// <param name="source">Source floor</param>
  335. /// <param name="destination">Destination floor</param>
  336. /// <param name="lifterID">Lifter ID</param>
  337. /// <param name="result">Process result</param>
  338. /// <returns>Change layer response message</returns>
  339. public static WrapperMessage Get_ID_9084_ChangeLayerResponse(string commandID, int source, int destination, int lifterID, bool result)
  340. {
  341. return new WrapperMessage()
  342. {
  343. ID = 84,
  344. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  345. S84 = new S84_ChangeLayerResponse()
  346. {
  347. CmdID = commandID,
  348. SourceLayer = source,
  349. DestinationLayer = destination,
  350. LifterID = lifterID,
  351. ReplyCode = result ? 0 : 1
  352. }
  353. };
  354. }
  355. /// <summary>
  356. /// Get ID 9091 lifter arrival report
  357. /// </summary>
  358. /// <param name="lifterID">Lifter ID</param>
  359. /// <param name="lifterLocation">Lifter current floor</param>
  360. /// <returns>Lifter arrival report message</returns>
  361. public static WrapperMessage Get_ID_9091_LifterArrivalReport(int lifterID, int lifterLocation)
  362. {
  363. return new WrapperMessage()
  364. {
  365. ID = 91,
  366. LocalSystemTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
  367. P91 = new P91_LifterArrivalReport()
  368. {
  369. LifterID = lifterID,
  370. LifterLocation = lifterLocation
  371. }
  372. };
  373. }
  374. }
  375. }