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.

204 lines
8.0 KiB

8 months ago
  1. using System;
  2. namespace Mirle.Component.API.AutomatedGuideVehicleController.Models
  3. {
  4. /// <summary>
  5. /// Enumerate for transaction name
  6. /// </summary>
  7. public enum TransactionName
  8. {
  9. /// <summary>
  10. /// Set mission request
  11. /// </summary>
  12. /// <remarks>2.1.a</remarks>
  13. SetMissionRequest,
  14. /// <summary>
  15. /// Set mission reply
  16. /// </summary>
  17. /// <remarks>2.1.b</remarks>
  18. SetMissionReply,
  19. /// <summary>
  20. /// Set mission result
  21. /// </summary>
  22. /// <remarks>2.1.c</remarks>
  23. SetMissionResult,
  24. /// <summary>
  25. /// set mission ack
  26. /// </summary>
  27. /// <remarks>2.1.d</remarks>
  28. SetMissionAck,
  29. /// <summary>
  30. /// set mission status request
  31. /// </summary>
  32. /// <remarks>2.2.a</remarks>
  33. SetMissionStatusRequest,
  34. /// <summary>
  35. /// Set mission status reply
  36. /// </summary>
  37. /// <remarks>2.2.b</remarks>
  38. SetMissionStatusReply,
  39. /// <summary>
  40. /// Set mission status result
  41. /// </summary>
  42. /// <remarks>2.2.c</remarks>
  43. SetMissionStatusResult,
  44. /// <summary>
  45. /// Set mission status ack
  46. /// </summary>
  47. /// <remarks>2.2.d</remarks>
  48. SetMissionStatusAck,
  49. /// <summary>
  50. /// Set amr list request
  51. /// </summary>
  52. /// <remarks>2.3.a</remarks>
  53. SetAmrListRequest,
  54. /// <summary>
  55. /// Set amr list reply
  56. /// </summary>
  57. /// <remarks>2.3.b</remarks>
  58. SetAmrListReply,
  59. /// <summary>
  60. /// Set amr list result
  61. /// </summary>
  62. /// <remarks>2.3.c</remarks>
  63. SetAmrListResult,
  64. /// <summary>
  65. /// Set amr list ack
  66. /// </summary>
  67. /// <remarks>2.3.d</remarks>
  68. SetAmrListAck,
  69. /// <summary>
  70. /// Set amr health request
  71. /// </summary>
  72. /// <remarks>2.4.a</remarks>
  73. SetAmrHealthRequest,
  74. /// <summary>
  75. /// Set amr health reply
  76. /// </summary>
  77. /// <remarks>2.4.b</remarks>
  78. SetAmrHealthReply,
  79. /// <summary>
  80. /// Set amr health result
  81. /// </summary>
  82. /// <remarks>2.4.c</remarks>
  83. SetAmrHealthResult,
  84. /// <summary>
  85. /// Set amr health ack
  86. /// </summary>
  87. /// <remarks>2.4.d</remarks>
  88. SetAmrHealthAck,
  89. /// <summary>
  90. /// Set amr emergency request
  91. /// </summary>
  92. /// <remarks>2.5.a</remarks>
  93. SetAmrEmergencyRequest,
  94. /// <summary>
  95. /// Set amr emergency reply
  96. /// </summary>
  97. /// <remarks>2.5.b</remarks>
  98. SetAmrEmergencyReply,
  99. /// <summary>
  100. /// Set amr emergency result
  101. /// </summary>
  102. /// <remarks>2.5.c</remarks>
  103. SetAmrEmergencyResult,
  104. /// <summary>
  105. /// Set amr emergency ack
  106. /// </summary>
  107. /// <remarks>2.5.d</remarks>
  108. SetAmrEmergencyAck,
  109. /// <summary>
  110. /// Component fault alert report
  111. /// </summary>
  112. /// <remarks>3.1.alert</remarks>
  113. ComponentFaultAlert,
  114. /// <summary>
  115. /// Heartbeat report
  116. /// </summary>
  117. /// <remarks>3.2.Heartbeat</remarks>
  118. Heartbeat,
  119. /// <summary>
  120. /// System status report
  121. /// </summary>
  122. /// <remarks>3.3.Online</remarks>
  123. Online
  124. }
  125. /// <summary>
  126. /// Class for transaction name extension apporach
  127. /// </summary>
  128. public static class TransactionNameExtension
  129. {
  130. /// <summary>
  131. /// Convert to web application programming interface url
  132. /// </summary>
  133. /// <param name="transactionName">Enumerate fro transaction name</param>
  134. /// <returns>Web application programming interface url</returns>
  135. /// <exception cref="ArgumentException"></exception>
  136. public static string ToUrl(this TransactionName transactionName)
  137. {
  138. return transactionName switch
  139. {
  140. TransactionName.SetMissionRequest => "awd/rms/set_mission_request",
  141. TransactionName.SetMissionReply => "awd/rms/set_mission_reply",
  142. TransactionName.SetMissionResult => "awd/rms/set_mission_result",
  143. TransactionName.SetMissionAck => "awd/rms/set_mission_ack",
  144. TransactionName.SetMissionStatusRequest => "awd/rms/set_mission_status_request",
  145. TransactionName.SetMissionStatusReply => "awd/rms/set_mission_status_reply",
  146. TransactionName.SetMissionStatusResult => "awd/rms/set_mission_status_result",
  147. TransactionName.SetMissionStatusAck => "awd/rms/set_mission_status_ack",
  148. TransactionName.SetAmrListRequest => "awd/rms/set_amr_list_request",
  149. TransactionName.SetAmrListReply => "awd/rms/set_amr_list_reply",
  150. TransactionName.SetAmrListResult => "awd/rms/set_amr_list_result",
  151. TransactionName.SetAmrListAck => "awd/rms/set_amr_list_ack",
  152. TransactionName.SetAmrHealthRequest => "awd/rms/set_amr_health_request",
  153. TransactionName.SetAmrHealthReply => "awd/rms/set_amr_health_reply",
  154. TransactionName.SetAmrHealthResult => "awd/rms/set_amr_health_result",
  155. TransactionName.SetAmrHealthAck => "awd/rms/set_amr_health_ack",
  156. TransactionName.SetAmrEmergencyRequest => "awd/rms/set_amr_emergency_request",
  157. TransactionName.SetAmrEmergencyReply => "awd/rms/set_amr_emergency_reply",
  158. TransactionName.SetAmrEmergencyResult => "awd/rms/set_amr_emergency_result",
  159. TransactionName.SetAmrEmergencyAck => "awd/rms/set_amr_emergency_ack",
  160. TransactionName.ComponentFaultAlert => "awd/rms/component_fault_alert",
  161. TransactionName.Heartbeat => "awd/rms/heartbeat",
  162. TransactionName.Online => "awd/rms/online",
  163. _ => throw new ArgumentException($"Transaction name unknown by {transactionName}")
  164. };
  165. }
  166. /// <summary>
  167. /// Convert to transaction identify number
  168. /// </summary>
  169. /// <param name="transactionName">Enumerate for transaction name</param>
  170. /// <returns>Transaction identify number</returns>
  171. /// <exception cref="ArgumentException"></exception>
  172. public static string ToTransactionName(this TransactionName transactionName)
  173. {
  174. return transactionName switch
  175. {
  176. TransactionName.SetMissionRequest => "2.1.a",
  177. TransactionName.SetMissionReply => "2.1.b",
  178. TransactionName.SetMissionResult => "2.1.c",
  179. TransactionName.SetMissionAck => "2.1.d",
  180. TransactionName.SetMissionStatusRequest => "2.2.a",
  181. TransactionName.SetMissionStatusReply => "2.2.b",
  182. TransactionName.SetMissionStatusResult => "2.2.c",
  183. TransactionName.SetMissionStatusAck => "2.2.d",
  184. TransactionName.SetAmrListRequest => "2.3.a",
  185. TransactionName.SetAmrListReply => "2.3.b",
  186. TransactionName.SetAmrListResult => "2.3.c",
  187. TransactionName.SetAmrListAck => "2.3.d",
  188. TransactionName.SetAmrHealthRequest => "2.4.a",
  189. TransactionName.SetAmrHealthReply => "2.4.b",
  190. TransactionName.SetAmrHealthResult => "2.4.c",
  191. TransactionName.SetAmrHealthAck => "2.4.d",
  192. TransactionName.SetAmrEmergencyRequest => "2.5.a",
  193. TransactionName.SetAmrEmergencyReply => "2.5.b",
  194. TransactionName.SetAmrEmergencyResult => "2.5.c",
  195. TransactionName.SetAmrEmergencyAck => "2.5.d",
  196. TransactionName.ComponentFaultAlert => "3.1.alert",
  197. TransactionName.Heartbeat => "3.2.Heartbeat",
  198. TransactionName.Online => "3.3.Online",
  199. _ => throw new ArgumentException($"Transaction name unknown by {transactionName}")
  200. };
  201. }
  202. }
  203. }