forked from GavinYellow/SharpSCADA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeviceAddress.cs
More file actions
45 lines (40 loc) · 1.38 KB
/
Copy pathDeviceAddress.cs
File metadata and controls
45 lines (40 loc) · 1.38 KB
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
using System;
using System.Runtime.InteropServices;
namespace DataService
{
[StructLayout(LayoutKind.Sequential)]
public struct DeviceAddress : IComparable<DeviceAddress>
{
public int Area;
public int Start;
public ushort DBNumber;
public ushort DataSize;
public ushort CacheIndex;
public byte Bit;
public DataType VarType;
public ByteOrder ByteOrder;
public DeviceAddress(int area, ushort dbnumber, ushort cIndex, int start, ushort size, byte bit, DataType type, ByteOrder order = ByteOrder.None)
{
Area = area;
DBNumber = dbnumber;
CacheIndex = cIndex;
Start = start;
DataSize = size;
Bit = bit;
VarType = type;
ByteOrder = order;
}
public static readonly DeviceAddress Empty = new DeviceAddress(0, 0, 0, 0, 0, 0, DataType.NONE);
public int CompareTo(DeviceAddress other)
{
return this.Area > other.Area ? 1 :
this.Area < other.Area ? -1 :
this.DBNumber > other.DBNumber ? 1 :
this.DBNumber < other.DBNumber ? -1 :
this.Start > other.Start ? 1 :
this.Start < other.Start ? -1 :
this.Bit > other.Bit ? 1 :
this.Bit < other.Bit ? -1 : 0;
}
}
}