As sent to ST for the last test on Fuzhou300 system

- new component with VZ15 and modified position of VZ13
- fixed start method evaluation OK
- handling of entry forms cleaned-up
This commit is contained in:
Milan Hanajik
2014-09-23 13:16:59 +02:00
parent c3bfe5223b
commit 2f6f24e281
12 changed files with 302 additions and 130 deletions
@@ -5,7 +5,7 @@ using TBF.BenchControl.GenericDevices;
namespace TBF.BenchControl.DataEntry.Munich namespace TBF.BenchControl.DataEntry.Munich
{ {
public class EntryForm : Generic.IComponent, IOperation, GenericDevices.IDataEntry, GenericDevices.IHasProtocolTitle public class EntryForm : Generic.IComponent, IOperation, IDataEntry, IHasCycleBeginForm, IHasCycleEndForm, IHasProtocolTitle
{ {
readonly EntryFormCfg entryFormCfg; readonly EntryFormCfg entryFormCfg;
public Generic.IComponentCfg Cfg { get { return entryFormCfg; } } public Generic.IComponentCfg Cfg { get { return entryFormCfg; } }
@@ -44,7 +44,7 @@ namespace TBF.BenchControl.DataEntry.Munich
bool resultSaved; bool resultSaved;
IList<GenericDevices.IWaterMeter> waterMeters; IList<IWaterMeter> waterMeters;
public enum CurrentOp public enum CurrentOp
{ {
@@ -63,7 +63,7 @@ namespace TBF.BenchControl.DataEntry.Munich
} }
/// <returns>Reference to the operation</returns> /// <returns>Reference to the operation</returns>
public IOperation ShowCycleBeginFormOp(IList<GenericDevices.IWaterMeter> waterMeters) public IOperation ShowCycleBeginFormOp(IList<IWaterMeter> waterMeters)
{ {
if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
currentOp = CurrentOp.ShowFormAtCycleBeginning; currentOp = CurrentOp.ShowFormAtCycleBeginning;
@@ -72,7 +72,7 @@ namespace TBF.BenchControl.DataEntry.Munich
} }
/// <returns>Reference to the operation</returns> /// <returns>Reference to the operation</returns>
public IOperation ShowCycleEndFormOp(IList<GenericDevices.IWaterMeter> waterMeters) public IOperation ShowCycleEndFormOp(IList<IWaterMeter> waterMeters)
{ {
if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
currentOp = CurrentOp.ShowFormAtCycleEnd; currentOp = CurrentOp.ShowFormAtCycleEnd;
@@ -129,7 +129,7 @@ namespace TBF.BenchControl.DataEntry.Munich
/// <returns>Event.ResultsPrinted</returns> /// <returns>Event.ResultsPrinted</returns>
public Event Run() public Event Run()
{ {
if (!(modelessDlg as GenericDevices.IHasCompleted).Completed) if (!(modelessDlg as IHasCompleted).Completed)
{ {
return Event.None; /// Return 'None' when form was not closed yet return Event.None; /// Return 'None' when form was not closed yet
} }
@@ -5,7 +5,7 @@ using TBF.BenchControl.GenericDevices;
namespace TBF.BenchControl.DataEntry.Munich3 namespace TBF.BenchControl.DataEntry.Munich3
{ {
public class EntryForm : Generic.IComponent, IOperation, GenericDevices.IDataEntry, GenericDevices.IHasProtocolTitle public class EntryForm : Generic.IComponent, IOperation, IDataEntry, IHasCycleBeginForm, IHasCycleEndForm, IHasProtocolTitle
{ {
readonly EntryFormCfg entryFormCfg; readonly EntryFormCfg entryFormCfg;
public Generic.IComponentCfg Cfg { get { return entryFormCfg; } } public Generic.IComponentCfg Cfg { get { return entryFormCfg; } }
@@ -38,7 +38,7 @@ namespace TBF.BenchControl.DataEntry.Munich3
bool resultSaved; bool resultSaved;
IList<GenericDevices.IWaterMeter> waterMeters; IList<IWaterMeter> waterMeters;
public enum CurrentOp public enum CurrentOp
{ {
@@ -57,7 +57,7 @@ namespace TBF.BenchControl.DataEntry.Munich3
} }
/// <returns>Reference to the operation</returns> /// <returns>Reference to the operation</returns>
public IOperation ShowCycleBeginFormOp(IList<GenericDevices.IWaterMeter> waterMeters) public IOperation ShowCycleBeginFormOp(IList<IWaterMeter> waterMeters)
{ {
if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
currentOp = CurrentOp.ShowFormAtCycleBeginning; currentOp = CurrentOp.ShowFormAtCycleBeginning;
@@ -66,7 +66,7 @@ namespace TBF.BenchControl.DataEntry.Munich3
} }
/// <returns>Reference to the operation</returns> /// <returns>Reference to the operation</returns>
public IOperation ShowCycleEndFormOp(IList<GenericDevices.IWaterMeter> waterMeters) public IOperation ShowCycleEndFormOp(IList<IWaterMeter> waterMeters)
{ {
if (currentOp != CurrentOp.None) throw new Exception("Sequence error"); if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
currentOp = CurrentOp.ShowFormAtCycleEnd; currentOp = CurrentOp.ShowFormAtCycleEnd;
@@ -123,7 +123,7 @@ namespace TBF.BenchControl.DataEntry.Munich3
/// <returns>Event.ResultsPrinted</returns> /// <returns>Event.ResultsPrinted</returns>
public Event Run() public Event Run()
{ {
if (!(modelessDlg as GenericDevices.IHasCompleted).Completed) if (!(modelessDlg as IHasCompleted).Completed)
{ {
return Event.None; /// Return 'None' when form was not closed yet return Event.None; /// Return 'None' when form was not closed yet
} }
@@ -5,7 +5,7 @@ using TBF.BenchControl.GenericDevices;
namespace TBF.BenchControl.DataEntry.WMStates namespace TBF.BenchControl.DataEntry.WMStates
{ {
public class EntryForm : Generic.IComponent, IOperation, GenericDevices.IDataEntry public class EntryForm : Generic.IComponent, IOperation, IDataEntry, IHasWMStatesForm
{ {
readonly EntryFormCfg entryFormCfg; readonly EntryFormCfg entryFormCfg;
public Generic.IComponentCfg Cfg { get { return entryFormCfg; } } public Generic.IComponentCfg Cfg { get { return entryFormCfg; } }
@@ -66,13 +66,13 @@ namespace TBF.BenchControl.DataEntry.WMStates
} }
/// <returns>Reference to the operation</returns> /// <returns>Reference to the operation</returns>
public IOperation ShowCycleBeginFormOp(IList<GenericDevices.IWaterMeter> waterMeters) public IOperation ShowCycleBeginFormOp(IList<IWaterMeter> waterMeters)
{ {
return null; return null;
} }
/// <returns>Reference to the operation</returns> /// <returns>Reference to the operation</returns>
public IOperation ShowCycleEndFormOp(IList<GenericDevices.IWaterMeter> waterMeters) public IOperation ShowCycleEndFormOp(IList<IWaterMeter> waterMeters)
{ {
return null; return null;
} }
@@ -126,7 +126,7 @@ namespace TBF.BenchControl.DataEntry.WMStates
/// <returns>Event.ResultsPrinted</returns> /// <returns>Event.ResultsPrinted</returns>
public Event Run() public Event Run()
{ {
if (!(modelessDlg as GenericDevices.IHasCompleted).Completed) if (!(modelessDlg as IHasCompleted).Completed)
{ {
return Event.None; /// Return 'None' when form was not closed yet return Event.None; /// Return 'None' when form was not closed yet
} }
@@ -0,0 +1,14 @@
using System.Collections.Generic;
namespace TBF.BenchControl.GenericDevices
{
public interface IHasCycleBeginForm
{
/// <summary>
/// Displays form at the beginning of the cycle (usually to enter S/N).
/// </summary>
/// <param name="waterMeters">Watermetes to be updated by the operation</param>
/// <returns>Operation to be used in the sequence</returns>
IOperation ShowCycleBeginFormOp(IList<IWaterMeter> waterMeters);
}
}
@@ -0,0 +1,14 @@
using System.Collections.Generic;
namespace TBF.BenchControl.GenericDevices
{
public interface IHasCycleEndForm
{
/// <summary>
/// Displays form at the end of the cycle (usually to enter the end state).
/// </summary>
/// <param name="waterMeters">Watermetes to be updated by the operation</param>
/// <returns>Operation to be used in the sequence</returns>
IOperation ShowCycleEndFormOp(IList<IWaterMeter> waterMeters);
}
}
@@ -0,0 +1,13 @@
namespace TBF.BenchControl.GenericDevices
{
public interface IHasWMStatesForm
{
/// <summary>
/// Displays form at the beginning of the cycle (usually to enter S/N).
/// </summary>
/// <param name="waterMeters">Watermetes to be updated by the operation</param>
/// <returns>Operation to be used in the sequence</returns>
IOperation ShowWMStatesFormOp();
}
}
@@ -139,11 +139,11 @@ namespace TBF.BenchControl.Sequences
//-------------------------------- //--------------------------------
GenericDevices.IDataEntry dataEntryCmpnt = GenericDevices.IDataEntry dataEntryCmpnt =
TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IDataEntry; TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IDataEntry;
if (dataEntryCmpnt != null) if (dataEntryCmpnt is IHasCycleBeginForm)
{ {
Bridge.OnActivity(this, "Enter the water meter data"); Bridge.OnActivity(this, "Enter the water meter data");
State.Create("MainSeq : Enter begin data") State.Create("MainSeq : Enter begin data")
.AddPermanentOperation(dataEntryCmpnt.ShowCycleBeginFormOp(WaterMeters)) .AddPermanentOperation((dataEntryCmpnt as IHasCycleBeginForm).ShowCycleBeginFormOp(WaterMeters))
.AddOperation(checkUiOp) .AddOperation(checkUiOp)
.EnterState(); .EnterState();
e = StateMachine.WaitRunDevsRunOps(); e = StateMachine.WaitRunDevsRunOps();
@@ -272,40 +272,46 @@ namespace TBF.BenchControl.Sequences
{ {
Bridge.OnActivity(this, "Enter the protocol data"); Bridge.OnActivity(this, "Enter the protocol data");
if (!State.LastEvents.Contains(Event.ModelessFormClosed)) if (dataEntryCmpnt is IHasCycleBeginForm)
{ {
/// Wait until modeless dialg is closed if (!State.LastEvents.Contains(Event.ModelessFormClosed))
State.Create("MainSeq : Check whether the entry form is closed") {
.AddOperation(checkUiOp) /// Wait until modeless dialg is closed
.EnterState(); State.Create("MainSeq : Check whether the entry form is closed")
do .AddOperation(checkUiOp)
{ .EnterState();
e = StateMachine.WaitRunDevsRunOps(); do
if (e.Contains(Event.UiCmdStop)) goto stop; {
} e = StateMachine.WaitRunDevsRunOps();
while (!e.Contains(Event.ModelessFormClosed)); if (e.Contains(Event.UiCmdStop)) goto stop;
} }
while (!e.Contains(Event.ModelessFormClosed));
}
/// A state without any dataEntryCmpnt operation so that Stop() when entering /// A state without any dataEntryCmpnt operation so that Stop() when entering
/// this state and Start() when entering the following state are executed. /// this state and Start() when entering the following state are executed.
State.Create("MainSeq : Nothing") State.Create("MainSeq : Nothing")
.AddOperation(checkUiOp) .AddOperation(checkUiOp)
.RemovePermanentOperation(dataEntryCmpnt as IOperation) .RemovePermanentOperation(dataEntryCmpnt as IOperation)
.EnterState(); .EnterState();
e = StateMachine.WaitRunDevsRunOps(); e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.UiCmdStop)) goto stop; if (e.Contains(Event.UiCmdStop)) goto stop;
}
/// Open the modeless form for the end of the cycle if (dataEntryCmpnt is IHasCycleEndForm)
State.Create("MainSeq : Enter end data") {
.AddOperation((dataEntryCmpnt as GenericDevices.IDataEntry).ShowCycleEndFormOp(WaterMeters)) /// Open the modeless form for the end of the cycle
.AddOperation(checkUiOp) State.Create("MainSeq : Enter end data")
.EnterState(); .AddOperation((dataEntryCmpnt as GenericDevices.IHasCycleEndForm).ShowCycleEndFormOp(WaterMeters))
do .AddOperation(checkUiOp)
{ .EnterState();
e = StateMachine.WaitRunDevsRunOps(); do
if (e.Contains(Event.UiCmdStop)) goto stop; {
} e = StateMachine.WaitRunDevsRunOps();
while (!e.Contains(Event.ModelessFormClosed)); if (e.Contains(Event.UiCmdStop)) goto stop;
}
while (!e.Contains(Event.ModelessFormClosed));
}
if (dataEntryCmpnt is IHasProtocolTitle) if (dataEntryCmpnt is IHasProtocolTitle)
{ {
@@ -178,30 +178,27 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
/// ///
GenericDevices.IDataEntry dataEntryCmpnt = GenericDevices.IDataEntry dataEntryCmpnt =
TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IDataEntry; TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IDataEntry;
if (dataEntryCmpnt != null) if (dataEntryCmpnt is GenericDevices.IHasWMStatesForm)
{ {
IOperation showFormOp = dataEntryCmpnt.ShowWMStatesFormOp(); Bridge.OnActivity(this, "Enter the water meter data");
if (showFormOp != null) State.Create("FixedStartMassCollection : Enter begin-state")
.AddOperation((dataEntryCmpnt as GenericDevices.IHasWMStatesForm).ShowWMStatesFormOp())
.AddOperation(checkUiOp)
.EnterState();
do
{ {
Bridge.OnActivity(this, "Enter the water meter data"); e = StateMachine.WaitRunDevsRunOps();
State.Create("FixedStartMassCollection : Enter begin-state") if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
.AddOperation(showFormOp) }
.AddOperation(checkUiOp) while (!e.Contains(Event.ModelessFormClosed));
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.UiCmdStop)) { retVal = Event.Error; goto stopTest; }
}
while (!e.Contains(Event.ModelessFormClosed));
for (int i = 0; i < Program.WMsCount; i++) for (int i = 0; i < Program.WMsCount; i++)
{ {
BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader = BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader =
sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
registerReader.BeginWMState = dataEntryCmpnt.WMState(i); registerReader.BeginWMState = dataEntryCmpnt.WMState(i);
registerReader.EndWMState = dataEntryCmpnt.WMState(i); registerReader.EndWMState = dataEntryCmpnt.WMState(i);
} tstRslt.Meters[i].VolumeStart = dataEntryCmpnt.WMState(i) / registerReader.PulsesPerLtr; /// liter
} }
} }
@@ -241,7 +238,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
State.Create("FixedStartMassCollection : Starting the test") State.Create("FixedStartMassCollection : Starting the test")
.AddOperation(checkUiOp) .AddOperation(checkUiOp)
.AddOperations(measureOperations) .AddOperations(measureOperations)
.AddOperation(cBrd.StartMeasurementOp(outPath.FlowMeter, totalPulses, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro, (float)test.TolerRed)) .AddOperation(cBrd.StartMeasurementOp(outPath.FlowMeter, 2 * totalPulses, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro, (float)test.TolerRed))
.EnterState(); .EnterState();
do do
{ {
@@ -275,20 +272,20 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
ResetAveragedData(); ResetAveragedData();
/// Measurement loop - begin /// Measurement loop - begin
while (true) do
{ {
//-------------------------------- //--------------------------------
switch (ReadRegistersTempPressAmbient(measureOperations, true)) switch (ReadRegistersTempPressAmbient(measureOperations, true))
{ {
case Event.Error: { retVal = Event.Error; goto stopTest; } case Event.Error: { retVal = Event.Error; goto stopTest; }
case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
case Event.MeasurementCompleted: goto test_completed; case Event.MeasurementCompleted: goto test_completed;
} }
if (firstTime) if (firstTime)
{ {
firstTime = false; /// Do the following only once firstTime = false; /// Do the following only once
tstRslt.TempInStart = tempIn.Val; tstRslt.TempInStart = tempIn.Val;
tstRslt.TempOutStart = tempOut.Val; tstRslt.TempOutStart = tempOut.Val;
tstRslt.TempDivStart = tempDiv.Val; tstRslt.TempDivStart = tempDiv.Val;
tstRslt.PressInStart = pressIn.Val; tstRslt.PressInStart = pressIn.Val;
@@ -302,7 +299,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
tstRslt.PressOutEnd = pressOut.Val; tstRslt.PressOutEnd = pressOut.Val;
tstRslt.MassEndRaw = mass.Val; tstRslt.MassEndRaw = mass.Val;
AccumulateAveragedData(); AccumulateAveragedData();
refFreq.Val = cBrd.ReferenceFreq; refFreq.Val = cBrd.ReferenceFreq;
refFlow.Val = cBrd.ReferenceFlow; refFlow.Val = cBrd.ReferenceFlow;
@@ -310,25 +307,26 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
tstRslt.AmbientPressAve = airPressure.Val; tstRslt.AmbientPressAve = airPressure.Val;
tstRslt.AmbientHumiAve = airHumidity.Val; tstRslt.AmbientHumiAve = airHumidity.Val;
string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq, string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq,
cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow); cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow);
for (int i = 0; i < Program.WMsCount; i++) for (int i = 0; i < Program.WMsCount; i++)
{ {
logstr += string.Format(" M{0}=({1},{2})", i + 1, WMRefPulses[i], WMPulses[i]); logstr += string.Format(" M{0}=({1},{2})", i + 1, WMRefPulses[i], WMPulses[i]);
} }
log.Info(logstr); log.Info(logstr);
float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime); float progress = Formulas.TestProgress(cBrd.EtPulses(0), totalPulses, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, cBrd.TTime, progress)); Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, cBrd.TTime, progress));
} }
while (cBrd.EtPulses(0) < totalPulses);
/// Measurement loop - end /// Measurement loop - end
test_completed: test_completed:
State.Create("FixedStartMassCollection : Closing the start/stop valve at the end of the fixed start test") State.Create("FixedStartMassCollection : Closing the start/stop valve at the end of the fixed start test")
.AddOperation(checkUiOp) .AddOperation(checkUiOp)
.AddOperation(StateMachine.ControlBoard.SetValvesOp(outPath.StartValve, null)) .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.StartValve))
.AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp())
.EnterState(); .EnterState();
do do
@@ -339,6 +337,18 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
while (!e.Contains(Event.ValvesSet)); while (!e.Contains(Event.ValvesSet));
State.Create("FixedStartMassCollection : Stopping diverter, gate, etc.")
.AddOperation(checkUiOp)
.AddOperation(cBrd.StopPreviousOp())
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.PreviousStopped));
//------------------------------------------------ //------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight); Bridge.OnActivity(this, Strings.Measuring_the_weight);
//------------------------------------------------ //------------------------------------------------
@@ -370,30 +380,27 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
/// ///
/// Enter watermeter end states here /// Enter watermeter end states here
/// ///
if (dataEntryCmpnt != null) if (dataEntryCmpnt is GenericDevices.IHasWMStatesForm)
{ {
IOperation showFormOp = dataEntryCmpnt.ShowWMStatesFormOp(); Bridge.OnActivity(this, "Enter the water meter data");
if (showFormOp != null) State.Create("FixedStartMassCollection : Enter end-state")
.AddOperation((dataEntryCmpnt as GenericDevices.IHasWMStatesForm).ShowWMStatesFormOp())
.AddOperation(checkUiOp)
.EnterState();
do
{ {
Bridge.OnActivity(this, "Enter the water meter data"); e = StateMachine.WaitRunDevsRunOps();
State.Create("FixedStartMassCollection : Enter end-state") if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
.AddOperation(showFormOp) }
.AddOperation(checkUiOp) while (!e.Contains(Event.ModelessFormClosed));
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.UiCmdStop)) { retVal = Event.Error; goto stopTest; }
}
while (!e.Contains(Event.ModelessFormClosed));
for (int i = 0; i < Program.WMsCount; i++) for (int i = 0; i < Program.WMsCount; i++)
{ {
BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader = BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader =
sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader;
registerReader.EndWMState = dataEntryCmpnt.WMState(i); registerReader.EndWMState = dataEntryCmpnt.WMState(i);
} tstRslt.Meters[i].VolumeEnd = dataEntryCmpnt.WMState(i) / registerReader.PulsesPerLtr; /// liter
} }
} }
@@ -443,29 +450,23 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
tstRslt.TimeDivEnd5 = 0; tstRslt.TimeDivEnd5 = 0;
for (int i = 0; i < Program.WMsCount; i++) for (int i = 0; i < Program.WMsCount; i++)
{ {
if (sensPath.RegisterReaders[i] != null) tstRslt.Meters[i].SerialNr = "wm" + (i + 1).ToString();
tstRslt.Meters[i].VolumeMeter = tstRslt.Meters[i].VolumeEnd - tstRslt.Meters[i].VolumeStart;
tstRslt.Meters[i].VolumeRef = tstRslt.VolumeCTV; /// liter
tstRslt.Meters[i].PulsesMeter = 0;
tstRslt.Meters[i].PulsesMaster = tstRslt.PulsesMaster;
tstRslt.Meters[i].Time = cBrd.TTime;
if (WMPulses[i] > 0 && tstRslt.Meters[i].VolumeRef > 0)
{ {
tstRslt.Meters[i].SerialNr = "wm" + (i + 1).ToString(); tstRslt.Meters[i].VolumeErrorPct =
tstRslt.Meters[i].VolumeStart = 0; /// liter 100 * (tstRslt.Meters[i].VolumeMeter - tstRslt.Meters[i].VolumeRef) / tstRslt.Meters[i].VolumeRef;
tstRslt.Meters[i].VolumeEnd = 0; /// liter /// %
if (sensPath.RegisterReaders[i].PulsesPerLtr <= float.Epsilon) tstRslt.Meters[i].VolumeMeter = 0;
else tstRslt.Meters[i].VolumeMeter = Convert.ToSingle(WMPulses[i]) / sensPath.RegisterReaders[i].PulsesPerLtr;
tstRslt.Meters[i].VolumeRef = tstRslt.ConstMaster * WMRefPulses[i]; /// liter
tstRslt.Meters[i].PulsesMeter = WMPulses[i];
tstRslt.Meters[i].PulsesMaster = WMRefPulses[i];
tstRslt.Meters[i].Time = cBrd.TTime;
if (WMPulses[i] > 0 && tstRslt.Meters[i].VolumeRef > 0)
{
tstRslt.Meters[i].VolumeErrorPct =
100 * (tstRslt.Meters[i].VolumeMeter - tstRslt.Meters[i].VolumeRef) / tstRslt.Meters[i].VolumeRef;
/// %
}
else
{
tstRslt.Meters[i].VolumeErrorPct = -100;
}
tstRslt.Meters[i].Passed = (tstRslt.ErrLimLo <= tstRslt.Meters[i].VolumeErrorPct) && (tstRslt.Meters[i].VolumeErrorPct <= tstRslt.ErrLimHi);
} }
else
{
tstRslt.Meters[i].VolumeErrorPct = -100;
}
tstRslt.Meters[i].Passed = (tstRslt.ErrLimLo <= tstRslt.Meters[i].VolumeErrorPct) && (tstRslt.Meters[i].VolumeErrorPct <= tstRslt.ErrLimHi);
} }
/// Add data - end /// Add data - end
+119
View File
@@ -0,0 +1,119 @@
namespace TBF.Boxes
{
public class DoubleBox
{
/// Box value
private double val;
public double Val
{
get { return (valid ? val : 0); }
set { val = value; valid = true; }
}
/// Box name
string name;
public string Name
{
get { return name; }
set { name = value; }
}
/// Validity flag: true = the box value is valid
private bool valid = false;
public bool Valid
{
get { return valid; }
}
/// <summary> Parameterless constructor </summary>
public DoubleBox()
{
}
/// <summary> Constructor that initializes the value </summary>
public DoubleBox(double val)
{
this.Val = val;
}
/// <summary>
/// Clear the box value and the valid flag
/// </summary>
public void Clear()
{
val = 0;
valid = false;
}
///
/// Specifies a conversion to a string.
/// In the most complex case the conversion is:
/// string.Format(FormatEx, val.ToString(Format))
/// If the value is invalid, the conversion result is 'FormatInvalid'.
///
public string Format = null;
public string FormatEx = "{0}";
public string FormatInvalid = "---";
public double Factor = 1.0;
public double LimitLo = double.MinValue;
public double LimitHi = double.MaxValue;
/// <summary>
/// Converts the box value to a string representation
/// </summary>
public override string ToString()
{
if (!valid)
{
return FormatInvalid;
}
else if (Format == null)
{
return string.Format(FormatEx, Val * Factor);
}
else
{
return string.Format(FormatEx, (Val * Factor).ToString(Format));
}
}
/// <summary>
/// Validate the string representation of the box value
/// </summary>
/// <param name="strVal">String representation of the parameter</param>
/// <returns>true = string is OK, false = string is wrong (see 'message')</returns>
public bool ValidateParam(string strVal)
{
float dummy;
return Utils.TryParseSFloat(strVal, out dummy) &&
((dummy / Factor) >= LimitLo) &&
((dummy / Factor) <= LimitHi);
}
/// <summary>
/// Update the parameter from a string
/// </summary>
/// <param name="strVal">String representation of the box value</param>
public void UpdateParam(string strVal)
{
try
{
Val = (double)Utils.ParseSFloat(strVal) / Factor;
}
catch { };
}
public DoubleBox Clone()
{
DoubleBox newDoubleBox = new DoubleBox();
newDoubleBox.name = name;
newDoubleBox.val = val;
newDoubleBox.valid = valid;
newDoubleBox.Format = Format;
newDoubleBox.FormatInvalid = FormatInvalid;
newDoubleBox.FormatEx = FormatEx;
newDoubleBox.Factor = Factor;
return newDoubleBox;
}
}
}
+2 -1
View File
@@ -14,7 +14,8 @@ namespace TBF.Mappings
Map(x => x.Qto); Map(x => x.Qto);
Map(x => x.RegulValve); Map(x => x.RegulValve);
Map(x => x.FlowMeter); Map(x => x.FlowMeter);
Map(x => x.Diverter); Map(x => x.StartValve);
Map(x => x.Diverter);
Map(x => x.TempDiv); Map(x => x.TempDiv);
Map(x => x.Balance); Map(x => x.Balance);
Map(x => x.EmptyTankValve); Map(x => x.EmptyTankValve);
+4
View File
@@ -323,7 +323,10 @@
<Compile Include="BenchControl\GenericDevices\ICameraRoi.cs" /> <Compile Include="BenchControl\GenericDevices\ICameraRoi.cs" />
<Compile Include="BenchControl\GenericDevices\IDataEntry.cs" /> <Compile Include="BenchControl\GenericDevices\IDataEntry.cs" />
<Compile Include="BenchControl\GenericDevices\IHasCompleted.cs" /> <Compile Include="BenchControl\GenericDevices\IHasCompleted.cs" />
<Compile Include="BenchControl\GenericDevices\IHasCycleBeginForm.cs" />
<Compile Include="BenchControl\GenericDevices\IHasCycleEndForm.cs" />
<Compile Include="BenchControl\GenericDevices\IHasProtocolTitle.cs" /> <Compile Include="BenchControl\GenericDevices\IHasProtocolTitle.cs" />
<Compile Include="BenchControl\GenericDevices\IHasWMStatesForm.cs" />
<Compile Include="BenchControl\GenericDevices\IPumpFM.cs" /> <Compile Include="BenchControl\GenericDevices\IPumpFM.cs" />
<Compile Include="BenchControl\GenericDevices\IResultsPrinter.cs" /> <Compile Include="BenchControl\GenericDevices\IResultsPrinter.cs" />
<Compile Include="BenchControl\GenericDevices\IPump.cs" /> <Compile Include="BenchControl\GenericDevices\IPump.cs" />
@@ -492,6 +495,7 @@
<DependentUpon>WaterMeterCfgCtrl.cs</DependentUpon> <DependentUpon>WaterMeterCfgCtrl.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="BenchControl\WaterMeter\WaterMeterFactory.cs" /> <Compile Include="BenchControl\WaterMeter\WaterMeterFactory.cs" />
<Compile Include="Boxes\DoubleBox.cs" />
<Compile Include="Boxes\FloatBox.cs" /> <Compile Include="Boxes\FloatBox.cs" />
<Compile Include="Boxes\IBox.cs" /> <Compile Include="Boxes\IBox.cs" />
<Compile Include="Boxes\IntBox.cs" /> <Compile Include="Boxes\IntBox.cs" />