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

129 lines
3.2 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", 52).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 <4; 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 < 8; 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 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; }
}
}