|
|
@@ -1,11 +1,19 @@
|
|
|
using AntDesign;
|
|
|
+using EasyTemplate.Tool;
|
|
|
+using EasyTemplate.Tool.Entity;
|
|
|
+using Masuit.Tools;
|
|
|
+using Microsoft.AspNetCore.Components;
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
using OneOf.Types;
|
|
|
+using SqlSugar;
|
|
|
+using System.Globalization;
|
|
|
using System.Net.Sockets;
|
|
|
+using System.Reflection.Emit;
|
|
|
using System.Runtime.InteropServices;
|
|
|
using System.Security.Cryptography;
|
|
|
using System.Text;
|
|
|
+using System.Xml.Linq;
|
|
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
|
|
|
|
namespace EasyTemplate.Service
|
|
|
@@ -18,6 +26,14 @@ namespace EasyTemplate.Service
|
|
|
|
|
|
public Dictionary<int, NozzleState> g_mNozzleState = new Dictionary<int, NozzleState>();
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 注入实例
|
|
|
+ /// </summary>
|
|
|
+ [Inject] private SqlSugarRepository<TRecord> _RepoRecord { get; set; }
|
|
|
+
|
|
|
+ [Inject] private SqlSugarRepository<TProduct> _Repository { get; set; }
|
|
|
+
|
|
|
+
|
|
|
public UdpListenerService(ILogger<UdpListenerService> logger)
|
|
|
{
|
|
|
_logger = logger;
|
|
|
@@ -127,9 +143,20 @@ namespace EasyTemplate.Service
|
|
|
g_mNozzleState[down.noz].nozzlestate = Tool.NozzleState_Idle;
|
|
|
break;
|
|
|
case 4:
|
|
|
- filling_record record = extractFillingRecord(result.Buffer, startindex);
|
|
|
+ TRecord record = extractFillingRecord(result.Buffer, startindex);
|
|
|
g_mNozzleState[record.noz].nozzlestate = Tool.NozzleState_Idle;
|
|
|
- g_mNozzleState[record.noz].VLR = ((double)record.VLR / 1000).ToString("F2");
|
|
|
+ g_mNozzleState[record.noz].VLR = ((double)record.vlr / 1000).ToString("F2");
|
|
|
+
|
|
|
+
|
|
|
+ var con = Sql.Connect();
|
|
|
+ var res = con.Insertable<TRecord>(record).ExecuteCommand();
|
|
|
+
|
|
|
+ // RefAsync<int> total = 0;
|
|
|
+ //var s = _Repository.AsQueryable().Where(x => x.Id == record.fip).FirstAsync();
|
|
|
+
|
|
|
+ // var res = await _RepoRecord.InsertAsync(record);
|
|
|
+
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
|
|
|
@@ -212,29 +239,42 @@ namespace EasyTemplate.Service
|
|
|
data.current = handler.getData(2);
|
|
|
return data;
|
|
|
}
|
|
|
- public filling_record extractFillingRecord(byte[] Buffer, int startIndex)
|
|
|
+ public TRecord extractFillingRecord(byte[] Buffer, int startIndex)
|
|
|
{
|
|
|
int bufferlen = Buffer.Length;
|
|
|
|
|
|
- filling_record data = new filling_record();
|
|
|
+ TRecord data = new TRecord();
|
|
|
BufferHandler handler = new BufferHandler(Buffer, startIndex);
|
|
|
data.board = handler.getData(1);
|
|
|
data.noz = handler.getData(1);
|
|
|
data.fip = data.board;
|
|
|
- if (bufferlen != 22)//兼容旧协议,解析顺序改变
|
|
|
+ if (bufferlen == 22)//兼容旧协议,解析顺序不同
|
|
|
+ {
|
|
|
+ data.tmEnd = DateTime.Now;
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
data.ttc = handler.getData(4);
|
|
|
}
|
|
|
- data.liquidVL = handler.getData(3);
|
|
|
- data.liquidFR = handler.getData(2);
|
|
|
- data.vaporVL = handler.getData(3);
|
|
|
- data.vaporFR = handler.getData(2);
|
|
|
- data.VLR = handler.getData(2);
|
|
|
- data.tmBegin = handler.getDataString_BCD(7);
|
|
|
- data.tmEnd = handler.getDataString_BCD(7);
|
|
|
+ data.liquidVl = handler.getData(3);
|
|
|
+ data.liquidFr = handler.getData(2);
|
|
|
+ data.vaporVl = handler.getData(3);
|
|
|
+ data.vaporFr = handler.getData(2);
|
|
|
+ data.vlr = handler.getData(2);
|
|
|
+ string s1 = handler.getDataString_BCD(7);
|
|
|
+ if (s1 != "")
|
|
|
+ {
|
|
|
+ data.tmBegin = DateTime.ParseExact(s1, "yyyyMMddHHmmss", CultureInfo.InvariantCulture);
|
|
|
+ }
|
|
|
+ string s2 = handler.getDataString_BCD(7);
|
|
|
+ if (s2 != "")
|
|
|
+ {
|
|
|
+ data.tmEnd = DateTime.ParseExact(s2, "yyyyMMddHHmmss", CultureInfo.InvariantCulture);
|
|
|
+ }
|
|
|
data.errornum = handler.getData(2);
|
|
|
- data.vaporPA = handler.getData(2);
|
|
|
+ data.vaporPa = handler.getData(2);
|
|
|
data.pwm = handler.getData(2);
|
|
|
+ data.vccerrorinfo = "";
|
|
|
return data;
|
|
|
}
|
|
|
|