using System;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace Mirle.Component.API.AutomatedGuideVehicleController.Models
{
///
/// 緊急狀況請求類別
///
/// 2.5.a
public class SetAmrEmergencyRequestDto : CommonMessage
{
///
/// 緊急事件種類
///
///
/// earthquake
/// fire
///
[Required, StringLength(10), JsonPropertyName("event"), JsonPropertyOrder(101)]
public string Event { get; set; }
///
/// 取得緊急狀況請求
///
/// 通訊協議版本
/// 訊息流水號
/// 訊息優先權
/// 緊急事件
/// 緊急狀況請求
///
/// @event : 0 = earthquake, 1 = fire
///
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"
};
}
}
///
/// 緊急狀況回應類別
///
/// 2.5.b
public class SetAmrEmergencyReplyDto : CommonMessage
{
///
/// 指令確認結果
///
///
/// ACK
/// NG
///
[Required, StringLength(3), JsonPropertyName("reply"), JsonPropertyOrder(101)]
public string Reply { get; set; }
///
/// 失敗理由
///
[StringLength(255), JsonPropertyName("reason"), JsonPropertyOrder(102)]
public string Reason { get; set; }
///
/// 取得緊急狀況回應
///
/// 通訊協議版本
/// 訊息流水號
/// 訊息優先權
/// 回應結果
/// 失敗原因
/// 緊急狀況回應
/// reply : true = ACK, false = NG
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
};
}
}
///
/// 緊急狀況結果回報類別
///
/// 2.5.b
public class SetAmrEmergencyResultDto : CommonMessage
{
///
/// 緊急事件
///
///
/// earthquake
/// fire
///
[Required, StringLength(10), JsonPropertyName("event"), JsonPropertyOrder(101)]
public string Event { get; set; }
///
/// 執行結果
///
///
/// OK
/// NG
///
[Required, StringLength(2), JsonPropertyName("result"), JsonPropertyOrder(102)]
public string Result { get; set; }
///
/// 失敗理由
///
[StringLength(255), JsonPropertyName("reason"), JsonPropertyOrder(103)]
public string Reason { get; set; }
}
///
/// 緊急狀況回應類別
///
public class SetAmrEmergencyAckDto : CommonMessage
{
///
/// 回應
///
///
/// OK
///
[Required, StringLength(2), JsonPropertyName("ack"), JsonPropertyOrder(101)]
public string Ack { get; set; }
///
/// 取得緊急狀況回應
///
/// 通訊協議版本
/// 訊息流水號
/// 訊息優先權
/// 緊急狀況回應
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"
};
}
}
}