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.
68 lines
2.3 KiB
C#
68 lines
2.3 KiB
C#
namespace WorkerSynReport.Plc;
|
|
|
|
public class WeightPraEntity
|
|
{
|
|
byte[] bytes;
|
|
|
|
public WeightPraEntity(byte[] bytes)
|
|
{
|
|
this.bytes = bytes;
|
|
}
|
|
|
|
public List<WeightParaE> Silo => new WeightParaArrayManager(15, 694, 18, bytes).GetList();
|
|
public List<WeightParaE> Daybin => new WeightParaArrayManager(12, 964, 18, bytes).GetList();
|
|
public List<WeightParaE> Hoper => new WeightParaArrayManager(4, 1180, 18, bytes).GetList();
|
|
public List<WeightParaE> Water => new WeightParaArrayManager(4, 1252, 18, bytes).GetList();
|
|
}
|
|
|
|
|
|
|
|
public class WeightParaE
|
|
{
|
|
public WeightParaE(byte[] content)
|
|
{
|
|
HighSpeed = PlcConnect.Instance.ByteTransform.TransSingle(content, 0);
|
|
LowSpeed = PlcConnect.Instance.ByteTransform.TransSingle(content, 4);
|
|
WeightSlow = PlcConnect.Instance.ByteTransform.TransSingle(content, 8);
|
|
Precut = PlcConnect.Instance.ByteTransform.TransSingle(content, 12);
|
|
JogTime = PlcConnect.Instance.ByteTransform.TransInt16(content, 16);
|
|
|
|
}
|
|
|
|
public float HighSpeed { get; private set; }
|
|
public float LowSpeed { get; private set; }
|
|
public float WeightSlow { get; private set; }
|
|
public float Precut { get; private set; }
|
|
public int JogTime { get; private set; }
|
|
|
|
}
|
|
|
|
public class WeightParaArrayManager
|
|
{
|
|
private int Length;
|
|
private int StartSet;
|
|
private int SLength;
|
|
byte[] bytes;
|
|
|
|
public WeightParaArrayManager(ushort length, int startSet, int sLength, byte[] bytes)
|
|
{
|
|
Length = length;
|
|
StartSet = startSet;
|
|
SLength = sLength;
|
|
this.bytes = bytes;
|
|
}
|
|
|
|
public List<WeightParaE> GetList()
|
|
{
|
|
List<WeightParaE> ListE = new List<WeightParaE>(Length);
|
|
//var getListE = PlcConnect.Instance.Read("DB2107." + StartSet + ".0", Convert.ToUInt16(Length * SLength));
|
|
var content = bytes.Skip(StartSet).Take(Length * SLength).ToArray();
|
|
|
|
for (int i = 0; i < Length; i++)
|
|
{
|
|
var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray();
|
|
ListE.Add(new WeightParaE(singleBlock));
|
|
}
|
|
return ListE;
|
|
}
|
|
} |