StandingStartMassCollectionSeq : Start mass measurement and start state data entry done at the same time, ver. 3.1.1654
This commit is contained in:
+103
-97
@@ -496,126 +496,108 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
|
||||
if (heatMetersPath == null) LogProcessDataHeader(processDataLogger, "Start mass");
|
||||
else LogProcessDataHeaderHeatMeters(processDataLogger, "Start mass");
|
||||
|
||||
State.Create(string.Format("{0}({1}) : Measure the start mass", test.Method, test.Name))
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperations(readTempPressOps)
|
||||
.AddOperation(testInProgress)
|
||||
.AddOperation(scale.ReadStableMassOp(ref StartMass, test.TimeFlow2Mass, test.MassMethod, test.MassRepeats, test.MassSpread))
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
if (e.Contains(Event.ScaleTimeout))
|
||||
{
|
||||
Bridge.OnError(this, Strings.Mass_measurement_timeout);
|
||||
retVal = Event.RecoverableError;
|
||||
goto stopTest;
|
||||
}
|
||||
}
|
||||
while (!e.Contains(Event.ScaleDone) && !e.Contains(Event.Next));
|
||||
///
|
||||
tMass1 = StateMachine.Time;
|
||||
|
||||
|
||||
///
|
||||
/// Enter watermeter begin states here
|
||||
/// Enter water meter begin states and read the start mass at the same time
|
||||
///
|
||||
GenericDevices.IHasWMStatesForm dataEntryCmpnt = TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IHasWMStatesForm;
|
||||
IOperation readStartMassOp = scale.ReadStableMassOp(ref StartMass, test.TimeFlow2Mass, test.MassMethod, test.MassRepeats, test.MassSpread);
|
||||
|
||||
if (dataEntryCmpnt != null)
|
||||
{
|
||||
string fileName = string.Format("{0}-start.bmp", test.Name);
|
||||
if (dataEntryCmpnt != null)
|
||||
{
|
||||
string fileName = string.Format("{0}-start.bmp", test.Name);
|
||||
|
||||
if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera)
|
||||
{
|
||||
string[] startImages = new string[sensPath.RegisterReaders.Length];
|
||||
if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera)
|
||||
{
|
||||
string[] startImages = new string[sensPath.RegisterReaders.Length];
|
||||
|
||||
State state2 = State.Create(string.Format("{0}({1}) : Grab images", test.Method, test.Name))
|
||||
.AddOperation(checkUiOp)
|
||||
State state2 = State.Create(string.Format("{0}({1}) : Grab images", test.Method, test.Name))
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperations(readTempPressOps)
|
||||
.AddOperation(readStartMassOp)
|
||||
.AddOperation(testInProgress);
|
||||
|
||||
for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
|
||||
{
|
||||
GenericDevices.IRegReaderStillCamera roi = sensPath.RegisterReaders[i] as GenericDevices.IRegReaderStillCamera;
|
||||
if (roi != null)
|
||||
{
|
||||
string directory = Path.Combine(Program.TempImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString());
|
||||
Directory.CreateDirectory(directory);
|
||||
startImages[i] = Path.Combine(directory, fileName);
|
||||
state2.AddOperation(roi.GrabImageOp(startImages[i]));
|
||||
}
|
||||
}
|
||||
state2.EnterState();
|
||||
do {
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
|
||||
{
|
||||
GenericDevices.IRegReaderStillCamera roi = sensPath.RegisterReaders[i] as GenericDevices.IRegReaderStillCamera;
|
||||
if (roi != null)
|
||||
{
|
||||
string directory = Path.Combine(Program.TempImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString());
|
||||
Directory.CreateDirectory(directory);
|
||||
startImages[i] = Path.Combine(directory, fileName);
|
||||
state2.AddOperation(roi.GrabImageOp(startImages[i]));
|
||||
}
|
||||
}
|
||||
state2.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
|
||||
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
|
||||
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test));
|
||||
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; break; }
|
||||
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; break; }
|
||||
}
|
||||
while (e.Contains(Event.CameraBusy));
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; break; }
|
||||
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; break; }
|
||||
}
|
||||
while (e.Contains(Event.CameraBusy));
|
||||
|
||||
(dataEntryCmpnt as GenericDevices.IDataEntryForCamera).StartImages = startImages;
|
||||
}
|
||||
(dataEntryCmpnt as GenericDevices.IDataEntryForCamera).StartImages = startImages;
|
||||
}
|
||||
|
||||
Bridge.OnActivity(this, Strings.Enter_water_meter_data);
|
||||
State.Create(string.Format("{0}({1}) : Enter start states of water meters", test.Method, test.Name))
|
||||
Bridge.OnActivity(this, Strings.Enter_water_meter_data);
|
||||
State.Create(string.Format("{0}({1}) : Enter start states of water meters", test.Method, test.Name))
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperations(readTempPressOps)
|
||||
.AddOperation(readStartMassOp)
|
||||
.AddOperation(testInProgress)
|
||||
.AddOperation((dataEntryCmpnt as GenericDevices.IHasWMStatesForm).ShowTestStartFormOp(sensPath.RegisterReaders))
|
||||
.EnterState();
|
||||
do {
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.ModelessFormClosed));
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.ModelessFormClosed));
|
||||
|
||||
if (heatMetersTestParams != null)
|
||||
{
|
||||
for (int i = 0; i < Config.Data.HeatMetersCount; i++)
|
||||
{
|
||||
if (heatMetersTestParams != null)
|
||||
{
|
||||
for (int i = 0; i < Config.Data.HeatMetersCount; i++)
|
||||
{
|
||||
Rig.RegisterReaders.StandingStartStop.RegisterReader volumeRegisterReader =
|
||||
sensPath.RegisterReaders[2 * i] as Rig.RegisterReaders.StandingStartStop.RegisterReader;
|
||||
|
||||
Rig.RegisterReaders.StandingStartStop.RegisterReader energyRegisterReader =
|
||||
sensPath.RegisterReaders[2 * i + 1] as Rig.RegisterReaders.StandingStartStop.RegisterReader;
|
||||
|
||||
if (volumeRegisterReader != null) volumeRegisterReader.BeginWMState = dataEntryCmpnt.WMStartState(i);
|
||||
if (energyRegisterReader != null && dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm)
|
||||
{
|
||||
energyRegisterReader.BeginWMState = (float)(dataEntryCmpnt as GenericDevices.IHasHeatMtrStatesForm).EnergyStartState(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < Config.Data.WMsCount; i++)
|
||||
{
|
||||
GenericDevices.IRegReader rr = sensPath.RegisterReaders[i];
|
||||
|
||||
if (rr is Rig.RegisterReaders.StandingStartStop.RegisterReader)
|
||||
(rr as Rig.RegisterReaders.StandingStartStop.RegisterReader).BeginWMState = dataEntryCmpnt.WMStartState(i);
|
||||
|
||||
if (rr is Rig.Network.Camera.RoiForFixedStart.Roi)
|
||||
(rr as Rig.Network.Camera.RoiForFixedStart.Roi).BeginWMState = dataEntryCmpnt.WMStartState(i);
|
||||
if (volumeRegisterReader != null) volumeRegisterReader.BeginWMState = dataEntryCmpnt.WMStartState(i);
|
||||
if (energyRegisterReader != null && dataEntryCmpnt is GenericDevices.IHasHeatMtrStatesForm)
|
||||
{
|
||||
energyRegisterReader.BeginWMState = (float)(dataEntryCmpnt as GenericDevices.IHasHeatMtrStatesForm).EnergyStartState(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < Config.Data.WMsCount; i++)
|
||||
{
|
||||
GenericDevices.IRegReader rr = sensPath.RegisterReaders[i];
|
||||
|
||||
if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera && (dataEntryCmpnt as GenericDevices.IDataEntryForCamera).SaveImages)
|
||||
{
|
||||
/// SaveImages==true ... copy images to the directory that will be archived at the end of the cycle
|
||||
for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
|
||||
{
|
||||
GenericDevices.IRegReaderStillCamera roi = sensPath.RegisterReaders[i] as GenericDevices.IRegReaderStillCamera;
|
||||
if (roi != null)
|
||||
{
|
||||
string srcDir = Path.Combine(Program.TempImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString());
|
||||
string destDir = Path.Combine(Program.ImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString());
|
||||
if (rr is Rig.RegisterReaders.StandingStartStop.RegisterReader)
|
||||
(rr as Rig.RegisterReaders.StandingStartStop.RegisterReader).BeginWMState = dataEntryCmpnt.WMStartState(i);
|
||||
|
||||
if (rr is Rig.Network.Camera.RoiForFixedStart.Roi)
|
||||
(rr as Rig.Network.Camera.RoiForFixedStart.Roi).BeginWMState = dataEntryCmpnt.WMStartState(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (dataEntryCmpnt is GenericDevices.IDataEntryForCamera && (dataEntryCmpnt as GenericDevices.IDataEntryForCamera).SaveImages)
|
||||
{
|
||||
/// SaveImages==true ... copy images to the directory that will be archived at the end of the cycle
|
||||
for (int i = 0; i < sensPath.RegisterReaders.Length; i++)
|
||||
{
|
||||
GenericDevices.IRegReaderStillCamera roi = sensPath.RegisterReaders[i] as GenericDevices.IRegReaderStillCamera;
|
||||
if (roi != null)
|
||||
{
|
||||
string srcDir = Path.Combine(Program.TempImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString());
|
||||
string destDir = Path.Combine(Program.ImagesDir, BatchRslts.Batch.BatchNr.ToString(), (i + 1).ToString());
|
||||
try
|
||||
{
|
||||
if (File.Exists(Path.Combine(srcDir, fileName)))
|
||||
@@ -629,9 +611,33 @@ namespace TBF.Rig.TestMethods.StandingStartMassCollection
|
||||
log.ErrorFormat("Failed to copy image {0} to {1}: {2}", fileName, destDir, exc.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
State.Create(string.Format("{0}({1}) : Measure the start mass", test.Method, test.Name))
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperations(readTempPressOps)
|
||||
.AddOperation(testInProgress)
|
||||
.AddOperation(readStartMassOp)
|
||||
.EnterState();
|
||||
do {
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
|
||||
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
if (e.Contains(Event.ScaleTimeout))
|
||||
{
|
||||
Bridge.OnError(this, Strings.Mass_measurement_timeout);
|
||||
retVal = Event.RecoverableError;
|
||||
goto stopTest;
|
||||
}
|
||||
}
|
||||
while (!e.Contains(Event.ScaleDone) && !e.Contains(Event.Next));
|
||||
}
|
||||
///
|
||||
tMass1 = StateMachine.Time;
|
||||
|
||||
|
||||
if (heatMetersPath == null)
|
||||
|
||||
Reference in New Issue
Block a user