Water meter data cleared at the beginning of each cycle.

This commit is contained in:
Milan Hanajik 2015-12-04 12:24:55 +01:00
parent b1ccdcb5c1
commit e3aa3f6721
4 changed files with 60 additions and 21 deletions

View File

@ -7,6 +7,8 @@ namespace TBF.BenchControl.GenericDevices
{
public interface IWaterMeter : IComponent
{
void ClearData();
string Producer { get; }
float Qn { get; }
string ApprovalInfo { get; }

View File

@ -226,8 +226,14 @@ namespace TBF.BenchControl.Sequences
StateMachine.LoadProcedure(false);
if (StateMachine.Procedure == null) goto select_procedure;
StateMachine.LoadProcedureParams(StateMachine.Procedure);
///
/// Procedure selected at this point, a new batch was started
///
StateMachine.CycleStartTimeStamp = DateTime.Now;
foreach (var wm in WaterMeters) wm.ClearData(); /// Clean water meter data
ResetResults();
StateMachine.LoadProcedureParams(StateMachine.Procedure);
Bridge.OnProcedureSelected(this, new ProcedureSelectedEventArgs(StateMachine.Procedure));
/// Display 'Cycle Begin Form'
@ -423,8 +429,6 @@ namespace TBF.BenchControl.Sequences
if (selection == Selection.Cycle)
{
StateMachine.CycleStartTimeStamp = DateTime.Now;
TimeEstimateTotal = 0;
for (int i = simultWithPurgingCount; i < StateMachine.Tests.Count - simultWithEvacuationCount; i++)
{

View File

@ -73,13 +73,23 @@ namespace TBF.BenchControl.WaterMeters.WaterMeter
public WaterMeter()
{
ClearData();
}
public WaterMeter(WaterMeterCfg cfg)
: base(cfg)
{
ClearData();
waterMeterCfg = cfg;
log.Debug(this.ToString());
}
public void ClearData()
{
serialNr = string.Empty;
endState = string.Empty;
beginState = string.Empty;
disabled = false;
}
}
}

View File

@ -55,9 +55,8 @@ namespace TBF.BenchControl.WaterMeters.iPerl
if (ConfigStruct != null) return configStruct.PCBNumber2String();
else return string.Empty;
}
set { serialNr = value; }
set { }
}
string serialNr;
public string EndState
{
@ -106,7 +105,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
CalibrationStruct calibrationStruct;
public ushort OriginalCalibFactor;
public ushort CalibrationFactor { get { return CalibrationStruct.Calibration; } }
public ushort CalibrationFactor { get { return (CalibrationStruct != null) ? CalibrationStruct.Calibration : (ushort)0; } }
public double Q2ErrorWOCorrection;
public bool Q2CorrectionDone;
@ -266,35 +265,47 @@ namespace TBF.BenchControl.WaterMeters.iPerl
public WaterMeter()
{
disabled = false;
commFailed = false;
ClearData();
}
public WaterMeter(WaterMeterCfg cfg)
: base(cfg)
{
disabled = false;
commFailed = false;
ClearData();
iPerlCfg = cfg;
log.Debug(this.ToString());
}
int NrFormName(string name)
{
int len = name.Length;
if (len < 2) return 0;
/// <summary>
/// Clear data related to a specific water meter
/// </summary>
public void ClearData()
{
disabled = false;
commFailed = false;
endState = string.Empty;
beginState = string.Empty;
int loNr = (int)name[len - 1] - (int)'0';
int hiNr = (int)name[len - 2] - (int)'0';
if (hiNr < 1 || hiNr > 4) hiNr = 0;
configStruct = null;
calibrationStruct = null;
return 10 * hiNr + loNr;
}
LastTestResult = null;
NominalTestFlow = 0;
OriginalCalibFactor = 0;
Q2ErrorWOCorrection = 0;
Q2CorrectionDone = false;
CurrentQ2Correction = 0;
optoDataCount = 0;
}
public void Initialize()
{
if (DebugLevel == Entities.DebugMode.Normal)
ClearData();
if (DebugLevel == Entities.DebugMode.Normal)
{
optoSerialPortParsingEnabled = false;
@ -787,5 +798,17 @@ namespace TBF.BenchControl.WaterMeters.iPerl
case MeterType.DN40: return 16.0;
}
}
}
int PositionNrFormWMName(string name)
{
int len = name.Length;
if (len < 2) return 0;
int loNr = (int)name[len - 1] - (int)'0';
int hiNr = (int)name[len - 2] - (int)'0';
if (hiNr < 1 || hiNr > 4) hiNr = 0;
return 10 * hiNr + loNr;
}
}
}