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.
297 lines
7.5 KiB
C#
297 lines
7.5 KiB
C#
using DataBlockHelper.Entity.DB2107Entity;
|
|
using DataBlockHelper.Entity.DB2105Entity;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DataBlockHelper.DBHelpers
|
|
{
|
|
public class DB2105Helper : DBHelper
|
|
{
|
|
public DB2105Helper()
|
|
{
|
|
this.bytes = PlcConnect.Instance.Read("DB2105.0.0", 222).Content;
|
|
}
|
|
public List<PlanEntity> Plan => new PlanArrayManager(4, 0, 12, bytes).GetList();
|
|
public bool[] Status => new FourBoolArrayManager(48, bytes).GetList();
|
|
public bool[] End => new FourBoolArrayManager(50, bytes).GetList();
|
|
|
|
|
|
/// <summary>
|
|
/// 设置启动运行
|
|
/// </summary>
|
|
public List<NoVal> GetStartJob
|
|
{
|
|
get
|
|
{
|
|
List<NoVal> ls = new List<NoVal>();
|
|
var b = bytes.Skip(52).Take(1).First();
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
{
|
|
int no = i + 1;
|
|
ls.Add(new NoVal()
|
|
{
|
|
No = no,
|
|
Val = b.GetBit(i)
|
|
});
|
|
|
|
}
|
|
|
|
return ls;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取手动加粉料数据
|
|
/// </summary>
|
|
public List<NoVal> GetManScrew
|
|
{
|
|
get
|
|
{
|
|
List<NoVal> ls = new List<NoVal>();
|
|
var b = bytes.Skip(53).Take(1).First();
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
{
|
|
int no = i + 1;
|
|
ls.Add(new NoVal()
|
|
{
|
|
No = no,
|
|
Val = b.GetBit(i)
|
|
});
|
|
|
|
}
|
|
|
|
return ls;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取设定值
|
|
/// </summary>
|
|
public List<SetValue> GetSetValue
|
|
{
|
|
get
|
|
{
|
|
// 54 58
|
|
// 62 66
|
|
// 70 74
|
|
// 78 82
|
|
// 86 90
|
|
// 94 98
|
|
// 102 106
|
|
// 110 114
|
|
|
|
int start = 54;
|
|
List<SetValue> ls = new List<SetValue>();
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
int no = i + 1;
|
|
var b = bytes.Skip(start).Take(8).ToArray();
|
|
|
|
ls.Add(new SetValue()
|
|
{
|
|
No = no,
|
|
Value = PlcConnect.Instance.ByteTransform.TransSingle(b, 0),
|
|
Toterance = PlcConnect.Instance.ByteTransform.TransSingle(b, 4),
|
|
});
|
|
start += 8;
|
|
}
|
|
|
|
return ls;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public bool FeededPdG1 => FeededPdG(94);
|
|
public bool FeededPdG2 => FeededPdG(96);
|
|
public bool FeededPdG3 => FeededPdG(98);
|
|
public bool FeededPdG4 => FeededPdG(100);
|
|
public bool FeededPdG5 => FeededPdG(102);
|
|
public bool FeededPdG6 => FeededPdG(104);
|
|
public bool FeededPdG7 => FeededPdG(106);
|
|
|
|
public bool FeededPdG8 => FeededPdG(108);
|
|
|
|
|
|
|
|
|
|
public List<bool> ReadReadyG1 => ReadReady(94);
|
|
|
|
public List<bool> ReadReadyG2 => ReadReady(96);
|
|
|
|
public List<bool> ReadReadyG3 => ReadReady(98);
|
|
|
|
public List<bool> ReadReadyG4 => ReadReady(100);
|
|
|
|
public List<bool> ReadReadyG5 => ReadReady(102);
|
|
|
|
|
|
public List<bool> ReadReadyG6 => ReadReady(104);
|
|
|
|
|
|
public List<bool> ReadReadyG7 => ReadReady(106);
|
|
|
|
public List<bool> ReadReadyG8 => ReadReady(108);
|
|
|
|
|
|
|
|
public bool ReadReadyM1 => ReadReadyM(110);
|
|
|
|
public bool ReadReadyM2 => ReadReadyM(112);
|
|
|
|
public bool ReadReadyM3 => ReadReadyM(114);
|
|
|
|
public bool ReadReadyM4 => ReadReadyM(116);
|
|
|
|
|
|
public bool ReadReadyM5 => ReadReadyM(118);
|
|
|
|
public bool ReadReadyM6 => ReadReadyM(120);
|
|
|
|
public bool ReadReadyM7 => ReadReadyM(122);
|
|
|
|
public bool ReadReadyM8 => ReadReadyM(124);
|
|
|
|
/// <summary>
|
|
/// M1
|
|
/// </summary>
|
|
|
|
public bool FeededDry => ReadReady(110, 4);
|
|
|
|
|
|
//
|
|
public ManualH H1 => ReadH(134);
|
|
|
|
public ManualH H2 => ReadH(148);
|
|
|
|
public ManualH H3 => ReadH(162);
|
|
|
|
public ManualH H4 => ReadH(176);
|
|
|
|
public ForceWaterEntity Force_HA => new ForceWaterEntity(bytes, 190);
|
|
public ForceWaterEntity Force_HB => new ForceWaterEntity(bytes, 198);
|
|
public ForceWaterEntity Force_CA => new ForceWaterEntity(bytes, 206);
|
|
public ForceWaterEntity Force_CB => new ForceWaterEntity(bytes, 214);
|
|
|
|
/// <summary>
|
|
/// 获取所有的 feededDry 是不是读取好了
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<bool> FeededDryList()
|
|
{
|
|
List<bool> ls = new List<bool>(8);
|
|
|
|
for (int i = 110; i <= 124; i = i + 2)
|
|
{
|
|
ls.Add(ReadReady(i, 4));
|
|
}
|
|
return ls;
|
|
}
|
|
|
|
|
|
//94
|
|
public List<bool> ReadReady(int start)
|
|
{
|
|
var first = bytes.Skip(start).Take(1).First();
|
|
List<bool> ls = new List<bool>(3);
|
|
var pd = first.GetBit(3);
|
|
var cw = first.GetBit(4);
|
|
var hw = first.GetBit(5);
|
|
|
|
ls.Add(pd);
|
|
ls.Add(cw);
|
|
ls.Add(hw);
|
|
return ls;
|
|
|
|
}
|
|
|
|
public bool FeededPdG(int start)
|
|
{
|
|
var first = bytes.Skip(start).Take(1).First();
|
|
var pd = first.GetBit(6);
|
|
return pd;
|
|
}
|
|
|
|
public bool ReadReadyM(int start)
|
|
{
|
|
var first = bytes.Skip(start).Take(1).First();
|
|
return first.GetBit(1);
|
|
}
|
|
|
|
|
|
|
|
public bool ReadReady(int start, int bit)
|
|
{
|
|
var first = bytes.Skip(start).Take(1).First();
|
|
return first.GetBit(bit);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 读取称量的重量 和称量开始 称量结束
|
|
/// </summary>
|
|
/// <param name="start"></param>
|
|
/// <returns></returns>
|
|
public ManualH ReadH(int start)
|
|
{
|
|
ManualH manual = new ManualH();
|
|
|
|
var content = bytes.Skip(start).Take(14).ToArray();
|
|
var first = bytes.Skip(start).Take(1).First();
|
|
|
|
manual.FeedStartL = first.GetBit(0);
|
|
manual.FeedStartR = first.GetBit(1);
|
|
manual.FeedStop = first.GetBit(2);
|
|
manual.RunStatus = first.GetBit(3);
|
|
|
|
manual.SetValueL = PlcConnect.Instance.ByteTransform.TransSingle(content, 2);
|
|
manual.SetValueR = PlcConnect.Instance.ByteTransform.TransSingle(content, 6);
|
|
manual.Toterance = PlcConnect.Instance.ByteTransform.TransSingle(content, 10);
|
|
return manual;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public class NoVal
|
|
{
|
|
public int No { get; set; }
|
|
public bool Val { get; set; }
|
|
}
|
|
|
|
|
|
public class SetValue
|
|
{
|
|
public int No { get; set; }
|
|
public float Value { get; set; }
|
|
public float Toterance { get; set; }
|
|
}
|
|
|
|
public class ManualH
|
|
{
|
|
public ManualH() { }
|
|
public bool FeedStartL { get; set; }
|
|
public bool FeedStartR { get; set; }
|
|
public bool FeedStop { get; set; }
|
|
public bool RunStatus { get; set; }
|
|
public float SetValueL { get; set; }
|
|
|
|
public float SetValueR { get; set; }
|
|
public float Toterance { get; set; }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|