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/DB92Help.cs

133 lines
3.2 KiB
C#

using HslCommunication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataBlockHelper.DBHelpers
{
public class DB92Help: DBHelper
{
public DB92Help()
{
OperateResult<byte[]> db = PlcConnect.Instance.Read("DB92.0.0", 34);
bytes = db.Content;
}
public Pipe GetPipe => new Pipe(2, bytes);
}
public class Pipe
{
public Pipe()
{
}
public Pipe(ushort startSet, byte[] bytes)
{
var trans = PlcConnect.Instance.ByteTransform;
byte[] content = bytes.Skip(startSet).Take(32).ToArray();
MainPipieA=trans.TransSingle(content, 0);
AuxPipieA = trans.TransSingle(content, 4);
MainPipieB = trans.TransSingle(content,8);
AuxPipieB=trans.TransSingle(content,12);
MainPipieC = trans.TransSingle(content, 16);
AuxPipieC = trans.TransSingle(content, 20);
UpperPressure=trans.TransSingle(content, 24);
LowerPressure = trans.TransSingle(content, 28);
}
public float MainPipieA { get; set; }
public float AuxPipieA { get; set; }
public float MainPipieB { get; set; }
public float AuxPipieB { get; set; }
public float MainPipieC { get; set; }
public float AuxPipieC { get; set; }
public float UpperPressure { get; set; }
public float LowerPressure { get; set; }
}
public class Db92DengHelp : DBHelper
{
public Db92DengHelp()
{
OperateResult<byte[]> db = PlcConnect.Instance.Read("DB92.0.0", 46);
bytes = db.Content;
}
public BoolDeg DegA=>new BoolDeg(40,bytes);
public BoolDeg DegB => new BoolDeg(42, bytes);
public BoolDeg DegC => new BoolDeg(44, bytes);
}
public class BoolDeg
{
public BoolDeg(ushort startSet, byte[] bytes)
{
var trans = PlcConnect.Instance.ByteTransform;
byte[] content = bytes.Skip(startSet).Take(2).ToArray();
byte bte=content[0];
A = bte.GetBit(0);
B = bte.GetBit(1);
C = bte.GetBit(2);
D = bte.GetBit(3);
E = bte.GetBit(4);
F = bte.GetBit(5);
G = bte.GetBit(6);
H = bte.GetBit(7);
bte=content[1];
I = bte.GetBit(0);
J = bte.GetBit(1);
K = bte.GetBit(2);
L = bte.GetBit(3);
M = bte.GetBit(4);
N = bte.GetBit(5);
O = bte.GetBit(6);
}
public bool A { get; set; }
public bool B { get; set; }
public bool C { get; set; }
public bool D { get; set; }
public bool E { get; set; }
public bool F { get; set; }
public bool G { get; set; }
public bool H { get; set; }
public bool I { get; set; }
public bool J { get; set; }
public bool K { get; set; }
public bool L { get; set; }
public bool M { get; set; }
public bool N { get; set; }
public bool O { get; set; }
}
}