From 1578632dbf266857f3dafa563034db0b875a6828 Mon Sep 17 00:00:00 2001 From: sl <965026003@qq.com> Date: Tue, 14 May 2024 15:13:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=A9=E6=B9=BF=E5=BA=A6=E5=92=8C=E7=94=B5?= =?UTF-8?q?=E8=A1=A8=20=20=E8=8E=B7=E5=8F=96=E5=80=BC=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Manager/EMeterModbus527Tool.cs | 8 ++--- .../Manager/ElecMeterEqmManger.cs | 33 ++++++++++++++----- .../Manager/HumiMeterModbusTool.cs | 4 +-- Monitor.Models/MEMeterParamResult.cs | 2 +- 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/Module.EMeter.ModbusTcp.Tool/Manager/EMeterModbus527Tool.cs b/Module.EMeter.ModbusTcp.Tool/Manager/EMeterModbus527Tool.cs index 8539f5d..102cc7a 100644 --- a/Module.EMeter.ModbusTcp.Tool/Manager/EMeterModbus527Tool.cs +++ b/Module.EMeter.ModbusTcp.Tool/Manager/EMeterModbus527Tool.cs @@ -264,11 +264,11 @@ namespace Module.EMeter.ModbusTcp /// /// 吸收有功电能二次侧 /// - private float _show_energy; + private decimal _show_energy; /// /// 吸收有功电能二次侧 003FH~0040H(吸收有功电能) /// - public float F_ShowEnergy + public decimal F_ShowEnergy { get { @@ -533,8 +533,8 @@ namespace Module.EMeter.ModbusTcp var CT = _client.ByteTransform.TransInt16(operateResult1.Content, 8); //_total_active_power = _client.ByteTransform.TransUInt16(_client.Read("x=3;45", 150).Content, 4); //_total_active_energy = _client.ByteTransform.TransSingle(_client.Read("x=3;45", 150).Content, 56) / 1000f; - var transInt16 = (new decimal(_client.ByteTransform.TransUInt16(operateResult2.Content, 0)) * 65536 + _client.ByteTransform.TransUInt16(operateResult2.Content, 2) / new decimal(1000f)) * new decimal(PT) * new decimal(CT); - _show_energy = (float)transInt16; + var transInt16 = ((new decimal(_client.ByteTransform.TransUInt16(operateResult2.Content, 0)) * 65536 + _client.ByteTransform.TransUInt16(operateResult2.Content, 2) )/ new decimal(1000f)) * new decimal(PT) * new decimal(CT); + _show_energy = transInt16; MEMeterParamResult paramRlt = new MEMeterParamResult() { F_EqmCode = _eqm_code, diff --git a/Module.EMeter.ModbusTcp.Tool/Manager/ElecMeterEqmManger.cs b/Module.EMeter.ModbusTcp.Tool/Manager/ElecMeterEqmManger.cs index b71800d..797cbaf 100644 --- a/Module.EMeter.ModbusTcp.Tool/Manager/ElecMeterEqmManger.cs +++ b/Module.EMeter.ModbusTcp.Tool/Manager/ElecMeterEqmManger.cs @@ -110,6 +110,10 @@ namespace Module.EMeter.ModbusTcp CmnElecMeterBaseInfo.EBC07.Connect(); } Thread.Sleep(100); + if (!CmnElecMeterBaseInfo.EBC08.F_NetConnected) + { + CmnElecMeterBaseInfo.EBC08.Connect(); + } Thread.Sleep(100); @@ -303,18 +307,31 @@ namespace Module.EMeter.ModbusTcp result.Add(CmnElecMeterBaseInfo.EBC03.F_EMeterParamResult); } - + + if (CmnElecMeterBaseInfo.EBC04.F_NetConnected) + { result.Add(CmnElecMeterBaseInfo.EBC04.F_EMeterParamResult); - - + } + + if (CmnElecMeterBaseInfo.EBC05.F_NetConnected) + { result.Add(CmnElecMeterBaseInfo.EBC05.F_EMeterParamResult); + } + if (CmnElecMeterBaseInfo.EBC06.F_NetConnected) + { + result.Add(CmnElecMeterBaseInfo.EBC06.F_EMeterParamResult); + } + if (CmnElecMeterBaseInfo.EBC07.F_NetConnected) + { + result.Add(CmnElecMeterBaseInfo.EBC07.F_EMeterParamResult); + } + if (CmnElecMeterBaseInfo.EBC08.F_NetConnected) + { + result.Add(CmnElecMeterBaseInfo.EBC08.F_EMeterParamResult); + } - result.Add(CmnElecMeterBaseInfo.EBC06.F_EMeterParamResult); - - result.Add(CmnElecMeterBaseInfo.EBC07.F_EMeterParamResult); - - + diff --git a/Module.Humiture.ModBusTcp/Manager/HumiMeterModbusTool.cs b/Module.Humiture.ModBusTcp/Manager/HumiMeterModbusTool.cs index 51b72c3..6e0ab94 100644 --- a/Module.Humiture.ModBusTcp/Manager/HumiMeterModbusTool.cs +++ b/Module.Humiture.ModBusTcp/Manager/HumiMeterModbusTool.cs @@ -426,8 +426,8 @@ namespace Module.HMeter.ModBusTcp if (readResult.IsSuccess) { byte[] byteResult = readResult.Content; - UInt16 tempVal = _client.ByteTransform.TransUInt16(byteResult, 0); - UInt16 humiVal = _client.ByteTransform.TransUInt16(byteResult, 2); + UInt16 humiVal = _client.ByteTransform.TransUInt16(byteResult, 0); + UInt16 tempVal= _client.ByteTransform.TransUInt16(byteResult, 2); MHumiParamResult paramRlt = new MHumiParamResult() { F_TempValue = (float)tempVal/10, diff --git a/Monitor.Models/MEMeterParamResult.cs b/Monitor.Models/MEMeterParamResult.cs index 11f2d22..1929640 100644 --- a/Monitor.Models/MEMeterParamResult.cs +++ b/Monitor.Models/MEMeterParamResult.cs @@ -25,7 +25,7 @@ namespace Monitor.Models /// /// 吸收有功电能二次侧 003FH~0040H /// - public float F_ShowEnergy { get; set; } + public decimal F_ShowEnergy { get; set; } } }