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

213 lines
5.2 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 DB2114Helper: DBHelper
{
public DB2114Helper()
{
OperateResult<byte[]> db = PlcConnect.Instance.Read("DB2114.0.0", 9);
bytes = db.Content;
}
public Rdy Rdy
{
get
{
byte[] content = bytes.Skip(0).Take(2).ToArray();
var trans = PlcConnect.Instance.ByteTransform;
Rdy rdy = new Rdy();
return rdy;
}
}
/// <summary>
/// 糊化机已经加完冷水
/// </summary>
public FeedCW CW
{
get
{
FeedCW feedCW = new FeedCW();
byte[] content = bytes.Skip(5).Take(2).ToArray();
var a = content[0];
feedCW.G1=a.GetBit(4);
feedCW.G2 = a.GetBit(5);
feedCW.G3 = a.GetBit(6);
feedCW.G4 = a.GetBit(7);
var b = content[1];
feedCW.G5 = b.GetBit(0);
feedCW.G6 = b.GetBit(1);
feedCW.G7 = b.GetBit(2);
feedCW.G8 = b.GetBit(3);
return feedCW;
}
}
/// <summary>
/// 糊化机已经加完热水
/// </summary>
public FeedCW HW
{
get
{
FeedCW feedHW = new FeedCW();
byte[] content = bytes.Skip(6).Take(2).ToArray();
var a = content[0];
feedHW.G1 = a.GetBit(4);
feedHW.G2 = a.GetBit(5);
feedHW.G3 = a.GetBit(6);
feedHW.G4 = a.GetBit(7);
var b = content[1];
feedHW.G5 = b.GetBit(0);
feedHW.G6 = b.GetBit(1);
feedHW.G7 = b.GetBit(2);
feedHW.G8 = b.GetBit(3);
return feedHW;
}
}
/// <summary>
/// 湿混机已经加完干混料
/// </summary>
public FeedDry Dry
{
get
{
FeedDry dry=new FeedDry();
byte[] content = bytes.Skip(3).Take(2).ToArray();
var a = content[0];
dry.M1 = a.GetBit(4);
dry.M2 = a.GetBit(5);
dry.M3 = a.GetBit(6);
dry.M4 = a.GetBit(7);
var b = content[1];
dry.M5 = b.GetBit(0);
dry.M6 = b.GetBit(1);
dry.M7 = b.GetBit(2);
dry.M8 = b.GetBit(3);
return dry;
}
}
/// <summary>
/// 湿混机已经加完糊化料
/// </summary>
public FeedDry Gel
{
get
{
FeedDry dry = new FeedDry();
byte[] content = bytes.Skip(4).Take(2).ToArray();
var a = content[0];
dry.M1 = a.GetBit(4);
dry.M2 = a.GetBit(5);
dry.M3 = a.GetBit(6);
dry.M4 = a.GetBit(7);
var b = content[1];
dry.M5 = b.GetBit(0);
dry.M6 = b.GetBit(1);
dry.M7 = b.GetBit(2);
dry.M8 = b.GetBit(3);
return dry;
}
}
public FeedCW PD
{
get
{
FeedCW cW = new FeedCW();
byte[] content = bytes.Skip(7).Take(2).ToArray();
var a = content[0];
cW.G1 = a.GetBit(4);
cW.G2 = a.GetBit(5);
cW.G3 = a.GetBit(6);
cW.G4 = a.GetBit(7);
var b = content[1];
cW.G5 = b.GetBit(0);
cW.G6 = b.GetBit(1);
cW.G7 = b.GetBit(2);
cW.G8 = b.GetBit(3);
return cW;
}
}
}
public class Rdy
{
public bool B1 { get; set; }
public bool B2 { get; set; }
public bool B3 { get; set; }
public bool B4 { get; set; }
public bool B5 { get; set; }
public bool B6 { get; set; }
public bool B7 { get; set; }
public bool B8 { get; set; }
public bool B9 { get; set; }
public bool B10 { get; set; }
public bool B11 { get; set; }
public bool B12 { get; set; }
}
/// <summary>
///
/// </summary>
public class FeedCW
{
public bool G1 { get; set; }
public bool G2 { get; set; }
public bool G3 { get; set; }
public bool G4 { get; set; }
public bool G5 { get; set; }
public bool G6 { get; set; }
public bool G7 { get; set; }
public bool G8 { get; set; }
}
public class FeedDry
{
public bool M1 { get; set;}
public bool M2 { get; set; }
public bool M3 { get; set; }
public bool M4 { get; set; }
public bool M5 { get; set; }
public bool M6 { get; set; }
public bool M7 { get; set; }
public bool M8 { get; set; }
}
}