lj_plc/DataBlockHelper/Entity/DB2106Entity/DryReportEntity.cs

139 lines
5.2 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;
public DryerReportEntity(int startSet)
{
this.StartSet = startSet;
}
public Dryer_ Dryer_A => new Dryer_(StartSet);
public Dryer_ Dryer_B => new Dryer_(StartSet + 268);
public Dryer_ Dryer_C => new Dryer_(StartSet + 536);
public Dryer_ Dryer_D => new Dryer_(StartSet + 804);
}
public class Dryer_
{
private int StartSet;
public Dryer_(int startSet)
{
this.StartSet = startSet;
}
public List<Report_DosE> Dos => new ReportArrayManager(4, StartSet, 22).GetReport_DosEList();
public List<Report_MixE> Mix => new ReportArrayManager(10, StartSet + 88, 18).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)
{
var read = PlcConnect.Instance.Read("DB2107." + startSet + ".0", 22);
var content = read.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 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;
public ReportArrayManager(ushort length, int startSet, int sLength)
{
Length = length;
StartSet = startSet;
SLength = sLength;
}
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 = getListE.Content;
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 = getListE.Content;
for (int i = 0; i < Length; i++)
{
var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray();
ListE.Add(new Report_DosE(singleBlock));
}
return ListE;
}
}
}