Files
Modbus.Net/Modbus.Net/ModBus.Net/SimenseStructDefinition.cs
parallelbgls@outlook.com 81f9df8117 2015-04-09 update 2
2015-04-09 17:08:04 +08:00

97 lines
3.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ModBus.Net
{
public struct TodClockStatus
{
public bool KV
{
get
{
var pos = 15;
return ValueHelper.Instance.GetBit(ValueHelper.Instance.GetBytes(TodValue), ref pos);
}
set { TodValue = ValueHelper.Instance.SetBit(ValueHelper.Instance.GetBytes(TodValue), 15, value); }
}
public byte K0_4
{
get
{
var pos = 0;
var byteValue = ValueHelper.Instance.GetByte(ValueHelper.Instance.GetBytes(TodValue), ref pos);
return (byte)(byteValue%64/4);
}
set
{
var pos = 0;
var byteValue = ValueHelper.Instance.GetByte(ValueHelper.Instance.GetBytes(TodValue), ref pos);
byteValue = (byte)(byteValue - (byteValue%128/4) + value);
TodValue = (ushort)(TodValue%128 + byteValue*128);
}
}
public bool ZNA
{
get
{
var pos = 5;
return ValueHelper.Instance.GetBit(ValueHelper.Instance.GetBytes(TodValue), ref pos);
}
set { TodValue = ValueHelper.Instance.SetBit(ValueHelper.Instance.GetBytes(TodValue), 5, value); }
}
public byte UA
{
get
{
var pos = 3;
var low = ValueHelper.Instance.GetBit(ValueHelper.Instance.GetBytes(TodValue), ref pos) ? 1 : 0;
var high = ValueHelper.Instance.GetBit(ValueHelper.Instance.GetBytes(TodValue), ref pos) ? 1 : 0;
high *= 2;
return (byte) (high + low);
}
set
{
TodValue = ValueHelper.Instance.SetBit(ValueHelper.Instance.GetBytes(TodValue), 3, value % 2 >= 1);
TodValue = ValueHelper.Instance.SetBit(ValueHelper.Instance.GetBytes(TodValue), 4, value / 2 >= 1);
}
}
public bool UZS
{
get
{
var pos = 2;
return ValueHelper.Instance.GetBit(ValueHelper.Instance.GetBytes(TodValue), ref pos);
}
set { TodValue = ValueHelper.Instance.SetBit(ValueHelper.Instance.GetBytes(TodValue), 2, value); }
}
public bool ESY
{
get
{
var pos = 1;
return ValueHelper.Instance.GetBit(ValueHelper.Instance.GetBytes(TodValue), ref pos);
}
set { TodValue = ValueHelper.Instance.SetBit(ValueHelper.Instance.GetBytes(TodValue), 1, value); }
}
public bool SYA
{
get
{
var pos = 0;
return ValueHelper.Instance.GetBit(ValueHelper.Instance.GetBytes(TodValue), ref pos);
}
set { TodValue = ValueHelper.Instance.SetBit(ValueHelper.Instance.GetBytes(TodValue), 0, value); }
}
public ushort TodValue { get; set; }
}
}