using System; using System.Text.Json.Serialization; namespace Mirle.Component.API.ProgrammableLogicController.Models { /// /// 交易名稱列舉 /// [JsonConverter(typeof(JsonStringEnumConverter))] public enum TransactionName { /// /// 建立命令請求 /// TP_001_CreateCommandRequest, /// /// 建立命令回應 /// FP_002_CreateCommandResponse, /// /// 執行命令回報 /// FP_003_ExecuteCommandReport, /// /// 執行命令回應 /// TP_004_ExecuteCommandAck, /// /// 完成命令回報 /// FP_005_FinishCommandReport, /// /// 完成命令回應 /// TP_006_FinishCommandAck, /// /// 取消命令請求 /// TP_007_CancelCommandRequest, /// /// 取消命令回應 /// FP_008_CancelCommandResponse, /// /// 建立取放貨請求 /// TP_009_CreateLoadUnloadRequest, /// /// 建立取放貨回應 /// FP_010_CreateLoadUnloadResponse, /// /// 完成取放貨回報 /// TP_011_FinishLoadUnloadReport, /// /// 完成取放貨回應 /// FP_012_FinishLoadUnloadAck, /// /// 允許取放貨回報 /// FP_013_PermitLoadUnloadReport, /// /// 允許取放貨回應 /// TP_014_PermitLoadUnloadAck, /// /// 確認載具編號請求 /// FP_015_CheckCarrierIDRequest, /// /// 確認載具編號回應 /// TP_016_CheckCarruerIDResponse, /// /// 棧板供收狀態回報 /// FP_017_PalletSupplyStatusReport, /// /// 棧板供收狀態回應 /// TP_018_PalletSupplyStatusAck, /// /// 移動台車狀態請求 /// TP_019_MoveCarStatusRequest, /// /// 移動台車狀態回應 /// FP_020_MoveCarStatusResponse, /// /// 呼叫電梯請求 /// TP_021_CallLifterRequest, /// /// 呼叫電梯回應 /// FP_022_CallLifterResponse, /// /// 電梯抵達回報 /// FP_023_ArrivedLifterReport, /// /// 電梯抵達回應 /// TP_024_ArrivedLifterAck, /// /// 電梯貨物檢知回報 /// TP_025_CheckLifterItemReport, /// /// 電梯貨物檢知回應 /// FP_026_CheckLifterItemAck, /// /// 發生異常回報 /// FP_027_HappenAlarmReport, /// /// 發生異常回應 /// TP_028_HappenAlarmAck, /// /// 清除異常回報 /// FP_029_ResetAlarmReport, /// /// 清除異常回應 /// TP_030_ResetAlarmAck, /// /// 使用維修門請求 /// FP_031_UseRepairDoorRequest, /// /// 使用維修門回應 /// TP_032_UseRepairDoorResponse, /// /// 釋放維修門回報 /// TP_033_ReleaseRepairDoorReport, /// /// 釋放維修門回應 /// FP_034_ReleaseRepairDoorAck, /// /// 維修門狀態回報 /// FP_035_RepairDoorStatusReport, /// /// 維修門狀態回應 /// TP_036_RepairDoorStatusAck, /// /// 使用鐵捲門請求 /// TP_037_UseRollingDoorRequest, /// /// 使用鐵捲門回應 /// FP_038_UseRollingDoorResponse, /// /// 鐵捲門狀態回報 /// FP_039_RollingDoorStatusReport, /// /// 鐵捲門狀態回應 /// TP_040_RollingDoorStatusAck, /// /// 心跳包請求 /// FP_041_HeartbeatReport, /// /// 心跳包回應 /// TP_042_HeartbeatAck, /// /// 操作模式回報 /// FP_043_OperationModeReport, /// /// 操作模式回應 /// TP_044_OperationModeAck, /// /// 鎖定庫區命令派送回報 /// FP_045_LockStorageDispatchReport, /// /// 鎖定庫區命令派送回應 /// TP_046_LockStorageDispatchAck, /// /// 量測物料重量請求 /// TP_047_MaterialWeightRequest, /// /// 量測物料重量回應 /// FP_048_MaterialWeightResponse, /// /// 消防警訊通知回報 /// FP_049_FireAlarmNotifyReport, /// /// 消防警訊通知回應 /// TP_050_FireAlarmNotifyAck, /// /// 緊急應變請求 /// TP_051_EmergencyEventRequest, /// /// 緊急應變回應 /// FP_052_EmergencyEventResponse, /// /// 緊急停止回報 /// FP_053_EmergencyOffReport, /// /// 緊急停止回應 /// TP_054_EmergencyoffAck, /// /// 建立電梯命令請求 /// TP_055_CreateLifterCommandRequest, /// /// 建立電梯命令回應 /// FP_056_CreateLifterCommandResponse, /// /// 完成電梯命令回報 /// FP_057_FinishLifterCommandReport, /// /// 完成電梯命令回應 /// TP_058_FinishLifterCommandAck, /// /// 取消電梯命令請求 /// TP_059_CancelLifterCommandRequest, /// /// 取消電梯命令回應 /// FP_060_CancelLifterCommandResponse } /// /// 交易名稱擴充方法類別 /// public static class TransactionNameExtension { /// /// 轉轉換成交易識別碼 /// /// 交易名稱列舉項目 /// 交易識別碼 /// 未知交易名稱列舉項目 public static string ToTransactionName(this TransactionName transactionName) { return (transactionName) switch { TransactionName.TP_001_CreateCommandRequest => "TP001", TransactionName.FP_002_CreateCommandResponse => "FP002", TransactionName.FP_003_ExecuteCommandReport => "FP003", TransactionName.TP_004_ExecuteCommandAck => "TP004", TransactionName.FP_005_FinishCommandReport => "FP005", TransactionName.TP_006_FinishCommandAck => "TP006", TransactionName.TP_007_CancelCommandRequest => "TP007", TransactionName.FP_008_CancelCommandResponse => "FP008", TransactionName.TP_009_CreateLoadUnloadRequest => "TP009", TransactionName.FP_010_CreateLoadUnloadResponse => "FP010", TransactionName.TP_011_FinishLoadUnloadReport => "TP011", TransactionName.FP_012_FinishLoadUnloadAck => "FP012", TransactionName.FP_013_PermitLoadUnloadReport => "FP013", TransactionName.TP_014_PermitLoadUnloadAck => "TP014", TransactionName.FP_015_CheckCarrierIDRequest => "FP015", TransactionName.TP_016_CheckCarruerIDResponse => "TP016", TransactionName.FP_017_PalletSupplyStatusReport => "FP017", TransactionName.TP_018_PalletSupplyStatusAck => "TP018", TransactionName.TP_019_MoveCarStatusRequest => "TP019", TransactionName.FP_020_MoveCarStatusResponse => "FP020", TransactionName.TP_021_CallLifterRequest => "TP021", TransactionName.FP_022_CallLifterResponse => "FP022", TransactionName.FP_023_ArrivedLifterReport => "FP023", TransactionName.TP_024_ArrivedLifterAck => "TP024", TransactionName.TP_025_CheckLifterItemReport => "TP025", TransactionName.FP_026_CheckLifterItemAck => "FP026", TransactionName.FP_027_HappenAlarmReport => "FP027", TransactionName.TP_028_HappenAlarmAck => "TP028", TransactionName.FP_029_ResetAlarmReport => "FP029", TransactionName.TP_030_ResetAlarmAck => "TP030", TransactionName.FP_031_UseRepairDoorRequest => "FP031", TransactionName.TP_032_UseRepairDoorResponse => "TP032", TransactionName.TP_033_ReleaseRepairDoorReport => "TP033", TransactionName.FP_034_ReleaseRepairDoorAck => "FP034", TransactionName.FP_035_RepairDoorStatusReport => "FP035", TransactionName.TP_036_RepairDoorStatusAck => "TP036", TransactionName.TP_037_UseRollingDoorRequest => "TP037", TransactionName.FP_038_UseRollingDoorResponse => "FP038", TransactionName.FP_039_RollingDoorStatusReport => "FP039", TransactionName.TP_040_RollingDoorStatusAck => "TP040", TransactionName.FP_041_HeartbeatReport => "FP041", TransactionName.TP_042_HeartbeatAck => "TP042", TransactionName.FP_043_OperationModeReport => "FP043", TransactionName.TP_044_OperationModeAck => "TP044", TransactionName.FP_045_LockStorageDispatchReport => "FP045", TransactionName.TP_046_LockStorageDispatchAck => "TP046", TransactionName.TP_047_MaterialWeightRequest => "TP047", TransactionName.FP_048_MaterialWeightResponse => "FP048", TransactionName.FP_049_FireAlarmNotifyReport => "FP049", TransactionName.TP_050_FireAlarmNotifyAck => "TP050", TransactionName.TP_051_EmergencyEventRequest => "TP051", TransactionName.FP_052_EmergencyEventResponse => "FP052", TransactionName.FP_053_EmergencyOffReport => "FP053", TransactionName.TP_054_EmergencyoffAck => "TP054", TransactionName.TP_055_CreateLifterCommandRequest => "TP055", TransactionName.FP_056_CreateLifterCommandResponse => "FP056", TransactionName.FP_057_FinishLifterCommandReport => "FP057", TransactionName.TP_058_FinishLifterCommandAck => "TP058", TransactionName.TP_059_CancelLifterCommandRequest => "TP059", TransactionName.FP_060_CancelLifterCommandResponse => "FP060", _ => throw new ArgumentException($"Unknow transaction name: {transactionName}") }; } /// /// 轉換成 WEB API URL /// /// 交易名稱列舉項目 /// WEB API URL /// 未知交易名稱列舉項目 public static string ToUrl(this TransactionName transactionName) { return (transactionName) switch { TransactionName.TP_001_CreateCommandRequest => "PLCC/ToPLCC/CREATE_COMMAND", TransactionName.FP_002_CreateCommandResponse => "PLCC/FromPLCC/CREATE_COMMAND", TransactionName.FP_003_ExecuteCommandReport => "PLCC/FromPLCC/EXECUTE_COMMAND", TransactionName.TP_004_ExecuteCommandAck => "PLCC/ToPLCC/EXECUTE_COMMAND", TransactionName.FP_005_FinishCommandReport => "PLCC/FromPLCC/FINISH_COMMAND", TransactionName.TP_006_FinishCommandAck => "PLCC/ToPLCC/FINISH_COMMAND", TransactionName.TP_007_CancelCommandRequest => "PLCC/ToPLCC/CANCEL_COMMAND", TransactionName.FP_008_CancelCommandResponse => "PLCC/FromPLCC/CANCEL_COMMAND", TransactionName.TP_009_CreateLoadUnloadRequest => "PLCC/ToPLCC/CREATE_LOAD_UNLOAD", TransactionName.FP_010_CreateLoadUnloadResponse => "PLCC/FromPLCC/CREATE_LOAD_UNLOAD", TransactionName.TP_011_FinishLoadUnloadReport => "PLCC/ToPLCC/FINISH_LOAD_UNLOAD", TransactionName.FP_012_FinishLoadUnloadAck => "PLCC/FromPLCC/FINISH_LOAD_UNLOAD", TransactionName.FP_013_PermitLoadUnloadReport => "PLCC/FromPLCC/PERMIT_LOAD_UNLOAD", TransactionName.TP_014_PermitLoadUnloadAck => "PLCC/ToPLCC/PERMIT_LOAD_UNLOAD", TransactionName.FP_015_CheckCarrierIDRequest => "PLCC/FromPLCC/CHECK_CARRIER_ID", TransactionName.TP_016_CheckCarruerIDResponse => "PLCC/ToPLCC/CHECK_CARRIER_ID", TransactionName.FP_017_PalletSupplyStatusReport => "PLCC/FromPLCC/PALLET_SUPPLY_STATUS", TransactionName.TP_018_PalletSupplyStatusAck => "PLCC/ToPLCC/PALLET_SUPPLY_STATUS", TransactionName.TP_019_MoveCarStatusRequest => "PLCC/ToPLCC/MOVE_CAR_STATUS", TransactionName.FP_020_MoveCarStatusResponse => "PLCC/FromPLCC/MOVE_CAR_STATUS", TransactionName.TP_021_CallLifterRequest => "PLCC/ToPLCC/CALL_LIFTER", TransactionName.FP_022_CallLifterResponse => "PLCC/FromPLCC/CALL_LIFTER", TransactionName.FP_023_ArrivedLifterReport => "PLCC/FromPLCC/ARRIVED_LIFTER", TransactionName.TP_024_ArrivedLifterAck => "PLCC/ToPLCC/ARRIVED_LIFTER", TransactionName.TP_025_CheckLifterItemReport => "PLCC/ToPLCC/CHECK_LIFTER_ITEM", TransactionName.FP_026_CheckLifterItemAck => "PLCC/FromPLCC/CHECK_LIFTER_ITEM", TransactionName.FP_027_HappenAlarmReport => "PLCC/FromPLCC/HAPPEN_ALARM", TransactionName.TP_028_HappenAlarmAck => "PLCC/ToPLCC/HAPPEN_ALARM", TransactionName.FP_029_ResetAlarmReport => "PLCC/FromPLCC/RESET_ALARM", TransactionName.TP_030_ResetAlarmAck => "PLCC/ToPLCC/RESET_ALARM", TransactionName.FP_031_UseRepairDoorRequest => "PLCC/FromPLCC/USE_REPAIR_DOOR", TransactionName.TP_032_UseRepairDoorResponse => "PLCC/ToPLCC/USE_REPAIR_DOOR", TransactionName.TP_033_ReleaseRepairDoorReport => "PLCC/ToPLCC/RELEASE_REPAIR_DOOR", TransactionName.FP_034_ReleaseRepairDoorAck => "PLCC/FromPLCC/RELEASE_REPAIR_DOOR", TransactionName.FP_035_RepairDoorStatusReport => "PLCC/FromPLCC/REPAIR_DOOR_STATUS", TransactionName.TP_036_RepairDoorStatusAck => "PLCC/ToPLCC/REPAIR_DOOR_STATUS", TransactionName.TP_037_UseRollingDoorRequest => "PLCC/ToPLCC/USE_ROLLING_DOOR", TransactionName.FP_038_UseRollingDoorResponse => "PLCC/FromPLCC/USE_ROLLING_DOOR", TransactionName.FP_039_RollingDoorStatusReport => "PLCC/FromPLCC/ROLLING_DOOR_STATUS", TransactionName.TP_040_RollingDoorStatusAck => "PLCC/ToPLCC/ROLLING_DOOR_STATUS", TransactionName.FP_041_HeartbeatReport => "PLCC/FromPLCC/HEARTBEAT", TransactionName.TP_042_HeartbeatAck => "PLCC/ToPLCC/HEARTBEAT", TransactionName.FP_043_OperationModeReport => "PLCC/FromPLCC/OPERATION_MODE", TransactionName.TP_044_OperationModeAck => "PLCC/ToPLCC/OPERATION_MODE", TransactionName.FP_045_LockStorageDispatchReport => "PLCC/FromPLCC/LOCK_STORAGE_DISPATCH", TransactionName.TP_046_LockStorageDispatchAck => "PLCC/ToPLCC/LOCK_STORAGE_DISPATCH", TransactionName.TP_047_MaterialWeightRequest => "PLCC/FromPLCC/MATERIAL_WEIGHT", TransactionName.FP_048_MaterialWeightResponse => "PLCC/ToPLCC/MATERIAL_WEIGHT", TransactionName.FP_049_FireAlarmNotifyReport => "PLCC/FromPLCC/FIRE_ALARM_NOTIFY", TransactionName.TP_050_FireAlarmNotifyAck => "PLCC/ToPLCC/FIRE_ALARM_NOTIFY", TransactionName.TP_051_EmergencyEventRequest => "PLCC/ToPLCC/EMERGRNCY_EVENT", TransactionName.FP_052_EmergencyEventResponse => "PLCC/FromPLCC/EMERGENCY_ENVET", TransactionName.FP_053_EmergencyOffReport => "PLCC/FromPLCC/EMERGENCY_OFF", TransactionName.TP_054_EmergencyoffAck => "PLCC/ToPLCC/EMERGENCY_OFF", TransactionName.TP_055_CreateLifterCommandRequest => "PLCC/ToPLCC/CREATE_LIFTER_COMMAND", TransactionName.FP_056_CreateLifterCommandResponse => "PLCC/FromPLCC/CREATE_LIFTER_COMMAND", TransactionName.FP_057_FinishLifterCommandReport => "PLCC/FromPLCC/FINISH_LIFTER_COMMAND", TransactionName.TP_058_FinishLifterCommandAck => "PLCC/ToPLCC/FINISH_LIFTER_COMMAND", TransactionName.TP_059_CancelLifterCommandRequest => "PLCC/ToPLCC/CANCLE_LIFTER_COMMAND", TransactionName.FP_060_CancelLifterCommandResponse => "PLCC/FromPLCC/CANCLE_LIFTER_COMMAND", _ => throw new ArgumentException($"Unknow transaction name: {transactionName}") }; } } }