using System;
using System.Text.Json.Serialization;
namespace Mirle.Component.API.WarehouseExecutionSystem.Models
{
///
/// 回應代碼
///
public enum ReplyCode
{
///
/// 成功
///
OK,
///
/// 失敗
///
NG
}
#region === [Mode] ===
///
/// 搬運命令模式
///
public enum CommandMode
{
///
/// 入庫
///
StoreIn,
///
/// 出庫
///
StoreOut,
///
/// 撿料/盤點
///
TaskInventory,
///
/// 站對站
///
StationToStaion,
///
/// 庫對庫
///
StorageToStorage,
///
/// 盤點作業
///
TakeInventoryOperation,
///
/// 盤點調帳
///
TaskInventoryAdjust,
///
/// 儲位維護
///
MaintenanceLoc
}
///
/// 取消命令模式
///
public enum CancelMode
{
///
/// 取消
///
Cancel,
///
/// 強制取消
///
ForceCancel,
///
/// 強制完成
///
ForceComplete
}
#endregion
#region === [Status] ===
///
/// 命令完成狀態
///
public enum CommandCompleteStatus
{
///
/// 成功
///
Complete,
///
/// 強制完成
///
ForceComplete,
///
/// 強制取消
///
ForceCancel,
///
/// 失敗
///
Failed
}
///
/// 棧板供應狀態
///
public enum PalletSupplyStatus
{
///
/// 滿載
///
Full,
///
/// 空載
///
Empty
}
#endregion
#region === [Event] ===
///
/// 緊急事件類別
///
public enum EmergencyEvent
{
///
/// 地震
///
Earthquake,
///
/// 消防
///
Fire
}
#endregion
#region === [Result Code] ===
///
/// 建立命令結果
///
public enum CreateCommandResultCode
{
///
/// 成功
///
Success,
///
/// 拒絕
///
Reject,
///
/// 拆解命令錯誤
///
DismantleCommandError
}
///
/// 取消結果代碼
///
public enum CancelCommandResultCode
{
///
/// 成功
///
Success,
///
/// 搬運命令已經執行
///
AlreadyExecute,
///
/// 取消命令錯誤
///
CancelCommandError,
///
/// PLC-C 拒絕取消命令
///
PLCCRejectCancel,
///
/// AGV-C 拒絕取消命令
///
AGVCRejectCancel,
///
/// SH-C 拒絕取消命令
///
SHTCRejectCancel,
///
/// 搬運命令序號不存在
///
CommandSequenceNumberIsNotExist
}
///
/// 檢查載具編號及物料編號結果
///
public enum CarrierIDInsepectResultCode
{
///
/// 成功
///
Success,
///
/// 載具編號錯誤
///
CarrierIDError,
///
/// 物料編號錯誤
///
MaterialIDError
}
///
/// 物料檢測結果
///
public enum MaterialInspectResultCode
{
///
/// 成功
///
Success,
///
/// 過輕
///
TooLight,
///
/// 過重
///
TooHeavy,
///
/// 沒有重量
///
NoWeight
}
///
/// 緊急事件結果
///
public enum EmergencyEventResultCode
{
///
/// 成功
///
Success,
///
/// 失敗
///
Failed
}
#endregion
///
/// 訊息擴充方法類別
///
public static class MessageExtension
{
///
/// 轉換成任務模式
///
/// 搬運命令模式
/// 任務模式
/// 未定義列舉項目
public static int ToTaskMode(this CommandMode commandMode)
{
return (commandMode) switch
{
CommandMode.StoreIn => 1,
CommandMode.StoreOut => 2,
CommandMode.TaskInventory => 3,
CommandMode.StationToStaion => 4,
CommandMode.StorageToStorage => 5,
CommandMode.TakeInventoryOperation => 6,
CommandMode.TaskInventoryAdjust => 7,
CommandMode.MaintenanceLoc => 8,
_ => throw new ArgumentException($"Unknown command mode {commandMode}")
};
}
///
/// 轉換成任務狀態
///
/// 取消模式列舉
/// 任務狀態
/// 未定義列舉項目
public static int ToTaskStatus(this CancelMode cancelMode)
{
return (cancelMode) switch
{
CancelMode.ForceComplete => 5,
CancelMode.Cancel => 7,
CancelMode.ForceCancel => 8,
_ => throw new ArgumentException($"Unknown cancel mode {cancelMode}")
};
}
}
}