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/DBHelpers/DB112Helper.cs

107 lines
2.9 KiB
C#

12 months ago
using HslCommunication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataBlockHelper.DBHelpers
{
public class DB112Helper : DBHelper
12 months ago
{
public DB112Helper()
{
12 months ago
OperateResult<byte[]> db112 = PlcConnect.Instance.Read("DB112.0.0", 151);
bytes = db112.Content;
}
5 months ago
/// <summary>
/// 这个就是那个产线在运行
/// </summary>
/// <returns></returns>
5 months ago
public XX GetXX()
{
XX x=new XX();
var content = bytes.Skip(0).Take(1).ToArray().First();
x.A=content.GetBit(0);
x.B=content.GetBit(1);
x.C=content.GetBit(2);
return x;
}
12 months ago
public Conveyor PressureA => new Conveyor(2, bytes);
public Conveyor PressureB => new Conveyor(34, bytes);
public Conveyor PressureC => new Conveyor(66, bytes);
public ConveyorTimer LineTimeA => new ConveyorTimer(98, bytes);
12 months ago
public ConveyorTimer LineTimeB => new ConveyorTimer(102, bytes);
public ConveyorTimer LineTimeC => new ConveyorTimer(104, bytes);
}
5 months ago
public class XX
{
public bool A { get; set; }
public bool B { get; set; }
public bool C { get; set; }
}
12 months ago
public class Conveyor
{
public Conveyor() { }
public Conveyor(ushort startSet, byte[] bytes)
{
byte[] content = bytes.Skip(startSet).Take(32).ToArray();
var trans = PlcConnect.Instance.ByteTransform;
12 months ago
SetValue1 = trans.TransSingle(content, 0);
SetValue2 = trans.TransSingle(content, 4);
SetValue3 = trans.TransSingle(content, 8);
SetValue4 = trans.TransSingle(content, 12);
SetValue5 = trans.TransSingle(content, 16);
SetValue6 = trans.TransSingle(content, 20);
SetValue7 = trans.TransSingle(content, 24);
SetValue8 = trans.TransSingle(content, 28);
}
public float SetValue1 { get; set; }
public float SetValue2 { get; set; }
public float SetValue3 { get; set; }
public float SetValue4 { get; set; }
public float SetValue5 { get; set; }
public float SetValue6 { get; set; }
public float SetValue7 { get; set; }
public float SetValue8 { get; set; }
}
public class ConveyorTimer
{
public ConveyorTimer()
{
}
public ConveyorTimer(ushort startSet, byte[] bytes)
{
byte[] content = bytes.Skip(startSet).Take(4).ToArray();
var trans = PlcConnect.Instance.ByteTransform;
SetValue1 = trans.TransInt16(content, 0);
SetValue2 = trans.TransInt16(content, 2);
}
public short SetValue1 { get; set; }
public short SetValue2 { get; set; }
}
}