From 99cb6d98248a6cb23b7c913c166df567ea8916a4 Mon Sep 17 00:00:00 2001 From: iioter <535915157@qq.com> Date: Mon, 24 Jul 2023 10:38:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0double=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Drivers/PLC.ModBusMaster/DeviceModBusMaster.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Plugins/Drivers/PLC.ModBusMaster/DeviceModBusMaster.cs b/Plugins/Drivers/PLC.ModBusMaster/DeviceModBusMaster.cs index 5e49625..190af2d 100644 --- a/Plugins/Drivers/PLC.ModBusMaster/DeviceModBusMaster.cs +++ b/Plugins/Drivers/PLC.ModBusMaster/DeviceModBusMaster.cs @@ -652,6 +652,17 @@ namespace PLC.ModBusMaster }; ret.Value = BitConverter.ToSingle(bytes, 0); } + else if (ioArg.ValueType.ToString().Contains("Double")) + { + var bytes = new[] + { + (byte)(retBuffers[0] & 0xff), (byte)((retBuffers[0] >> 8) & 0xff), + (byte)(retBuffers[1] & 0xff), (byte)((retBuffers[1] >> 8) & 0xff), + (byte)(retBuffers[2] & 0xff), (byte)((retBuffers[2] >> 8) & 0xff), + (byte)(retBuffers[3] & 0xff), (byte)((retBuffers[3] >> 8) & 0xff) + }; + ret.Value = BitConverter.ToDouble(bytes, 0); + } else if (ioArg.ValueType.ToString().Contains("AsciiString")) { var str = Encoding.ASCII.GetString(GetBytes(retBuffers).ToArray());