From 9868c41640099f7dae82d3cfb93d411ef436a5b8 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Wed, 24 Sep 2014 19:58:05 +0200 Subject: [PATCH] Zmeny urobene v ST pri testovani kamery --- .../BenchControl/Cameras/IdcCamera/Idc100.cs | 5 +- .../BenchControl/Elde/ControlBoardDev.cs | 10 +- .../CameraRoiDetection/RoiDetectionSeq.cs | 142 +++++------------- .../FlyingStartCollectionMethodSeq.cs | 5 +- .../Resources/Strings.Designer.cs | 9 ++ TestBenchFramework/Resources/Strings.resx | 3 + 6 files changed, 65 insertions(+), 109 deletions(-) diff --git a/TestBenchFramework/BenchControl/Cameras/IdcCamera/Idc100.cs b/TestBenchFramework/BenchControl/Cameras/IdcCamera/Idc100.cs index 9d16555f5..96ef29f18 100644 --- a/TestBenchFramework/BenchControl/Cameras/IdcCamera/Idc100.cs +++ b/TestBenchFramework/BenchControl/Cameras/IdcCamera/Idc100.cs @@ -74,7 +74,10 @@ namespace TBF.BenchControl.Cameras.IdcCamera { get { - if (measurements.Count < 1 || wm_nrBegin >= measurements.Count) return 0; + if (measurements.Count < 1 || wm_nrBegin >= measurements.Count) + { + return 0; + } return measurements[measurements.Count - 1].angle - measurements[wm_nrBegin].angle; } } diff --git a/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs b/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs index 173ba2625..7f56c1832 100644 --- a/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs +++ b/TestBenchFramework/BenchControl/Elde/ControlBoardDev.cs @@ -126,7 +126,7 @@ namespace TBF.BenchControl.Elde #if FUZHOU300 if ((FMFreq == null) || (FMFreq.Length != 6)) { - if (index == 0) FMFreq = new float[6] { power, 0, 0, 0, 0, 0 }; + if (index == 0) FMFreq = new float[6] { power, 0, 0, 0, 0, 0 }; else if (index == 1) FMFreq = new float[6] { 0, power, 0, 0, 0, 0 }; else if (index == 2) FMFreq = new float[6] { 0, 0, power, 0, 0, 0 }; else if (index == 3) FMFreq = new float[6] { 0, 0, 0, power, 0, 0 }; @@ -139,9 +139,9 @@ namespace TBF.BenchControl.Elde FMFreq[index] = power; } #else - if (index == 0) FMFreq = new float[2] { power, 0 }; + if (index == 0) FMFreq = new float[2] { power, 0 }; else if (index == 1) FMFreq = new float[2] { 0, power }; - else FMFreq = new float[2] { 0, 0 }; + else FMFreq = new float[2] { 0, 0 }; #endif } @@ -161,7 +161,11 @@ namespace TBF.BenchControl.Elde { if (cfg == null) throw new ArgumentNullException("cfg"); this.controlBoardCfg = cfg; +#if FUZHOU300 FMFreq = new float[6] { 0, 0, 0, 0, 0, 0 }; /// Nr. of pumps: Fuzhou150=2, Fuzhou300=6 +#else + FMFreq = new float[2] { 0, 0 }; /// Nr. of pumps: Fuzhou150=2, Fuzhou300=6 +#endif emergencyStop = false; previousEmergencyStop = false; } diff --git a/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs index e15967ed1..dc9a3b324 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs @@ -17,19 +17,9 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; IList e; /// Events from currently running operations + Event retVal = Event.Done; - //-------------------------------- - State.Create("RoiDetection : Starting the detection sequence") - .AddOperation(checkUiOp) - .AddOperation(cBrd.StopPreviousOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.UiCmdStop)) goto stop; - } - while (!e.Contains(Event.PreviousStopped)); - + processDataLoggingOp = null; //==================================== /// Start the test, initialize test results @@ -38,13 +28,14 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection tstRslt.DoNotEvaluate = true; tstRslt.DoNotPublish = true; + //==================================== // Transition or SetRoute - Start //==================================== switch (Transition(transitionStart, TransitionContext.TestStart)) { - case Event.Error: goto error; - case Event.UiCmdStop: goto stop; + case Event.Error: { retVal = Event.Error; goto stopTest; } + case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } } //------------------------------------------------ @@ -58,7 +49,7 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection do { e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.UiCmdStop)) goto stop; + if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } } while (!e.Contains(Event.ValvesSet)); @@ -70,8 +61,10 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection do { e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.UiCmdStop)) goto stop; - if (e.Contains(Event.RegulValveTimeOut)) goto error; + + if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; } + if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } + if (e.Contains(Event.RegulValveTimeOut)) { retVal = Event.Error; goto stopTest; } if (e.Contains(Event.Next)) goto flow_set; } while (!e.Contains(Event.FlowReached)); @@ -98,106 +91,51 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection do { e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) goto error; - if (e.Contains(Event.UiCmdStop)) goto stop; + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } } while (e.Contains(Event.CameraBusy)); - if (e.Contains(Event.CameraOpFailed)) goto error; /// TODO: resolve in some other way + if (e.Contains(Event.CameraOpFailed)) + { + retVal = Event.Error; + Bridge.OnActivity(this, Strings.Detection_failed); + goto stopTest; + } //------------------------------------------------ Bridge.OnActivity(this, Strings.Detection_completed); //------------------------------------------------ - State.Create("RoiDetection : Stopping the pump") - .AddOperation(checkUiOp) - .AddOperation((inPath != null && inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOffOp() : null) - .AddOperation(cBrd.SetValvesOp(null, inPath.Pump)) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.UiCmdStop)) goto stop; - } - while (!e.Contains(Event.ValvesSet)); - - //-------------------------------- - State.Create("RoiDetection : Stopping diverter, gate, etc.") - .AddOperation(checkUiOp) - .AddOperation(cBrd.StopPreviousOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.UiCmdStop)) goto stop; - } - while (!e.Contains(Event.PreviousStopped)); + stopTest: ///----------------------/// /// Quit this sequence /// ///----------------------/// - /// Stop the pump - State.Create("RoiDetection : Detection of ROI-s completed -> Stopping the pump") - .AddOperation(checkUiOp) - .AddOperation(cBrd.SetValvesOp(null, inPath.Pump)) - .AddOperation((inPath != null && inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOffOp() : null) - .EnterState(); - do { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) goto error; - } - while (!e.Contains(Event.ValvesSet) || ((inPath.Pump is GenericDevices.IPumpFM) && !e.Contains(Event.TurnPumpOnOffDone))); - - /// Transition or SetRoute - End - switch (Transition(transitionStop, TransitionContext.TestEnd)) + State.Create("FlyingStartCollectionMethod : Stopping diverter, gate, etc.") + .AddOperation(checkUiOp) + .AddOperation(cBrd.StopPreviousOp()) + .EnterState(); + do { - case Event.Error: goto error; - case Event.UiCmdStop: goto stop; + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.PreviousStopped)); + + /// Transition sequence at the end of test + /// Prevent overwriting 'retVal' in case it was set to non-default value earlier + switch (Transition(transitionStop, TransitionContext.TestEnd)) + { + case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } + case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } } - /// Create the return value: a list with one event Event.Done - IList retval = new List(); - retval.Add(Event.Done); - return retval; - - //==================================== - stop: - cBrd.SetFMFreq(0, 0); /// Stop FM controlled pumps - State.Create("RoiDetection : User selected STOP -> Closing the valves") - .AddOperation(checkUiOp) - .AddOperation((inPath != null && inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOffOp() : null) - .AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose)) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) goto error; - } - while (!e.Contains(Event.ValvesSet)); - - IList retval2 = new List(); - retval2.Add(Event.UiCmdStop); - return retval2; - - //==================================== - error: - cBrd.SetFMFreq(0, 0); /// Stop FM controlled pumps - State.Create("RoiDetection : ERROR -> Closing the valves") - .AddOperation(checkUiOp) - .AddOperation((inPath != null && inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOffOp() : null) - .AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose)) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) goto error; - } - while (!e.Contains(Event.ValvesSet)); - - IList retval3 = new List(); - retval3.Add(Event.Error); - return retval3; - } + /// Create a list with one item 'retVal' (default is Event.Done) and return it + IList retList = new List(); + retList.Add(retVal); + return retList; + } } } diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs index 01607b799..429e19c8e 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs @@ -40,7 +40,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod /// float timeSec = 3600.0f * timeHr; /// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow)); int totalPulses = (int)(test.Volume / ltrPerRefPulse); - + processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this); int repetitionNr = 1; /// First test: repetitionNr=1 @@ -134,13 +134,12 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; } if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; } - if (e.Contains(Event.RegulValveTimeOut)) { retVal = Event.Error; goto stopTest; } + if (e.Contains(Event.RegulValveTimeOut)) { log.Warn("FlowSetTimeout"); retVal = Event.Error; goto stopTest; } if (e.Contains(Event.Next)) goto flow_set; } while (!e.Contains(Event.FlowReached)); flow_set: - int time = StateMachine.Time; float currentFlow = refFlow.Val; diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs index b64392aa0..ba0f7d357 100644 --- a/TestBenchFramework/Resources/Strings.Designer.cs +++ b/TestBenchFramework/Resources/Strings.Designer.cs @@ -429,6 +429,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Detection failed. + /// + internal static string Detection_failed { + get { + return ResourceManager.GetString("Detection_failed", resourceCulture); + } + } + /// /// Looks up a localized string similar to Detection threshold [%]. /// diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx index c66239ca3..ba11783fc 100644 --- a/TestBenchFramework/Resources/Strings.resx +++ b/TestBenchFramework/Resources/Strings.resx @@ -844,4 +844,7 @@ State: + + Detection failed + \ No newline at end of file