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.
79 lines
2.8 KiB
C#
79 lines
2.8 KiB
C#
using NewLife;
|
|
|
|
namespace WorkerSynReport.Plc;
|
|
|
|
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);
|
|
FeedValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 24);
|
|
ActTolerance = 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 FeedValue { get; private set; }
|
|
public float ActTolerance { get; private set; }
|
|
}
|
|
|
|
|
|
public class UntiStatusHMIArrayManager
|
|
{
|
|
private int Length;
|
|
private int StartSet;
|
|
private int SLength;
|
|
private byte[] Bytes;
|
|
|
|
/// <summary>
|
|
/// 数组处理
|
|
/// </summary>
|
|
/// <param name="length">数组长度</param>
|
|
/// <param name="startSet">数组起始偏移量</param>
|
|
/// <param name="sLength">数组单个元素长度</param>
|
|
public UntiStatusHMIArrayManager(ushort length, int startSet, int sLength, byte[] bytes)
|
|
{
|
|
Length = length;
|
|
StartSet = startSet;
|
|
SLength = sLength;
|
|
Bytes = bytes;
|
|
}
|
|
|
|
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 = 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 UntiStatusHMIArrayEntity(singleBlock));
|
|
}
|
|
return ListE;
|
|
}
|
|
} |