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

using System;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace Mirle.Component.API.AutomatedGuideVehicleController.Models
{
/// <summary>
/// 緊急狀況請求類別
/// </summary>
/// <remarks>2.5.a</remarks>
public class SetAmrEmergencyRequestDto : CommonMessage
{
/// <summary>
/// 緊急事件種類
/// </summary>
/// <value>
/// earthquake <br/>
/// fire <br/>
/// </value>
[Required, StringLength(10), JsonPropertyName("event"), JsonPropertyOrder(101)]
public string Event { get; set; }
/// <summary>
/// 取得緊急狀況請求
/// </summary>
/// <param name="protocolVersion">通訊協議版本</param>
/// <param name="sequence">訊息流水號</param>
/// <param name="priority">訊息優先權</param>
/// <param name="event">緊急事件</param>
/// <returns>緊急狀況請求</returns>
/// <remarks>
/// @event : 0 = earthquake, 1 = fire
/// </remarks>
public static SetAmrEmergencyRequestDto Get(string protocolVersion, string sequence, string priority, int @event)
{
return new SetAmrEmergencyRequestDto()
{
ProtocolVersion = protocolVersion,
Sequence = sequence,
Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
Priority = priority,
Event = @event == 1 ? "earthquake" : "fire"
};
}
}
/// <summary>
/// 緊急狀況回應類別
/// </summary>
/// <remarks>2.5.b</remarks>
public class SetAmrEmergencyReplyDto : CommonMessage
{
/// <summary>
/// 指令確認結果
/// </summary>
/// <value>
/// ACK <br/>
/// NG <br/>
/// </value>
[Required, StringLength(3), JsonPropertyName("reply"), JsonPropertyOrder(101)]
public string Reply { get; set; }
/// <summary>
/// 失敗理由
/// </summary>
[StringLength(255), JsonPropertyName("reason"), JsonPropertyOrder(102)]
public string Reason { get; set; }
/// <summary>
/// 取得緊急狀況回應
/// </summary>
/// <param name="protocolVersion">通訊協議版本</param>
/// <param name="sequence">訊息流水號</param>
/// <param name="priority">訊息優先權</param>
/// <param name="reply">回應結果</param>
/// <param name="reason">失敗原因</param>
/// <returns>緊急狀況回應</returns>
/// <remarks>reply : true = ACK, false = NG</remarks>
public static SetAmrEmergencyReplyDto Get(string protocolVersion, string sequence, string priority, bool reply, string reason = "NA")
{
return new SetAmrEmergencyReplyDto()
{
ProtocolVersion = protocolVersion,
Sequence = sequence,
Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
Priority = priority,
Reply = reply ? "ACK" : "NG",
Reason = reason
};
}
}
/// <summary>
/// 緊急狀況結果回報類別
/// </summary>
/// <remarks>2.5.b</remarks>
public class SetAmrEmergencyResultDto : CommonMessage
{
/// <summary>
/// 緊急事件
/// </summary>
/// <value>
/// earthquake <br/>
/// fire <br/>
/// </value>
[Required, StringLength(10), JsonPropertyName("event"), JsonPropertyOrder(101)]
public string Event { get; set; }
/// <summary>
/// 執行結果
/// </summary>
/// <value>
/// OK <br/>
/// NG <br/>
/// </value>
[Required, StringLength(2), JsonPropertyName("result"), JsonPropertyOrder(102)]
public string Result { get; set; }
/// <summary>
/// 失敗理由
/// </summary>
[StringLength(255), JsonPropertyName("reason"), JsonPropertyOrder(103)]
public string Reason { get; set; }
}
/// <summary>
/// 緊急狀況回應類別
/// </summary>
public class SetAmrEmergencyAckDto : CommonMessage
{
/// <summary>
/// 回應
/// </summary>
/// <value>
/// OK
/// </value>
[Required, StringLength(2), JsonPropertyName("ack"), JsonPropertyOrder(101)]
public string Ack { get; set; }
/// <summary>
/// 取得緊急狀況回應
/// </summary>
/// <param name="protocolVersion">通訊協議版本</param>
/// <param name="sequence">訊息流水號</param>
/// <param name="priority">訊息優先權</param>
/// <returns>緊急狀況回應</returns>
public static SetAmrEmergencyAckDto Get(string protocolVersion, string sequence, string priority)
{
return new SetAmrEmergencyAckDto()
{
ProtocolVersion = protocolVersion,
Sequence = sequence,
Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
Priority = priority,
Ack = "OK"
};
}
}
}