using MiniExcelLibs.Attributes;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace JinYuan.Models
{
///
/// 通信设备实体类
///
public class PlcDevice
{
///
/// PLC编号
///
public int PlcNum { get; set; }
///
/// IP地址
///
public string IPAddress { get; set; }
///
/// 端口
///
public int Port { get; set; }
///
/// PLC类型
///
public string PLCType { get; set; }
///
/// 是否启用
///
public bool IsActive { get; set; }
///
/// 心跳地址
///
public string HeartBeat { get; set; }
///
/// 是否启用心跳消息
///
public bool IsHeartBeat { get; set; }
///
/// 链接成功标志
///
public bool IsConnected { get; set; }
///
/// 是否是首次连接
///
public bool IsFirstConnect { get; set; } = true;
///
/// 重连周期
///
public int ReConnectTime { get; set; } = 2000;
///
/// 休眠时间
///
public int SleepTime { get; set; } = 10;
///
/// 大小端
///
[JsonIgnore]
public int DataFormat { get; set; } = 0;
///
/// 出错次数
///
public int ErrorTimes { get; set; }
///
/// 容错次数
///
public int AllowErrorTimes { get; set; } = 3;
///
/// 多线程取消源标志位
///
public CancellationTokenSource Cts { get; set; }
///
/// 通信组集合
///
public List GroupList { get; set; } = new List();
}
public class PlcGroup
{
///
/// PLC编号
///
public int PlcNum { get; set; }
///
///通信组名称
///
public string GroupName { get; set; }
///
/// 起始地址
///
public string Start { get; set; }
///
/// 长度
///
public ushort Length { get; set; }
///
/// 是否为触发读取
///
public bool IsTiggerRead { get; set; }
///
/// 是否需要反馈结果到PLC
///
public bool IsFeedbackPlc { get; set; }
///
/// 是否启用
///
public bool IsActive { get; set; }
///
/// 备注说明
///
public string Remark { get; set; }
///
/// 机架号,对于物流线需要带线号,对于组盘机只要子架号
///
public string StationName { get; set; }
///
/// 变量集合
///
[ExcelIgnore]
public List VarList { get; set; }
}
///
/// 变量属性类
///
public class PlcVariable
{
///
/// PLC编号
///
public int PlcNum { get; set; }
///
/// 变量名称
///
public string VarName { get; set; }
///
/// 变量地址
///
public string VarAddress { get; set; }
///
/// 起始索引
///
public string Start { get; set; }
///
/// 数据类型
///
public string DataType { get; set; }
///
/// 偏移或长度
///
public int OffsetOrLength { get; set; }
///
/// 所属通信组名称
///
public string GroupName { get; set; }
///
/// 机架号,对于物流线需要带线号,对于组盘机只要子架号
///
public string StationName { get; set; }
}
public class PlcStates
{
// ... 现有的属性 ...
public short OldStatus { get; set; }
public int StatusCount { get; set; }
public string GuidAlarm { get; set; }
public List Status { get; set; }
}
// 串口配置类
public class SerialPortConfig
{
public bool IsActive { get; set; }
public string PortName { get; set; }
public int BaudRate { get; set; }
public string DeviceName { get; set; }
public SerialPort serialPort { get; set; }
public bool IsConnected { get; set; }
}
}