From 6e2bf48b431453690db203730830f6fdfe705e60 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Mon, 8 Feb 2016 17:03:07 +0100 Subject: [PATCH] (1) State of the RegulValve checked after ValveMove (#, position, ...), (2) RFID results are saved only when SimultWithPrevious == true. --- .../BenchControl/DB/SensusOracle/Database.cs | 3 +- .../RegulValve/SetRegulValvePositionOp.cs | 85 +++++++++++++------ .../iPerlCommunicationForm.cs | 5 +- .../WaterMeters/iPerl/WaterMeter.cs | 2 +- 4 files changed, 65 insertions(+), 30 deletions(-) diff --git a/TestBenchFramework/BenchControl/DB/SensusOracle/Database.cs b/TestBenchFramework/BenchControl/DB/SensusOracle/Database.cs index 2388a5c7f..9087a59c9 100644 --- a/TestBenchFramework/BenchControl/DB/SensusOracle/Database.cs +++ b/TestBenchFramework/BenchControl/DB/SensusOracle/Database.cs @@ -469,6 +469,7 @@ namespace TBF.BenchControl.DB.SensusOracle public Retv WriteLogsToDisk(Results.Entities.Batch batch) { +#if IPERLST if (logger == null) return Retv.Error; try @@ -723,7 +724,7 @@ namespace TBF.BenchControl.DB.SensusOracle log.ErrorFormat("Results not saved to disk: {0}", exc.Message); return Retv.Error; } - +#endif return Retv.OK; /// OK } diff --git a/TestBenchFramework/BenchControl/Elde/RegulValve/SetRegulValvePositionOp.cs b/TestBenchFramework/BenchControl/Elde/RegulValve/SetRegulValvePositionOp.cs index 274d2409f..f9fd11759 100644 --- a/TestBenchFramework/BenchControl/Elde/RegulValve/SetRegulValvePositionOp.cs +++ b/TestBenchFramework/BenchControl/Elde/RegulValve/SetRegulValvePositionOp.cs @@ -16,6 +16,20 @@ namespace TBF.BenchControl.Elde.RegulValve return string.Format("SetRegulValvePositionOp({0},{1},{2})", regulValve.Name, posLoPct, posHiPct); } + const int CoaxValveNr = 7; /// Coax. valve has number 7 + + /// + /// Internal states of this operation + /// + enum OpState + { + Idle = 0, + MoveToPosition, /// Send commend to move to position + CheckState, /// Check RV state by reading statos word + MovingToPosition, /// Command passed OK, RV is moving to a position + } + OpState opState; + /// Set by the constructor readonly ControlBoardDev controlBoard; readonly RegulValve regulValve; @@ -72,6 +86,7 @@ namespace TBF.BenchControl.Elde.RegulValve positionReached = false; expireTime = StateMachine.Time + timeout; log.InfoFormat("Start(): RV#={0}, reqPosLo={1}%, reqPosHi={2}%", regulValveNr, posLoPct.ToString("F1"), posHiPct.ToString("F1")); + opState = OpState.MoveToPosition; } /// Run this operation @@ -82,7 +97,7 @@ namespace TBF.BenchControl.Elde.RegulValve /// public Event Run() { - if (firstRun) + if (opState == OpState.MoveToPosition) { if (posLoPct > posHiPct || (!regulValve.IsCoax && posLoPct == posHiPct) || posLoPct > 100.0f || posHiPct < 0) @@ -96,41 +111,57 @@ namespace TBF.BenchControl.Elde.RegulValve RegulValveMode.TargetPosition, new float[2] { posLoPct, posHiPct }, regulValve.StableTime); + opState = OpState.CheckState; return Event.None; } - if (positionReached) return Event.PositionReached; + if (positionReached) return Event.PositionReached; - float positionPct = controlBoard.RValvePosition(regulValveNr); - log.WarnFormat("Run(): RV#={0}, actPos={1}%", regulValveNr, positionPct.ToString("F1")); + float positionPct = controlBoard.RValvePosition(regulValveNr); + log.WarnFormat("Run(): RV#={0}, actPos={1}%", regulValveNr, positionPct.ToString("F1")); - if (posLoPct >= posHiPct || posLoPct >= 100.0f || posHiPct <= 0) - { - return Event.OpArgumentError; - } - else if (posLoPct <= positionPct && positionPct <= posHiPct) - { - positionReached = true; - return Event.PositionReached; - } - else if (StateMachine.Time > expireTime) - { - return Event.RegulValveTimeOut; - } - else - { - return Event.None; - } - } + if (opState == OpState.CheckState) + { + if (regulValveNr == CoaxValveNr && ((ulong)controlBoard.StatusP & (ulong)StatusP.CoaxRegValveBusy) == 0) + { + opState = OpState.MoveToPosition; + return Event.None; + } + else if (posLoPct <= positionPct && positionPct <= posHiPct) + { + positionReached = true; + return Event.PositionReached; + } + else if ((regulValveNr < 6) && (controlBoard.RegulValveState(regulValveNr) != RegulValveState.DacValueRegul)) + { + opState = OpState.MoveToPosition; /// Resend move command again in the next run + return Event.None; + } + else + { + opState = OpState.MovingToPosition; + return Event.None; + } + } + else if (StateMachine.Time > expireTime) + { + return Event.RegulValveTimeOut; + } + else if (opState == OpState.MovingToPosition) + { + if (posLoPct <= positionPct && positionPct <= posHiPct) + { + positionReached = true; + return Event.PositionReached; + } + return Event.None; + } + return Event.None; + } /// Stop this operation public void Stop() { - if (!regulValve.IsCoax) - { - controlBoard.ValveMove(regulValveNr, RegulValveMode.Stop, - new float[2] { posLoPct, posHiPct }, regulValve.StableTime); - } } } } diff --git a/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs b/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs index 10f9f4996..f8ca3b45a 100644 --- a/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs +++ b/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs @@ -545,7 +545,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication CommCompletedHandler = null; AllCompletedHandler = null; - UpdateRfidCommResult(tests); /// TODO: Pass the test info in a correct way + if (multiTestParams != null && multiTestParams.Count > 0 && multiTestParams[0].SimultWithPrevious) + { + UpdateRfidCommResult(tests); /// TODO: Pass the test info in a correct way + } TBF.UiBridge.Bridge.OnTestCompleted(this, new TBF.UiBridge.TestCompletedEventArgs(StateMachine.Tests[0].Name, 0)); diff --git a/TestBenchFramework/BenchControl/WaterMeters/iPerl/WaterMeter.cs b/TestBenchFramework/BenchControl/WaterMeters/iPerl/WaterMeter.cs index 006a27760..e8e3720db 100644 --- a/TestBenchFramework/BenchControl/WaterMeters/iPerl/WaterMeter.cs +++ b/TestBenchFramework/BenchControl/WaterMeters/iPerl/WaterMeter.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2015 Sensus Metering Systems +/// Copyright (c) 2015-2016 Sensus Metering Systems /// Author: Milan Hanajík /// using System;