Blame view

sys/sys_HSL/Hh.Mes.HSL/Core/Reflection/HslAddressAttribute.cs 2.45 KB
高翔 authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;

namespace HslCommunication
{
    /// <summary>
    /// 应用于Hsl组件库读取的动态地址解析
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
    public class HslDeviceAddressAttribute : Attribute
    {
        /// <summary>
        /// 设备的类似,这将决定是否使用当前的PLC地址
        /// </summary>
        public Type deviceType { get; set; }

        /// <summary>
        /// 数据的地址信息
        /// </summary>
        public string address { get; }

        /// <summary>
        /// 数据长度
        /// </summary>
        public int length { get; }

        /// <summary>
        /// 实例化一个地址特性,指定地址信息
        /// </summary>
        /// <param name="address">真实的地址信息</param>
        public HslDeviceAddressAttribute(string address)
        {
            this.address = address;
            this.length = -1;
            this.deviceType = null;
        }

        /// <summary>
        /// 实例化一个地址特性,指定地址信息
        /// </summary>
        /// <param name="address">真实的地址信息</param>
        /// <param name="deviceType">设备的地址信息</param>
        public HslDeviceAddressAttribute(string address, Type deviceType)
        {
            this.address = address;
            this.length = -1;
            this.deviceType = deviceType;
        }

        /// <summary>
        /// 实例化一个地址特性,指定地址信息和数据长度,通常应用于数组的批量读取
        /// </summary>
        /// <param name="address">真实的地址信息</param>
        /// <param name="length">读取的数据长度</param>
        public HslDeviceAddressAttribute(string address, int length)
        {
            this.address = address;
            this.length = length;
            this.deviceType = null;
        }

        /// <summary>
        /// 实例化一个地址特性,指定地址信息和数据长度,通常应用于数组的批量读取
        /// </summary>
        /// <param name="address">真实的地址信息</param>
        /// <param name="length">读取的数据长度</param>
        /// <param name="deviceType">设备类型</param>
        public HslDeviceAddressAttribute(string address, int length, Type deviceType)
        {
            this.address = address;
            this.length = length;
            this.deviceType = deviceType;
        }
    }
}