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/WetReportEntity.cs

87 lines
3.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataBlockHelper.Entity.DB2106Entity
{
public class WetMixingEntity
{
private int StartSet;
public WetMixingEntity(int startSet)
{
this.StartSet = startSet;
}
public List<Report_WMixE> WetMixing_A => new WetReportArrayManager(10, StartSet, 26).GetList();
public List<Report_WMixE> WetMixing_B => new WetReportArrayManager(10, StartSet + 260, 26).GetList();
public List<Report_WMixE> WetMixing_C => new WetReportArrayManager(10, StartSet + 520, 26).GetList();
public List<Report_WMixE> WetMixing_D => new WetReportArrayManager(10, StartSet + 780, 26).GetList();
public List<Report_WMixE> WetMixing_E => new WetReportArrayManager(10, StartSet + 1040, 26).GetList();
public List<Report_WMixE> WetMixing_F => new WetReportArrayManager(10, StartSet + 1300, 26).GetList();
public List<Report_WMixE> WetMixing_G => new WetReportArrayManager(10, StartSet + 1560, 26).GetList();
public List<Report_WMixE> WetMixing_H => new WetReportArrayManager(10, StartSet + 1820, 26).GetList();
}
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);
}
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; }
}
public class WetReportArrayManager
{
private int Length;
private int StartSet;
private int SLength;
public WetReportArrayManager(ushort length, int startSet, int sLength)
{
Length = length;
StartSet = startSet;
SLength = sLength;
}
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 = getListE.Content;
for (int i = 0; i < Length; i++)
{
var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray();
ListE.Add(new Report_WMixE(singleBlock));
}
return ListE;
}
}
}