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.

150 lines
5.2 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. /// <remarks>2.5.a</remarks>
  10. public class SetAmrEmergencyRequestDto : CommonMessage
  11. {
  12. /// <summary>
  13. /// 緊急事件種類
  14. /// </summary>
  15. /// <value>
  16. /// earthquake <br/>
  17. /// fire <br/>
  18. /// </value>
  19. [Required, StringLength(10), JsonPropertyName("event"), JsonPropertyOrder(101)]
  20. public string Event { get; set; }
  21. /// <summary>
  22. /// 取得緊急狀況請求
  23. /// </summary>
  24. /// <param name="protocolVersion">通訊協議版本</param>
  25. /// <param name="sequence">訊息流水號</param>
  26. /// <param name="priority">訊息優先權</param>
  27. /// <param name="event">緊急事件</param>
  28. /// <returns>緊急狀況請求</returns>
  29. /// <remarks>
  30. /// @event : 0 = earthquake, 1 = fire
  31. /// </remarks>
  32. public static SetAmrEmergencyRequestDto Get(string protocolVersion, string sequence, string priority, int @event)
  33. {
  34. return new SetAmrEmergencyRequestDto()
  35. {
  36. ProtocolVersion = protocolVersion,
  37. Sequence = sequence,
  38. Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
  39. Priority = priority,
  40. Event = @event == 1 ? "earthquake" : "fire"
  41. };
  42. }
  43. }
  44. /// <summary>
  45. /// 緊急狀況回應類別
  46. /// </summary>
  47. /// <remarks>2.5.b</remarks>
  48. public class SetAmrEmergencyReplyDto : CommonMessage
  49. {
  50. /// <summary>
  51. /// 指令確認結果
  52. /// </summary>
  53. /// <value>
  54. /// ACK <br/>
  55. /// NG <br/>
  56. /// </value>
  57. [Required, StringLength(3), JsonPropertyName("reply"), JsonPropertyOrder(101)]
  58. public string Reply { get; set; }
  59. /// <summary>
  60. /// 失敗理由
  61. /// </summary>
  62. [StringLength(255), JsonPropertyName("reason"), JsonPropertyOrder(102)]
  63. public string Reason { get; set; }
  64. /// <summary>
  65. /// 取得緊急狀況回應
  66. /// </summary>
  67. /// <param name="protocolVersion">通訊協議版本</param>
  68. /// <param name="sequence">訊息流水號</param>
  69. /// <param name="priority">訊息優先權</param>
  70. /// <param name="reply">回應結果</param>
  71. /// <param name="reason">失敗原因</param>
  72. /// <returns>緊急狀況回應</returns>
  73. /// <remarks>reply : true = ACK, false = NG</remarks>
  74. public static SetAmrEmergencyReplyDto Get(string protocolVersion, string sequence, string priority, bool reply, string reason = "NA")
  75. {
  76. return new SetAmrEmergencyReplyDto()
  77. {
  78. ProtocolVersion = protocolVersion,
  79. Sequence = sequence,
  80. Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
  81. Priority = priority,
  82. Reply = reply ? "ACK" : "NG",
  83. Reason = reason
  84. };
  85. }
  86. }
  87. /// <summary>
  88. /// 緊急狀況結果回報類別
  89. /// </summary>
  90. /// <remarks>2.5.b</remarks>
  91. public class SetAmrEmergencyResultDto : CommonMessage
  92. {
  93. /// <summary>
  94. /// 緊急事件
  95. /// </summary>
  96. /// <value>
  97. /// earthquake <br/>
  98. /// fire <br/>
  99. /// </value>
  100. [Required, StringLength(10), JsonPropertyName("event"), JsonPropertyOrder(101)]
  101. public string Event { get; set; }
  102. /// <summary>
  103. /// 執行結果
  104. /// </summary>
  105. /// <value>
  106. /// OK <br/>
  107. /// NG <br/>
  108. /// </value>
  109. [Required, StringLength(2), JsonPropertyName("result"), JsonPropertyOrder(102)]
  110. public string Result { get; set; }
  111. /// <summary>
  112. /// 失敗理由
  113. /// </summary>
  114. [StringLength(255), JsonPropertyName("reason"), JsonPropertyOrder(103)]
  115. public string Reason { get; set; }
  116. }
  117. /// <summary>
  118. /// 緊急狀況回應類別
  119. /// </summary>
  120. public class SetAmrEmergencyAckDto : CommonMessage
  121. {
  122. /// <summary>
  123. /// 回應
  124. /// </summary>
  125. /// <value>
  126. /// OK
  127. /// </value>
  128. [Required, StringLength(2), JsonPropertyName("ack"), JsonPropertyOrder(101)]
  129. public string Ack { get; set; }
  130. /// <summary>
  131. /// 取得緊急狀況回應
  132. /// </summary>
  133. /// <param name="protocolVersion">通訊協議版本</param>
  134. /// <param name="sequence">訊息流水號</param>
  135. /// <param name="priority">訊息優先權</param>
  136. /// <returns>緊急狀況回應</returns>
  137. public static SetAmrEmergencyAckDto Get(string protocolVersion, string sequence, string priority)
  138. {
  139. return new SetAmrEmergencyAckDto()
  140. {
  141. ProtocolVersion = protocolVersion,
  142. Sequence = sequence,
  143. Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
  144. Priority = priority,
  145. Ack = "OK"
  146. };
  147. }
  148. }
  149. }