Changes for Milwaukee: DataStream.Reader bug fix, MefImport.MinSamplesCount =10.
This commit is contained in:
parent
186bbdcc25
commit
674dde8d74
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -25,16 +25,16 @@ namespace TBF.BenchControl.DataEntry.Standard24
|
||||
/// </summary>
|
||||
bool[] disabled; /// This array is shared between forms
|
||||
|
||||
string[] wmCycleEndState;
|
||||
public string WMCycleEndState(int wmNr) { return (wmNr >= 0 && wmNr < wmCycleEndState.Length) ? wmCycleEndState[wmNr] : string.Empty; }
|
||||
|
||||
double[] wmStartState;
|
||||
public double WMStartState(int wmNr) { return (wmNr >= 0 && wmNr < wmStartState.Length) ? wmStartState[wmNr] : 0; }
|
||||
|
||||
string[] wmStartStateStr;
|
||||
|
||||
double[] wmEndState;
|
||||
public double WMEndState(int wmNr) { return (wmNr >= 0 && wmNr < wmEndState.Length) ? wmEndState[wmNr] : 0; }
|
||||
|
||||
string[] wmStartStateStr;
|
||||
string[] wmCycleEndState;
|
||||
public string WMCycleEndState(int wmNr) { return (wmNr >= 0 && wmNr < wmCycleEndState.Length) ? wmCycleEndState[wmNr] : string.Empty; }
|
||||
|
||||
|
||||
System.Windows.Forms.Form modelessDlg;
|
||||
@ -74,6 +74,7 @@ namespace TBF.BenchControl.DataEntry.Standard24
|
||||
wmStartState = new double[Config.Data.WMsCount];
|
||||
wmStartStateStr = new string[Config.Data.WMsCount];
|
||||
wmEndState = new double[Config.Data.WMsCount];
|
||||
wmCycleEndState = new string[Config.Data.WMsCount];
|
||||
currentOp = CurrentOp.None;
|
||||
log.FatalFormat("{0} initialized: {1}", Name, this);
|
||||
}
|
||||
|
||||
@ -18,8 +18,7 @@ namespace TBF.BenchControl.RegisterReaders.DataStream.MefImport
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(MefImport));
|
||||
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
|
||||
|
||||
const Int64 MIN_SAMPLES_COUNT = 20;
|
||||
public Int64 MinSamplesCount { get { return MIN_SAMPLES_COUNT; } }
|
||||
public Int64 MinSamplesCount { get { return 10; } }
|
||||
|
||||
|
||||
[Import(typeof(IDataStreamMeter))]
|
||||
|
||||
@ -23,8 +23,6 @@ namespace TBF.BenchControl.RegisterReaders.DataStream.Reader
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(Reader));
|
||||
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
|
||||
|
||||
const Int64 MinSamplesCount = 20;
|
||||
|
||||
MefImport.MefImport mefImport;
|
||||
Int64 minSamplesCount { get { return mefImport.MinSamplesCount; } }
|
||||
|
||||
@ -126,31 +124,48 @@ namespace TBF.BenchControl.RegisterReaders.DataStream.Reader
|
||||
public void Start()
|
||||
{
|
||||
Clear();
|
||||
mefImport.DataStreamIFace.OpenConnection(Position - 1, "", out waterMeterID);
|
||||
timeUnit = mefImport.DataStreamIFace.GetTimeUnits();
|
||||
volumeUnit = mefImport.DataStreamIFace.GetVolumeUnits();
|
||||
mefImport.DataStreamIFace.StartMeasurement(Position - 1);
|
||||
|
||||
if (TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters.Count >= Position &&
|
||||
TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters[Position - 1] != null &&
|
||||
!TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters[Position - 1].Disabled)
|
||||
{
|
||||
timeUnit = mefImport.DataStreamIFace.GetTimeUnits();
|
||||
volumeUnit = mefImport.DataStreamIFace.GetVolumeUnits();
|
||||
log.DebugFormat("timeUnit = {0}, volumeUnit = {1}", timeUnit, volumeUnit);
|
||||
|
||||
bool started = mefImport.DataStreamIFace.StartMeasurement(Position - 1);
|
||||
log.DebugFormat("{0} : DataStreamIFace.StartMeasurement({1}) in Start() returned {2}", Name, Position - 1, started);
|
||||
}
|
||||
}
|
||||
|
||||
public Event Run()
|
||||
{
|
||||
return Event.None;
|
||||
log.DebugFormat("Run() name={0} position={1}", Name, Position - 1);
|
||||
return Event.ReadRegisterDone;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
mefImport.DataStreamIFace.StopMeasurement(Position - 1, out storedFramesCount);
|
||||
|
||||
if (storedFramesCount >= minSamplesCount)
|
||||
if (TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters.Count >= Position &&
|
||||
TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters[Position - 1] != null &&
|
||||
!TBF.BenchControl.Sequences.ProcessData.BatchRslts.Batch.WaterMeters[Position - 1].Disabled)
|
||||
{
|
||||
startIx = storedFramesCount / minSamplesCount;
|
||||
endIx = (storedFramesCount * (minSamplesCount - 1) / minSamplesCount) - 1;
|
||||
bool stopped = mefImport.DataStreamIFace.StopMeasurement(Position - 1, out storedFramesCount);
|
||||
log.DebugFormat("{0} : DataStreamIFace.StopMeasurement({1}) in Stop() returned {2}, storedFramesCount = {3}", Name, Position - 1, stopped, storedFramesCount);
|
||||
|
||||
beginWMState = VolumeLtrStart;
|
||||
endWMState = VolumeLtrEnd;
|
||||
wmVolume = Math.Abs(VolumeLtrEnd - VolumeLtrStart);
|
||||
wmPulses = (int)Math.Round(wmVolume * PulsesPerLtr);
|
||||
wmRefPulses = StateMachine.ControlBoard.EtPulses(0);
|
||||
if (storedFramesCount >= minSamplesCount)
|
||||
{
|
||||
startIx = storedFramesCount / minSamplesCount;
|
||||
endIx = (storedFramesCount * (minSamplesCount - 1) / minSamplesCount) - 1;
|
||||
|
||||
beginWMState = VolumeLtrStart;
|
||||
endWMState = VolumeLtrEnd;
|
||||
wmVolume = Math.Abs(VolumeLtrEnd - VolumeLtrStart);
|
||||
wmPulses = (int)Math.Round(wmVolume * PulsesPerLtr);
|
||||
wmRefPulses = StateMachine.ControlBoard.EtPulses(0);
|
||||
log.DebugFormat("Stop() ... Position={0}, wmVolume={1}, wmPulses={2}, wmRefPulses={3}", Position, wmVolume, wmPulses, wmRefPulses);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,15 +188,20 @@ namespace TBF.BenchControl.RegisterReaders.DataStream.Reader
|
||||
|
||||
if (samplesDict.TryGetValue(ix, out oneFrame))
|
||||
{
|
||||
return DataStreamInterface.Units.ConvertFrom(timeUnit, oneFrame.Time);
|
||||
double time = DataStreamInterface.Units.ConvertFrom(timeUnit, oneFrame.Time);
|
||||
log.DebugFormat("GetTimeFromSamples({0}) returns {1} ... value from dictionary", ix, time);
|
||||
return time;
|
||||
}
|
||||
else if ((frames = mefImport.DataStreamIFace.GetFrames(Position - 1, ix, 1)).Length == 1)
|
||||
{
|
||||
samplesDict.Add(ix, frames[0]);
|
||||
return DataStreamInterface.Units.ConvertFrom(timeUnit, frames[0].Time);
|
||||
double time = DataStreamInterface.Units.ConvertFrom(timeUnit, frames[0].Time);
|
||||
log.DebugFormat("GetTimeFromSamples({0}) returns {1} ... value obtained by DataStreamIFace.GetFrames({2}, {0}, 1)", ix, time, Position - 1);
|
||||
return time;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.DebugFormat("GetTimeFromSamples({0}) returns 0", ix);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -193,15 +213,20 @@ namespace TBF.BenchControl.RegisterReaders.DataStream.Reader
|
||||
|
||||
if (samplesDict.TryGetValue(ix, out oneFrame))
|
||||
{
|
||||
return DataStreamInterface.Units.ConvertFrom(volumeUnit, oneFrame.Volume);
|
||||
double volume = DataStreamInterface.Units.ConvertFrom(volumeUnit, oneFrame.Volume);
|
||||
log.DebugFormat("GetVolumeFromSamples({0}) returns {1} ... value from dictionary", ix, volume);
|
||||
return volume;
|
||||
}
|
||||
else if ((frames = mefImport.DataStreamIFace.GetFrames(Position - 1, ix, 1)).Length == 1)
|
||||
{
|
||||
samplesDict.Add(ix, frames[0]);
|
||||
return DataStreamInterface.Units.ConvertFrom(volumeUnit, frames[0].Volume);
|
||||
double volume = DataStreamInterface.Units.ConvertFrom(volumeUnit, frames[0].Volume);
|
||||
log.DebugFormat("GetVolumeFromSamples({0}) returns {1} ... value obtained by DataStreamIFace.GetFrames({2}, {0}, 1)", ix, volume, Position - 1);
|
||||
return volume;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.DebugFormat("GetVolumeFromSamples({0}) returns 0", ix);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2016 Sensus Metering Systems
|
||||
/// Copyright (c) 2013-2021 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user