You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.4 KiB
45 lines
1.4 KiB
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;
|
|
}
|
|
}
|
|
|
|
}
|
|
|