diff --git a/Data/LjLogEntity.cs b/Data/LjLogEntity.cs
new file mode 100644
index 0000000..4334e64
--- /dev/null
+++ b/Data/LjLogEntity.cs
@@ -0,0 +1,61 @@
+using Chloe.Annotations;
+
+namespace WorkerSynReport.Data;
+
+[Table(Name = "Manual_Log")]
+public class LjLogEntity
+{
+
+
+ [Column(IsPrimaryKey = true)]
+ [AutoIncrement]
+ public int id { get; set; }
+
+ ///
+ /// 0无 1水称 2螺旋
+ ///
+
+ public int? devicekind { get; set; }
+
+ ///
+ /// 设备编号
+ ///
+
+ public int? deviceno { get; set; }
+
+ ///
+ /// 日志内容
+ ///
+
+ public string logtext { get; set; } = string.Empty;
+
+ ///
+ /// 记录时间
+ ///
+
+ public DateTime? logtime { get; set; }
+
+ ///
+ /// 操作用户名
+ ///
+
+ public string userid { get; set; } = string.Empty;
+
+ ///
+ /// 日志值
+ ///
+
+ public int? value { get; set; }
+
+ ///
+ /// 0无 1水称设定值 2水称称量值 3螺旋设定值 4螺旋称量值
+ ///
+
+ public int? valuekind { get; set; }
+
+ ///
+ /// 当前日期
+ ///
+ public string createdate { get; set; }
+
+}
diff --git a/PclWorker.cs b/PclWorker.cs
new file mode 100644
index 0000000..ee6b498
--- /dev/null
+++ b/PclWorker.cs
@@ -0,0 +1,44 @@
+using NewLife.Log;
+using NewLife.Threading;
+using WorkerSynReport.Plc;
+
+namespace WorkerSynReport;
+
+public class PclWorker:BackgroundService
+{
+ private readonly IServiceScopeFactory _scopeFactory;
+ private readonly ILogger _logger;
+
+ TimerX? _timer;
+ public PclWorker(ILogger logger, IServiceScopeFactory scopeFactory)
+ {
+ _logger = logger;
+ this._scopeFactory = scopeFactory;
+ }
+
+
+ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
+ {
+ _timer ??= new TimerX(DoPlc, "", 100, 1000);
+ _timer.Async = true;
+
+ // while (!stoppingToken.IsCancellationRequested)
+ // {
+ //
+ // await Task.Delay(1000, stoppingToken);
+ // }
+ }
+
+ private void DoPlc(Object state)
+ {
+ _logger.LogInformation("{Data}",DateTime.Now.ToFullString());
+ //todo 备份数据库
+
+ // using var scope = _scopeFactory.CreateScope();
+ // var services = scope.ServiceProvider;
+ // ReportReadDb? readDb = services.GetService();
+ //
+ // readDb?.ReadReport();
+ // readDb?.ReadFeededDry();
+ }
+}
\ No newline at end of file
diff --git a/Plc/ControlSignEntity.cs b/Plc/ControlSignEntity.cs
new file mode 100644
index 0000000..7a042dc
--- /dev/null
+++ b/Plc/ControlSignEntity.cs
@@ -0,0 +1,37 @@
+using NewLife;
+
+namespace WorkerSynReport.Plc;
+
+public class ControlSignEntity
+{
+ public ControlSignEntity(byte[] bytes)
+ {
+ //OperateResult read = PlcConnect.Instance.Read("DB2107.10.0", 2);
+
+ var content = bytes.Skip(10).Take(2).ToArray();
+
+ byte byt = content[0];
+
+ AutoMode = byt.GetBit(0);
+ LocMode = byt.GetBit(1);
+ TestMode = byt.GetBit(2);
+ Start = byt.GetBit(3);
+ Pause = byt.GetBit(4);
+ Stop = byt.GetBit(5);
+ Reset = byt.GetBit(6);
+ AlarmAck = byt.GetBit(7);
+
+ byt = content[1];
+
+ LampTest = byt.GetBit(0);
+ }
+ public bool AutoMode { get; private set; }
+ public bool LocMode { get; private set; }
+ public bool TestMode { get; private set; }
+ public bool Start { get; private set; }
+ public bool Pause { get; private set; }
+ public bool Stop { get; private set; }
+ public bool Reset { get; private set; }
+ public bool AlarmAck { get; private set; }
+ public bool LampTest { get; private set; }
+}
\ No newline at end of file
diff --git a/Plc/DB2106Helper.cs b/Plc/DB2106Helper.cs
new file mode 100644
index 0000000..115dccc
--- /dev/null
+++ b/Plc/DB2106Helper.cs
@@ -0,0 +1,12 @@
+namespace WorkerSynReport.Plc;
+
+public class DB2106Helper : DBHelper
+{
+ public DB2106Helper()
+ {
+ this.bytes = PlcConnect.Instance.Read("DB2106.0.0", 6440).Content;
+ }
+ public DryerReportEntity DryReport => new DryerReportEntity(bytes);
+ public GelReportEntity GelReport => new GelReportEntity(1864, bytes);
+ public WetMixingEntity WetReport => new WetMixingEntity(4360, bytes);
+}
\ No newline at end of file
diff --git a/Plc/DB2107Helper.cs b/Plc/DB2107Helper.cs
new file mode 100644
index 0000000..d5a9e48
--- /dev/null
+++ b/Plc/DB2107Helper.cs
@@ -0,0 +1,82 @@
+namespace WorkerSynReport.Plc;
+
+ public class Db2107Helper : DBHelper
+ {
+
+ public Db2107Helper()
+ {
+ bytes = PlcConnect.Instance.Read("DB2107.0.0", 2064).Content;
+ }
+
+ // public OperateResult GetAll=>PlcConnect.Instance.Read("DB2107.0.0", 2057);
+
+ public NormalStatusEntity NormalStatus => NormalS(bytes);
+
+ private NormalStatusEntity NormalS(byte[] bytes)
+ {
+ return new NormalStatusEntity(bytes);
+ }
+
+ public ControlSignEntity ControlSign => ControlS(bytes);
+
+
+ private ControlSignEntity ControlS(byte[] bytes)
+ {
+ return new ControlSignEntity(bytes);
+ }
+
+ public PressureEntity Pressure => Press(bytes);
+
+ private PressureEntity Press(byte[] bytes)
+ {
+ return new PressureEntity(bytes);
+ }
+
+ public PIDEntity PID => Pid(bytes);
+
+ private PIDEntity Pid(byte[] bytes)
+ {
+ return new PIDEntity(bytes);
+ }
+
+ public WeightEntity Weight => Weigh(bytes);
+
+ private WeightEntity Weigh(byte[] bytes)
+ {
+ return new WeightEntity(bytes);
+ }
+
+ public WeightPraEntity WeightPra => WeightP(bytes);
+
+ private WeightPraEntity WeightP(byte[] bytes)
+ {
+ return new WeightPraEntity(bytes);
+ }
+
+ public SpeedEntity Speed => Spee(bytes);
+
+ private SpeedEntity Spee(byte[] bytes)
+ {
+ return new SpeedEntity(bytes);
+ }
+
+ public List Dryer => new UntiStatusHMIArrayManager(4, 1408, 32, bytes).GetList();
+ public List Gelater => new UntiStatusHMIArrayManager(8, 1536, 32, bytes).GetList();
+ public List Weter => new UntiStatusHMIArrayManager(8, 1792, 32, bytes).GetList();
+
+ public ValveEntity Valve => Val(bytes);
+
+ private ValveEntity Val(byte[] bytes)
+ {
+ return new ValveEntity(bytes);
+ }
+
+ public LevelEntity Level => Lev(bytes);
+
+ private LevelEntity Lev(byte[] bytes)
+ {
+ return new LevelEntity(bytes);
+ }
+
+
+ }
\ No newline at end of file
diff --git a/Plc/DB2107WriteHelper.cs b/Plc/DB2107WriteHelper.cs
new file mode 100644
index 0000000..5af1279
--- /dev/null
+++ b/Plc/DB2107WriteHelper.cs
@@ -0,0 +1,48 @@
+namespace WorkerSynReport.Plc;
+
+public class DB2107WriteHelper
+{
+ static string DbName = "DB2107";
+ public static void CleanSpare(int no)
+ {
+ int dian = no + 1;
+ var siemensS7Net = PlcConnect.Instance;
+ siemensS7Net.Write($"{DbName}.8.{dian}", false);
+ }
+
+
+
+
+ public static void CleanWater(int no)
+ {
+ int dian = no + 1;
+ var siemensS7Net = PlcConnect.Instance;
+ siemensS7Net.Write($"{DbName}.5.{dian}", false);
+ }
+
+
+ public static void Spare1(bool b)
+ {
+ var siemensS7Net = PlcConnect.Instance;
+ siemensS7Net.Write($"{DbName}.4.5", b);
+ }
+
+ public static void Spare2(bool b)
+ {
+ var siemensS7Net = PlcConnect.Instance;
+ siemensS7Net.Write($"{DbName}.4.6", b);
+ }
+
+ public static void Spare3(bool b)
+ {
+ var siemensS7Net = PlcConnect.Instance;
+ siemensS7Net.Write($"{DbName}.4.7", b);
+ }
+
+
+ public static void Spare4(bool b)
+ {
+ var siemensS7Net = PlcConnect.Instance;
+ siemensS7Net.Write($"{DbName}.5.0", b);
+ }
+}
\ No newline at end of file
diff --git a/Plc/DB2111Helper.cs b/Plc/DB2111Helper.cs
new file mode 100644
index 0000000..1918f9f
--- /dev/null
+++ b/Plc/DB2111Helper.cs
@@ -0,0 +1,19 @@
+namespace WorkerSynReport.Plc;
+
+public class DB2111Helper : DBHelper
+{
+ public DB2111Helper()
+ {
+ bytes = PlcConnect.Instance.Read("DB2111.0.0", 1682).Content;
+ }
+
+ public ReportDosEntity hwReport_A => new ReportDosEntity(bytes, 1506);
+ public ReportDosEntity hwReport_B => new ReportDosEntity(bytes, 1528);
+ public ReportDosEntity cwReport_A => new ReportDosEntity(bytes, 1550);
+ public ReportDosEntity cwReport_B => new ReportDosEntity(bytes, 1572);
+
+ public ReportDosEntity DryDosing_A => new ReportDosEntity(bytes, 1594);
+ public ReportDosEntity DryDosing_B => new ReportDosEntity(bytes, 1616);
+ public ReportDosEntity DryDosing_C => new ReportDosEntity(bytes, 1638);
+ public ReportDosEntity DryDosing_D => new ReportDosEntity(bytes, 1660);
+}
\ No newline at end of file
diff --git a/Plc/DBHelper.cs b/Plc/DBHelper.cs
new file mode 100644
index 0000000..568947e
--- /dev/null
+++ b/Plc/DBHelper.cs
@@ -0,0 +1,20 @@
+using NewLife;
+
+namespace WorkerSynReport.Plc;
+
+public class DBHelper
+{
+ public byte[] bytes;
+
+ public DBHelper(byte[] bytes)
+ {
+ this.bytes = bytes;
+ }
+
+ public DBHelper() { }
+
+ public bool ReadBitBySet(int word, int bit)
+ {
+ return bytes[word].GetBit(bit);
+ }
+}
\ No newline at end of file
diff --git a/Plc/DryerReportEntity.cs b/Plc/DryerReportEntity.cs
new file mode 100644
index 0000000..5ea3185
--- /dev/null
+++ b/Plc/DryerReportEntity.cs
@@ -0,0 +1,169 @@
+namespace WorkerSynReport.Plc;
+
+ public class DryerReportEntity
+ {
+
+ byte[] Bytes;
+ public DryerReportEntity( byte[] bytes)
+ {
+
+ this.Bytes = bytes;
+ }
+ public Dryer_ Dryer_A => new Dryer_(0, Bytes);
+
+ public Dryer_ Dryer_B => new Dryer_(466, Bytes);
+ public Dryer_ Dryer_C => new Dryer_(932, Bytes);
+ public Dryer_ Dryer_D => new Dryer_(1398, Bytes);
+ }
+
+ public class Dryer_
+ {
+
+ private byte[] Bytes;
+ int start;
+ int mixStart;
+ public Dryer_(int start, byte[] bytes)
+ {
+ this.start = start;
+ mixStart = start + 286;
+ this.Bytes = bytes;
+ }
+
+ public List Dos
+ {
+ get
+ {
+ List ListE = new List();
+
+ var content = Bytes.Skip(start).Take(286).ToArray();
+
+ for (int i = 0; i < 13; i++)
+ {
+ var singleBlock = content.Skip(i*22).Take(22).ToArray();
+ ListE.Add(new Report_DosE(singleBlock));
+ }
+ return ListE;
+ }
+ }
+ public List Mix
+ {
+ get
+ {
+ List ListE = new List();
+
+ var content = Bytes.Skip(mixStart).Take(180).ToArray();
+
+ for (int i = 0; i < 10; i++)
+ {
+ var singleBlock = content.Skip(i * 18).Take(18).ToArray();
+ ListE.Add(new Report_MixE(singleBlock));
+ }
+ return ListE;
+ }
+ }
+ }
+
+ public class Report_DosE
+ {
+ public Report_DosE(byte[] content)
+ {
+ EqNo = PlcConnect.Instance.ByteTransform.TransInt16(content, 0);
+ Batch = PlcConnect.Instance.ByteTransform.TransInt16(content, 2);
+ MatCode = PlcConnect.Instance.ByteTransform.TransInt16(content, 4);
+ SetValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 6);
+ SetToler = PlcConnect.Instance.ByteTransform.TransSingle(content, 10);
+ ActValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 14);
+ ActToler = PlcConnect.Instance.ByteTransform.TransSingle(content, 18);
+ }
+
+ public Report_DosE(ushort startSet, byte[] bytes)
+ {
+ //var read = PlcConnect.Instance.Read("DB2107." + startSet + ".0", 22);
+ var content = bytes.Skip(startSet).Take(22).ToArray();
+
+ EqNo = PlcConnect.Instance.ByteTransform.TransInt16(content, 0);
+ Batch = PlcConnect.Instance.ByteTransform.TransInt16(content, 2);
+ MatCode = PlcConnect.Instance.ByteTransform.TransInt16(content, 4);
+ SetValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 6);
+ SetToler = PlcConnect.Instance.ByteTransform.TransSingle(content, 10);
+ ActValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 14);
+ ActToler = PlcConnect.Instance.ByteTransform.TransSingle(content, 18);
+ }
+
+
+
+ public short EqNo { get; private set; }
+ public short Batch { get; private set; }
+ public short MatCode { get; private set; }
+ public float SetValue { get; private set; }
+ public float SetToler { get; private set; }
+ public float ActValue { get; private set; }
+ public float ActToler { get; private set; }
+ }
+
+ public class Report_MixE
+ {
+ public Report_MixE(byte[] content)
+ {
+ EqNo = PlcConnect.Instance.ByteTransform.TransInt16(content, 0);
+ MixBatch = PlcConnect.Instance.ByteTransform.TransInt16(content, 2);
+ MixStep = PlcConnect.Instance.ByteTransform.TransInt16(content, 4);
+ ActCode = PlcConnect.Instance.ByteTransform.TransInt16(content, 6);
+ MixTime = PlcConnect.Instance.ByteTransform.TransInt16(content, 8);
+ MixTemp = PlcConnect.Instance.ByteTransform.TransSingle(content, 10);
+ MixSpeed = PlcConnect.Instance.ByteTransform.TransSingle(content, 14);
+ }
+
+
+ public short EqNo { get; private set; }
+ public short MixBatch { get; private set; }
+ public short MixStep { get; private set; }
+ public short ActCode { get; private set; }
+ public short MixTime { get; private set; }
+ public float MixTemp { get; private set; }
+ public float MixSpeed { get; private set; }
+
+ }
+
+ public class ReportArrayManager
+ {
+ private int Length;
+ private int StartSet;
+ private int SLength;
+ private byte[] Bytes;
+ public ReportArrayManager(ushort length, int startSet, int sLength, byte[] bytes)
+ {
+ Length = length;
+ StartSet = startSet;
+ SLength = sLength;
+ Bytes = bytes;
+ }
+
+ public List GetReport_MixEList()
+ {
+ List ListE = new List();
+ //var getListE = PlcConnect.Instance.Read("DB2106." + StartSet + ".0", Convert.ToUInt16(Length * SLength));
+ var content = Bytes.Skip(StartSet).Take(Length * SLength).ToArray();
+
+ for (int i = 0; i < Length; i++)
+ {
+ var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray();
+ ListE.Add(new Report_MixE(singleBlock));
+ }
+ return ListE;
+ }
+
+ public List GetReport_DosEList()
+ {
+ List ListE = new List(Length);
+ //var getListE = PlcConnect.Instance.Read("DB2106." + StartSet + ".0", Convert.ToUInt16(Length * SLength));
+ var content = Bytes.Skip(StartSet).Take(Length * SLength).ToArray();
+
+ for (int i = 0; i < Length; i++)
+ {
+ var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray();
+ ListE.Add(new Report_DosE(singleBlock));
+ }
+ return ListE;
+ }
+ }
\ No newline at end of file
diff --git a/Plc/GelReportEntity.cs b/Plc/GelReportEntity.cs
new file mode 100644
index 0000000..87978bc
--- /dev/null
+++ b/Plc/GelReportEntity.cs
@@ -0,0 +1,36 @@
+namespace WorkerSynReport.Plc;
+
+public class GelReportEntity
+{
+ private int StartSet;
+ private byte[] bytes;
+ public GelReportEntity(int startSet, byte[] bytes)
+ {
+ this.StartSet = startSet;
+ this.bytes = bytes;
+ }
+ public Gel_ Gel_A => new Gel_(StartSet, bytes);
+ public Gel_ Gel_B => new Gel_(StartSet + 312, bytes);
+ public Gel_ Gel_C => new Gel_(StartSet + 624, bytes);
+ public Gel_ Gel_D => new Gel_(StartSet + 936, bytes);
+ public Gel_ Gel_E => new Gel_(StartSet + 1248, bytes);
+ public Gel_ Gel_F => new Gel_(StartSet + 1560, bytes);
+ public Gel_ Gel_G => new Gel_(StartSet + 1872, bytes);
+ public Gel_ Gel_H => new Gel_(StartSet + 2184, bytes);
+}
+
+public class Gel_
+{
+ private int StartSet;
+ private byte[] bytes;
+ public Gel_(int startSet, byte[] bytes)
+ {
+ this.StartSet = startSet;
+ this.bytes = bytes;
+ }
+
+ public List GelDosing => new ReportArrayManager(4, StartSet, 22, bytes).GetReport_DosEList();
+ public Report_DosE HotWater => new Report_DosE(Convert.ToUInt16(StartSet + 88), bytes);
+ public Report_DosE CoolWater => new Report_DosE(Convert.ToUInt16(StartSet + 110), bytes);
+ public List GelMixing => new ReportArrayManager(10, StartSet + 132, 18, bytes).GetReport_MixEList();
+}
diff --git a/Plc/LevelEntity.cs b/Plc/LevelEntity.cs
new file mode 100644
index 0000000..bedbcd2
--- /dev/null
+++ b/Plc/LevelEntity.cs
@@ -0,0 +1,73 @@
+using NewLife;
+
+namespace WorkerSynReport.Plc;
+
+ public class LevelEntity
+ {
+ public LevelEntity(byte[] bytes)
+ {
+ //OperateResult read = PlcConnect.Instance.Read("DB2107.2060.0", 3);
+
+ var content = bytes.Skip(2060).Take(3).ToArray();
+
+ byte byt = content[0];
+
+ LowLevel_D1 = byt.GetBit(0);
+ HighLevel_D1 = byt.GetBit(1);
+ LowLevel_D2 = byt.GetBit(2);
+ HighLevel_D2 = byt.GetBit(3);
+ LowLevel_D3 = byt.GetBit(4);
+ HighLevel_D3 = byt.GetBit(5);
+ LowLevel_D4 = byt.GetBit(6);
+ HighLevel_D4 = byt.GetBit(7);
+
+ byt = content[1];
+
+ LowLevel_D5 = byt.GetBit(0);
+ HighLevel_D5 = byt.GetBit(1);
+ LowLevel_D6 = byt.GetBit(2);
+ HighLevel_D6 = byt.GetBit(3);
+ LowLevel_D7 = byt.GetBit(4);
+ HighLevel_D7 = byt.GetBit(5);
+ LowLevel_D8 = byt.GetBit(6);
+ HighLevel_D8 = byt.GetBit(7);
+
+ byt = content[2];
+
+ LowLevel_D9 = byt.GetBit(0);
+ HighLevel_D9 = byt.GetBit(1);
+ LowLevel_D10 = byt.GetBit(2);
+ HighLevel_D10 = byt.GetBit(3);
+ LowLevel_D11 = byt.GetBit(4);
+ HighLevel_D11 = byt.GetBit(5);
+ LowLevel_D12 = byt.GetBit(6);
+ HighLevel_D12 = byt.GetBit(7);
+
+ }
+
+ public bool LowLevel_D1 { get; private set; }
+ public bool HighLevel_D1 { get; private set; }
+ public bool LowLevel_D2 { get; private set; }
+ public bool HighLevel_D2 { get; private set; }
+ public bool LowLevel_D3 { get; private set; }
+ public bool HighLevel_D3 { get; private set; }
+ public bool LowLevel_D4 { get; private set; }
+ public bool HighLevel_D4 { get; private set; }
+ public bool LowLevel_D5 { get; private set; }
+ public bool HighLevel_D5 { get; private set; }
+ public bool LowLevel_D6 { get; private set; }
+ public bool HighLevel_D6 { get; private set; }
+ public bool LowLevel_D7 { get; private set; }
+ public bool HighLevel_D7 { get; private set; }
+ public bool LowLevel_D8 { get; private set; }
+ public bool HighLevel_D8 { get; private set; }
+ public bool LowLevel_D9 { get; private set; }
+ public bool HighLevel_D9 { get; private set; }
+ public bool LowLevel_D10 { get; private set; }
+ public bool HighLevel_D10 { get; private set; }
+ public bool LowLevel_D11 { get; private set; }
+ public bool HighLevel_D11 { get; private set; }
+ public bool LowLevel_D12 { get; private set; }
+ public bool HighLevel_D12 { get; private set; }
+
+ }
\ No newline at end of file
diff --git a/Plc/LjLogControl.cs b/Plc/LjLogControl.cs
new file mode 100644
index 0000000..cfdf7e5
--- /dev/null
+++ b/Plc/LjLogControl.cs
@@ -0,0 +1,147 @@
+using System.Data;
+using Chloe;
+using WorkerSynReport.Data;
+
+namespace WorkerSynReport.Plc;
+
+ ///
+ /// 配料日志
+ ///
+ public class LjLogControl
+ {
+ private IDbContextLocal _dbContext;
+
+ public LjLogControl(IDbContextLocal dbContext)
+ {
+ _dbContext = dbContext;
+ }
+
+
+ ///
+ /// 通过内容查询日志
+ ///
+ /// 查询关键字
+ public DataTable ManualLogSelect(string txt)
+ {
+ string sql;
+ if (!string.IsNullOrEmpty(txt))
+ {
+ sql = BaseSelect($"where logtext like '%{txt}%'");
+ }
+ else
+ {
+ sql = BaseSelect("");
+ }
+
+ return _dbContext.Session.ExecuteDataTable(sql);
+
+
+ }
+
+ ///
+ /// 通过内容和机台号查询日志
+ ///
+ /// 查询关键字
+ public DataTable ManualLogSelect(string txt, int deviceNo)
+ {
+ string sql;
+ if (deviceNo == 0)
+ {
+ return ManualLogSelect(txt);
+ }
+ else
+ {
+ sql = BaseSelect($"where deviceNo = {deviceNo} and logtext like '%{txt}%'");
+ return _dbContext.Session.ExecuteDataTable(sql);
+ }
+ }
+
+ ///
+ /// 通过时间查询日志
+ ///
+ /// 查询关键字
+ public DataTable ManualLogSelect(string startTime, string endTime)
+ {
+ string sql = BaseSelect($"where logtime BETWEEN '{startTime}' AND '{endTime}'");
+ return _dbContext.Session.ExecuteDataTable(sql);
+ }
+
+
+
+ private static string BaseSelect(string sql)
+ {
+ string s = "select top 500 id, logtext, logtime, value, deviceno from Manual_Log " + sql +
+ " order by id desc";
+ return s;
+ }
+
+ ///
+ /// 完整手动日志插入
+ ///
+ /// 日志内容
+ /// 值
+ /// 值类型 0无 1水称设定值 2水称称量值 3螺旋设定值 4螺旋称量值
+ /// 设备编号
+ /// 设备类型 0无 1水称 2螺旋(湿混) 3糊化 4干混
+ public void ManualLogControl(string logName, int value, int valuekind, int deviceno, int devicekind)
+ {
+ var Log = new LjLogEntity()
+ {
+ logtext = logName,
+ logtime = DateTime.Now,
+ userid = "Admin",
+ value = value,
+ deviceno = deviceno,
+ devicekind = devicekind,
+ valuekind = valuekind,
+ createdate = DateTime.Now.ToString("yyyyMMdd")
+ };
+
+ _dbContext.Save(Log);
+
+ }
+
+ ///
+ /// 无数值 有设备 日志记录
+ ///
+ /// 日志内容
+ /// 设备编号
+ /// 设备类型
+ public void ManualLogControl(string logName, int deviceno, int devicekind)
+ {
+ var Log = new LjLogEntity()
+ {
+ logtext = logName,
+ logtime = DateTime.Now,
+ userid = "Admin",
+ value = 0,
+ deviceno = deviceno,
+ devicekind = devicekind,
+ valuekind = 0,
+ createdate = DateTime.Now.ToString("yyyyMMdd")
+ };
+
+ _dbContext.Save(Log);
+ }
+
+ ///
+ /// 无数值 无设备 日志记录
+ ///
+ ///
+ public void ManualLogControl(string logName)
+ {
+ var Log = new LjLogEntity()
+ {
+ logtext = logName,
+ logtime = DateTime.Now,
+ userid = "Admin",
+ value = 0,
+ deviceno = 0,
+ devicekind = 0,
+ valuekind = 0,
+ createdate = DateTime.Now.ToString("yyyyMMdd")
+ };
+
+ _dbContext.Save(Log);
+ }
+ }
\ No newline at end of file
diff --git a/Plc/NormalStatusEntity.cs b/Plc/NormalStatusEntity.cs
new file mode 100644
index 0000000..94d0572
--- /dev/null
+++ b/Plc/NormalStatusEntity.cs
@@ -0,0 +1,112 @@
+using NewLife;
+
+namespace WorkerSynReport.Plc;
+
+ public class NormalStatusEntity
+ {
+ public NormalStatusEntity(byte[] bytes)
+ {
+ //OperateResult read = PlcConnect.Instance.Read("DB2107.2.0", 7);
+
+ var content = bytes.Skip(2).Take(7).ToArray();
+
+ WatchDog = PlcConnect.Instance.ByteTransform.TransInt16(content, 0);
+
+ byte byt = content[2];
+
+ RecipeRun = byt.GetBit(0);
+ RecipePause = byt.GetBit(1);
+ Ready = byt.GetBit(2);
+ Alarm = byt.GetBit(3);
+ EMStop = byt.GetBit(4);
+ RdyRpt_V1 = byt.GetBit(5);
+ RdyRpt_V2 = byt.GetBit(6);
+ RdyRpt_V3 = byt.GetBit(7);
+
+ byt = content[3];
+
+ RdyRpt_V4 = byt.GetBit(0);
+ RdyRpt_V5 = byt.GetBit(1);
+ RdyRpt_W1 = byt.GetBit(2);
+ RdyRpt_W2 = byt.GetBit(3);
+ RdyRpt_W3 = byt.GetBit(4);
+ RdyRpt_W4 = byt.GetBit(5);
+ RdyRpt_D1 = byt.GetBit(6);
+ RdyRpt_D2 = byt.GetBit(7);
+
+ byt = content[4];
+
+ RdyRpt_D3 = byt.GetBit(0);
+ RdyRpt_D4 = byt.GetBit(1);
+ RdyRpt_G1 = byt.GetBit(2);
+ RdyRpt_G2 = byt.GetBit(3);
+ RdyRpt_G3 = byt.GetBit(4);
+ RdyRpt_G4 = byt.GetBit(5);
+ RdyRpt_G5 = byt.GetBit(6);
+ RdyRpt_G6 = byt.GetBit(7);
+
+ byt = content[5];
+
+ RdyRpt_G7 = byt.GetBit(0);
+ RdyRpt_G8 = byt.GetBit(1);
+ RdyRpt_M1 = byt.GetBit(2);
+ RdyRpt_M2 = byt.GetBit(3);
+ RdyRpt_M3 = byt.GetBit(4);
+ RdyRpt_M4 = byt.GetBit(5);
+ RdyRpt_M5 = byt.GetBit(6);
+ RdyRpt_M6 = byt.GetBit(7);
+
+ byt = content[6];
+
+ RdyRpt_M7 = byt.GetBit(0);
+ RdyRpt_M8 = byt.GetBit(1);
+
+ spare1= byt.GetBit(2);
+ spare2 = byt.GetBit(3);
+ spare3 = byt.GetBit(4);
+ spare4 = byt.GetBit(5);
+
+ }
+
+ public int WatchDog { get; private set; }
+ public bool RecipeRun { get; private set; }
+ public bool RecipePause { get; private set; }
+ public bool Ready { get; private set; }
+ public bool Alarm { get; private set; }
+ public bool EMStop { get; private set; }
+ public bool RdyRpt_V1 { get; private set; }
+ public bool RdyRpt_V2 { get; private set; }
+ public bool RdyRpt_V3 { get; private set; }
+ public bool RdyRpt_V4 { get; private set; }
+ public bool RdyRpt_V5 { get; private set; }
+ public bool RdyRpt_W1 { get; private set; }
+ public bool RdyRpt_W2 { get; private set; }
+ public bool RdyRpt_W3 { get; private set; }
+ public bool RdyRpt_W4 { get; private set; }
+ public bool RdyRpt_D1 { get; private set; }
+ public bool RdyRpt_D2 { get; private set; }
+ public bool RdyRpt_D3 { get; private set; }
+ public bool RdyRpt_D4 { get; private set; }
+ public bool RdyRpt_G1 { get; private set; }
+ public bool RdyRpt_G2 { get; private set; }
+ public bool RdyRpt_G3 { get; private set; }
+ public bool RdyRpt_G4 { get; private set; }
+ public bool RdyRpt_G5 { get; private set; }
+ public bool RdyRpt_G6 { get; private set; }
+ public bool RdyRpt_G7 { get; private set; }
+ public bool RdyRpt_G8 { get; private set; }
+ public bool RdyRpt_M1 { get; private set; }
+ public bool RdyRpt_M2 { get; private set; }
+ public bool RdyRpt_M3 { get; private set; }
+ public bool RdyRpt_M4 { get; private set; }
+ public bool RdyRpt_M5 { get; private set; }
+ public bool RdyRpt_M6 { get; private set; }
+ public bool RdyRpt_M7 { get; private set; }
+ public bool RdyRpt_M8 { get; private set; }
+
+
+ public bool spare1 { get; private set; }
+ public bool spare2 { get; private set; }
+ public bool spare3 { get; private set; }
+ public bool spare4 { get; private set; }
+ }
\ No newline at end of file
diff --git a/Plc/PIDEntity.cs b/Plc/PIDEntity.cs
new file mode 100644
index 0000000..4f36430
--- /dev/null
+++ b/Plc/PIDEntity.cs
@@ -0,0 +1,39 @@
+namespace WorkerSynReport.Plc;
+
+public class PIDEntity
+{
+
+ byte[] bytes;
+
+ public PIDEntity(byte[] bytes)
+ {
+ this.bytes = bytes;
+ }
+
+ public PID_HMI Convey_V1 => new PID_HMI(614, bytes);
+ public PID_HMI Purge_V1 => new PID_HMI(622, bytes);
+ public PID_HMI Convey_V2 => new PID_HMI(630, bytes);
+ public PID_HMI Purge_V2 => new PID_HMI(638, bytes);
+ public PID_HMI Convey_V3 => new PID_HMI(646, bytes);
+ public PID_HMI Purge_V3 => new PID_HMI(654, bytes);
+ public PID_HMI Convey_V4 => new PID_HMI(662, bytes);
+ public PID_HMI Purge_V4 => new PID_HMI(670, bytes);
+ public PID_HMI Convey_V5 => new PID_HMI(678, bytes);
+ public PID_HMI Purge_V5 => new PID_HMI(686, bytes);
+}
+
+public class PID_HMI
+{
+ public PID_HMI(ushort startSet, byte[] bytes)
+ {
+ //OperateResult read = PlcConnect.Instance.Read("DB2107." + startSet + ".0", 8);
+
+ var content = bytes.Skip(startSet).Take(8).ToArray();
+
+ PV = PlcConnect.Instance.ByteTransform.TransSingle(content, 0);
+ SV = PlcConnect.Instance.ByteTransform.TransSingle(content, 4);
+ }
+
+ public float PV { get; private set; }
+ public float SV { get; private set; }
+}
\ No newline at end of file
diff --git a/Plc/PressureEntity.cs b/Plc/PressureEntity.cs
new file mode 100644
index 0000000..7c5ea8b
--- /dev/null
+++ b/Plc/PressureEntity.cs
@@ -0,0 +1,73 @@
+using NewLife;
+
+namespace WorkerSynReport.Plc;
+
+ public class PressureEntity
+ {
+ byte[] bytes;
+
+ public PressureEntity(byte[] bytes)
+ {
+ this.bytes = bytes;
+ }
+
+ public Pressure_HMI MainPress_V1 => new Pressure_HMI(12, bytes);
+ public Pressure_HMI TopPressure_V1 => new Pressure_HMI(26, bytes);
+ public Pressure_HMI LinePressure_V1 => new Pressure_HMI(40, bytes);
+ public Pressure_HMI MainPress_V2 => new Pressure_HMI(54, bytes);
+ public Pressure_HMI TopPressure_V2 => new Pressure_HMI(68, bytes);
+ public Pressure_HMI LinePressure_V2 => new Pressure_HMI(82, bytes);
+ public Pressure_HMI MainPress_V3 => new Pressure_HMI(96, bytes);
+ public Pressure_HMI TopPressure_V3 => new Pressure_HMI(110, bytes);
+ public Pressure_HMI LinePressure_V3 => new Pressure_HMI(124, bytes);
+ public Pressure_HMI MainPress_V4 => new Pressure_HMI(138, bytes);
+ public Pressure_HMI TopPressure_V4 => new Pressure_HMI(152, bytes);
+ public Pressure_HMI LinePressure_V4 => new Pressure_HMI(166, bytes);
+ public Pressure_HMI MainPress_V5 => new Pressure_HMI(180, bytes);
+ public Pressure_HMI TopPressure_V5 => new Pressure_HMI(194, bytes);
+ public Pressure_HMI LinePressure_V5 => new Pressure_HMI(208, bytes);
+ public Pressure_HMI PressDaybin_B1 => new Pressure_HMI(222, bytes);
+ public Pressure_HMI PressDaybin_B2 => new Pressure_HMI(236, bytes);
+ public Pressure_HMI PressDaybin_B3 => new Pressure_HMI(250, bytes);
+ public Pressure_HMI PressDaybin_B4 => new Pressure_HMI(264, bytes);
+ public Pressure_HMI PressDaybin_B5 => new Pressure_HMI(278, bytes);
+ public Pressure_HMI PressDaybin_B6 => new Pressure_HMI(292, bytes);
+ public Pressure_HMI PressDaybin_B7 => new Pressure_HMI(306, bytes);
+ public Pressure_HMI PressDaybin_B8 => new Pressure_HMI(320, bytes);
+ public Pressure_HMI PressDaybin_B9 => new Pressure_HMI(334, bytes);
+ public Pressure_HMI PressDaybin_B10 => new Pressure_HMI(348, bytes);
+ public Pressure_HMI PressDaybin_B11 => new Pressure_HMI(362, bytes);
+ public Pressure_HMI PressDaybin_B12 => new Pressure_HMI(376, bytes);
+ public Pressure_HMI PR2PCP01 => new Pressure_HMI(390, bytes);
+ public Pressure_HMI PR2PCP02 => new Pressure_HMI(404, bytes);
+ public Pressure_HMI PR2PCP03 => new Pressure_HMI(418, bytes);
+
+
+ }
+
+ public class Pressure_HMI
+ {
+ public Pressure_HMI(ushort startSet, byte[] bytes)
+ {
+ //OperateResult read = PlcConnect.Instance.Read("DB2107." + startSet + ".0", 14);
+
+ var content = bytes.Skip(startSet).Take(14).ToArray();
+
+ ActualValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 0);
+ LowLimit = PlcConnect.Instance.ByteTransform.TransSingle(content, 4);
+ HighLimit = PlcConnect.Instance.ByteTransform.TransSingle(content, 8);
+
+
+ var operateResult = PlcConnect.Instance.ReadFloat("Db2107.20.0");
+
+ byte byt = content[12];
+
+ Alarm = byt.GetBit(0);
+
+ }
+
+ public float ActualValue { get; private set; }
+ public float LowLimit { get; private set; }
+ public float HighLimit { get; private set; }
+ public bool Alarm { get; private set; }
+ }
diff --git a/Plc/ReportDosEntity.cs b/Plc/ReportDosEntity.cs
new file mode 100644
index 0000000..862f7f4
--- /dev/null
+++ b/Plc/ReportDosEntity.cs
@@ -0,0 +1,28 @@
+namespace WorkerSynReport.Plc;
+
+public class ReportDosEntity
+{
+ public ReportDosEntity(byte[] bytes, int StartSet)
+ {
+ //OperateResult read = PlcConnect.Instance.Read("DB2107.10.0", 2);
+
+ var content = bytes.Skip(StartSet).Take(22).ToArray();
+
+ eqNo = PlcConnect.Instance.ByteTransform.TransInt16(content, 0);
+ batch = PlcConnect.Instance.ByteTransform.TransInt16(content, 2);
+ matCode = PlcConnect.Instance.ByteTransform.TransInt16(content, 4);
+ setValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 6);
+ setToler = PlcConnect.Instance.ByteTransform.TransSingle(content, 10);
+ actValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 14);
+ actToler = PlcConnect.Instance.ByteTransform.TransSingle(content, 18);
+
+
+ }
+ public short eqNo { get; private set; }
+ public short batch { get; private set; }
+ public short matCode { get; private set; }
+ public float setValue { get; private set; }
+ public float setToler { get; private set; }
+ public float actValue { get; private set; }
+ public float actToler { get; private set; }
+}
\ No newline at end of file
diff --git a/Plc/ReportReadDb.cs b/Plc/ReportReadDb.cs
new file mode 100644
index 0000000..732ce2b
--- /dev/null
+++ b/Plc/ReportReadDb.cs
@@ -0,0 +1,598 @@
+using WorkerSynReport.Data;
+
+namespace WorkerSynReport.Plc;
+
+ public class ReportReadDb
+ {
+
+ private IDbContextLocal _dbContext;
+ private LjLogControl _logControl;
+
+ public ReportReadDb(IDbContextLocal dbContext)
+ {
+ _dbContext = dbContext;
+ _logControl = new LjLogControl(_dbContext);
+ }
+
+
+
+ ///
+ /// 干混料插入日志
+ ///
+ public void ReadFeededDry()
+ {
+ Db2107Helper dB2107Helper = new Db2107Helper();
+ var nornalStatus = dB2107Helper.NormalStatus;
+ DB2111Helper dB2111Helper = new DB2111Helper();
+ //黑粉准备好信号
+ if (nornalStatus.spare1)
+ {
+ FeededDry(1, dB2111Helper.DryDosing_A);
+ DB2107WriteHelper.CleanSpare(1);
+ }
+
+ if (nornalStatus.spare2)
+ {
+ FeededDry(2, dB2111Helper.DryDosing_B);
+ DB2107WriteHelper.CleanSpare(2);
+ }
+
+ if (nornalStatus.spare3)
+ {
+ FeededDry(3, dB2111Helper.DryDosing_C);
+ DB2107WriteHelper.CleanSpare(3);
+ }
+
+ if (nornalStatus.spare4)
+ {
+ FeededDry(4, dB2111Helper.DryDosing_D);
+ DB2107WriteHelper.CleanSpare(4);
+ }
+
+
+ ///热水秤A
+
+ if (nornalStatus.RdyRpt_W1)
+ {
+ FeededWaterHA(dB2111Helper.hwReport_A);
+ }
+ ///冷水秤A
+ if (nornalStatus.RdyRpt_W2)
+ {
+ FeededWaterCA(dB2111Helper.cwReport_A);
+ }
+
+ //热水B
+ if (nornalStatus.RdyRpt_W3)
+ {
+ FeededWaterHB(dB2111Helper.hwReport_B);
+ }
+ ///冷水秤B
+ if (nornalStatus.RdyRpt_W4)
+ {
+ FeededWaterCB(dB2111Helper.cwReport_B);
+ }
+ }
+
+
+
+ //热水A
+ private void FeededWaterHA(ReportDosEntity entity)
+ {
+ var actValue = Convert.ToInt32(entity.actValue);
+ string logName = $"热水秤A向 [{entity.eqNo}] 加水 {actValue}";
+
+ _logControl.ManualLogControl(logName, actValue, 2, entity.eqNo, 1);
+ DB2107WriteHelper.CleanWater(1);
+ }
+
+ private void FeededWaterCA(ReportDosEntity entity)
+ {
+ var actValue = Convert.ToInt32(entity.actValue);
+ string logName = $"冷水秤A向 [{entity.eqNo}] 加水 {actValue}";
+
+ _logControl.ManualLogControl(logName, actValue, 2, entity.eqNo, 1);
+ DB2107WriteHelper.CleanWater(2);
+ }
+
+
+ private void FeededWaterHB(ReportDosEntity entity)
+ {
+ var actValue = Convert.ToInt32(entity.actValue);
+ string logName = $"热水秤B向 [{entity.eqNo+4}] 加水 {actValue}";
+
+ _logControl.ManualLogControl(logName, actValue, 2, entity.eqNo+4, 1);
+ DB2107WriteHelper.CleanWater(3);
+ }
+
+ private void FeededWaterCB(ReportDosEntity entity)
+ {
+ var actValue = Convert.ToInt32(entity.actValue);
+ string logName = $"冷水秤B向 [{entity.eqNo + 4}] 加水 {actValue}";
+
+ _logControl.ManualLogControl(logName, actValue, 2, entity.eqNo + 4, 1);
+ DB2107WriteHelper.CleanWater(4);
+ }
+
+ ///
+ /// 解决算法有问题
+ ///
+ ///
+ ///
+
+ private void FeededDry(int deviceno, ReportDosEntity entity)
+ {
+
+ int no = deviceno * 2;
+ if (entity.eqNo == 1)
+ {
+ no = no - 1;
+ }
+ var actValue = Convert.ToInt32(entity.actValue);
+ string logName = $"用户[Admin] 螺旋{deviceno}向湿混机 [{no}] 投料 {actValue}";
+
+ _logControl.ManualLogControl(logName, actValue, 4, no, 2);
+
+
+ }
+
+ public void ReadReport()
+ {
+
+
+
+ Db2107Helper dB2107Helper = new Db2107Helper();
+ NormalStatusEntity normal = dB2107Helper.NormalStatus;
+ if (normal.RdyRpt_D1)
+ {
+
+ InsertD(1);
+ PlcConnect.Instance.Write("DB2107.5.6", false);
+ }
+ if (normal.RdyRpt_D2)
+ {
+
+ InsertD(2);
+ PlcConnect.Instance.Write("DB2107.5.7", false);
+ }
+
+ if (normal.RdyRpt_D3)
+ {
+
+ InsertD(3);
+ PlcConnect.Instance.Write("DB2107.6.0", false);
+ }
+
+ if (normal.RdyRpt_D4)
+ {
+
+ InsertD(4);
+ PlcConnect.Instance.Write("DB2107.6.1", false);
+ }
+
+ if (normal.RdyRpt_G1)
+ {
+
+ InsertG(1);
+ PlcConnect.Instance.Write("DB2107.6.2", false);
+ }
+
+ if (normal.RdyRpt_G2)
+ {
+
+ InsertG(2);
+ PlcConnect.Instance.Write("DB2107.6.3", false);
+ }
+ if (normal.RdyRpt_G3)
+ {
+
+ InsertG(3);
+ PlcConnect.Instance.Write("DB2107.6.4", false);
+ }
+
+ if (normal.RdyRpt_G4)
+ {
+
+ InsertG(4);
+ PlcConnect.Instance.Write("DB2107.6.5", false);
+ }
+
+ if (normal.RdyRpt_G5)
+ {
+
+ InsertG(5);
+ PlcConnect.Instance.Write("DB2107.6.6", false);
+ }
+
+ if (normal.RdyRpt_G6)
+ {
+
+ InsertG(6);
+ PlcConnect.Instance.Write("DB2107.6.7", false);
+ }
+
+ if (normal.RdyRpt_G7)
+ {
+
+ InsertG(7);
+ PlcConnect.Instance.Write("DB2107.7.0", false);
+ }
+
+ if (normal.RdyRpt_G8)
+ {
+
+ InsertG(8);
+ PlcConnect.Instance.Write("DB2107.7.1", false);
+ }
+
+ if (normal.RdyRpt_M1)
+ {
+
+ InsertM(1);
+ PlcConnect.Instance.Write("DB2107.7.2", false);
+ }
+
+ if (normal.RdyRpt_M2)
+ {
+
+ InsertM(2);
+ PlcConnect.Instance.Write("DB2107.7.3", false);
+ }
+
+ if (normal.RdyRpt_M3)
+ {
+
+ InsertM(3);
+ PlcConnect.Instance.Write("DB2107.7.4", false);
+ }
+
+ if (normal.RdyRpt_M4)
+ {
+
+ InsertM(4);
+ PlcConnect.Instance.Write("DB2107.7.5", false);
+ }
+
+ if (normal.RdyRpt_M5)
+ {
+
+ InsertM(5);
+ PlcConnect.Instance.Write("DB2107.7.6", false);
+ }
+
+ if (normal.RdyRpt_M6)
+ {
+
+ InsertM(6);
+ PlcConnect.Instance.Write("DB2107.7.7", false);
+ }
+
+ if (normal.RdyRpt_M7)
+ {
+
+ InsertM(7);
+ PlcConnect.Instance.Write("DB2107.8.0", false);
+ }
+
+ if (normal.RdyRpt_M8)
+ {
+
+ InsertM(8);
+ PlcConnect.Instance.Write("DB2107.8.1", false);
+ }
+ }
+
+
+
+ private void InsertD(int no)
+ {
+ DB2106Helper dB2106 = new DB2106Helper();
+ Dryer_ dryer = null;
+ switch (no)
+ {
+ case 1:
+ dryer = dB2106.DryReport.Dryer_A;
+ break;
+ case 2:
+ dryer = dB2106.DryReport.Dryer_B;
+ break;
+ case 3:
+ dryer = dB2106.DryReport.Dryer_C;
+ break;
+ case 4:
+ dryer = dB2106.DryReport.Dryer_D;
+ break;
+ }
+
+ Report_Dry dry = new Report_Dry();
+ List lsDos = new List();
+ List lsMix = new List();
+
+ dry.reportId = Guid.NewGuid().ToString("N");
+ dry.recipeCode = 0;
+ dry.recipeName = "";
+ dry.planCode = 0;
+ dry.planName = "";
+ dry.recordTime = DateTime.Now;
+ dry.dryNo = no;
+ dry.Batch = 0;
+
+ foreach (var item in dryer.Dos)
+ {
+ if (item.EqNo != 0)
+ {
+ lsDos.Add(new Report_DryDos_Detail()
+ {
+ reportId = dry.reportId,
+ eqNo = item.EqNo,
+ batch = item.Batch,
+ matCode = item.MatCode,
+ setToler = item.SetToler,
+ setValue = item.SetValue,
+ actToler = item.ActToler,
+ actValue = item.ActValue,
+ recordTime = DateTime.Now
+ });
+ }
+
+ }
+
+ foreach (var item in dryer.Mix)
+ {
+ if (item.EqNo != 0)
+ {
+ lsMix.Add(new Report_DryMixer_Detail()
+ {
+ reportId = dry.reportId,
+ actCode = item.ActCode,
+ eqNo = item.EqNo,
+ mixBatch = item.MixBatch,
+ mixStep = item.MixStep,
+ mixSpeed = item.MixSpeed,
+ mixTemp = item.MixTemp,
+ mixTime = item.MixTime,
+ recordTime = DateTime.Now
+ }) ;
+ }
+ }
+
+ if (lsDos.Any())
+ {
+ dry.Batch=lsDos.Where(x=>x.batch>0).Select(x=>x.batch).First();
+
+ _dbContext.Insert(dry);
+ _dbContext.InsertRange(lsDos);
+ _dbContext.InsertRange(lsMix);
+
+ // FreeSqlUnit.Instance.Insert(dry).ExecuteAffrows();
+ // FreeSqlUnit.Instance.Insert(lsDos).ExecuteAffrows();
+ // FreeSqlUnit.Instance.Insert(lsMix).ExecuteAffrows();
+
+ }
+
+
+ }
+
+ private void InsertG(int no)
+ {
+ DB2106Helper dB2106 = new DB2106Helper();
+ Gel_ gel = null;
+ switch (no)
+ {
+ case 1:
+ gel = dB2106.GelReport.Gel_A;
+ break;
+ case 2:
+ gel = dB2106.GelReport.Gel_B;
+ break;
+ case 3:
+ gel = dB2106.GelReport.Gel_C;
+ break;
+ case 4:
+ gel = dB2106.GelReport.Gel_D;
+ break;
+ case 5:
+ gel = dB2106.GelReport.Gel_E;
+ break;
+ case 6:
+ gel = dB2106.GelReport.Gel_F;
+ break;
+ case 7:
+ gel = dB2106.GelReport.Gel_G;
+ break;
+ case 8:
+ gel = dB2106.GelReport.Gel_H;
+ break;
+ }
+ Report_Gel gelDb = new Report_Gel();
+
+ gelDb.reportId = Guid.NewGuid().ToString("N");
+ gelDb.recipeCode = 0;
+ gelDb.recipeName = "";
+ gelDb.planCode = 0;
+ gelDb.planName = "";
+ gelDb.recordTime = DateTime.Now;
+
+ gelDb.gelNo = no;
+ gelDb.Batch = 0;
+
+ List lsdetail = new List();
+ List lsMixing = new List();
+
+ var dosList = gel.GelDosing;
+ foreach (var dos in dosList)
+ {
+ if (dos.EqNo != 0)
+ {
+ lsdetail.Add(new Report_GelDoser_Detail()
+ {
+ eqNo = dos.EqNo,
+ batch = dos.Batch,
+ matCode = dos.MatCode,
+ setValue = dos.SetValue,
+ setToler = dos.SetToler,
+ actToLer = dos.ActToler,
+ actValue = dos.ActValue,
+ reportId = gelDb.reportId,
+ recordTime = DateTime.Now,
+ kinds = 1
+ });
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ var mixList = gel.GelMixing;
+ foreach (var mix in mixList)
+ {
+ if (mix.EqNo != 0)
+ {
+ lsMixing.Add(new Report_GelMixing_Detail()
+ {
+ eqNo = mix.EqNo,
+ mixBatch = mix.MixBatch,
+ mixStep = mix.MixStep,
+ actCode = mix.ActCode,
+ mixTime = mix.MixTime,
+ mixSpeed = mix.MixSpeed,
+ mixTemp = mix.MixTemp,
+ reportId = gelDb.reportId,
+ recordTime = DateTime.Now,
+ });
+ }
+ }
+
+ var hotWater = gel.HotWater;
+ if (hotWater != null)
+ {
+ lsdetail.Add(new Report_GelDoser_Detail()
+ {
+ eqNo = hotWater.EqNo,
+ batch = hotWater.Batch,
+ matCode = hotWater.MatCode,
+ setValue = hotWater.SetValue,
+ setToler = hotWater.SetToler,
+ actToLer = hotWater.ActToler,
+ actValue = hotWater.ActValue,
+ reportId = gelDb.reportId,
+ recordTime = DateTime.Now,
+ kinds = 2
+ });
+ }
+
+ var coolWater = gel.CoolWater;
+ if (coolWater != null)
+ {
+ lsdetail.Add(new Report_GelDoser_Detail()
+ {
+ eqNo = coolWater.EqNo,
+ batch = coolWater.Batch,
+ matCode = coolWater.MatCode,
+ setValue = coolWater.SetValue,
+ setToler = coolWater.SetToler,
+ actToLer = coolWater.ActToler,
+ actValue = coolWater.ActValue,
+ reportId = gelDb.reportId,
+ recordTime = DateTime.Now,
+ kinds = 3
+ });
+ }
+
+
+ if(null!= lsdetail && lsdetail.Any())
+ {
+ gelDb.Batch = lsdetail.Select(x => x.batch).FirstOrDefault();
+
+
+ _dbContext.Insert(gelDb);
+ _dbContext.InsertRange(lsdetail);
+ _dbContext.InsertRange(lsMixing);
+
+
+ }
+
+ }
+
+
+
+ private void InsertM(int no)
+ {
+ DB2106Helper dB2106 = new DB2106Helper();
+ List ls = null;
+ switch (no)
+ {
+ case 1:
+ ls = dB2106.WetReport.WetMixing_A;
+ break;
+ case 2:
+ ls = dB2106.WetReport.WetMixing_B;
+ break;
+ case 3:
+ ls = dB2106.WetReport.WetMixing_C;
+ break;
+ case 4:
+ ls = dB2106.WetReport.WetMixing_D;
+ break;
+ case 5:
+ ls = dB2106.WetReport.WetMixing_E;
+ break;
+ case 6:
+ ls = dB2106.WetReport.WetMixing_F;
+ break;
+ case 7:
+ ls = dB2106.WetReport.WetMixing_G;
+ break;
+ case 8:
+ ls = dB2106.WetReport.WetMixing_H;
+ break;
+ }
+
+ Report_WetMixer report = new Report_WetMixer();
+
+ report.reportId = Guid.NewGuid().ToString("N");
+ report.recipeCode = 0;
+ report.recipeName = "";
+ report.planCode = 0;
+ report.planName = "";
+ report.recordTime = DateTime.Now;
+ report.reportTime = DateTime.Now;
+ report.WetNo = no;
+ report.Batch = report.Batch;
+
+ List lde = new List();
+ foreach (var item in ls)
+ {
+ if (item.EqNo != 0)
+ {
+ lde.Add(new Report_WetMixer_Detail()
+ {
+ recordTime = DateTime.Now,
+ reportId = report.reportId,
+ eqNo = item.EqNo,
+ mixBatch = item.MixBatch,
+ mixSpeed = item.MixSpeed,
+ actCode = item.ActCode,
+ mixTemp = item.MixTemp,
+ mixStep = item.MixStep,
+ mixTime = item.MixTime,
+ actTolerence = item.ActTolerence,
+ actWeight = item.ActWeight,
+ });
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ if(lde.Count > 0)
+ {
+ report.Batch=lde.Select(x=>x.mixBatch).First();
+ this._dbContext.Insert(report);
+ this._dbContext.InsertRange(lde);
+
+ }
+ }
+ }
\ No newline at end of file
diff --git a/Plc/SpeedEntity.cs b/Plc/SpeedEntity.cs
new file mode 100644
index 0000000..c5481b7
--- /dev/null
+++ b/Plc/SpeedEntity.cs
@@ -0,0 +1,55 @@
+namespace WorkerSynReport.Plc;
+
+public class SpeedEntity
+{
+ public SpeedEntity(byte[] bytes)
+ {
+ //OperateResult read = PlcConnect.Instance.Read("DB2107.1324.0", 84);
+
+ var content = bytes.Skip(1324).Take(84).ToArray();
+
+ ManSpeed_D1 = PlcConnect.Instance.ByteTransform.TransSingle(content, 0);
+ ManSpeed_D2 = PlcConnect.Instance.ByteTransform.TransSingle(content, 4);
+ ManSpeed_D3 = PlcConnect.Instance.ByteTransform.TransSingle(content, 8);
+ ManSpeed_D4 = PlcConnect.Instance.ByteTransform.TransSingle(content, 12);
+ ManSpeed_G1 = PlcConnect.Instance.ByteTransform.TransSingle(content, 16);
+ ManSpeed_G2 = PlcConnect.Instance.ByteTransform.TransSingle(content, 20);
+ ManSpeed_G3 = PlcConnect.Instance.ByteTransform.TransSingle(content, 24);
+ ManSpeed_G4 = PlcConnect.Instance.ByteTransform.TransSingle(content, 28);
+ ManSpeed_G5 = PlcConnect.Instance.ByteTransform.TransSingle(content, 32);
+ ManSpeed_G6 = PlcConnect.Instance.ByteTransform.TransSingle(content, 36);
+ ManSpeed_G7 = PlcConnect.Instance.ByteTransform.TransSingle(content, 40);
+ ManSpeed_G8 = PlcConnect.Instance.ByteTransform.TransSingle(content, 44);
+ ManSpeed_H1 = PlcConnect.Instance.ByteTransform.TransSingle(content, 48);
+ ManSpeed_H2 = PlcConnect.Instance.ByteTransform.TransSingle(content, 52);
+ ManSpeed_H3 = PlcConnect.Instance.ByteTransform.TransSingle(content, 56);
+ ManSpeed_H4 = PlcConnect.Instance.ByteTransform.TransSingle(content, 60);
+ ManSpeed_S1 = PlcConnect.Instance.ByteTransform.TransSingle(content, 64);
+ ManSpeed_S5 = PlcConnect.Instance.ByteTransform.TransSingle(content, 68);
+ ManSpeed_S7 = PlcConnect.Instance.ByteTransform.TransSingle(content, 72);
+ ManSpeed_S11 = PlcConnect.Instance.ByteTransform.TransSingle(content, 76);
+ ManSpeed_S15 = PlcConnect.Instance.ByteTransform.TransSingle(content, 80);
+ }
+
+ public float ManSpeed_D1 { get; private set; }
+ public float ManSpeed_D2 { get; private set; }
+ public float ManSpeed_D3 { get; private set; }
+ public float ManSpeed_D4 { get; private set; }
+ public float ManSpeed_G1 { get; private set; }
+ public float ManSpeed_G2 { get; private set; }
+ public float ManSpeed_G3 { get; private set; }
+ public float ManSpeed_G4 { get; private set; }
+ public float ManSpeed_G5 { get; private set; }
+ public float ManSpeed_G6 { get; private set; }
+ public float ManSpeed_G7 { get; private set; }
+ public float ManSpeed_G8 { get; private set; }
+ public float ManSpeed_H1 { get; private set; }
+ public float ManSpeed_H2 { get; private set; }
+ public float ManSpeed_H3 { get; private set; }
+ public float ManSpeed_H4 { get; private set; }
+ public float ManSpeed_S1 { get; private set; }
+ public float ManSpeed_S5 { get; private set; }
+ public float ManSpeed_S7 { get; private set; }
+ public float ManSpeed_S11 { get; private set; }
+ public float ManSpeed_S15 { get; private set; }
+}
\ No newline at end of file
diff --git a/Plc/UntiStatusHMIArrayEntity.cs b/Plc/UntiStatusHMIArrayEntity.cs
new file mode 100644
index 0000000..0213359
--- /dev/null
+++ b/Plc/UntiStatusHMIArrayEntity.cs
@@ -0,0 +1,79 @@
+using NewLife;
+
+namespace WorkerSynReport.Plc;
+
+ public class UntiStatusHMIArrayEntity
+ {
+ public UntiStatusHMIArrayEntity(byte[] content)
+ {
+
+
+ byte byt = content[0];
+ Mode = byt.GetBit(0);
+ Status = byt.GetBit(1);
+
+ Batch = PlcConnect.Instance.ByteTransform.TransUInt16(content, 2);
+ Step = PlcConnect.Instance.ByteTransform.TransUInt16(content, 4);
+ StepCode = PlcConnect.Instance.ByteTransform.TransUInt16(content, 6);
+ TotalTime = PlcConnect.Instance.ByteTransform.TransInt32(content, 8);
+ StepTime = PlcConnect.Instance.ByteTransform.TransInt32(content, 12);
+ Temperature = PlcConnect.Instance.ByteTransform.TransSingle(content, 16);
+ Speed = PlcConnect.Instance.ByteTransform.TransSingle(content, 20);
+ FeedValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 24);
+ ActTolerance = PlcConnect.Instance.ByteTransform.TransSingle(content, 28);
+ }
+
+ public bool Mode { get; private set; }
+ public bool Status { get; private set; }
+ public ushort Batch { get; private set; }
+ public ushort Step { get; private set; }
+ public ushort StepCode { get; private set; }
+ public int TotalTime { get; private set; }
+ public int StepTime { get; private set; }
+ public float Temperature { get; private set; }
+ public float Speed { get; private set; }
+ public float FeedValue { get; private set; }
+ public float ActTolerance { get; private set; }
+ }
+
+
+ public class UntiStatusHMIArrayManager
+ {
+ private int Length;
+ private int StartSet;
+ private int SLength;
+ private byte[] Bytes;
+
+ ///
+ /// 数组处理
+ ///
+ /// 数组长度
+ /// 数组起始偏移量
+ /// 数组单个元素长度
+ public UntiStatusHMIArrayManager(ushort length, int startSet, int sLength, byte[] bytes)
+ {
+ Length = length;
+ StartSet = startSet;
+ SLength = sLength;
+ Bytes = bytes;
+ }
+
+ public List GetList()
+ {
+ List ListE = new List(Length);
+ //var getListE = PlcConnect.Instance.Read("DB2107." + StartSet + ".0", Convert.ToUInt16(Length * SLength));
+
+ //if (!getListE.IsSuccess)
+ //{
+ // throw new Exception(getListE.Message);
+ //}
+ var content = Bytes.Skip(StartSet).Take(Length * SLength).ToArray();
+
+ for (int i = 0; i < Length; i++)
+ {
+ var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray();
+ ListE.Add(new UntiStatusHMIArrayEntity(singleBlock));
+ }
+ return ListE;
+ }
+ }
\ No newline at end of file
diff --git a/Plc/ValveEntity.cs b/Plc/ValveEntity.cs
new file mode 100644
index 0000000..85f48fd
--- /dev/null
+++ b/Plc/ValveEntity.cs
@@ -0,0 +1,219 @@
+using NewLife;
+
+namespace WorkerSynReport.Plc;
+
+ public class ValveEntity
+ {
+ public ValveEntity(byte[] bytes)
+ {
+
+ //OperateResult read = PlcConnect.Instance.Read("DB2107.2048.0", 11);
+
+ var content = bytes.Skip(2048).Take(11).ToArray();
+
+ byte byt = content[0];
+
+ AS1BLT01 = byt.GetBit(0);
+ AS1BLT02 = byt.GetBit(1);
+ AS1BLT03 = byt.GetBit(2);
+ AS1BLT04 = byt.GetBit(3);
+ AS1BLT05 = byt.GetBit(4);
+ AS2BLT01 = byt.GetBit(5);
+ AS2BLT02 = byt.GetBit(6);
+ AS2BLT03 = byt.GetBit(7);
+
+ byt = content[1];
+
+ AS2BLT04 = byt.GetBit(0);
+ AS2BLT05 = byt.GetBit(1);
+ AS3BLT01 = byt.GetBit(2);
+ AS3BLT02 = byt.GetBit(3);
+ AS3BLT03 = byt.GetBit(4);
+ AS3BLT04 = byt.GetBit(5);
+ AS3BLT05 = byt.GetBit(6);
+ AS4BLT01 = byt.GetBit(7);
+
+ byt = content[2];
+
+ AS4BLT02 = byt.GetBit(0);
+ AS4BLT03 = byt.GetBit(1);
+ AS4BLT04 = byt.GetBit(2);
+ AS4BLT05 = byt.GetBit(3);
+ AS5BLT01 = byt.GetBit(4);
+ AS5BLT02 = byt.GetBit(5);
+ AS5BLT03 = byt.GetBit(6);
+ AS5BLT04 = byt.GetBit(7);
+
+ byt = content[3];
+
+ AS5BLT05 = byt.GetBit(0);
+ AS1OIS01 = byt.GetBit(1);
+ AS1OIS02 = byt.GetBit(2);
+ AS1OIS03 = byt.GetBit(3);
+ AS2OIS01 = byt.GetBit(4);
+ AS2OIS02 = byt.GetBit(5);
+ AS2OIS03 = byt.GetBit(6);
+ AS3OIS01 = byt.GetBit(7);
+
+ byt = content[4];
+
+ AS3OIS02 = byt.GetBit(0);
+ AS3OIS03 = byt.GetBit(1);
+ AS4OIS01 = byt.GetBit(2);
+ AS4OIS02 = byt.GetBit(3);
+ AS4OIS03 = byt.GetBit(4);
+ AS2PCP01 = byt.GetBit(5);
+ AS2PCP02 = byt.GetBit(6);
+ AS2PCP03 = byt.GetBit(7);
+
+ byt = content[5];
+
+ PV1ADB01 = byt.GetBit(0);
+ PV1BDB01 = byt.GetBit(1);
+ PV1CDB01 = byt.GetBit(2);
+ PV1DDB01 = byt.GetBit(3);
+ PV1EDB01 = byt.GetBit(4);
+ PV1FDB01 = byt.GetBit(5);
+ PV1GDB01 = byt.GetBit(6);
+ PV1HDB01 = byt.GetBit(7);
+
+ byt = content[6];
+
+ PV1IDB01 = byt.GetBit(0);
+ PV1JDB01 = byt.GetBit(1);
+ PV1KDB01 = byt.GetBit(2);
+ PV1LDB01 = byt.GetBit(3);
+ PM1ADF01 = byt.GetBit(4);
+ PM1BDF01 = byt.GetBit(5);
+ PM1CDF01 = byt.GetBit(6);
+ PM1DDF01 = byt.GetBit(7);
+
+ byt = content[7];
+
+ PM1EDF01 = byt.GetBit(0);
+ PM1FDF01 = byt.GetBit(1);
+ PM1GDF01 = byt.GetBit(2);
+ PM1HDF01 = byt.GetBit(3);
+ PM1IDF01 = byt.GetBit(4);
+ PM1JDF01 = byt.GetBit(5);
+ PM1KDF01 = byt.GetBit(6);
+ PM1LDF01 = byt.GetBit(7);
+
+ byt = content[8];
+
+ PV2ADB01 = byt.GetBit(0);
+ PV2BDB01 = byt.GetBit(1);
+ PV2CDB01 = byt.GetBit(2);
+ PV2DDB01 = byt.GetBit(3);
+ AS1GET01 = byt.GetBit(4);
+ AS1GET02 = byt.GetBit(5);
+ AS2GET01 = byt.GetBit(6);
+ AS2GET02 = byt.GetBit(7);
+
+ byt = content[9];
+
+ AS3GET01 = byt.GetBit(0);
+ AS3GET02 = byt.GetBit(1);
+ AS4GET01 = byt.GetBit(2);
+ AS4GET02 = byt.GetBit(3);
+ AS5GET01 = byt.GetBit(4);
+ AS5GET02 = byt.GetBit(5);
+ AS6GET01 = byt.GetBit(6);
+ AS6GET02 = byt.GetBit(7);
+
+ byt = content[10];
+
+ AS7GET01 = byt.GetBit(0);
+ AS7GET02 = byt.GetBit(1);
+ AS8GET01 = byt.GetBit(2);
+ AS8GET02 = byt.GetBit(3);
+
+ }
+
+ public bool AS1BLT01 { get; private set; }
+ public bool AS1BLT02 { get; private set; }
+ public bool AS1BLT03 { get; private set; }
+ public bool AS1BLT04 { get; private set; }
+ public bool AS1BLT05 { get; private set; }
+ public bool AS2BLT01 { get; private set; }
+ public bool AS2BLT02 { get; private set; }
+ public bool AS2BLT03 { get; private set; }
+ public bool AS2BLT04 { get; private set; }
+ public bool AS2BLT05 { get; private set; }
+ public bool AS3BLT01 { get; private set; }
+ public bool AS3BLT02 { get; private set; }
+ public bool AS3BLT03 { get; private set; }
+ public bool AS3BLT04 { get; private set; }
+ public bool AS3BLT05 { get; private set; }
+ public bool AS4BLT01 { get; private set; }
+ public bool AS4BLT02 { get; private set; }
+ public bool AS4BLT03 { get; private set; }
+ public bool AS4BLT04 { get; private set; }
+ public bool AS4BLT05 { get; private set; }
+ public bool AS5BLT01 { get; private set; }
+ public bool AS5BLT02 { get; private set; }
+ public bool AS5BLT03 { get; private set; }
+ public bool AS5BLT04 { get; private set; }
+ public bool AS5BLT05 { get; private set; }
+ public bool AS1OIS01 { get; private set; }
+ public bool AS1OIS02 { get; private set; }
+ public bool AS1OIS03 { get; private set; }
+ public bool AS2OIS01 { get; private set; }
+ public bool AS2OIS02 { get; private set; }
+ public bool AS2OIS03 { get; private set; }
+ public bool AS3OIS01 { get; private set; }
+ public bool AS3OIS02 { get; private set; }
+ public bool AS3OIS03 { get; private set; }
+ public bool AS4OIS01 { get; private set; }
+ public bool AS4OIS02 { get; private set; }
+ public bool AS4OIS03 { get; private set; }
+ public bool AS2PCP01 { get; private set; }
+ public bool AS2PCP02 { get; private set; }
+ public bool AS2PCP03 { get; private set; }
+ public bool PV1ADB01 { get; private set; }
+ public bool PV1BDB01 { get; private set; }
+ public bool PV1CDB01 { get; private set; }
+ public bool PV1DDB01 { get; private set; }
+ public bool PV1EDB01 { get; private set; }
+ public bool PV1FDB01 { get; private set; }
+ public bool PV1GDB01 { get; private set; }
+ public bool PV1HDB01 { get; private set; }
+ public bool PV1IDB01 { get; private set; }
+ public bool PV1JDB01 { get; private set; }
+ public bool PV1KDB01 { get; private set; }
+ public bool PV1LDB01 { get; private set; }
+ public bool PM1ADF01 { get; private set; }
+ public bool PM1BDF01 { get; private set; }
+ public bool PM1CDF01 { get; private set; }
+ public bool PM1DDF01 { get; private set; }
+ public bool PM1EDF01 { get; private set; }
+ public bool PM1FDF01 { get; private set; }
+ public bool PM1GDF01 { get; private set; }
+ public bool PM1HDF01 { get; private set; }
+ public bool PM1IDF01 { get; private set; }
+ public bool PM1JDF01 { get; private set; }
+ public bool PM1KDF01 { get; private set; }
+ public bool PM1LDF01 { get; private set; }
+ public bool PV2ADB01 { get; private set; }
+ public bool PV2BDB01 { get; private set; }
+ public bool PV2CDB01 { get; private set; }
+ public bool PV2DDB01 { get; private set; }
+ public bool AS1GET01 { get; private set; }
+ public bool AS1GET02 { get; private set; }
+ public bool AS2GET01 { get; private set; }
+ public bool AS2GET02 { get; private set; }
+ public bool AS3GET01 { get; private set; }
+ public bool AS3GET02 { get; private set; }
+ public bool AS4GET01 { get; private set; }
+ public bool AS4GET02 { get; private set; }
+ public bool AS5GET01 { get; private set; }
+ public bool AS5GET02 { get; private set; }
+ public bool AS6GET01 { get; private set; }
+ public bool AS6GET02 { get; private set; }
+ public bool AS7GET01 { get; private set; }
+ public bool AS7GET02 { get; private set; }
+ public bool AS8GET01 { get; private set; }
+ public bool AS8GET02 { get; private set; }
+
+
+ }
\ No newline at end of file
diff --git a/Plc/WeightEntity.cs b/Plc/WeightEntity.cs
new file mode 100644
index 0000000..c95a25e
--- /dev/null
+++ b/Plc/WeightEntity.cs
@@ -0,0 +1,55 @@
+using NewLife;
+
+namespace WorkerSynReport.Plc;
+
+public class WeightEntity
+{
+
+ byte[] bytes;
+
+ public WeightEntity(byte[] bytes)
+ {
+ this.bytes = bytes;
+ }
+
+ public Silo_HMI Hopper_1 => new Silo_HMI(432, bytes);
+ public Silo_HMI Hopper_2 => new Silo_HMI(446, bytes);
+ public Silo_HMI Hopper_3 => new Silo_HMI(460, bytes);
+ public Silo_HMI Hopper_4 => new Silo_HMI(474, bytes);
+ public Silo_HMI Vessel_1 => new Silo_HMI(488, bytes);
+ public Silo_HMI Vessel_2 => new Silo_HMI(502, bytes);
+ public Silo_HMI Vessel_3 => new Silo_HMI(516, bytes);
+ public Silo_HMI Vessel_4 => new Silo_HMI(530, bytes);
+ public Silo_HMI Vessel_5 => new Silo_HMI(544, bytes);
+ public Silo_HMI WScale_1 => new Silo_HMI(558, bytes);
+ public Silo_HMI WScale_2 => new Silo_HMI(572, bytes);
+ public Silo_HMI WScale_3 => new Silo_HMI(586, bytes);
+ public Silo_HMI WScale_4 => new Silo_HMI(600, bytes);
+
+}
+
+public class Silo_HMI
+{
+ public Silo_HMI(ushort startSet, byte[] bytes)
+ {
+ //OperateResult read = PlcConnect.Instance.Read("DB2107." + startSet + ".0", 14);
+
+ var content = bytes.Skip(startSet).Take(14).ToArray();
+
+ ActWeight = PlcConnect.Instance.ByteTransform.TransSingle(content, 0);
+ HighWeight = PlcConnect.Instance.ByteTransform.TransSingle(content, 4);
+ LowWeight = PlcConnect.Instance.ByteTransform.TransSingle(content, 8);
+
+ byte byt = content[12];
+
+ HighLevel = byt.GetBit(0);
+ Lowlevel = byt.GetBit(1);
+ }
+
+ public float ActWeight { get; private set; }
+ public float HighWeight { get; private set; }
+ public float LowWeight { get; private set; }
+ public bool HighLevel { get; private set; }
+ public bool Lowlevel { get; private set; }
+
+}
\ No newline at end of file
diff --git a/Plc/WeightPraEntity.cs b/Plc/WeightPraEntity.cs
new file mode 100644
index 0000000..392902d
--- /dev/null
+++ b/Plc/WeightPraEntity.cs
@@ -0,0 +1,68 @@
+namespace WorkerSynReport.Plc;
+
+ public class WeightPraEntity
+ {
+ byte[] bytes;
+
+ public WeightPraEntity(byte[] bytes)
+ {
+ this.bytes = bytes;
+ }
+
+ public List Silo => new WeightParaArrayManager(15, 694, 18, bytes).GetList();
+ public List Daybin => new WeightParaArrayManager(12, 964, 18, bytes).GetList();
+ public List Hoper => new WeightParaArrayManager(4, 1180, 18, bytes).GetList();
+ public List Water => new WeightParaArrayManager(4, 1252, 18, bytes).GetList();
+ }
+
+
+
+ public class WeightParaE
+ {
+ public WeightParaE(byte[] content)
+ {
+ HighSpeed = PlcConnect.Instance.ByteTransform.TransSingle(content, 0);
+ LowSpeed = PlcConnect.Instance.ByteTransform.TransSingle(content, 4);
+ WeightSlow = PlcConnect.Instance.ByteTransform.TransSingle(content, 8);
+ Precut = PlcConnect.Instance.ByteTransform.TransSingle(content, 12);
+ JogTime = PlcConnect.Instance.ByteTransform.TransInt16(content, 16);
+
+ }
+
+ public float HighSpeed { get; private set; }
+ public float LowSpeed { get; private set; }
+ public float WeightSlow { get; private set; }
+ public float Precut { get; private set; }
+ public int JogTime { get; private set; }
+
+ }
+
+ public class WeightParaArrayManager
+ {
+ private int Length;
+ private int StartSet;
+ private int SLength;
+ byte[] bytes;
+
+ public WeightParaArrayManager(ushort length, int startSet, int sLength, byte[] bytes)
+ {
+ Length = length;
+ StartSet = startSet;
+ SLength = sLength;
+ this.bytes = bytes;
+ }
+
+ public List GetList()
+ {
+ List ListE = new List(Length);
+ //var getListE = PlcConnect.Instance.Read("DB2107." + StartSet + ".0", Convert.ToUInt16(Length * SLength));
+ var content = bytes.Skip(StartSet).Take(Length * SLength).ToArray();
+
+ for (int i = 0; i < Length; i++)
+ {
+ var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray();
+ ListE.Add(new WeightParaE(singleBlock));
+ }
+ return ListE;
+ }
+ }
\ No newline at end of file
diff --git a/Plc/WetMixingEntity.cs b/Plc/WetMixingEntity.cs
new file mode 100644
index 0000000..a4a5378
--- /dev/null
+++ b/Plc/WetMixingEntity.cs
@@ -0,0 +1,83 @@
+namespace WorkerSynReport.Plc;
+
+ public class WetMixingEntity
+ {
+ private int StartSet;
+ private byte[] bytes;
+ public WetMixingEntity(int startSet, byte[] bytes)
+ {
+ this.StartSet = startSet;
+ this.bytes = bytes;
+ }
+
+ public List WetMixing_A => new WetReportArrayManager(10, StartSet, 26, bytes).GetList();
+ public List WetMixing_B => new WetReportArrayManager(10, StartSet + 260, 26, bytes).GetList();
+ public List WetMixing_C => new WetReportArrayManager(10, StartSet + 520, 26, bytes).GetList();
+ public List WetMixing_D => new WetReportArrayManager(10, StartSet + 780, 26, bytes).GetList();
+ public List WetMixing_E => new WetReportArrayManager(10, StartSet + 1040, 26, bytes).GetList();
+ public List WetMixing_F => new WetReportArrayManager(10, StartSet + 1300, 26, bytes).GetList();
+ public List WetMixing_G => new WetReportArrayManager(10, StartSet + 1560, 26, bytes).GetList();
+ public List WetMixing_H => new WetReportArrayManager(10, StartSet + 1820, 26, bytes).GetList();
+
+
+ }
+
+
+
+ public class Report_WMixE
+ {
+ public Report_WMixE(byte[] content)
+ {
+ EqNo = PlcConnect.Instance.ByteTransform.TransInt16(content, 0);
+ MixBatch = PlcConnect.Instance.ByteTransform.TransInt16(content, 2);
+ MixStep = PlcConnect.Instance.ByteTransform.TransInt16(content, 4);
+ ActCode = PlcConnect.Instance.ByteTransform.TransInt16(content, 6);
+ MixTime = PlcConnect.Instance.ByteTransform.TransInt16(content, 8);
+ MixTemp = PlcConnect.Instance.ByteTransform.TransSingle(content, 10);
+ MixSpeed = PlcConnect.Instance.ByteTransform.TransSingle(content, 14);
+ ActWeight = PlcConnect.Instance.ByteTransform.TransSingle(content, 18);
+ ActTolerence = PlcConnect.Instance.ByteTransform.TransSingle(content, 22);
+
+ }
+
+ public short EqNo { get; private set; }
+ public short MixBatch { get; private set; }
+ public short MixStep { get; private set; }
+ public short ActCode { get; private set; }
+ public short MixTime { get; private set; }
+ public float MixTemp { get; private set; }
+ public float MixSpeed { get; private set; }
+ public float ActWeight { get; private set; }
+ public float ActTolerence { get; private set; }
+
+ }
+
+ public class WetReportArrayManager
+ {
+ private int Length;
+ private int StartSet;
+ private int SLength;
+ private byte[] Bytes;
+
+ public WetReportArrayManager(ushort length, int startSet, int sLength, byte[] bytes)
+ {
+ Length = length;
+ StartSet = startSet;
+ SLength = sLength;
+ Bytes = bytes;
+ }
+
+ public List GetList()
+ {
+ List ListE = new List(Length);
+ //var getListE = PlcConnect.Instance.Read("DB2106." + StartSet + ".0", Convert.ToUInt16(Length * SLength));
+ var content = Bytes.Skip(StartSet).Take(Length * SLength).ToArray();
+
+ for (int i = 0; i < Length; i++)
+ {
+ var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray();
+ ListE.Add(new Report_WMixE(singleBlock));
+ }
+ return ListE;
+ }
+ }
\ No newline at end of file
diff --git a/Program.cs b/Program.cs
index e126937..83515f6 100644
--- a/Program.cs
+++ b/Program.cs
@@ -1,19 +1,20 @@
using NewLife.Extensions.Hosting.AgentService;
using NewLife.Log;
using WorkerSynReport;
+using WorkerSynReport.Plc;
XTrace.UseConsole();
IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
-
services.AddScoped(a => new DbContextLocal("Data Source=172.18.4.130;Initial Catalog=CWSSHG;user=sa;password=123456;"));
-
services.AddScoped(a => new DbContextHttp("Data Source=192.168.202.22;Initial Catalog=CWSSHG;user=sa;password=Lanju@123;"));
+ // services.AddHostedService();
+
+ services.AddScoped();
-
- services.AddHostedService();
+ services.AddHostedService();
})
.UseAgentService(options =>
{
diff --git a/Worker.cs b/Worker.cs
index 4fa7228..10622b9 100644
--- a/Worker.cs
+++ b/Worker.cs
@@ -44,7 +44,7 @@ namespace WorkerSynReport
.OrderByDesc(x => x.objId).Select(x => x.reportId).FirstOrDefaultAsync();
- var objId=await dbContextLocal.Query().Where(x => x.reportId == reportId)
+ var objId=await dbContextLocal!.Query().Where(x => x.reportId == reportId)
.Select(x => x.objId).FirstOrDefaultAsync();
if (objId>0)
{
@@ -79,7 +79,7 @@ namespace WorkerSynReport
var reportId=await dbContextHttp!.Query()
.OrderByDesc(x => x.objId).Select(x => x.reportId).FirstOrDefaultAsync();
- var objId=await dbContextLocal.Query().Where(x => x.reportId == reportId)
+ var objId=await dbContextLocal!.Query().Where(x => x.reportId == reportId)
.Select(x => x.objId).FirstOrDefaultAsync();
if (objId > 0)
@@ -122,7 +122,7 @@ namespace WorkerSynReport
var reportId=await dbContextHttp!.Query()
.OrderByDesc(x => x.objId).Select(x => x.reportId).FirstOrDefaultAsync();
- var objId=await dbContextLocal.Query().Where(x => x.reportId == reportId)
+ var objId=await dbContextLocal!.Query().Where(x => x.reportId == reportId)
.Select(x => x.objId).FirstOrDefaultAsync();
if (objId > 0)