From 0ed9e6344affe735a8db73d8fb29b65d4df5825e Mon Sep 17 00:00:00 2001 From: smartwyy <645583145@qq.com> Date: Wed, 29 May 2024 20:38:34 +0800 Subject: [PATCH] =?UTF-8?q?modbus=E8=A7=A3=E6=9E=90=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HybirdFrameworkDriver/ModbusTcpMaster/ModbusDecoder.cs | 3 +-- Service/Plc/Client/PlcClient.cs | 8 ++++---- WebStarter/Controllers/SwapMonitorController.cs | 5 ++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/HybirdFrameworkDriver/ModbusTcpMaster/ModbusDecoder.cs b/HybirdFrameworkDriver/ModbusTcpMaster/ModbusDecoder.cs index 7ea7a41..18f7fbd 100644 --- a/HybirdFrameworkDriver/ModbusTcpMaster/ModbusDecoder.cs +++ b/HybirdFrameworkDriver/ModbusTcpMaster/ModbusDecoder.cs @@ -1,6 +1,5 @@ using HybirdFrameworkCore.Const; using HybirdFrameworkCore.Utils; -using HybirdFrameworkDriver.Common; using log4net; namespace HybirdFrameworkDriver.ModbusTcpMaster; @@ -42,7 +41,7 @@ public static class ModbusDecoder if (wordSeq == EndingConst.WordSeq.CD) { - decodeUseBytes = BitUtls.ReverseWordSeq(bytes); + decodeUseBytes = BitUtls.ReverseWordSeq(decodeUseBytes); } foreach (var field in fields) diff --git a/Service/Plc/Client/PlcClient.cs b/Service/Plc/Client/PlcClient.cs index 4cd54bc..7d5d8b3 100644 --- a/Service/Plc/Client/PlcClient.cs +++ b/Service/Plc/Client/PlcClient.cs @@ -1,7 +1,7 @@ using HybirdFrameworkCore.Autofac.Attribute; +using HybirdFrameworkCore.Const; using HybirdFrameworkDriver.ModbusTcpMaster; using Repository.Station; -using Service.Execute.Api; using Service.Plc.Msg; namespace Service.Plc.Client; @@ -33,14 +33,14 @@ public class PlcClient : ModbusTcpMaster { PlcMgr.DataValidityTime = DateTime.Now; - ModbusDecoder.Decode(bytes01, PlcMgr.HostToPlcData); + ModbusDecoder.Decode(bytes01, PlcMgr.HostToPlcData, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } var bytes02 = master.BatchReadHolderRegister(201, 222); if (bytes02 != null) { PlcMgr.DataValidityTime = DateTime.Now; - ModbusDecoder.Decode(bytes02, PlcMgr.PlcToHostData); + ModbusDecoder.Decode(bytes02, PlcMgr.PlcToHostData, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); _binInfoRepository.Update(it => it.Exists == PlcMgr.PlcToHostData.MaterialDetec01.Value, it => it.No == "1"); @@ -68,7 +68,7 @@ public class PlcClient : ModbusTcpMaster if (bytes03 != null) { PlcMgr.DataValidityTime = DateTime.Now; - ModbusDecoder.Decode(bytes03, PlcMgr.PlcFaultData); + ModbusDecoder.Decode(bytes03, PlcMgr.PlcFaultData, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } } } \ No newline at end of file diff --git a/WebStarter/Controllers/SwapMonitorController.cs b/WebStarter/Controllers/SwapMonitorController.cs index 1309650..b1549cc 100644 --- a/WebStarter/Controllers/SwapMonitorController.cs +++ b/WebStarter/Controllers/SwapMonitorController.cs @@ -1,4 +1,3 @@ -using Entity.Api.Req; using Entity.Api.Resp; using Entity.Constant; using HybirdFrameworkCore.Entity; @@ -17,9 +16,9 @@ namespace WebStarter.Controllers; [Route("api/[controller]")] public class SwapMonitorController : ControllerBase { - private readonly MonitorService? _swapMonitorService; + private readonly MonitorService _swapMonitorService; - public SwapMonitorController(MonitorService? swapMonitorService) + public SwapMonitorController(MonitorService swapMonitorService) { _swapMonitorService = swapMonitorService; }