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.

191 lines
7.0 KiB

8 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.Text.Json.Serialization;
  5. namespace Mirle.Component.API.AutomatedGuideVehicleController.Models
  6. {
  7. /// <summary>
  8. /// Class for set mission request
  9. /// </summary>
  10. public class SetMissionRequestDto : CommonMessage
  11. {
  12. /// <summary>
  13. /// Constructure
  14. /// </summary>
  15. public SetMissionRequestDto()
  16. {
  17. SubMissions = new List<SubMission>();
  18. }
  19. /// <summary>
  20. /// Sub mission list
  21. /// </summary>
  22. [Required, JsonPropertyName("sub_missions"), JsonPropertyOrder(101)]
  23. public List<SubMission> SubMissions { get; set; }
  24. /// <summary>
  25. /// Get set mission request data object
  26. /// </summary>
  27. /// <param name="protocolVersion">Auotmated guide vehicle controller protocol version</param>
  28. /// <param name="sequence">Message sequnce number</param>
  29. /// <param name="priority">Message priority</param>
  30. /// <param name="subMission">Sub mission list</param>
  31. /// <returns>Set mission request data object</returns>
  32. public static SetMissionRequestDto Get(string protocolVersion, string sequence, string priority, List<SubMission> subMission)
  33. {
  34. return new SetMissionRequestDto
  35. {
  36. ProtocolVersion = protocolVersion,
  37. Sequence = sequence,
  38. Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
  39. Priority = priority,
  40. SubMissions = subMission
  41. };
  42. }
  43. }
  44. /// <summary>
  45. /// Class for sub mission
  46. /// </summary>
  47. public class SubMission
  48. {
  49. /// <summary>
  50. /// Space is meaning port or station
  51. /// </summary>
  52. [Required, StringLength(9), JsonPropertyName("space"), JsonPropertyOrder(1)]
  53. public string Space { get; set; }
  54. /// <summary>
  55. /// Current equipment completed executd action or will be execute action
  56. /// </summary>
  57. /// <value>
  58. /// load <br/>
  59. /// unload <br/>
  60. /// idle <br/>
  61. /// ask-open-gate <br/>
  62. /// read-code <br/>
  63. /// ack-close-gate <br/>
  64. /// </value>
  65. [Required, StringLength(20), JsonPropertyName("action"), JsonPropertyOrder(2)]
  66. public string Action { get; set; }
  67. }
  68. /// <summary>
  69. /// Get set mission reply data object
  70. /// </summary>
  71. public class SetMissionReplyDto : CommonMessage
  72. {
  73. /// <summary>
  74. /// Code of reply
  75. /// </summary>
  76. /// <value>
  77. /// ACK <br/>
  78. /// NG <br/>
  79. /// </value>
  80. [Required, StringLength(3), JsonPropertyName("reply"), JsonPropertyOrder(101)]
  81. public string Reply { get; set; }
  82. /// <summary>
  83. /// Failed reason when reply is NG
  84. /// </summary>
  85. [StringLength(255), JsonPropertyName("reason"), JsonPropertyOrder(102)]
  86. public string Reason { get; set; }
  87. /// <summary>
  88. /// Get set mission reply data object
  89. /// </summary>
  90. /// <param name="protocolVersion">Automated guide vehicle controller protocol version</param>
  91. /// <param name="sequence">Message sequnce number</param>
  92. /// <param name="priority">Message priority</param>
  93. /// <param name="reply">Process result</param>
  94. /// <param name="reason">Failed reason</param>
  95. /// <returns>Set mission reply data object</returns>
  96. /// <remarks>reply : true = ACK, false = NG</remarks>
  97. public static SetMissionReplyDto Get(string protocolVersion, string sequence, string priority, bool reply, string reason = "NA")
  98. {
  99. return new SetMissionReplyDto()
  100. {
  101. ProtocolVersion = protocolVersion,
  102. Sequence = sequence,
  103. Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
  104. Priority = priority,
  105. Reply = reply ? "ACK" : "NG",
  106. Reason = reason
  107. };
  108. }
  109. }
  110. /// <summary>
  111. /// Class for set mission result
  112. /// </summary>
  113. public class SetMissionResultDto : CommonMessage
  114. {
  115. /// <summary>
  116. /// AMR identify number of executing task/mission
  117. /// </summary>
  118. [Required, StringLength(10), JsonPropertyName("amr"), JsonPropertyOrder(101)]
  119. public string AMR { get; set; }
  120. /// <summary>
  121. /// Space is meaning port/station
  122. /// </summary>
  123. [Required, StringLength(9), JsonPropertyName("space"), JsonPropertyOrder(102)]
  124. public string Space { get; set; }
  125. /// <summary>
  126. /// Current equipment completed executd action or will be execute action
  127. /// </summary>
  128. /// <value>
  129. /// load <br/>
  130. /// unload <br/>
  131. /// idle <br/>
  132. /// ask-open-gate <br/>
  133. /// read-code <br/>
  134. /// ack-close-gate <br/>
  135. /// </value>
  136. [Required, StringLength(20), JsonPropertyName("action"), JsonPropertyOrder(103)]
  137. public string Action { get; set; }
  138. /// <summary>
  139. /// Permit equipment execute action or recevie equipment executed action
  140. /// </summary>
  141. /// <value>
  142. /// OK <br/>
  143. /// NG <br/>
  144. /// Cancel-by-user <br/>
  145. /// OK-by-user <br/>
  146. /// </value>
  147. [Required, StringLength(14), JsonPropertyName("result"), JsonPropertyOrder(104)]
  148. public string Result { get; set; }
  149. /// <summary>
  150. /// Failed reason when result is NG/Cancel-by-user
  151. /// </summary>
  152. [StringLength(255), JsonPropertyName("reason"), JsonPropertyOrder(105)]
  153. public string Reason { get; set; }
  154. }
  155. /// <summary>
  156. /// Class for set mission ack
  157. /// </summary>
  158. public class SetMissionAckDto : CommonMessage
  159. {
  160. /// <summary>
  161. /// Ack of message
  162. /// </summary>
  163. /// <value>
  164. /// OK <br/>
  165. /// NG <br/>
  166. /// </value>
  167. [Required, StringLength(2), JsonPropertyName("ack"), JsonPropertyOrder(101)]
  168. public string Ack { get; set; }
  169. /// <summary>
  170. /// Get set mission ack data object
  171. /// </summary>
  172. /// <param name="protocolVersion">Automated guide vehicle ccontroller protocol version</param>
  173. /// <param name="sequence">Message sequnce number</param>
  174. /// <param name="priority">Message priority</param>
  175. /// <param name="ack">Process result</param>
  176. /// <returns>Set mission ack data object</returns>
  177. /// <remarks>ack : true = OK, false = NG</remarks>
  178. public static SetMissionAckDto Get(string protocolVersion, string sequence, string priority, bool ack)
  179. {
  180. return new SetMissionAckDto()
  181. {
  182. ProtocolVersion = protocolVersion,
  183. Sequence = sequence,
  184. Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
  185. Priority = priority,
  186. Ack = ack ? "OK" : "NG"
  187. };
  188. }
  189. }
  190. }