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.

296 lines
6.7 KiB

8 months ago
  1. using System;
  2. using System.Text.Json.Serialization;
  3. namespace Mirle.Component.API.WarehouseExecutionSystem.Models
  4. {
  5. /// <summary>
  6. /// 回應代碼
  7. /// </summary>
  8. public enum ReplyCode
  9. {
  10. /// <summary>
  11. /// 成功
  12. /// </summary>
  13. OK,
  14. /// <summary>
  15. /// 失敗
  16. /// </summary>
  17. NG
  18. }
  19. #region === [Mode] ===
  20. /// <summary>
  21. /// 搬運命令模式
  22. /// </summary>
  23. public enum CommandMode
  24. {
  25. /// <summary>
  26. /// 入庫
  27. /// </summary>
  28. StoreIn,
  29. /// <summary>
  30. /// 出庫
  31. /// </summary>
  32. StoreOut,
  33. /// <summary>
  34. /// 撿料/盤點
  35. /// </summary>
  36. TaskInventory,
  37. /// <summary>
  38. /// 站對站
  39. /// </summary>
  40. StationToStaion,
  41. /// <summary>
  42. /// 庫對庫
  43. /// </summary>
  44. StorageToStorage,
  45. /// <summary>
  46. /// 盤點作業
  47. /// </summary>
  48. TakeInventoryOperation,
  49. /// <summary>
  50. /// 盤點調帳
  51. /// </summary>
  52. TaskInventoryAdjust,
  53. /// <summary>
  54. /// 儲位維護
  55. /// </summary>
  56. MaintenanceLoc
  57. }
  58. /// <summary>
  59. /// 取消命令模式
  60. /// </summary>
  61. public enum CancelMode
  62. {
  63. /// <summary>
  64. /// 取消
  65. /// </summary>
  66. Cancel,
  67. /// <summary>
  68. /// 強制取消
  69. /// </summary>
  70. ForceCancel,
  71. /// <summary>
  72. /// 強制完成
  73. /// </summary>
  74. ForceComplete
  75. }
  76. #endregion
  77. #region === [Status] ===
  78. /// <summary>
  79. /// 命令完成狀態
  80. /// </summary>
  81. public enum CommandCompleteStatus
  82. {
  83. /// <summary>
  84. /// 成功
  85. /// </summary>
  86. Complete,
  87. /// <summary>
  88. /// 強制完成
  89. /// </summary>
  90. ForceComplete,
  91. /// <summary>
  92. /// 強制取消
  93. /// </summary>
  94. ForceCancel,
  95. /// <summary>
  96. /// 失敗
  97. /// </summary>
  98. Failed
  99. }
  100. /// <summary>
  101. /// 棧板供應狀態
  102. /// </summary>
  103. public enum PalletSupplyStatus
  104. {
  105. /// <summary>
  106. /// 滿載
  107. /// </summary>
  108. Full,
  109. /// <summary>
  110. /// 空載
  111. /// </summary>
  112. Empty
  113. }
  114. #endregion
  115. #region === [Event] ===
  116. /// <summary>
  117. /// 緊急事件類別
  118. /// </summary>
  119. public enum EmergencyEvent
  120. {
  121. /// <summary>
  122. /// 地震
  123. /// </summary>
  124. Earthquake,
  125. /// <summary>
  126. /// 消防
  127. /// </summary>
  128. Fire
  129. }
  130. #endregion
  131. #region === [Result Code] ===
  132. /// <summary>
  133. /// 建立命令結果
  134. /// </summary>
  135. public enum CreateCommandResultCode
  136. {
  137. /// <summary>
  138. /// 成功
  139. /// </summary>
  140. Success,
  141. /// <summary>
  142. /// 拒絕
  143. /// </summary>
  144. Reject,
  145. /// <summary>
  146. /// 拆解命令錯誤
  147. /// </summary>
  148. DismantleCommandError
  149. }
  150. /// <summary>
  151. /// 取消結果代碼
  152. /// </summary>
  153. public enum CancelCommandResultCode
  154. {
  155. /// <summary>
  156. /// 成功
  157. /// </summary>
  158. Success,
  159. /// <summary>
  160. /// 搬運命令已經執行
  161. /// </summary>
  162. AlreadyExecute,
  163. /// <summary>
  164. /// 取消命令錯誤
  165. /// </summary>
  166. CancelCommandError,
  167. /// <summary>
  168. /// PLC-C 拒絕取消命令
  169. /// </summary>
  170. PLCCRejectCancel,
  171. /// <summary>
  172. /// AGV-C 拒絕取消命令
  173. /// </summary>
  174. AGVCRejectCancel,
  175. /// <summary>
  176. /// SH-C 拒絕取消命令
  177. /// </summary>
  178. SHTCRejectCancel,
  179. /// <summary>
  180. /// 搬運命令序號不存在
  181. /// </summary>
  182. CommandSequenceNumberIsNotExist
  183. }
  184. /// <summary>
  185. /// 檢查載具編號及物料編號結果
  186. /// </summary>
  187. public enum CarrierIDInsepectResultCode
  188. {
  189. /// <summary>
  190. /// 成功
  191. /// </summary>
  192. Success,
  193. /// <summary>
  194. /// 載具編號錯誤
  195. /// </summary>
  196. CarrierIDError,
  197. /// <summary>
  198. /// 物料編號錯誤
  199. /// </summary>
  200. MaterialIDError
  201. }
  202. /// <summary>
  203. /// 物料檢測結果
  204. /// </summary>
  205. public enum MaterialInspectResultCode
  206. {
  207. /// <summary>
  208. /// 成功
  209. /// </summary>
  210. Success,
  211. /// <summary>
  212. /// 過輕
  213. /// </summary>
  214. TooLight,
  215. /// <summary>
  216. /// 過重
  217. /// </summary>
  218. TooHeavy,
  219. /// <summary>
  220. /// 沒有重量
  221. /// </summary>
  222. NoWeight
  223. }
  224. /// <summary>
  225. /// 緊急事件結果
  226. /// </summary>
  227. public enum EmergencyEventResultCode
  228. {
  229. /// <summary>
  230. /// 成功
  231. /// </summary>
  232. Success,
  233. /// <summary>
  234. /// 失敗
  235. /// </summary>
  236. Failed
  237. }
  238. #endregion
  239. /// <summary>
  240. /// 訊息擴充方法類別
  241. /// </summary>
  242. public static class MessageExtension
  243. {
  244. /// <summary>
  245. /// 轉換成任務模式
  246. /// </summary>
  247. /// <param name="commandMode">搬運命令模式</param>
  248. /// <returns>任務模式</returns>
  249. /// <exception cref="ArgumentException">未定義列舉項目</exception>
  250. public static int ToTaskMode(this CommandMode commandMode)
  251. {
  252. return (commandMode) switch
  253. {
  254. CommandMode.StoreIn => 1,
  255. CommandMode.StoreOut => 2,
  256. CommandMode.TaskInventory => 3,
  257. CommandMode.StationToStaion => 4,
  258. CommandMode.StorageToStorage => 5,
  259. CommandMode.TakeInventoryOperation => 6,
  260. CommandMode.TaskInventoryAdjust => 7,
  261. CommandMode.MaintenanceLoc => 8,
  262. _ => throw new ArgumentException($"Unknown command mode {commandMode}")
  263. };
  264. }
  265. /// <summary>
  266. /// 轉換成任務狀態
  267. /// </summary>
  268. /// <param name="cancelMode">取消模式列舉</param>
  269. /// <returns>任務狀態</returns>
  270. /// <exception cref="ArgumentException">未定義列舉項目</exception>
  271. public static int ToTaskStatus(this CancelMode cancelMode)
  272. {
  273. return (cancelMode) switch
  274. {
  275. CancelMode.ForceComplete => 5,
  276. CancelMode.Cancel => 7,
  277. CancelMode.ForceCancel => 8,
  278. _ => throw new ArgumentException($"Unknown cancel mode {cancelMode}")
  279. };
  280. }
  281. }
  282. }