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.

167 lines
5.7 KiB

8 months ago
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.Text.Json.Serialization;
  4. namespace Mirle.Component.API.AutomatedGuideVehicleController.Models
  5. {
  6. /// <summary>
  7. /// 詢問車況請求類別
  8. /// </summary>
  9. public class SetAmrHealthRequestDto : CommonMessage
  10. {
  11. /// <summary>
  12. /// AMR名稱或車號
  13. /// </summary>
  14. [Required, JsonPropertyName("amr"), JsonPropertyOrder(101)]
  15. public string Amr { get; set; }
  16. /// <summary>
  17. /// 取得詢問車況請求
  18. /// </summary>
  19. /// <param name="protocolVersion">通訊協議版本</param>
  20. /// <param name="sequence">訊息流水號</param>
  21. /// <param name="priority">訊息優先權</param>
  22. /// <param name="amr">AMR名稱或車號</param>
  23. /// <returns>詢問車況請求</returns>
  24. public static SetAmrHealthRequestDto Get(string protocolVersion, string sequence, string priority, string amr)
  25. {
  26. return new SetAmrHealthRequestDto()
  27. {
  28. ProtocolVersion = protocolVersion,
  29. Sequence = sequence,
  30. Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
  31. Priority = priority,
  32. Amr = amr
  33. };
  34. }
  35. }
  36. /// <summary>
  37. /// 詢問車況回應類別
  38. /// </summary>
  39. public class SetAmrHealthReplyDto : CommonMessage
  40. {
  41. /// <summary>
  42. /// 指令確認結果
  43. /// </summary>
  44. /// <value>
  45. /// ACK <br/>
  46. /// NG <br/>
  47. /// </value>
  48. [Required, StringLength(3), JsonPropertyName("reply"), JsonPropertyOrder(101)]
  49. public string Reply { get; set; }
  50. /// <summary>
  51. /// 失敗理由
  52. /// </summary>
  53. [StringLength(255), JsonPropertyName("reason"), JsonPropertyOrder(102)]
  54. public string Reason { get; set; }
  55. /// <summary>
  56. /// 取得詢問車況回應
  57. /// </summary>
  58. /// <param name="protocolVersion">通訊協議版本</param>
  59. /// <param name="sequence">訊息流水號</param>
  60. /// <param name="priority">訊息優先權</param>
  61. /// <param name="reply">回應結果</param>
  62. /// <param name="reason">失敗原因</param>
  63. /// <returns>詢問車況回應</returns>
  64. /// <remarks>reply : true = ACK, false = NG</remarks>
  65. public static SetAmrHealthReplyDto Get(string protocolVersion, string sequence, string priority, bool reply, string reason = "NA")
  66. {
  67. return new SetAmrHealthReplyDto()
  68. {
  69. ProtocolVersion = protocolVersion,
  70. Sequence = sequence,
  71. Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
  72. Priority = priority,
  73. Reply = reply ? "ACK" : "NG",
  74. Reason = reason
  75. };
  76. }
  77. }
  78. /// <summary>
  79. /// 詢問車輛狀況回報類別
  80. /// </summary>
  81. public class SetAmrHealthResultDto : CommonMessage
  82. {
  83. /// <summary>
  84. /// AMR名稱或車號
  85. /// </summary>
  86. [Required, JsonPropertyName("amr"), JsonPropertyOrder(101)]
  87. public string Amr { get; set; }
  88. /// <summary>
  89. /// 健康情報
  90. /// </summary>
  91. [JsonPropertyName("health"), JsonPropertyOrder(102)]
  92. public Health Health { get; set; }
  93. }
  94. /// <summary>
  95. /// 車輛健康狀況類別
  96. /// </summary>
  97. public class Health
  98. {
  99. /// <summary>
  100. /// 運動狀態
  101. /// </summary>
  102. /// <value>
  103. /// running <br/>
  104. /// collision stop <br/>
  105. /// avoidance stop <br/>
  106. /// pause stop <br/>
  107. /// charging stop <br/>
  108. /// working stop <br/>
  109. /// standby stop <br/>
  110. /// </value>
  111. [StringLength(13), JsonPropertyName("motion")]
  112. public string Motion { get; set; }
  113. /// <summary>
  114. /// 電池電量資訊 (%)
  115. /// </summary>
  116. [StringLength(4), JsonPropertyName("battery_level")]
  117. public string BatteryLevel { get; set; }
  118. /// <summary>
  119. /// 電池電壓資訊 (V)
  120. /// </summary>
  121. [StringLength(4), JsonPropertyName("battery_voltage")]
  122. public string BatteryVoltage { get; set; }
  123. /// <summary>
  124. /// 車輛行進速度 (m/s)
  125. /// </summary>
  126. [StringLength(3), JsonPropertyName("velocity")]
  127. public string Velocity { get; set; }
  128. /// <summary>
  129. /// 車輛行走公里數 (m)
  130. /// </summary>
  131. [StringLength(5), JsonPropertyName("odometry")]
  132. public string Odometry { get; set; }
  133. }
  134. /// <summary>
  135. /// 詢問車輛狀況回應類別
  136. /// </summary>
  137. public class SetAmrHealthAckDto : CommonMessage
  138. {
  139. /// <summary>
  140. /// 回應
  141. /// </summary>
  142. /// <value>
  143. /// OK
  144. /// </value>
  145. [Required, StringLength(2), JsonPropertyName("ack"), JsonPropertyOrder(101)]
  146. public string Ack { get; set; }
  147. /// <summary>
  148. /// 取得詢問車輛狀況回應
  149. /// </summary>
  150. /// <param name="protocolVersion">通訊協議版本</param>
  151. /// <param name="sequence">訊息流水號</param>
  152. /// <param name="priority">訊息優先權</param>
  153. /// <returns>詢問車輛狀況回應</returns>
  154. public static SetAmrHealthAckDto Get(string protocolVersion, string sequence, string priority)
  155. {
  156. return new SetAmrHealthAckDto()
  157. {
  158. ProtocolVersion = protocolVersion,
  159. Sequence = sequence,
  160. Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
  161. Priority = priority,
  162. Ack = "OK"
  163. };
  164. }
  165. }
  166. }