PLCGroup.cs 2.16 KB
Newer Older
1 2 3
using Misc;
using Newtonsoft.Json;
using System;
潘栩锋's avatar
潘栩锋 committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;

namespace FLY.Modbus
{
    /// <summary>
    /// 加载通讯列表用
    /// </summary>
    public class PLCGroup
    {
        public class PLCDevice
        {
18 19 20 21 22
            /// <summary>
            /// PLC 名称 用于报警时,能有提示
            /// </summary>
            public string PlcName;

23
            [JsonConverter(typeof(IPEndPointJsonConverter))]
24
            public IPEndPoint EP;
潘栩锋's avatar
潘栩锋 committed
25 26 27 28 29 30 31
        }

        public class PLCVariable
        {
            /// <summary>
            /// 设备序号
            /// </summary>
32
            public int DeviceIndex;
潘栩锋's avatar
潘栩锋 committed
33 34 35
            /// <summary>
            /// 值为 0,1,3,4 ;对应modbus寄存器的区号
            /// </summary>
36
            public string Mode;
潘栩锋's avatar
潘栩锋 committed
37 38 39
            /// <summary>
            /// 区号的地址
            /// </summary>
40
            public int Addr;
潘栩锋's avatar
潘栩锋 committed
41 42 43
            /// <summary>
            /// 类型 只有 bool 才对应 bool, 其它数值类型 都转为 float
            /// </summary>
44
            public string Type;
潘栩锋's avatar
潘栩锋 committed
45 46 47
            /// <summary>
            /// 放大倍数
            /// </summary>
48
            public double Scale;
潘栩锋's avatar
潘栩锋 committed
49 50 51
            /// <summary>
            /// 属性拥有者名称
            /// </summary>
52
            public string OwnerName;
潘栩锋's avatar
潘栩锋 committed
53 54 55
            /// <summary>
            /// 属性名称
            /// </summary>
56
            public string PropertyName;
潘栩锋's avatar
潘栩锋 committed
57

58 59 60 61 62
            /// <summary>
            /// 原始寄存器地址
            /// </summary>
            public string RegAddr;

潘栩锋's avatar
潘栩锋 committed
63 64
            public override string ToString()
            {
65
                return $"{OwnerName}.{PropertyName} ({RegAddr})=dev{DeviceIndex}[{Mode}]({Addr})";
潘栩锋's avatar
潘栩锋 committed
66 67 68
            }
        }

69 70 71 72
        /// <summary>
        /// 版本
        /// </summary>
        public string Version;
潘栩锋's avatar
潘栩锋 committed
73

74 75 76
        /// <summary>
        /// 设备列表
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
77
        public List<PLCDevice> Devices = new List<PLCDevice>();
78 79 80 81

        /// <summary>
        /// 寄存器列表
        /// </summary>
潘栩锋's avatar
潘栩锋 committed
82 83 84
        public List<PLCVariable> Variables = new List<PLCVariable>();
    }
}