You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lj_plc/DataBlockHelper/Entity/DB2107Entity/WeightEntity.cs

58 lines
1.9 KiB
C#

using HslCommunication;
using System.Linq;
namespace DataBlockHelper.Entity.DB2107Entity
{
public class WeightEntity
{
byte[] bytes;
public WeightEntity(byte[] bytes)
{
this.bytes = bytes;
}
public Silo_HMI Hopper_1 => new Silo_HMI(432, bytes);
public Silo_HMI Hopper_2 => new Silo_HMI(446, bytes);
public Silo_HMI Hopper_3 => new Silo_HMI(460, bytes);
public Silo_HMI Hopper_4 => new Silo_HMI(474, bytes);
public Silo_HMI Vessel_1 => new Silo_HMI(488, bytes);
public Silo_HMI Vessel_2 => new Silo_HMI(502, bytes);
public Silo_HMI Vessel_3 => new Silo_HMI(516, bytes);
public Silo_HMI Vessel_4 => new Silo_HMI(530, bytes);
public Silo_HMI Vessel_5 => new Silo_HMI(544, bytes);
public Silo_HMI WScale_1 => new Silo_HMI(558, bytes);
public Silo_HMI WScale_2 => new Silo_HMI(572, bytes);
public Silo_HMI WScale_3 => new Silo_HMI(586, bytes);
public Silo_HMI WScale_4 => new Silo_HMI(600, bytes);
}
public class Silo_HMI
{
public Silo_HMI(ushort startSet, byte[] bytes)
{
//OperateResult<byte[]> read = PlcConnect.Instance.Read("DB2107." + startSet + ".0", 14);
var content = bytes.Skip(startSet).Take(14).ToArray();
ActWeight = PlcConnect.Instance.ByteTransform.TransSingle(content, 0);
HighWeight = PlcConnect.Instance.ByteTransform.TransSingle(content, 4);
LowWeight = PlcConnect.Instance.ByteTransform.TransSingle(content, 8);
byte byt = content[12];
HighLevel = byt.GetBit(0);
Lowlevel = byt.GetBit(1);
}
public float ActWeight { get; private set; }
public float HighWeight { get; private set; }
public float LowWeight { get; private set; }
public bool HighLevel { get; private set; }
public bool Lowlevel { get; private set; }
}
}