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/DB2106Entity/DryReportEntity.cs

144 lines
5.5 KiB
C#

using HslCommunication;
using HslCommunication.Profinet.Inovance;
using HslCommunication.Profinet.Knx;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataBlockHelper.Entity.DB2106Entity
{
public class DryerReportEntity
{
private int StartSet;
byte[] Bytes;
public DryerReportEntity(int startSet, byte[] bytes)
{
this.StartSet = startSet;
this.Bytes = bytes;
}
public Dryer_ Dryer_A => new Dryer_(StartSet, Bytes);
public Dryer_ Dryer_B => new Dryer_(StartSet + 268, Bytes);
public Dryer_ Dryer_C => new Dryer_(StartSet + 536, Bytes);
public Dryer_ Dryer_D => new Dryer_(StartSet + 804, Bytes);
}
public class Dryer_
{
private int StartSet;
private byte[] Bytes;
public Dryer_(int startSet, byte[] bytes)
{
this.StartSet = startSet;
this.Bytes = bytes;
}
public List<Report_DosE> Dos => new ReportArrayManager(4, StartSet, 22, Bytes).GetReport_DosEList();
public List<Report_MixE> Mix => new ReportArrayManager(10, StartSet + 88, 18, Bytes).GetReport_MixEList();
}
public class Report_DosE
{
public Report_DosE(byte[] content)
{
EqNo = PlcConnect.Instance.ByteTransform.TransInt16(content, 0);
Batch = PlcConnect.Instance.ByteTransform.TransInt16(content, 2);
MatCode = PlcConnect.Instance.ByteTransform.TransInt16(content, 4);
SetValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 6);
SetToler = PlcConnect.Instance.ByteTransform.TransSingle(content, 10);
ActValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 14);
ActToler = PlcConnect.Instance.ByteTransform.TransSingle(content, 18);
}
public Report_DosE(ushort startSet, byte[] bytes)
{
//var read = PlcConnect.Instance.Read("DB2107." + startSet + ".0", 22);
var content = bytes.Skip(startSet).Take(22).ToArray();
EqNo = PlcConnect.Instance.ByteTransform.TransInt16(content, 0);
Batch = PlcConnect.Instance.ByteTransform.TransInt16(content, 2);
MatCode = PlcConnect.Instance.ByteTransform.TransInt16(content, 4);
SetValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 6);
SetToler = PlcConnect.Instance.ByteTransform.TransSingle(content, 10);
ActValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 14);
ActToler = PlcConnect.Instance.ByteTransform.TransSingle(content, 18);
}
public short EqNo { get; private set; }
public short Batch { get; private set; }
public short MatCode { get; private set; }
public float SetValue { get; private set; }
public float SetToler { get; private set; }
public float ActValue { get; private set; }
public float ActToler { get; private set; }
}
public class Report_MixE
{
public Report_MixE(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);
}
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 class ReportArrayManager
{
private int Length;
private int StartSet;
private int SLength;
private byte[] Bytes;
public ReportArrayManager(ushort length, int startSet, int sLength, byte[] bytes)
{
Length = length;
StartSet = startSet;
SLength = sLength;
Bytes = bytes;
}
public List<Report_MixE> GetReport_MixEList()
{
List<Report_MixE> ListE = new List<Report_MixE>(Length);
//var getListE = PlcConnect.Instance.Read("DB2106." + 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 Report_MixE(singleBlock));
}
return ListE;
}
public List<Report_DosE> GetReport_DosEList()
{
List<Report_DosE> ListE = new List<Report_DosE>(Length);
//var getListE = PlcConnect.Instance.Read("DB2106." + 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 Report_DosE(singleBlock));
}
return ListE;
}
}
}