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

104 lines
3.3 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;
public DryerEntity(int startSet)
{
this.StartSet = startSet;
}
public DaybinE Daybin => new DaybinE(StartSet);
public List<Recipe_GmixE> Step => new RecipeArrayManager(10, StartSet + 40, 12).GetRecipe_GmixEList();
}
public class DaybinE
{
private int StartSet;
public DaybinE(int startSet)
{
this.StartSet = startSet;
}
public List<Recipe_DosE> Recipe => new RecipeArrayManager(4, StartSet, 10).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;
public RecipeArrayManager(ushort length, int startSet, int sLength)
{
Length = length;
StartSet = startSet;
SLength = sLength;
}
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 = getListE.Content;
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 = getListE.Content;
for (int i = 0; i < Length; i++)
{
var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray();
ListE.Add(new Recipe_DosE(singleBlock));
}
return ListE;
}
}
}