Decimal numbers in OptoData logfiles use commas instead of dots, Delta time fixed, test start/end labels added.
This commit is contained in:
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
TestBenchFramework/bin/
|
|
||||||
TestBenchFramework/obj/
|
|
||||||
Config/bin/
|
Config/bin/
|
||||||
Config/obj/
|
Config/obj/
|
||||||
Results/bin/
|
Results/bin/
|
||||||
Results/obj/
|
Results/obj/
|
||||||
ResultsBrowser/bin/
|
ResultsBrowser/bin/
|
||||||
ResultsBrowser/obj/
|
ResultsBrowser/obj/
|
||||||
|
TestBenchFramework/bin/
|
||||||
|
TestBenchFramework/obj/
|
||||||
TBFSetup/Debug/
|
TBFSetup/Debug/
|
||||||
TBFSetup/Release/
|
TBFSetup/Release/
|
||||||
Doc/
|
Doc/
|
||||||
|
|||||||
@@ -6,11 +6,19 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
public class OptoTelegramRaw
|
public class OptoTelegramRaw
|
||||||
{
|
{
|
||||||
public static readonly int Length = 42;
|
public static readonly int Length = 42;
|
||||||
|
private static CultureInfo culture;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Strobed value
|
||||||
|
///
|
||||||
|
public static decimal TestStartTimestampDec;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Stored values
|
/// Stored values
|
||||||
///
|
///
|
||||||
public OptoTelegramFlags flags;
|
public OptoTelegramFlags Flags;
|
||||||
|
|
||||||
public DateTime DateTime; /// From PC
|
public DateTime DateTime; /// From PC
|
||||||
public int Counter;
|
public int Counter;
|
||||||
@@ -38,26 +46,31 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
public decimal TimestampDec() { return (decimal)Timestamp / (decimal)8192; }
|
public decimal TimestampDec() { return (decimal)Timestamp / (decimal)8192; }
|
||||||
public double RefFlow() { return 0; }
|
public double RefFlow() { return 0; }
|
||||||
public double VolumeDelta(double scalingFactor, OptoTelegramRaw previous) { return (previous == null) ? 0 : Volume(scalingFactor) - previous.Volume(scalingFactor); }
|
public double VolumeDelta(double scalingFactor, OptoTelegramRaw previous) { return (previous == null) ? 0 : Volume(scalingFactor) - previous.Volume(scalingFactor); }
|
||||||
public decimal TimeDelta(OptoTelegramRaw previous) { return (previous == null) ? 0 : TimestampDec() - previous.TimestampDec(); }
|
public decimal TimeDelta() { return TimestampDec() - TestStartTimestampDec; }
|
||||||
public string Label()
|
public string Label()
|
||||||
{
|
{
|
||||||
if (flags == OptoTelegramFlags.OK_TestStart) return "#### start test ####";
|
if (Flags == OptoTelegramFlags.OK_TestStart) return "#### start test ####";
|
||||||
else if (flags == OptoTelegramFlags.OK_TestEnd) return "#### end of test ####";
|
else if (Flags == OptoTelegramFlags.OK_TestEnd) return "#### end of test ####";
|
||||||
else return string.Empty;
|
else return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static OptoTelegramRaw()
|
||||||
|
{
|
||||||
|
culture = CultureInfo.CreateSpecificCulture("DE"); /// This is to use comma as decimal number separator
|
||||||
|
}
|
||||||
|
|
||||||
public OptoTelegramRaw()
|
public OptoTelegramRaw()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ToString(double scalingFactor, OptoTelegramRaw previous)
|
public string ToString(double scalingFactor, OptoTelegramRaw previous)
|
||||||
{
|
{
|
||||||
if (flags == OptoTelegramFlags.SyncError)
|
if (Flags == OptoTelegramFlags.SyncError)
|
||||||
{
|
{
|
||||||
return "Sychronization error";
|
return "Sychronization error";
|
||||||
}
|
}
|
||||||
else if (flags == OptoTelegramFlags.InvalidTelegram)
|
else if (Flags == OptoTelegramFlags.InvalidTelegram)
|
||||||
{
|
{
|
||||||
return "Invalid telegram";
|
return "Invalid telegram";
|
||||||
}
|
}
|
||||||
@@ -76,16 +89,16 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
Impedance.ToString("X4"),
|
Impedance.ToString("X4"),
|
||||||
Timestamp.ToString("X8"),
|
Timestamp.ToString("X8"),
|
||||||
CheckSum.ToString("X2"),
|
CheckSum.ToString("X2"),
|
||||||
EMF().ToString("F4"),
|
EMF().ToString("F4", culture),
|
||||||
MagneticField().ToString("F0"),
|
MagneticField().ToString("F0", culture),
|
||||||
Flow(scalingFactor).ToString("F2"),
|
Flow(scalingFactor).ToString("F2", culture),
|
||||||
Volume(scalingFactor).ToString("F4"),
|
Volume(scalingFactor).ToString("F4", culture),
|
||||||
FlipTime().ToString("F0"),
|
FlipTime().ToString("F0", culture),
|
||||||
TimestampDec().ToString("F4"),
|
TimestampDec().ToString("F4", culture),
|
||||||
RefFlow().ToString("F2"),
|
RefFlow().ToString("F2", culture),
|
||||||
VolumeDelta(scalingFactor, previous).ToString("F4"),
|
VolumeDelta(scalingFactor, previous).ToString("F4", culture),
|
||||||
TimeDelta(previous).ToString("F3"),
|
TimeDelta().ToString("F3", culture),
|
||||||
scalingFactor.ToString("F1"),
|
scalingFactor.ToString("F1", culture),
|
||||||
Label());
|
Label());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,7 +173,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
|
|
||||||
public void SetFlags(OptoTelegramFlags flags)
|
public void SetFlags(OptoTelegramFlags flags)
|
||||||
{
|
{
|
||||||
this.flags = flags;
|
this.Flags = flags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,6 +237,9 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
double timestampSecEnd2;
|
double timestampSecEnd2;
|
||||||
double timestampSecEnd3;
|
double timestampSecEnd3;
|
||||||
|
|
||||||
|
private int telegramIx;
|
||||||
|
public int TestStartTelegramIx;
|
||||||
|
public int TestEndTelegramIx;
|
||||||
|
|
||||||
private Boxes.IntBox pulses;
|
private Boxes.IntBox pulses;
|
||||||
private Boxes.IntBox refPulses;
|
private Boxes.IntBox refPulses;
|
||||||
@@ -442,6 +445,8 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
{
|
{
|
||||||
/// Reset opto data
|
/// Reset opto data
|
||||||
optoDataCount = 0;
|
optoDataCount = 0;
|
||||||
|
TestStartTelegramIx = 0;
|
||||||
|
TestEndTelegramIx = 0;
|
||||||
|
|
||||||
/// File name is: PCB_AA_BB_HH_MI_SS..txt
|
/// File name is: PCB_AA_BB_HH_MI_SS..txt
|
||||||
string wmPosition = Name.Substring(5);
|
string wmPosition = Name.Substring(5);
|
||||||
@@ -482,34 +487,40 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
/// Take the test start sample
|
/// Take the test start sample
|
||||||
VolumeLtrStart = volumeLtr;
|
VolumeLtrStart = volumeLtr;
|
||||||
TimestampSecStart = timestampSec;
|
TimestampSecStart = timestampSec;
|
||||||
|
TestStartTelegramIx = telegramIx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shift data in pipelines
|
/// Shift data in pipelines
|
||||||
VolumeLtrEnd = volumeLtrEnd3;
|
VolumeLtrEnd = volumeLtrEnd3;
|
||||||
|
|
||||||
//volumeLtrEnd6 = volumeLtrEnd5;
|
|
||||||
//volumeLtrEnd5 = volumeLtrEnd4;
|
|
||||||
//volumeLtrEnd4 = volumeLtrEnd3;
|
|
||||||
volumeLtrEnd3 = volumeLtrEnd2;
|
volumeLtrEnd3 = volumeLtrEnd2;
|
||||||
volumeLtrEnd2 = volumeLtrEnd1;
|
volumeLtrEnd2 = volumeLtrEnd1;
|
||||||
volumeLtrEnd1 = volumeLtr;
|
volumeLtrEnd1 = volumeLtr;
|
||||||
|
|
||||||
TimestampSecEnd = timestampSecEnd3;
|
TimestampSecEnd = timestampSecEnd3;
|
||||||
|
|
||||||
//timestampSecEnd6 = timestampSecEnd5;
|
|
||||||
//timestampSecEnd5 = timestampSecEnd4;
|
|
||||||
//timestampSecEnd4 = timestampSecEnd3;
|
|
||||||
timestampSecEnd3 = timestampSecEnd2;
|
timestampSecEnd3 = timestampSecEnd2;
|
||||||
timestampSecEnd2 = timestampSecEnd1;
|
timestampSecEnd2 = timestampSecEnd1;
|
||||||
timestampSecEnd1 = timestampSec;
|
timestampSecEnd1 = timestampSec;
|
||||||
|
|
||||||
|
TestEndTelegramIx = telegramIx - 3;
|
||||||
|
|
||||||
return Event.ReadRegisterDone;
|
return Event.ReadRegisterDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Stop this operation</summary>
|
/// <summary>Stop this operation</summary>
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
StopParsingOptoSerialPort();
|
if (TestStartTelegramIx > 0 && TestStartTelegramIx < optoData.Length && optoData[TestStartTelegramIx].Flags == OptoTelegramFlags.OK)
|
||||||
|
{
|
||||||
|
optoData[TestStartTelegramIx].Flags = OptoTelegramFlags.OK_TestStart;
|
||||||
|
OptoTelegramRaw.TestStartTimestampDec = optoData[TestStartTelegramIx].TimestampDec();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TestEndTelegramIx > 0 && TestEndTelegramIx < optoData.Length && optoData[TestEndTelegramIx].Flags == OptoTelegramFlags.OK)
|
||||||
|
{
|
||||||
|
optoData[TestEndTelegramIx].Flags = OptoTelegramFlags.OK_TestEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
StopParsingOptoSerialPort();
|
||||||
SaveOptoData();
|
SaveOptoData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -617,8 +628,8 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
// CR+LF found and (pos >= OptoTelegramRaw.Length - 2)
|
// CR+LF found and (pos >= OptoTelegramRaw.Length - 2)
|
||||||
else if (optoData[optoDataCount].UpdateFromString(allRcvd.Substring(pos - OptoTelegramRaw.Length + 2), optoDataCount))
|
else if (optoData[optoDataCount].UpdateFromString(allRcvd.Substring(pos - OptoTelegramRaw.Length + 2), optoDataCount))
|
||||||
{
|
{
|
||||||
OptoTelegramRreceived(optoData[optoDataCount++], synchronized2);
|
OptoTelegramRreceived(optoDataCount++, synchronized2);
|
||||||
synchronized2 = synchronized;
|
synchronized2 = synchronized;
|
||||||
allRcvd = allRcvd.Substring(pos + 2);
|
allRcvd = allRcvd.Substring(pos + 2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -660,8 +671,11 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OptoTelegramRreceived(OptoTelegramRaw optoTelegram, bool async)
|
void OptoTelegramRreceived(int currentIx, bool async)
|
||||||
{
|
{
|
||||||
|
OptoTelegramRaw optoTelegram = optoData[currentIx];
|
||||||
|
telegramIx = currentIx;
|
||||||
|
|
||||||
Int32 uncorrectedRawVolume = 0;
|
Int32 uncorrectedRawVolume = 0;
|
||||||
if (!lastVolumeRawValid)
|
if (!lastVolumeRawValid)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user