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