From 713fd9d0ae26ed510dd9e57902c0091646988e70 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Sun, 16 Aug 2015 20:34:06 +0200 Subject: [PATCH] Raw opto telegram added, TODO: complete OptoTelegramRaw implementation. --- .../WaterMeters/iPerl/OptoTelegramRaw.cs | 70 +++++++++++++++++++ TestBenchFramework/TBF.csproj | 1 + 2 files changed, 71 insertions(+) create mode 100644 TestBenchFramework/BenchControl/WaterMeters/iPerl/OptoTelegramRaw.cs diff --git a/TestBenchFramework/BenchControl/WaterMeters/iPerl/OptoTelegramRaw.cs b/TestBenchFramework/BenchControl/WaterMeters/iPerl/OptoTelegramRaw.cs new file mode 100644 index 000000000..03a583172 --- /dev/null +++ b/TestBenchFramework/BenchControl/WaterMeters/iPerl/OptoTelegramRaw.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace TBF.BenchControl.WaterMeters.iPerl +{ + public class OptoTelegramRaw + { + public static readonly int Length = 42; + + public Int32 EMF; + public Int16 MagneticField; + public Int16 Flow; + public Int32 Volume; + public Int16 Impedance; + public UInt32 Timestamp; + public byte GG; + + public OptoTelegramRaw() + { + } + + public override string ToString() + { + return ""; + } + + /// + /// Create a configuration structure from a complete byte array + /// + /// Telegram description: + /// + /// AAAAAA[tab]BBBB[tab]CCCC[tab]DDDDDD[tab]EEEE[tab]FFFFFFFF[tab]GG[cr][lf] (42 bytes) + /// + /// Data Comment Type Calculate to decimal + /// ---------------------------------------------------------------- + /// AAAAAA EMF Int24 Value * 0.000000333 + /// BBBB Magnetic field Int16 Value + /// CCCC Flow Int16 Value * 0.225 * Scalig factor + /// DDDDDD Volume Int24 Value / 16000 * Scaling factor + /// EEEE Impedance Int16 Value + /// FFFFFFFF Timestamp Uint32 Value / 8192 + /// GG + /// ---------------------------------------------------------------- + /// + /// Example: + /// FFFFFE 51EA 0000 65324E 0087 F6319DFF 86 + /// FFDD3A 51F9 0000 65324E 0088 F631A60B 45 + /// ... + /// + /// A complete byte array data + /// ConfigStruct or null when byte array was not complete + public static OptoTelegramRaw FromString(string telegram, MeterType meterType) + { + if ((telegram == null) || (telegram.Length < Length) || + (telegram[6] != '\t') || (telegram[11] != '\t') || + (telegram[16] != '\t') || (telegram[23] != '\t') || + (telegram[28] != '\t') || (telegram[37] != '\t') || + (telegram[40] != '\r') || (telegram[41] != '\n')) + { + return null; + } + + OptoTelegramRaw opto = new OptoTelegramRaw(); + + return opto; + } + } +} diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj index 8c0236262..14494ba28 100644 --- a/TestBenchFramework/TBF.csproj +++ b/TestBenchFramework/TBF.csproj @@ -359,6 +359,7 @@ +