using System;
namespace Mirle.Component.API.AutomatedGuideVehicleController.Models
{
///
/// Enumerate for transaction name
///
public enum TransactionName
{
///
/// Set mission request
///
/// 2.1.a
SetMissionRequest,
///
/// Set mission reply
///
/// 2.1.b
SetMissionReply,
///
/// Set mission result
///
/// 2.1.c
SetMissionResult,
///
/// set mission ack
///
/// 2.1.d
SetMissionAck,
///
/// set mission status request
///
/// 2.2.a
SetMissionStatusRequest,
///
/// Set mission status reply
///
/// 2.2.b
SetMissionStatusReply,
///
/// Set mission status result
///
/// 2.2.c
SetMissionStatusResult,
///
/// Set mission status ack
///
/// 2.2.d
SetMissionStatusAck,
///
/// Set amr list request
///
/// 2.3.a
SetAmrListRequest,
///
/// Set amr list reply
///
/// 2.3.b
SetAmrListReply,
///
/// Set amr list result
///
/// 2.3.c
SetAmrListResult,
///
/// Set amr list ack
///
/// 2.3.d
SetAmrListAck,
///
/// Set amr health request
///
/// 2.4.a
SetAmrHealthRequest,
///
/// Set amr health reply
///
/// 2.4.b
SetAmrHealthReply,
///
/// Set amr health result
///
/// 2.4.c
SetAmrHealthResult,
///
/// Set amr health ack
///
/// 2.4.d
SetAmrHealthAck,
///
/// Set amr emergency request
///
/// 2.5.a
SetAmrEmergencyRequest,
///
/// Set amr emergency reply
///
/// 2.5.b
SetAmrEmergencyReply,
///
/// Set amr emergency result
///
/// 2.5.c
SetAmrEmergencyResult,
///
/// Set amr emergency ack
///
/// 2.5.d
SetAmrEmergencyAck,
///
/// Component fault alert report
///
/// 3.1.alert
ComponentFaultAlert,
///
/// Heartbeat report
///
/// 3.2.Heartbeat
Heartbeat,
///
/// System status report
///
/// 3.3.Online
Online
}
///
/// Class for transaction name extension apporach
///
public static class TransactionNameExtension
{
///
/// Convert to web application programming interface url
///
/// Enumerate fro transaction name
/// Web application programming interface url
///
public static string ToUrl(this TransactionName transactionName)
{
return transactionName switch
{
TransactionName.SetMissionRequest => "awd/rms/set_mission_request",
TransactionName.SetMissionReply => "awd/rms/set_mission_reply",
TransactionName.SetMissionResult => "awd/rms/set_mission_result",
TransactionName.SetMissionAck => "awd/rms/set_mission_ack",
TransactionName.SetMissionStatusRequest => "awd/rms/set_mission_status_request",
TransactionName.SetMissionStatusReply => "awd/rms/set_mission_status_reply",
TransactionName.SetMissionStatusResult => "awd/rms/set_mission_status_result",
TransactionName.SetMissionStatusAck => "awd/rms/set_mission_status_ack",
TransactionName.SetAmrListRequest => "awd/rms/set_amr_list_request",
TransactionName.SetAmrListReply => "awd/rms/set_amr_list_reply",
TransactionName.SetAmrListResult => "awd/rms/set_amr_list_result",
TransactionName.SetAmrListAck => "awd/rms/set_amr_list_ack",
TransactionName.SetAmrHealthRequest => "awd/rms/set_amr_health_request",
TransactionName.SetAmrHealthReply => "awd/rms/set_amr_health_reply",
TransactionName.SetAmrHealthResult => "awd/rms/set_amr_health_result",
TransactionName.SetAmrHealthAck => "awd/rms/set_amr_health_ack",
TransactionName.SetAmrEmergencyRequest => "awd/rms/set_amr_emergency_request",
TransactionName.SetAmrEmergencyReply => "awd/rms/set_amr_emergency_reply",
TransactionName.SetAmrEmergencyResult => "awd/rms/set_amr_emergency_result",
TransactionName.SetAmrEmergencyAck => "awd/rms/set_amr_emergency_ack",
TransactionName.ComponentFaultAlert => "awd/rms/component_fault_alert",
TransactionName.Heartbeat => "awd/rms/heartbeat",
TransactionName.Online => "awd/rms/online",
_ => throw new ArgumentException($"Transaction name unknown by {transactionName}")
};
}
///
/// Convert to transaction identify number
///
/// Enumerate for transaction name
/// Transaction identify number
///
public static string ToTransactionName(this TransactionName transactionName)
{
return transactionName switch
{
TransactionName.SetMissionRequest => "2.1.a",
TransactionName.SetMissionReply => "2.1.b",
TransactionName.SetMissionResult => "2.1.c",
TransactionName.SetMissionAck => "2.1.d",
TransactionName.SetMissionStatusRequest => "2.2.a",
TransactionName.SetMissionStatusReply => "2.2.b",
TransactionName.SetMissionStatusResult => "2.2.c",
TransactionName.SetMissionStatusAck => "2.2.d",
TransactionName.SetAmrListRequest => "2.3.a",
TransactionName.SetAmrListReply => "2.3.b",
TransactionName.SetAmrListResult => "2.3.c",
TransactionName.SetAmrListAck => "2.3.d",
TransactionName.SetAmrHealthRequest => "2.4.a",
TransactionName.SetAmrHealthReply => "2.4.b",
TransactionName.SetAmrHealthResult => "2.4.c",
TransactionName.SetAmrHealthAck => "2.4.d",
TransactionName.SetAmrEmergencyRequest => "2.5.a",
TransactionName.SetAmrEmergencyReply => "2.5.b",
TransactionName.SetAmrEmergencyResult => "2.5.c",
TransactionName.SetAmrEmergencyAck => "2.5.d",
TransactionName.ComponentFaultAlert => "3.1.alert",
TransactionName.Heartbeat => "3.2.Heartbeat",
TransactionName.Online => "3.3.Online",
_ => throw new ArgumentException($"Transaction name unknown by {transactionName}")
};
}
}
}