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.
72 lines
1.9 KiB
C#
72 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DataBlockHelper.Entity.DB2104Entity
|
|
{
|
|
public class WeterEntity
|
|
{
|
|
int StartSet;
|
|
public WeterEntity(int startSet)
|
|
{
|
|
this.StartSet = startSet;
|
|
}
|
|
public List<Recipe_WMixE> Step => new WeterArrayManager(10, StartSet, 20).GetList();
|
|
}
|
|
|
|
|
|
|
|
public class Recipe_WMixE
|
|
{
|
|
public Recipe_WMixE(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);
|
|
SetValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 12);
|
|
Tolerance = PlcConnect.Instance.ByteTransform.TransSingle(content, 16);
|
|
}
|
|
|
|
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 float SetValue { get; private set; }
|
|
public float Tolerance { get; private set; }
|
|
|
|
|
|
}
|
|
|
|
public class WeterArrayManager
|
|
{
|
|
private int Length;
|
|
private int StartSet;
|
|
private int SLength;
|
|
|
|
public WeterArrayManager(ushort length, int startSet, int sLength)
|
|
{
|
|
Length = length;
|
|
StartSet = startSet;
|
|
SLength = sLength;
|
|
}
|
|
|
|
public List<Recipe_WMixE> GetList()
|
|
{
|
|
List<Recipe_WMixE> ListE = new List<Recipe_WMixE>(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_WMixE(singleBlock));
|
|
}
|
|
return ListE;
|
|
}
|
|
}
|
|
}
|