Raw opto telegram added, TODO: complete OptoTelegramRaw implementation.
This commit is contained in:
@@ -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 "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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
|
||||||
|
/// ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">A complete byte array data</param>
|
||||||
|
/// <returns>ConfigStruct or null when byte array was not complete</returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -359,6 +359,7 @@
|
|||||||
<Compile Include="BenchControl\WaterMeters\iPerl\Enums.cs" />
|
<Compile Include="BenchControl\WaterMeters\iPerl\Enums.cs" />
|
||||||
<Compile Include="BenchControl\WaterMeters\iPerl\OptoReceivedEventArgs.cs" />
|
<Compile Include="BenchControl\WaterMeters\iPerl\OptoReceivedEventArgs.cs" />
|
||||||
<Compile Include="BenchControl\WaterMeters\iPerl\OptoTelegram.cs" />
|
<Compile Include="BenchControl\WaterMeters\iPerl\OptoTelegram.cs" />
|
||||||
|
<Compile Include="BenchControl\WaterMeters\iPerl\OptoTelegramRaw.cs" />
|
||||||
<Compile Include="BenchControl\WaterMeters\iPerl\ProcParams.cs" />
|
<Compile Include="BenchControl\WaterMeters\iPerl\ProcParams.cs" />
|
||||||
<Compile Include="BenchControl\WaterMeters\iPerl\StatusStruct.cs" />
|
<Compile Include="BenchControl\WaterMeters\iPerl\StatusStruct.cs" />
|
||||||
<Compile Include="BenchControl\WaterMeters\iPerl\WaterMeter.cs" />
|
<Compile Include="BenchControl\WaterMeters\iPerl\WaterMeter.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user