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.

130 lines
4.5 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 SetAmrListRequestDto : CommonMessage
  10. {
  11. /// <summary>
  12. /// 區域
  13. /// </summary>
  14. /// <value>
  15. /// all
  16. /// </value>
  17. [Required, StringLength(3), JsonPropertyName("zone"), JsonPropertyOrder(101)]
  18. public string Zone { get; set; }
  19. /// <summary>
  20. /// 取得車輛清單請求
  21. /// </summary>
  22. /// <param name="protocolVersion">通訊協議版本</param>
  23. /// <param name="sequence">訊息流水號</param>
  24. /// <param name="priority">訊息優先權</param>
  25. /// <returns>車輛清單請求</returns>
  26. public static SetAmrListRequestDto Get(string protocolVersion, string sequence, string priority)
  27. {
  28. return new SetAmrListRequestDto()
  29. {
  30. ProtocolVersion = protocolVersion,
  31. Sequence = sequence,
  32. Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
  33. Priority = priority,
  34. Zone = "all"
  35. };
  36. }
  37. }
  38. /// <summary>
  39. /// 車輛清單回應類別
  40. /// </summary>
  41. public class SetAmrListReplyDto : CommonMessage
  42. {
  43. /// <summary>
  44. /// 指令確認結果
  45. /// </summary>
  46. /// <value>
  47. /// ACK <br/>
  48. /// NG <br/>
  49. /// </value>
  50. [Required, StringLength(3), JsonPropertyName("reply"), JsonPropertyOrder(101)]
  51. public string Reply { get; set; }
  52. /// <summary>
  53. /// 失敗理由
  54. /// </summary>
  55. [StringLength(255), JsonPropertyName("reason"), JsonPropertyOrder(102)]
  56. public string Reason { get; set; }
  57. /// <summary>
  58. /// 取得車輛清單回應
  59. /// </summary>
  60. /// <param name="protocolVersion">通訊協議版本</param>
  61. /// <param name="sequence">訊息流水號</param>
  62. /// <param name="priority">訊息優先權</param>
  63. /// <param name="reply">回應結果</param>
  64. /// <param name="reason">失敗原因</param>
  65. /// <returns>車輛清單回應</returns>
  66. /// <remarks>reply : true = ACK, false = NG</remarks>
  67. public static SetAmrListReplyDto Get(string protocolVersion, string sequence, string priority, bool reply, string reason = "NA")
  68. {
  69. return new SetAmrListReplyDto()
  70. {
  71. ProtocolVersion = protocolVersion,
  72. Sequence = sequence,
  73. Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
  74. Priority = priority,
  75. Reply = reply ? "ACK" : "NG",
  76. Reason = reason
  77. };
  78. }
  79. }
  80. /// <summary>
  81. /// 車輛清單回報類別
  82. /// </summary>
  83. public class SetAmrListResultDto : CommonMessage
  84. {
  85. /// <summary>
  86. /// 車輛總數
  87. /// </summary>
  88. [Required, JsonPropertyName("count"), JsonPropertyOrder(101)]
  89. public string Count { get; set; }
  90. /// <summary>
  91. /// 車輛名稱列表
  92. /// </summary>
  93. /// <remarks>逗號分隔</remarks>
  94. [JsonPropertyName("amrs"), JsonPropertyOrder(102)]
  95. public string Amrs { get; set; }
  96. }
  97. /// <summary>
  98. /// 車輛清單回應類別
  99. /// </summary>
  100. public class SetAmrListAckDto : CommonMessage
  101. {
  102. /// <summary>
  103. /// 回應
  104. /// </summary>
  105. /// <value>
  106. /// OK <br/>
  107. /// </value>
  108. [Required, StringLength(2), JsonPropertyName("ack"), JsonPropertyOrder(101)]
  109. public string Ack { get; set; }
  110. /// <summary>
  111. /// 取得車輛清單回應
  112. /// </summary>
  113. /// <param name="protocolVersion">通訊協議版本</param>
  114. /// <param name="sequence">訊息流水號</param>
  115. /// <param name="priority">訊息優先權</param>
  116. /// <returns>車輛清單回應</returns>
  117. public static SetAmrListAckDto Get(string protocolVersion, string sequence, string priority)
  118. {
  119. return new SetAmrListAckDto()
  120. {
  121. ProtocolVersion = protocolVersion,
  122. Sequence = sequence,
  123. Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
  124. Priority = priority,
  125. Ack = "OK"
  126. };
  127. }
  128. }
  129. }