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.
 
 
 
 
 

204 lines
8.0 KiB

using System;
namespace Mirle.Component.API.AutomatedGuideVehicleController.Models
{
/// <summary>
/// Enumerate for transaction name
/// </summary>
public enum TransactionName
{
/// <summary>
/// Set mission request
/// </summary>
/// <remarks>2.1.a</remarks>
SetMissionRequest,
/// <summary>
/// Set mission reply
/// </summary>
/// <remarks>2.1.b</remarks>
SetMissionReply,
/// <summary>
/// Set mission result
/// </summary>
/// <remarks>2.1.c</remarks>
SetMissionResult,
/// <summary>
/// set mission ack
/// </summary>
/// <remarks>2.1.d</remarks>
SetMissionAck,
/// <summary>
/// set mission status request
/// </summary>
/// <remarks>2.2.a</remarks>
SetMissionStatusRequest,
/// <summary>
/// Set mission status reply
/// </summary>
/// <remarks>2.2.b</remarks>
SetMissionStatusReply,
/// <summary>
/// Set mission status result
/// </summary>
/// <remarks>2.2.c</remarks>
SetMissionStatusResult,
/// <summary>
/// Set mission status ack
/// </summary>
/// <remarks>2.2.d</remarks>
SetMissionStatusAck,
/// <summary>
/// Set amr list request
/// </summary>
/// <remarks>2.3.a</remarks>
SetAmrListRequest,
/// <summary>
/// Set amr list reply
/// </summary>
/// <remarks>2.3.b</remarks>
SetAmrListReply,
/// <summary>
/// Set amr list result
/// </summary>
/// <remarks>2.3.c</remarks>
SetAmrListResult,
/// <summary>
/// Set amr list ack
/// </summary>
/// <remarks>2.3.d</remarks>
SetAmrListAck,
/// <summary>
/// Set amr health request
/// </summary>
/// <remarks>2.4.a</remarks>
SetAmrHealthRequest,
/// <summary>
/// Set amr health reply
/// </summary>
/// <remarks>2.4.b</remarks>
SetAmrHealthReply,
/// <summary>
/// Set amr health result
/// </summary>
/// <remarks>2.4.c</remarks>
SetAmrHealthResult,
/// <summary>
/// Set amr health ack
/// </summary>
/// <remarks>2.4.d</remarks>
SetAmrHealthAck,
/// <summary>
/// Set amr emergency request
/// </summary>
/// <remarks>2.5.a</remarks>
SetAmrEmergencyRequest,
/// <summary>
/// Set amr emergency reply
/// </summary>
/// <remarks>2.5.b</remarks>
SetAmrEmergencyReply,
/// <summary>
/// Set amr emergency result
/// </summary>
/// <remarks>2.5.c</remarks>
SetAmrEmergencyResult,
/// <summary>
/// Set amr emergency ack
/// </summary>
/// <remarks>2.5.d</remarks>
SetAmrEmergencyAck,
/// <summary>
/// Component fault alert report
/// </summary>
/// <remarks>3.1.alert</remarks>
ComponentFaultAlert,
/// <summary>
/// Heartbeat report
/// </summary>
/// <remarks>3.2.Heartbeat</remarks>
Heartbeat,
/// <summary>
/// System status report
/// </summary>
/// <remarks>3.3.Online</remarks>
Online
}
/// <summary>
/// Class for transaction name extension apporach
/// </summary>
public static class TransactionNameExtension
{
/// <summary>
/// Convert to web application programming interface url
/// </summary>
/// <param name="transactionName">Enumerate fro transaction name</param>
/// <returns>Web application programming interface url</returns>
/// <exception cref="ArgumentException"></exception>
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}")
};
}
/// <summary>
/// Convert to transaction identify number
/// </summary>
/// <param name="transactionName">Enumerate for transaction name</param>
/// <returns>Transaction identify number</returns>
/// <exception cref="ArgumentException"></exception>
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}")
};
}
}
}