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

162 lines
5.1 KiB
C#

using DataBlockHelper.Entity;
using HslCommunication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataBlockHelper.DBHelpers
{
public class Db2101Helper : DBHelper
{
public Db2101Helper()
{
OperateResult<byte[]> db = PlcConnect.Instance.Read("DB2101.0.0", 216);
bytes = db.Content;
}
public bool Start => PlcConnect.Instance.ByteTransform.TransBool(bytes, 0);
public Db2101Entity SiloA=>new Db2101Entity(2,bytes);
public Db2101Entity SiloB => new Db2101Entity(6, bytes);
public Db2101Entity SiloC => new Db2101Entity(10, bytes);
public Db2101Entity SiloD => new Db2101Entity(14, bytes);
public Db2101Entity SiloE => new Db2101Entity(18, bytes);
public Db2101Entity SiloF => new Db2101Entity(22, bytes);
public Db2101Entity SiloG => new Db2101Entity(26, bytes);
public Db2101Entity SiloH => new Db2101Entity(30, bytes);
public Db2101Entity SiloI => new Db2101Entity(34, bytes);
public Db2101Entity SiloJ => new Db2101Entity(38, bytes);
public Db2101Entity SiloK => new Db2101Entity(42, bytes);
public Db2101Entity SiloL => new Db2101Entity(46, bytes);
public Db2101Entity SiloM => new Db2101Entity(50, bytes);
public Db2101Entity SiloN => new Db2101Entity(54, bytes);
public Db2101Entity Siloo => new Db2101Entity(58, bytes);
public Db2101LinEntity LinA=>new Db2101LinEntity(124, bytes);
public Db2101LinEntity LinB => new Db2101LinEntity(134, bytes);
public Db2101LinEntity LinC => new Db2101LinEntity(144, bytes);
public short Ya => PlcConnect.Instance.ByteTransform.TransInt16(bytes, 186);
public short Yb => PlcConnect.Instance.ByteTransform.TransInt16(bytes, 188);
public short Yc => PlcConnect.Instance.ByteTransform.TransInt16(bytes, 190);
public short Yd => PlcConnect.Instance.ByteTransform.TransInt16(bytes, 192);
public short Ye => PlcConnect.Instance.ByteTransform.TransInt16(bytes, 194);
public short Yf => PlcConnect.Instance.ByteTransform.TransInt16(bytes, 196);
public short Yg => PlcConnect.Instance.ByteTransform.TransInt16(bytes, 198);
public short Yh => PlcConnect.Instance.ByteTransform.TransInt16(bytes, 200);
public short Yi => PlcConnect.Instance.ByteTransform.TransInt16(bytes, 202);
public short Yj => PlcConnect.Instance.ByteTransform.TransInt16(bytes, 204);
public short Yk => PlcConnect.Instance.ByteTransform.TransInt16(bytes, 206);
public short Yl => PlcConnect.Instance.ByteTransform.TransInt16(bytes, 208);
public short Ym => PlcConnect.Instance.ByteTransform.TransInt16(bytes, 210);
public short Yn => PlcConnect.Instance.ByteTransform.TransInt16(bytes, 212);
public short Yo => PlcConnect.Instance.ByteTransform.TransInt16(bytes, 214);
}
public class Db2101WriteHelp
{
public Db2101WriteHelp() { }
public bool WriteStart()
{
PlcConnect.Instance.Write("DB2101.0.0", true);
return true;
}
public bool Write(int begin, Db2101Entity entity)
{
PlcConnect.Instance.Write($"DB2101.{begin}.0", entity.enable);
// PlcConnect.Instance.Write($"DB2101.{begin}.1", entity.finished);
PlcConnect.Instance.Write($"DB2101.{begin+2}.0", entity.time);
return true;
}
public bool WriteA(Db2101Entity entity)
{
return Write(2, entity);
}
public bool WriteB(Db2101Entity entity)
{
return Write(6, entity);
}
public bool WriteC(Db2101Entity entity)
{
return Write(10, entity);
}
public bool WriteD(Db2101Entity entity)
{
return Write(14, entity);
}
public bool WriteE(Db2101Entity entity)
{
return Write(18, entity);
}
public bool WriteF(Db2101Entity entity)
{
return Write(22, entity);
}
public bool WriteG(Db2101Entity entity)
{
return Write(26, entity);
}
public bool WriteH(Db2101Entity entity)
{
return Write(30, entity);
}
public bool WriteI(Db2101Entity entity)
{
return Write(34, entity);
}
public bool WriteJ(Db2101Entity entity)
{
return Write(38, entity);
}
public bool WriteK(Db2101Entity entity)
{
return Write(42, entity);
}
public bool WriteL(Db2101Entity entity)
{
return Write(46, entity);
}
public bool WriteM(Db2101Entity entity)
{
return Write(50, entity);
}
public bool WriteN(Db2101Entity entity)
{
return Write(54, entity);
}
public bool WriteO(Db2101Entity entity)
{
return Write(58, entity);
}
}
}