|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DataBlockHelper.Entity.DB2107Entity
|
|
|
|
|
{
|
|
|
|
|
public class UntiStatusHMIArrayEntity
|
|
|
|
|
{
|
|
|
|
|
public UntiStatusHMIArrayEntity(byte[] content)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
byte byt = content[0];
|
|
|
|
|
Mode = byt.GetBit(0);
|
|
|
|
|
Status = byt.GetBit(1);
|
|
|
|
|
|
|
|
|
|
Batch = PlcConnect.Instance.ByteTransform.TransUInt16(content, 2);
|
|
|
|
|
Step = PlcConnect.Instance.ByteTransform.TransUInt16(content, 4);
|
|
|
|
|
StepCode = PlcConnect.Instance.ByteTransform.TransUInt16(content, 6);
|
|
|
|
|
TotalTime = PlcConnect.Instance.ByteTransform.TransInt32(content, 8);
|
|
|
|
|
StepTime = PlcConnect.Instance.ByteTransform.TransInt32(content, 12);
|
|
|
|
|
Temperature = PlcConnect.Instance.ByteTransform.TransSingle(content, 16);
|
|
|
|
|
Speed = PlcConnect.Instance.ByteTransform.TransSingle(content, 20);
|
|
|
|
|
Currnet = PlcConnect.Instance.ByteTransform.TransSingle(content, 24);
|
|
|
|
|
Pressure = PlcConnect.Instance.ByteTransform.TransSingle(content, 28);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Mode { get; private set; }
|
|
|
|
|
public bool Status { get; private set; }
|
|
|
|
|
public ushort Batch { get; private set; }
|
|
|
|
|
public ushort Step { get; private set; }
|
|
|
|
|
public ushort StepCode { get; private set; }
|
|
|
|
|
public int TotalTime { get; private set; }
|
|
|
|
|
public int StepTime { get; private set; }
|
|
|
|
|
public float Temperature { get; private set; }
|
|
|
|
|
public float Speed { get; private set; }
|
|
|
|
|
public float Currnet { get; private set; }
|
|
|
|
|
public float Pressure { get; private set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class UntiStatusHMIArrayManager
|
|
|
|
|
{
|
|
|
|
|
private int Length;
|
|
|
|
|
private int StartSet;
|
|
|
|
|
private int SLength;
|
|
|
|
|
public UntiStatusHMIArrayManager(ushort length, int startSet, int sLength)
|
|
|
|
|
{
|
|
|
|
|
Length = length;
|
|
|
|
|
StartSet = startSet;
|
|
|
|
|
SLength = sLength;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<UntiStatusHMIArrayEntity> GetList()
|
|
|
|
|
{
|
|
|
|
|
List<UntiStatusHMIArrayEntity> ListE = new List<UntiStatusHMIArrayEntity>(Length);
|
|
|
|
|
var getListE = PlcConnect.Instance.Read("DB2107." + StartSet + ".0", Convert.ToUInt16(Length * SLength));
|
|
|
|
|
if (!getListE.IsSuccess)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception(getListE.Message);
|
|
|
|
|
}
|
|
|
|
|
var content = getListE.Content;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < Length; i++)
|
|
|
|
|
{
|
|
|
|
|
var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray();
|
|
|
|
|
ListE.Add(new UntiStatusHMIArrayEntity(singleBlock));
|
|
|
|
|
}
|
|
|
|
|
return ListE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|