using System;
using System.Text.Json.Serialization;
namespace Mirle.Component.API.ProgrammableLogicController.Models
{
///
/// 異常等級
///
public enum AlarmLevel
{
///
/// 警告
///
Warning,
///
/// 異常
///
Alarm
}
///
/// 回應代碼
///
public enum ReplyCode
{
///
/// 成功
///
OK,
///
/// 失敗
///
NG
}
#region === [Mode] ===
///
/// 任務模式
///
public enum TaskActionMode
{
///
/// 入庫
///
StoreIn,
///
/// 出庫
///
StoreOut,
}
///
/// 取消模式
///
public enum TaskCancelMode
{
///
/// 取消
///
Cancel,
///
/// 強制取消
///
ForceCancel,
///
/// 強制完成
///
ForceComplete
}
///
/// 維修門動作
///
public enum RepairDoorActionMode
{
///
/// 開門
///
Open,
///
/// 關門
///
Close,
///
/// 取消
///
Cancel
}
///
/// 鐵捲門動作
///
public enum RollingDoorActionMode
{
///
/// 開啟
///
Open,
///
/// 關閉
///
Close
}
///
/// 操作模式
///
public enum OperationMode
{
///
/// 連線可控制
///
OnlineRemote,
///
/// 連線不可控制
///
OnlineLocal,
///
/// 離線
///
Offline
}
#endregion
#region === [Status] ===
///
/// 任務完成狀態
///
public enum TaskCompleteStatus
{
///
/// 完成
///
Complete,
///
/// 強制完成
///
ForceComplete,
///
/// 失敗
///
Failed,
///
/// 取消
///
Cancel,
///
/// 強制取消
///
ForceCancel
}
///
/// 棧板供應狀態
///
public enum PalletSupplyStatus
{
///
/// 滿載
///
Full,
///
/// 空載
///
Empty
}
///
/// 移動台車狀態
///
public enum MoveCarStatus
{
///
/// 回到原點
///
Ready,
///
/// 尚未回到原點
///
NotReady
}
///
/// 電梯狀態
///
public enum LifterStatus
{
///
/// 抵達
///
Arrived,
///
/// 異常
///
Alarm
}
///
/// 電梯貨物狀態
///
public enum LifterItemStatus
{
///
/// 有貨物
///
HadItem,
///
/// 無貨物
///
NotHaveItem
}
///
/// 鐵捲門狀態
///
public enum RollingDoorStatus
{
///
/// 開啟
///
Open,
///
/// 關閉
///
Close
}
///
/// 維修門狀態
///
//[JsonConverter(typeof(JsonStringEnumConverter))]
public enum RepairDoorStatus
{
///
/// 開啟
///
Open,
///
/// 強制開啟
///
ForceOpen,
///
/// 關閉
///
Close
}
#endregion
#region === [Event] ===
///
/// 取放貨事件
///
public enum LoadUnloadEvent
{
///
/// 取貨
///
Load,
///
/// 放貨
///
Unload
}
///
/// 緊急事件
///
public enum EmergencyEvent
{
///
/// 地震
///
Earthquake,
///
/// 消防
///
Fire
}
///
/// 庫區派送命令事件
///
public enum DispatchEvent
{
///
/// 上鎖
///
Lock,
///
/// 解鎖
///
Unlock
}
#endregion
#region === [Result Code] ===
///
/// 建立命令結果
///
public enum CreateCommandResultCode
{
///
/// 成功
///
Success,
///
/// 拒絕
///
Reject,
///
/// 起始位置不存在
///
SourceNotExist,
///
/// 目的位置不存在
///
DestinationNotExist
}
///
/// 取消命令結果
///
public enum CancelCommandResultCode
{
///
/// 成功
///
Success,
///
/// 拒絕
///
Reject
}
///
/// 建立取放貨結果
///
public enum CreateLoadUnloadResultCode
{
///
/// 成功
///
Success,
///
/// 失敗
///
Reject
}
///
/// 允許取放貨結果
///
public enum PermitLoadUnloadResultCode
{
///
/// 允許
///
Permit,
///
/// 不允許
///
NotPermit
}
///
/// 檢查載具編號及物料編號結果
///
public enum CarrierIDInsepectResultCode
{
///
/// 成功
///
Success,
///
/// 載具編號錯誤
///
CarrierIDError,
///
/// 物料編號錯誤
///
MaterialIDError
}
///
/// 移動台車詢問結果
///
public enum MoveCarResultCode
{
///
/// 成功
///
Success,
///
/// 拒絕
///
Reject
}
///
/// 呼叫電梯結果
///
public enum CallLifterResultCode
{
///
/// 成功
///
Success,
///
/// 拒絕
///
Reject
}
///
/// 使用維修門結果
///
public enum UseRepairDoorResultCode
{
///
/// 成功
///
Success,
///
/// 維修門不存在
///
RepairDoorNotExist
}
///
/// 使用鐵捲門結果
///
public enum UseRollingDoorResultCode
{
///
/// 成功
///
Success,
///
/// 拒絕
///
Reject
}
///
/// 物料檢測結果
///
public enum MaterialInspectResultCode
{
///
/// 成功
///
Success,
///
/// 過輕
///
TooLight,
///
/// 過重
///
TooHeavy,
///
/// 沒有重量
///
NoWeight
}
///
/// 緊急事件結果
///
public enum EmergencyEventResultCode
{
///
/// 成功
///
Success,
///
/// 失敗
///
Failed
}
///
/// 建立電梯命令結果
///
public enum CreateLifterCommandResultCode
{
///
/// 成功
///
Success,
///
/// 拒絕
///
Reject
}
///
/// 取消電梯命令結果
///
public enum CancelLifterCommandResultCode
{
///
/// 成功
///
Success,
///
/// 拒絕
///
Reject
}
#endregion
///
/// 訊息擴充方法類別
///
public static class MessageExtension
{
///
/// 轉換成任務模式
///
/// 任務模式 (資料庫)
/// 任務模式
/// 未定義數值
public static TaskActionMode ToTaskMode(this int taskMode)
{
return (taskMode) switch
{
1 => TaskActionMode.StoreIn,
2 => TaskActionMode.StoreOut,
_ => throw new ArgumentException($"Unknown task mode {taskMode}")
};
}
///
/// 轉換成任務狀態 (資料庫)
///
/// 任務完成狀態
/// 任務狀態 (資料庫)
/// 未定義列舉項目
public static int ToTaskStatus(this TaskCompleteStatus taskCompleteStatus)
{
return (taskCompleteStatus) switch
{
TaskCompleteStatus.Complete => 4,
TaskCompleteStatus.ForceComplete => 5,
TaskCompleteStatus.Failed => 6,
TaskCompleteStatus.Cancel => 7,
TaskCompleteStatus.ForceCancel => 8,
_ => throw new ArgumentException($"Unknown task complete status {taskCompleteStatus}")
};
}
///
/// 轉換成任務狀態
///
/// 取消模式列舉
/// 任務狀態
/// 未定義列舉項目
public static int ToTaskStatus(this TaskCancelMode cancelMode)
{
return (cancelMode) switch
{
TaskCancelMode.ForceComplete => 5,
TaskCancelMode.Cancel => 7,
TaskCancelMode.ForceCancel => 8,
_ => throw new ArgumentException($"Unknown cancel mode {cancelMode}")
};
}
///
/// 轉換成操作模式
///
/// 操作模式
/// 操作模式
public static int ToOperationMode(this OperationMode operationMode)
{
return (operationMode) switch
{
OperationMode.OnlineRemote => 0,
OperationMode.OnlineLocal => 1,
OperationMode.Offline => 2,
_ => 3
};
}
}
}