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.

83 lines
3.3 KiB
C#

10 months ago
namespace WorkerSynReport.Plc;
5 months ago
public class WetMixingEntity
{
private int StartSet;
private byte[] bytes;
public WetMixingEntity(int startSet, byte[] bytes)
{
this.StartSet = startSet;
this.bytes = bytes;
}
10 months ago
5 months ago
public List<Report_WMixE> WetMixing_A => new WetReportArrayManager(10, StartSet, 26, bytes).GetList();
public List<Report_WMixE> WetMixing_B => new WetReportArrayManager(10, StartSet + 260, 26, bytes).GetList();
public List<Report_WMixE> WetMixing_C => new WetReportArrayManager(10, StartSet + 520, 26, bytes).GetList();
public List<Report_WMixE> WetMixing_D => new WetReportArrayManager(10, StartSet + 780, 26, bytes).GetList();
public List<Report_WMixE> WetMixing_E => new WetReportArrayManager(10, StartSet + 1040, 26, bytes).GetList();
public List<Report_WMixE> WetMixing_F => new WetReportArrayManager(10, StartSet + 1300, 26, bytes).GetList();
public List<Report_WMixE> WetMixing_G => new WetReportArrayManager(10, StartSet + 1560, 26, bytes).GetList();
public List<Report_WMixE> WetMixing_H => new WetReportArrayManager(10, StartSet + 1820, 26, bytes).GetList();
10 months ago
5 months ago
}
10 months ago
5 months ago
public class Report_WMixE
{
public Report_WMixE(byte[] content)
{
EqNo = PlcConnect.Instance.ByteTransform.TransInt16(content, 0);
MixBatch = PlcConnect.Instance.ByteTransform.TransInt16(content, 2);
MixStep = PlcConnect.Instance.ByteTransform.TransInt16(content, 4);
ActCode = PlcConnect.Instance.ByteTransform.TransInt16(content, 6);
MixTime = PlcConnect.Instance.ByteTransform.TransInt16(content, 8);
MixTemp = PlcConnect.Instance.ByteTransform.TransSingle(content, 10);
MixSpeed = PlcConnect.Instance.ByteTransform.TransSingle(content, 14);
ActWeight = PlcConnect.Instance.ByteTransform.TransSingle(content, 18);
ActTolerence = PlcConnect.Instance.ByteTransform.TransSingle(content, 22);
10 months ago
5 months ago
}
10 months ago
5 months ago
public short EqNo { get; private set; }
public short MixBatch { get; private set; }
public short MixStep { get; private set; }
public short ActCode { get; private set; }
public short MixTime { get; private set; }
public float MixTemp { get; private set; }
public float MixSpeed { get; private set; }
public float ActWeight { get; private set; }
public float ActTolerence { get; private set; }
10 months ago
5 months ago
}
10 months ago
5 months ago
public class WetReportArrayManager
{
private int Length;
private int StartSet;
private int SLength;
private byte[] Bytes;
10 months ago
5 months ago
public WetReportArrayManager(ushort length, int startSet, int sLength, byte[] bytes)
{
Length = length;
StartSet = startSet;
SLength = sLength;
Bytes = bytes;
}
10 months ago
5 months ago
public List<Report_WMixE> GetList()
{
List<Report_WMixE> ListE = new List<Report_WMixE>(Length);
//var getListE = PlcConnect.Instance.Read("DB2106." + StartSet + ".0", Convert.ToUInt16(Length * SLength));
var content = Bytes.Skip(StartSet).Take(Length * SLength).ToArray();
10 months ago
5 months ago
for (int i = 0; i < Length; i++)
{
var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray();
ListE.Add(new Report_WMixE(singleBlock));
}
return ListE;
}
}