PLCGroup.cs 1.67 KB
using Misc;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;

namespace FLY.Modbus
{
    /// <summary>
    /// 加载通讯列表用
    /// </summary>
    public class PLCGroup
    {
        public class PLCDevice
        {
            [JsonConverter(typeof(IPEndPointJsonConverter))]
            public IPEndPoint EP;
        }

        public class PLCVariable
        {
            /// <summary>
            /// 设备序号
            /// </summary>
            public int DeviceIndex;
            /// <summary>
            /// 值为 0,1,3,4 ;对应modbus寄存器的区号
            /// </summary>
            public string Mode;
            /// <summary>
            /// 区号的地址
            /// </summary>
            public int Addr;
            /// <summary>
            /// 类型 只有 bool 才对应 bool, 其它数值类型 都转为 float
            /// </summary>
            public string Type;
            /// <summary>
            /// 放大倍数
            /// </summary>
            public double Scale;
            /// <summary>
            /// 属性拥有者名称
            /// </summary>
            public string OwnerName;
            /// <summary>
            /// 属性名称
            /// </summary>
            public string PropertyName;

            public override string ToString()
            {
                return OwnerName + "." + PropertyName + " dev" + DeviceIndex + " [" + Mode + "](" + Addr + ")";
            }
        }


        public List<PLCDevice> Devices = new List<PLCDevice>();
        public List<PLCVariable> Variables = new List<PLCVariable>();
    }
}