using System;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace Mirle.Component.API.AutomatedGuideVehicleController.Models
{
///
/// 詢問車況請求類別
///
public class SetAmrHealthRequestDto : CommonMessage
{
///
/// AMR名稱或車號
///
[Required, JsonPropertyName("amr"), JsonPropertyOrder(101)]
public string Amr { get; set; }
///
/// 取得詢問車況請求
///
/// 通訊協議版本
/// 訊息流水號
/// 訊息優先權
/// AMR名稱或車號
/// 詢問車況請求
public static SetAmrHealthRequestDto Get(string protocolVersion, string sequence, string priority, string amr)
{
return new SetAmrHealthRequestDto()
{
ProtocolVersion = protocolVersion,
Sequence = sequence,
Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
Priority = priority,
Amr = amr
};
}
}
///
/// 詢問車況回應類別
///
public class SetAmrHealthReplyDto : 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 SetAmrHealthReplyDto Get(string protocolVersion, string sequence, string priority, bool reply, string reason = "NA")
{
return new SetAmrHealthReplyDto()
{
ProtocolVersion = protocolVersion,
Sequence = sequence,
Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
Priority = priority,
Reply = reply ? "ACK" : "NG",
Reason = reason
};
}
}
///
/// 詢問車輛狀況回報類別
///
public class SetAmrHealthResultDto : CommonMessage
{
///
/// AMR名稱或車號
///
[Required, JsonPropertyName("amr"), JsonPropertyOrder(101)]
public string Amr { get; set; }
///
/// 健康情報
///
[JsonPropertyName("health"), JsonPropertyOrder(102)]
public Health Health { get; set; }
}
///
/// 車輛健康狀況類別
///
public class Health
{
///
/// 運動狀態
///
///
/// running
/// collision stop
/// avoidance stop
/// pause stop
/// charging stop
/// working stop
/// standby stop
///
[StringLength(13), JsonPropertyName("motion")]
public string Motion { get; set; }
///
/// 電池電量資訊 (%)
///
[StringLength(4), JsonPropertyName("battery_level")]
public string BatteryLevel { get; set; }
///
/// 電池電壓資訊 (V)
///
[StringLength(4), JsonPropertyName("battery_voltage")]
public string BatteryVoltage { get; set; }
///
/// 車輛行進速度 (m/s)
///
[StringLength(3), JsonPropertyName("velocity")]
public string Velocity { get; set; }
///
/// 車輛行走公里數 (m)
///
[StringLength(5), JsonPropertyName("odometry")]
public string Odometry { get; set; }
}
///
/// 詢問車輛狀況回應類別
///
public class SetAmrHealthAckDto : CommonMessage
{
///
/// 回應
///
///
/// OK
///
[Required, StringLength(2), JsonPropertyName("ack"), JsonPropertyOrder(101)]
public string Ack { get; set; }
///
/// 取得詢問車輛狀況回應
///
/// 通訊協議版本
/// 訊息流水號
/// 訊息優先權
/// 詢問車輛狀況回應
public static SetAmrHealthAckDto Get(string protocolVersion, string sequence, string priority)
{
return new SetAmrHealthAckDto()
{
ProtocolVersion = protocolVersion,
Sequence = sequence,
Timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
Priority = priority,
Ack = "OK"
};
}
}
}