From 7ed21ff08cbcf380cc8b656e3266c0cf59bf1a04 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Tue, 22 Aug 2017 15:11:21 +0200 Subject: [PATCH] SwitchDiverterOp, Diverter sequence conditions, ver. 2.16.647 --- .../BenchControl/Elde/Diverter/Diverter.cs | 33 +++++++++++++-- .../Elde/Diverter/SwitchDiverterOp.cs | 42 +++++++++++++++++++ .../iPerlCommunicationForm.cs | 24 +++++------ TestBenchFramework/Properties/AssemblyInfo.cs | 4 +- TestBenchFramework/TBF.csproj | 1 + 5 files changed, 87 insertions(+), 17 deletions(-) create mode 100644 TestBenchFramework/BenchControl/Elde/Diverter/SwitchDiverterOp.cs diff --git a/TestBenchFramework/BenchControl/Elde/Diverter/Diverter.cs b/TestBenchFramework/BenchControl/Elde/Diverter/Diverter.cs index 501b3124d..101c1eee6 100644 --- a/TestBenchFramework/BenchControl/Elde/Diverter/Diverter.cs +++ b/TestBenchFramework/BenchControl/Elde/Diverter/Diverter.cs @@ -6,10 +6,11 @@ using System.Collections.Generic; using log4net; using Dirichlet.Numerics; using TBF.BenchControl.Generic; +using TBF.Resources; namespace TBF.BenchControl.Elde.Diverter { - public class Diverter : ComponentBase, IDevice, GenericDevices.IDiverter + public class Diverter : ComponentBase, IDevice, GenericDevices.IDiverter, GenericDevices.ISequenceCondition { private static readonly ILog log = LogManager.GetLogger(typeof(Diverter)); public override string ToString() { return string.Format("Diverter({0})", Cfg.ToString(1)); } @@ -28,15 +29,19 @@ namespace TBF.BenchControl.Elde.Diverter public static int[] DivStartingLevelPct; public static int[] DivStoppingLevelPct; - protected int diverterNr; /// 0-based diverter number + protected int diverterNr; /// 0-based diverter number readonly DiverterCfg diverterCfg; readonly ControlBoardDev controlBoard; - readonly UInt128 mask; /// derived from bitPosition in the constructor + readonly UInt128 mask; /// derived from bitPosition in the constructor public int AdcNr { get { return diverterCfg.AdcNr; } } + readonly IOperation diverterToTankOp; + readonly IOperation diverterToSinkOp; + + public bool State { get { return (controlBoard.Route & mask) != 0; } @@ -98,6 +103,9 @@ namespace TBF.BenchControl.Elde.Diverter Name, controlBoard.RegValveCalib.GetLength(0), diverterCfg.AdcNr); } + diverterToTankOp = new SwitchDiverterOp(controlBoard, true, Name.Contains("1") ? 1 : 3); + diverterToSinkOp = new SwitchDiverterOp(controlBoard, false, Name.Contains("1") ? 1 : 3); + log.Debug(this.ToString()); } @@ -115,6 +123,25 @@ namespace TBF.BenchControl.Elde.Diverter public void StopDevice() { } + /// + /// ISequenceCondition interface implementation + /// + public int ConditionsCount { get { return 2; } } + + /// Returned strings are added to the combo-box + public string ConditionName(int i) + { + if (i == 0) return string.Format("{0} {1}", Name, Strings.Start); + else return string.Format("{0} {1}", Name, Strings.End); + } + + public IOperation ConditionOp(int i) + { + if (i == 0) return diverterToTankOp; + else return diverterToSinkOp; + } + + #region Configuration Change Handling public static void OnCfgChange(object sender, CfgChangeArgs args) diff --git a/TestBenchFramework/BenchControl/Elde/Diverter/SwitchDiverterOp.cs b/TestBenchFramework/BenchControl/Elde/Diverter/SwitchDiverterOp.cs new file mode 100644 index 000000000..1e43c7783 --- /dev/null +++ b/TestBenchFramework/BenchControl/Elde/Diverter/SwitchDiverterOp.cs @@ -0,0 +1,42 @@ +/// +/// Copyright (c) 2017 Sensus Metering Systems +/// +using System; + +namespace TBF.BenchControl.Elde.Diverter +{ + public class SwitchDiverterOp : IOperation + { + ControlBoardDev controlBoard; + bool start; + int flowMtrNr; + + public SwitchDiverterOp(ControlBoardDev controlBoard, bool start, int flowMtrNr) + { + this.controlBoard = controlBoard; + this.start = start; + this.flowMtrNr = flowMtrNr; + } + + public void Start() + { + if (start) + { + controlBoard.DiverterToTank(flowMtrNr); + } + else + { + controlBoard.DiverterToSink(flowMtrNr); + } + } + + public Event Run() + { + return Event.ConditionMet; + } + + public void Stop() + { + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs b/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs index f681ca437..7c778f3b6 100644 --- a/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs +++ b/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs @@ -23,18 +23,18 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication public enum CommErr { None = 0, - CommFailed, - OpenPort, - Read, - Write, - ReadAfterWrite, - CmdActive, - CmdTest, - Verify, - WrongIPerlType, - CalibFactorOoRange, - MissingTest, - RFPowerRecordMissing, + CommFailed, /// 1 + OpenPort, /// 2 + Read, /// 3 + Write, /// 4 + ReadAfterWrite, /// 5 + CmdActive, /// 6 + CmdTest, /// 7 + Verify, /// 8 + WrongIPerlType, /// 9 + CalibFactorOoRange, /// A + MissingTest, /// B + RFPowerRecordMissing, /// C } diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index 680692e7f..2ffb35afd 100644 --- a/TestBenchFramework/Properties/AssemblyInfo.cs +++ b/TestBenchFramework/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.16.646.1")] -[assembly: AssemblyFileVersion("2.16.646.1")] +[assembly: AssemblyVersion("2.16.647.1")] +[assembly: AssemblyFileVersion("2.16.647.1")] diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj index 3fa2a0ce2..e2af394a0 100644 --- a/TestBenchFramework/TBF.csproj +++ b/TestBenchFramework/TBF.csproj @@ -456,6 +456,7 @@ +