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/DB2104Entity/DryerEntity.cs

109 lines
3.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataBlockHelper.Entity.DB2104Entity
{
public class DryerEntity
{
private int StartSet;
private byte[] Bytes;
public DryerEntity(int startSet, byte[] bytes)
{
this.StartSet = startSet;
this.Bytes = bytes;
}
public DaybinE Daybin => new DaybinE(StartSet, Bytes);
public List<Recipe_GmixE> Step => new RecipeArrayManager(10, StartSet + 40, 12, Bytes).GetRecipe_GmixEList();
}
public class DaybinE
{
private int StartSet;
private byte[] Bytes;
public DaybinE(int startSet, byte[] bytes)
{
this.StartSet = startSet;
this.Bytes = bytes;
}
public List<Recipe_DosE> Recipe => new RecipeArrayManager(4, StartSet, 10, Bytes).GetRecipe_DosEList();
}
public class Recipe_DosE
{
public Recipe_DosE(byte[] content)
{
Bin = PlcConnect.Instance.ByteTransform.TransInt16(content, 0);
Set = PlcConnect.Instance.ByteTransform.TransSingle(content, 2);
TolErance = PlcConnect.Instance.ByteTransform.TransSingle(content, 6);
}
public short Bin { get; private set; }
public float Set { get; private set; }
public float TolErance { get; private set; }
}
public class Recipe_GmixE
{
public Recipe_GmixE(byte[] content)
{
MixCode = PlcConnect.Instance.ByteTransform.TransInt16(content, 0);
MixTime = PlcConnect.Instance.ByteTransform.TransInt16(content, 2);
MixTemp = PlcConnect.Instance.ByteTransform.TransSingle(content, 4);
MixSpeed = PlcConnect.Instance.ByteTransform.TransSingle(content, 8);
}
public short MixCode { get; private set; }
public short MixTime { get; private set; }
public float MixTemp { get; private set; }
public float MixSpeed { get; private set; }
}
public class RecipeArrayManager
{
private int Length;
private int StartSet;
private int SLength;
private byte[] Bytes;
public RecipeArrayManager(ushort length, int startSet, int sLength, byte[] bytes)
{
Length = length;
StartSet = startSet;
SLength = sLength;
Bytes = bytes;
}
public List<Recipe_GmixE> GetRecipe_GmixEList()
{
List<Recipe_GmixE> ListE = new List<Recipe_GmixE>(Length);
//var getListE = PlcConnect.Instance.Read("DB2104." + 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 Recipe_GmixE(singleBlock));
}
return ListE;
}
public List<Recipe_DosE> GetRecipe_DosEList()
{
List<Recipe_DosE> ListE = new List<Recipe_DosE>(Length);
//var getListE = PlcConnect.Instance.Read("DB2104." + 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 Recipe_DosE(singleBlock));
}
return ListE;
}
}
}