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.
76 lines
2.0 KiB
C#
76 lines
2.0 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;
|
|
byte[] Bytes;
|
|
public WeterEntity(int startSet, byte[] bytes)
|
|
{
|
|
this.StartSet = startSet;
|
|
this.Bytes = bytes;
|
|
}
|
|
public List<Recipe_WMixE> Step => new WeterArrayManager(10, StartSet, 20, Bytes).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;
|
|
private byte[] Bytes;
|
|
|
|
public WeterArrayManager(ushort length, int startSet, int sLength, byte[] bytes)
|
|
{
|
|
Length = length;
|
|
StartSet = startSet;
|
|
SLength = sLength;
|
|
Bytes = bytes;
|
|
}
|
|
|
|
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 = 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_WMixE(singleBlock));
|
|
}
|
|
return ListE;
|
|
}
|
|
}
|
|
}
|