using SqlSugar;
using WIDESEAWCS_Core.DB.Models;
namespace WIDESEAWCS_Model.Models
{
///
/// 机械手状态数据库实体
///
///
/// 对应数据库表 Dt_RobotState,使用 Version 字段实现乐观并发控制。
/// 复杂对象(RobotCrane、CurrentTask、数组等)以 JSON 字符串存储。
///
[SugarTable(nameof(Dt_RobotState), "机械手状态表")]
public class Dt_RobotState : BaseEntity
{
///
/// 主键 ID
///
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主键ID")]
public int Id { get; set; }
///
/// 机械手 IP 地址,唯一索引
///
[SugarColumn(Length = 50, ColumnDescription = "机械手IP地址")]
public string IPAddress { get; set; } = string.Empty;
///
/// 版本号,用于乐观并发控制
///
///
/// 每次更新时自增。更新时 WHERE IPAddress = @ip AND Version = @expectedVersion。
/// 如果影响行数为 0,说明版本不匹配,返回 false。
///
[SugarColumn(ColumnDescription = "版本号(乐观锁)")]
public long Version { get; set; }
///
/// 是否已订阅消息事件
///
[SugarColumn(ColumnDescription = "是否已订阅消息事件")]
public bool IsEventSubscribed { get; set; }
///
/// 机械手运行模式
///
/// 1: 手动模式, 2: 自动模式
[SugarColumn(ColumnDescription = "运行模式", IsNullable = true)]
public int? RobotRunMode { get; set; }
///
/// 机械手控制模式
///
/// 1: 客户端控制, 2: 其他
[SugarColumn(ColumnDescription = "控制模式", IsNullable = true)]
public int? RobotControlMode { get; set; }
///
/// 机械手手臂抓取对象状态
///
/// 0: 无物料(手臂空闲), 1: 有物料(已抓取货物)
[SugarColumn(ColumnDescription = "手臂抓取状态", IsNullable = true)]
public int? RobotArmObject { get; set; }
///
/// 机械手设备基础信息(JSON 序列化)
///
[SugarColumn(Length = 2000, ColumnDescription = "设备信息JSON", IsNullable = true)]
public string? RobotCraneJson { get; set; }
///
/// 机械手初始化完成回到待机位状态
///
/// Possible values: "Homed", "Homing"
[SugarColumn(Length = 50, ColumnDescription = "回零状态", IsNullable = true)]
public string? Homed { get; set; }
///
/// 机械手当前正在执行的动作
///
[SugarColumn(Length = 50, ColumnDescription = "当前动作", IsNullable = true)]
public string? CurrentAction { get; set; }
///
/// 机械手当前运行状态
///
[SugarColumn(Length = 50, ColumnDescription = "运行状态", IsNullable = true)]
public string? OperStatus { get; set; }
///
/// 最近一次取货完成的位置数组(JSON)
///
[SugarColumn(Length = 500, ColumnDescription = "取货位置数组JSON", IsNullable = true)]
public string? LastPickPositionsJson { get; set; }
///
/// 最近一次放货完成的位置数组(JSON)
///
[SugarColumn(Length = 500, ColumnDescription = "放货位置数组JSON", IsNullable = true)]
public string? LastPutPositionsJson { get; set; }
///
/// 电池/货位条码列表(JSON)
///
[SugarColumn(Length = 2000, ColumnDescription = "电芯条码列表JSON", IsNullable = true)]
public string? CellBarcodeJson { get; set; }
///
/// 机械手当前正在执行的任务(JSON 序列化)
///
[SugarColumn(Length = 2000, ColumnDescription = "当前任务JSON", IsNullable = true)]
public string? CurrentTaskJson { get; set; }
///
/// 是否需要执行拆盘任务
///
[SugarColumn(ColumnDescription = "是否拆盘任务")]
public bool IsSplitPallet { get; set; }
///
/// 是否需要执行组盘任务
///
[SugarColumn(ColumnDescription = "是否组盘任务")]
public bool IsGroupPallet { get; set; }
///
/// 机器人已处理的任务总数
///
[SugarColumn(ColumnDescription = "已处理任务总数")]
public int RobotTaskTotalNum { get; set; }
///
/// 是否处于假电芯补充模式
///
[SugarColumn(ColumnDescription = "是否假电芯模式")]
public bool IsInFakeBatteryMode { get; set; }
///
/// 当前批次起始编号
///
[SugarColumn(ColumnDescription = "当前批次编号")]
public int CurrentBatchIndex { get; set; } = 1;
///
/// 换盘任务当前阶段
///
[SugarColumn(ColumnDescription = "换盘阶段")]
public int ChangePalletPhase { get; set; }
///
/// 是否扫码NG
///
[SugarColumn(ColumnDescription = "是否扫码NG")]
public bool IsScanNG { get; set; }
///
/// 是否电芯到位
///
[SugarColumn(ColumnDescription = "电芯是否到位")]
public bool BatteryArrived { get; set; }
}
}