diff --git a/TBF/BenchControl/ControlBoard/IControlBoard.cs b/TBF/BenchControl/ControlBoard/IControlBoard.cs index 2c781c5d2..bd43e5c7b 100644 --- a/TBF/BenchControl/ControlBoard/IControlBoard.cs +++ b/TBF/BenchControl/ControlBoard/IControlBoard.cs @@ -11,14 +11,6 @@ namespace TBF.BenchControl.ControlBoard { void SpecifyInvertedValves(UInt128 valvesToInvert); - /// - /// Display value in a third party component, update UI - /// - /// String parameter - /// Integer parameter - /// Value to be displayed - void UpdateUI(string sParam, int iParam, double value); - /// /// Called on beginning of a test /// diff --git a/TBF/BenchControl/ControlBoard/Papouch/CBoardCfgCtrl.cs b/TBF/BenchControl/ControlBoard/Papouch/CBoardCfgCtrl.cs index d98cdbcc9..be683ea3b 100644 --- a/TBF/BenchControl/ControlBoard/Papouch/CBoardCfgCtrl.cs +++ b/TBF/BenchControl/ControlBoard/Papouch/CBoardCfgCtrl.cs @@ -15,13 +15,13 @@ namespace TBF.BenchControl.ControlBoard.Papouch public bool ShowMore { get { return false; } } - CBoardCfg config; + PapouchCBCfg config; public IComponentCfg Config { get { return config as IComponentCfg; } set { - config = value as CBoardCfg; + config = value as PapouchCBCfg; Redraw(); } } diff --git a/TBF/BenchControl/ControlBoard/Papouch/CBoardFactory.cs b/TBF/BenchControl/ControlBoard/Papouch/Factory.cs similarity index 59% rename from TBF/BenchControl/ControlBoard/Papouch/CBoardFactory.cs rename to TBF/BenchControl/ControlBoard/Papouch/Factory.cs index bd6579e00..574b4ebda 100644 --- a/TBF/BenchControl/ControlBoard/Papouch/CBoardFactory.cs +++ b/TBF/BenchControl/ControlBoard/Papouch/Factory.cs @@ -6,25 +6,25 @@ using TBF.BenchControl.Generic; namespace TBF.BenchControl.ControlBoard.Papouch { - public class CBoardFactory : IComponentFactory + public class Factory : IComponentFactory { public string ClassName { get { return this.GetType().Namespace.Substring(17); } } public override string ToString() { return ClassName; } - public void ResetStaticProperties() { CBoard.ResetStaticProperties(); } + public void ResetStaticProperties() { PapouchCB.ResetStaticProperties(); } /// Max. number of components of this class in the system public int MaxCount { get { return 1; } } - public IComponent DummyComponent() { return new CBoard(); } + public IComponent DummyComponent() { return new PapouchCB(); } - public IComponent GetComponent(IComponentCfg cfg, IList components) { return new CBoard(cfg, components); } + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new PapouchCB(cfg, components); } - public IComponentCfg DefaultConfig() { return new CBoardCfg(this); } + public IComponentCfg DefaultConfig() { return new PapouchCBCfg(this); } public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { - return ComponentCfgBase.CreateFromDbEntity(CBoardCfg.Serializer, component, this); + return ComponentCfgBase.CreateFromDbEntity(PapouchCBCfg.Serializer, component, this); } } } diff --git a/TBF/BenchControl/ControlBoard/Papouch/CBoard.cs b/TBF/BenchControl/ControlBoard/Papouch/PapouchCB.cs similarity index 93% rename from TBF/BenchControl/ControlBoard/Papouch/CBoard.cs rename to TBF/BenchControl/ControlBoard/Papouch/PapouchCB.cs index a486bee8c..5bd482a96 100644 --- a/TBF/BenchControl/ControlBoard/Papouch/CBoard.cs +++ b/TBF/BenchControl/ControlBoard/Papouch/PapouchCB.cs @@ -16,12 +16,12 @@ using TBF.BenchControl.Sequences; namespace TBF.BenchControl.ControlBoard.Papouch { - public class CBoard : ComponentBase, IControlBoard, IOperation + public class PapouchCB : ComponentBase, IControlBoard, IOperation { - private static readonly ILog log = LogManager.GetLogger(typeof(CBoard)); + private static readonly ILog log = LogManager.GetLogger(typeof(PapouchCB)); public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(1)); } - readonly CBoardCfg cBoardCfg; + readonly PapouchCBCfg cbCfg; readonly GenericDevices.IModbus modbus; UInt32 currentOutputs; @@ -48,17 +48,17 @@ namespace TBF.BenchControl.ControlBoard.Papouch bool opCompleted; /// true = Operation was completed and waits for Stop(); - public CBoard() + public PapouchCB() { } /// /// Constructor /// - public CBoard(Generic.IComponentCfg cfg, IList components) + public PapouchCB(Generic.IComponentCfg cfg, IList components) : base(cfg) { - cBoardCfg = cfg as CBoardCfg; + cbCfg = cfg as PapouchCBCfg; modbus = (GenericDevices.IModbus)TbfComponents.FindComponent(cfg.ParentName, components); if (modbus == null) throw new Exception("Cannot find " + Name + " parent"); @@ -66,7 +66,7 @@ namespace TBF.BenchControl.ControlBoard.Papouch routeMask = 0; for (int i = 0; i < 128; i++) { - if (i < cBoardCfg.VirtualValvesRangeLo || i > cBoardCfg.VirtualValvesRangeHi) + if (i < cbCfg.VirtualValvesRangeLo || i > cbCfg.VirtualValvesRangeHi) { routeMask = routeMask | ((UInt128)1 << i); } @@ -105,11 +105,11 @@ namespace TBF.BenchControl.ControlBoard.Papouch public void RunDeviceBefore() { - if (cBoardCfg.DebugLevel == Config.Entities.DebugMode.Simulate) return; + if (cbCfg.DebugLevel == Config.Entities.DebugMode.Simulate) return; - if (modbus.ReceivedTelegrams[cBoardCfg.ModbusAddress].Count > 0) + if (modbus.ReceivedTelegrams[cbCfg.ModbusAddress].Count > 0) { - byte[] telegram = modbus.ReceivedTelegrams[cBoardCfg.ModbusAddress].Dequeue(); + byte[] telegram = modbus.ReceivedTelegrams[cbCfg.ModbusAddress].Dequeue(); if ((telegram.Length >= 8) && (telegram[1] == 0x11) && (telegram[2] == telegram.Length - 5)) { @@ -198,33 +198,33 @@ namespace TBF.BenchControl.ControlBoard.Papouch private void RequestInputs() { - byte addr = cBoardCfg.ModbusAddress; + byte addr = cbCfg.ModbusAddress; byte cmd = (byte)Function.ReadSingleInput; modbus.SendMessage(new byte[] { addr, cmd, 0, 0, 0, 2, 0, 0 }); } private void SendOutputs(UInt32 outputs) { - byte addr = cBoardCfg.ModbusAddress; + byte addr = cbCfg.ModbusAddress; byte cmd = (byte)Function.ForceMultipleCoils; byte dataLo = (byte)(outputs & 0xFF); byte data2 = (byte)(outputs >> 8); byte data3 = (byte)(outputs >> 16); byte dataHi = (byte)(outputs >> 24); - if (cBoardCfg.Variant == QuidoVariant.QuidoRS_4_4) + if (cbCfg.Variant == QuidoVariant.QuidoRS_4_4) { modbus.SendMessage(new byte[] { addr, cmd, 0, 0, 0, 4, 1, dataLo, 0, 0 }); } - else if (cBoardCfg.Variant == QuidoVariant.QuidoRS_8_8) + else if (cbCfg.Variant == QuidoVariant.QuidoRS_8_8) { modbus.SendMessage(new byte[] { addr, cmd, 0, 0, 0, 8, 1, dataLo, 0, 0 }); } - else if (cBoardCfg.Variant == QuidoVariant.QuidoRS_2_16) + else if (cbCfg.Variant == QuidoVariant.QuidoRS_2_16) { modbus.SendMessage(new byte[] { addr, cmd, 0, 0, 0, 16, 2, dataLo, data2, 0, 0 }); } - else if (cBoardCfg.Variant == QuidoVariant.QuidoRS_2_32) + else if (cbCfg.Variant == QuidoVariant.QuidoRS_2_32) { modbus.SendMessage(new byte[] { addr, cmd, 0, 0, 0, 32, 4, dataLo, data2, data3, dataHi, 0, 0 }); } @@ -265,7 +265,6 @@ namespace TBF.BenchControl.ControlBoard.Papouch public double TestTimeWM(int wmNr1) { return (wmNr1 > 0 && wmNr1 <= Config.Data.WMsCount) ? 1.0 : 1.0; } - public void UpdateUI(string sParam, int iParam, double value) { } public void ClearProcessValues() { } /// @@ -402,9 +401,9 @@ namespace TBF.BenchControl.ControlBoard.Papouch System.Drawing.Color backColor; TBF.BenchControl.Operations.MessageBoxForm messageBoxForm; /// - delegate void MessageBoxFormDlgt(CBoard myRef); + delegate void MessageBoxFormDlgt(PapouchCB myRef); /// - void OpenFormDlg(CBoard myRef) + void OpenFormDlg(PapouchCB myRef) { myRef.messageBoxForm = new TBF.BenchControl.Operations.MessageBoxForm(promptMsg, backColor); messageBoxForm.Show(); diff --git a/TBF/BenchControl/ControlBoard/Papouch/CBoardCfg.cs b/TBF/BenchControl/ControlBoard/Papouch/PapouchCBCfg.cs similarity index 90% rename from TBF/BenchControl/ControlBoard/Papouch/CBoardCfg.cs rename to TBF/BenchControl/ControlBoard/Papouch/PapouchCBCfg.cs index 242ae2859..955d1efa7 100644 --- a/TBF/BenchControl/ControlBoard/Papouch/CBoardCfg.cs +++ b/TBF/BenchControl/ControlBoard/Papouch/PapouchCBCfg.cs @@ -16,9 +16,9 @@ namespace TBF.BenchControl.ControlBoard.Papouch Count } - public class CBoardCfg : ComponentCfgBase, Generic.IChildComponentCfg + public class PapouchCBCfg : ComponentCfgBase, Generic.IChildComponentCfg { - public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(CBoardCfg) })[0]; + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(PapouchCBCfg) })[0]; public override XmlSerializer GetSerializer() { return Serializer; } public IComponentCfgCtrl GetControl(IList cmpntEntities) { return new CBoardCfgCtrl(); } @@ -32,7 +32,7 @@ namespace TBF.BenchControl.ControlBoard.Papouch public int VirtualValvesRangeHi; /// Private parameterless constructor invoked by all other (public) constructors - CBoardCfg() + PapouchCBCfg() { Name = "CB"; ParentName = "Modbus"; @@ -42,7 +42,7 @@ namespace TBF.BenchControl.ControlBoard.Papouch VirtualValvesRangeHi = 59; } - public CBoardCfg(IComponentFactory factory) + public PapouchCBCfg(IComponentFactory factory) : this() { this.Factory = factory; diff --git a/TBF/BenchControl/ControlBoard/Uni/Action.cs b/TBF/BenchControl/ControlBoard/Uni/Action.cs new file mode 100644 index 000000000..432c26bca --- /dev/null +++ b/TBF/BenchControl/ControlBoard/Uni/Action.cs @@ -0,0 +1,312 @@ +/// +/// Copyright (c) 2021 Sensus Slovensko a.s. +/// +using System.Collections.Generic; +using log4net; +using Dirichlet.Numerics; + +namespace TBF.BenchControl.ControlBoard.Uni +{ + public enum ActionID + { + /// Basic + ChangeRoute = 1, /// Change digital outputs (route) + SetFlow = 2, /// Set flow + MeasureFlow = 4, /// Activate a flow meter to measure the flow + StartTest = 8, /// Start a test + Stop = 16, /// Stop a test or a flow regulation + SwitchDiverter = 32, /// Switch diverter to tank/sink + + /// Advanced + GetDiverterTransitionData, + GetScopeAnalyzerData, + ResetScopeAnalyzer, + GetSwitchCounterData, + } + + public class Action + { + private static readonly ILog log = LogManager.GetLogger(typeof(Action)); + + public ActionID ActionId { get; set; } + public ulong Route { get; set; } /// ChangeRoute argument + public int FlowMId { get; set; } /// SetFlow, MeasureFlow and StartTest argument + public int RegVId { get; set; } /// SetFlow and StartTest argument + public int DivId { get; set; } /// StartTest and SwitchDiverter argument + public bool IsSyncMethod { get; set; } /// StartTest argument + public bool IsDivUsed { get; set; } /// StartTest argument + public bool ToTank { get; set; } /// SwitchDiverter argument + public int TotalPulsesCount { get; set; } /// StartTest argument + public int MassPulsesCount { get; set; } /// StartTest argument + public int FlowRegP1 { get; set; } /// SetFlow + public int FlowRegP2 { get; set; } /// SetFlow + public int PID { get; set; } /// SetFlow + public int TolerRV { get; set; } /// SetFlow + public int StabTime { get; set; } /// SetFlow + public int DivThreshold { get; set; } /// StartTest argument + int StartStop { get; set; } /// Implicitly used by SetFlow, StartTest and Stop: -1=not defined, 0=stop, 1=start + + + public Action() + { + /// Values -1 indicate the related arguments are not used yet + FlowMId = -1; + RegVId = -1; + DivId = -1; + StartStop = -1; + + /// These values are used by one action type only. No conflicts possible + Route = 0; + FlowRegP1 = 0; + FlowRegP2 = 0; + TotalPulsesCount = 0; + MassPulsesCount = 0; + } + + + public bool IsStart() + { + return (ActionId & (ActionID.SetFlow | ActionID.StartTest)) != 0; + } + + public bool IsStop() + { + return (ActionId & ActionID.Stop) != 0; + } + + ///---------------------------------------------------------------------------------------------- + public static Action ChangeRoute(ulong route) + { + return new Action + { + ActionId = ActionID.ChangeRoute, + Route = route, + }; + } + void SetChangeRouteArgs(Action action) + { + Route = action.Route; + } + bool CompareChangeRouteArgs(Action action) + { + return Route == action.Route; + } + + ///---------------------------------------------------------------------------------------------- + public static Action MeasureFlow(int flowMeterId) + { + return new Action + { + ActionId = ActionID.MeasureFlow, + FlowMId = flowMeterId, + }; + } + void SetMeasureFlowArgs(Action action) + { + FlowMId = action.FlowMId; + } + bool CompareMeasureFlowArgs(Action action) + { + return (FlowMId == -1 || FlowMId == action.FlowMId); + } + + ///---------------------------------------------------------------------------------------------- + public static Action SetFlow(int flowMeterId, int regValveId, int flowRegPar1, int flowRegPar2, + int pid, int tolerRV, int stabTime) + { + return new Action + { + ActionId = ActionID.SetFlow, + FlowMId = flowMeterId, + RegVId = regValveId, + FlowRegP1 = flowRegPar1, + FlowRegP2 = flowRegPar2, + PID = pid, + TolerRV = tolerRV, + StabTime = stabTime, + StartStop = 1, + }; + } + void SetSetFlowArgs(Action action) + { + FlowMId = action.FlowMId; + RegVId = action.RegVId; + FlowRegP1 = action.FlowRegP1; + FlowRegP2 = action.FlowRegP2; + PID = action.PID; + TolerRV = action.TolerRV; + StabTime = action.StabTime; + StartStop = 1; + } + bool CompareSetFlowArgs(Action action) + { + return (FlowMId == -1 || FlowMId == action.FlowMId) && + (RegVId == -1 || RegVId == action.RegVId) && + (StartStop == -1 || StartStop == 1); + } + + ///---------------------------------------------------------------------------------------------- + public static Action StartTest(int flowMId, int divId, int divThreshold, bool isSyncMethod, + bool isDivUsed, int totalPulsesCount, int massPulsesCount = -1) + { + return new Action + { + ActionId = ActionID.StartTest, + FlowMId = flowMId, + DivId = divId, + DivThreshold = divThreshold, + IsSyncMethod = isSyncMethod, + IsDivUsed = isDivUsed, + TotalPulsesCount = totalPulsesCount, + MassPulsesCount = (massPulsesCount == -1) ? totalPulsesCount : massPulsesCount, + StartStop = 1, + }; + } + void SetStartTestArgs(Action action) + { + FlowMId = action.FlowMId; + DivId = action.DivId; + DivThreshold = action.DivThreshold; + IsSyncMethod = action.IsSyncMethod; + IsDivUsed = action.IsDivUsed; + TotalPulsesCount = action.TotalPulsesCount; + MassPulsesCount = action.MassPulsesCount; + StartStop = 1; + } + bool CompareStartTestArgs(Action action) + { + return (FlowMId == -1 || FlowMId == action.FlowMId) && + (DivId == -1 || DivId == action.DivId) && + (StartStop == -1 || StartStop == 1); + } + + ///---------------------------------------------------------------------------------------------- + public static Action Stop() + { + return new Action() + { + ActionId = ActionID.Stop, + StartStop = 0, + }; + } + void SetStopArgs(Action action) + { + StartStop = 0; + } + bool CompareStopArgs(Action action) + { + return (StartStop == -1 || StartStop == 0); + } + + ///---------------------------------------------------------------------------------------------- + public static Action SwitchDiverter(int divId, bool toTank) + { + return new Action + { + ActionId = ActionID.SwitchDiverter, + DivId = divId, + ToTank = toTank, + }; + } + void SetSwitchDiverterArgs(Action action) + { + DivId = action.DivId; + ToTank = action.ToTank; + } + bool CompareSwitchDiverterArgs(Action action) + { + return (DivId == -1 || DivId == action.DivId); + } + + ///---------------------------------------------------------------------------------------------- + void SetArgs(Action action) + { + ActionId |= action.ActionId; + + switch (action.ActionId) + { + case ActionID.ChangeRoute: SetChangeRouteArgs(action); return; + case ActionID.MeasureFlow: SetMeasureFlowArgs(action); return; + case ActionID.SetFlow: SetSetFlowArgs(action); return; + case ActionID.StartTest: SetStartTestArgs(action); return; + case ActionID.Stop: SetStopArgs(action); return; + case ActionID.SwitchDiverter: SetSwitchDiverterArgs(action); return; + default: return; + } + } + + /// + /// Checks whether there is a conflict in usage of arguments. + /// + /// 2nd action + /// true if there is no conflict + bool CompareSharedArgs(Action action) + { + switch (action.ActionId) + { + case ActionID.ChangeRoute: return CompareChangeRouteArgs(action); + case ActionID.MeasureFlow: return CompareMeasureFlowArgs(action); + case ActionID.SetFlow: return CompareSetFlowArgs(action); + case ActionID.StartTest: return CompareStartTestArgs(action); + case ActionID.Stop: return CompareStopArgs(action); + case ActionID.SwitchDiverter: return CompareSwitchDiverterArgs(action); + default: return false; + } + } + + ///---------------------------------------------------------------------------------------------- + public static Action FetchNonConflictingActions(Queue queue) + { + log.Debug("Fetching non conflicting actions:"); + + if (queue == null || queue.Count == 0) return null; + + Action resultA = queue.Dequeue(); + log.Debug(resultA.ToString()); + + while (queue.Count > 0) + { + var peekA = queue.Peek(); + if ((resultA.ActionId & peekA.ActionId) == 0 && resultA.CompareSharedArgs(peekA) == true) + { + /// ActionId would not be repeated and arguments are compatible => apply the new action + resultA.SetArgs(peekA); + log.Debug(peekA.ToString()); + queue.Dequeue(); + } + else + { + /// Leave actions in the queue and quit the loop as the next scheduled action is incompatible + break; + } + } + + return resultA; + } + + public override string ToString() + { + string args; + switch (ActionId) + { + case ActionID.ChangeRoute: + args = string.Format("Route={0}", Route.ToString("X16")); + break; + case ActionID.SetFlow: + args = string.Format("Etalon={0} RV={1} Par1={2} Par2={3}", FlowMId, RegVId, FlowRegP1, FlowRegP2); + break; + case ActionID.MeasureFlow: + args = string.Format("Etalon={0}", FlowMId); + break; + case ActionID.StartTest: + args = string.Format("Etalon={0} TotalP={1} MassP={2}", FlowMId, TotalPulsesCount, MassPulsesCount); + break; + default: + args = string.Empty; + break; + } + + return string.Format(" {0} {1}", ActionId, args); + } + } +} diff --git a/TBF/BenchControl/ControlBoard/Uni/Enums.cs b/TBF/BenchControl/ControlBoard/Uni/Enums.cs index 6a2bb03dc..bf9f1503a 100644 --- a/TBF/BenchControl/ControlBoard/Uni/Enums.cs +++ b/TBF/BenchControl/ControlBoard/Uni/Enums.cs @@ -1,23 +1,21 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - +/// +/// Copyright (c) 2021 Sensus Slovensko a.s. +/// namespace TBF.BenchControl.ControlBoard.Uni { public class Const { public const byte STX = 0x10; - public const int WMsCount = 20; /// water meters count - public const int ADCsCount = 16; /// ADCs count: feedback from RV-s and diverters - public const int RVsCount = 8; /// 0..7 - public const int FlowmtrsCount = 7; /// ID=1..7, ID=0 ... flowmeters 1,2,3 parallel - public const int DivertersCount = 5; /// 1..5 - public const int DivTimeResolution = 2; /// [ms] - public const double TimeResolution = 0.0002; /// [s] + public const int WMsCount = 20; /// water meters count + public const int ADCsCount = 16; /// ADCs count: feedback from RV-s and diverters + public const int RVsCount = 8; /// 0..7 + public const int FlowmtrsCount = 7; /// ID=1..7, ID=0 ... flowmeters 1,2,3 parallel + public const int DivertersCount = 5; /// 1..5 + public const int DivTimeResolution = 2; /// [ms] + public const double TimeResolution = 0.0002; /// [s] } + public enum StatusP : ulong { /// byte 0 @@ -50,68 +48,4 @@ namespace TBF.BenchControl.ControlBoard.Uni Flowmtr2Active = 0x2000000000000, /// bit 49 Flowmtr3Active = 0x4000000000000, /// bit 50 } - - public enum Command : byte - { - RequestData = 0, - Start = 1, - Stop = 2, - GetDiverterTransitionData = 4, - GetScopeAnalyzerData = 7, - ResetScopeAnalyzer = 8, - GetSwitchCounterData = 9, - } - - public enum StartParam : byte - { - EtalonMask = 7, - DiverterStart = 8, - SynchroMethod = 16, - DirectGateStart = 32, /// ??? - StartStopMethod = 64, - CalibrationMode = 128, - } - - public enum StopDevs : byte - { - None = 0, - Reference = 0x01, /// bit 0 - Diverter = 0x02, /// bit 1 - GatePulse = 0x08, /// bit 3 - TimeMeasurement = 0x10, /// bit 4 - BypassDevCoupled2Div = 0x20, /// bit 5 - RegValveRegulation = 0x80, /// bit 7 - All = 0xFF, - } - - public enum TestMethods - { - Diverter = 0x01, /// bit 0: 1=Mass method (diverters are used), 0=Volume method - FixedStart = 0x02, /// bit 1: 1=fixed start method, 0=flying start method - Synchro = 0x04, /// bit 2: 1=Synchro method, 0=Pulse counting - MassAndContinue = 0x10, /// bit 4: 1=Method with mass measurement followed by a volume method - } - - public enum ValveChgFlag : byte - { - DoNotChange = 0, - Change = 1, - SendPressureMeterAddresses = 2, - } - - public enum RegValveMode : byte - { - None = 0, - PulseWidth = 1, /// Pulse width 0.05 .. 2 sec. - TargetPosition = 2, /// Low and high position (=DAC value) limits (0..100%) are specified - TargetFrequency = 3, /// Low and high frequency limits (0..2000Hz,0..2200Hz) are specified - Stop = 4, /// Stop regulation - } - - public enum RegValveState : byte - { - Idle = 0, - PwOrFreqRegul = 2, - DacValueRegul = 3, - } } diff --git a/TBF/BenchControl/ControlBoard/Uni/Factory.cs b/TBF/BenchControl/ControlBoard/Uni/Factory.cs index 264217c32..5b1fda16a 100644 --- a/TBF/BenchControl/ControlBoard/Uni/Factory.cs +++ b/TBF/BenchControl/ControlBoard/Uni/Factory.cs @@ -11,17 +11,17 @@ namespace TBF.BenchControl.ControlBoard.Uni public string ClassName { get { return this.GetType().Namespace.Substring(17); } } public override string ToString() { return ClassName; } - public void ResetStaticProperties() { CBoard.ResetStaticProperties(); } + public void ResetStaticProperties() { UniCB.ResetStaticProperties(); } - public IComponent DummyComponent() { return new CBoard(); } + public IComponent DummyComponent() { return new UniCB(); } - public IComponent GetComponent(IComponentCfg cfg, IList components) { return new CBoard(cfg); } + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new UniCB(cfg); } - public IComponentCfg DefaultConfig() { return new CBoardCfg("UniCB", this); } + public IComponentCfg DefaultConfig() { return new UniCBCfg("UniCB", this); } public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { - return ComponentCfgBase.CreateFromDbEntity(CBoardCfg.Serializer, component, this); + return ComponentCfgBase.CreateFromDbEntity(UniCBCfg.Serializer, component, this); } } } diff --git a/TBF/BenchControl/ControlBoard/Uni/GeneralData.cs b/TBF/BenchControl/ControlBoard/Uni/GeneralData.cs index 570c48c9a..668fd5d96 100644 --- a/TBF/BenchControl/ControlBoard/Uni/GeneralData.cs +++ b/TBF/BenchControl/ControlBoard/Uni/GeneralData.cs @@ -15,11 +15,11 @@ namespace TBF.BenchControl.ControlBoard.Uni public ulong Vystupy; public uint[] StavDA = new uint[2]; public double[] ReferenceFreq = new double[4]; - public uint[] EtPulses = new uint[Const.WMsCount + 1]; /// EtPulses[0]=total pulses, EtPulses[1..WMsCount] gated et.pulses for respective WM - public uint EtPulsesK; - public uint EtPulses2; - public uint EtPulses3; - public uint[] WMeterPuls = new uint[Const.WMsCount + 1]; /// WMsCount = 20 + public int[] EtPulses = new int[Const.WMsCount + 1]; /// EtPulses[0]=total pulses, EtPulses[1..WMsCount] gated et.pulses for respective WM + public int EtPulsesK; + public int EtPulses2; + public int EtPulses3; + public int[] WMeterPuls = new int[Const.WMsCount + 1]; /// WMsCount = 20 public double[] ImpulseTime = new double[Const.WMsCount + 1]; /// WMsCount = 20 public uint[] RegVStatus = new uint[Const.RVsCount + 1 + 1]; /// RVsCount = 8, posledny rValveStatus[9] je prudovy public float[] RegVMoveTime = new float[Const.RVsCount]; @@ -99,8 +99,8 @@ namespace TBF.BenchControl.ControlBoard.Uni TemperatureRaw[i] = GetInt16(data, offs + (int)Poz.Groch + 2 * i); } - EtPulses[0] = GetUInt24(data, offs + (int)Poz.Et1); /// Byte 73,74,75 - EtPulsesK = GetUInt24(data, offs + (int)Poz.EtK); /// Byte 76,77,78 + EtPulses[0] = Convert.ToInt32(GetUInt24(data, offs + (int)Poz.Et1));/// Byte 73,74,75 + EtPulsesK = Convert.ToInt32(GetUInt24(data, offs + (int)Poz.EtK)); /// Byte 76,77,78 byte spare1 = data[offs + (int)Poz.spare1]; /// byte 79 byte spare2 = data[offs + (int)Poz.spare2]; /// byte 82 @@ -125,13 +125,13 @@ namespace TBF.BenchControl.ControlBoard.Uni if ((State & (ulong)StatusP.SynchroMethod) != 0) { ushort pulses = GetUInt16(data, ix2); - WMeterPuls[wmNr] = pulses; - EtPulses[wmNr] = (pulses == 0) ? 0 : GetUInt24(data, ix1); - ImpulseTime[wmNr] = (pulses == 0) ? 0 : GetUInt24(data, ix1 + 3) * Const.TimeResolution; + WMeterPuls[wmNr] = Convert.ToInt32(pulses); + EtPulses[wmNr] = (pulses == 0) ? 0 : Convert.ToInt32(GetUInt24(data, ix1)); + ImpulseTime[wmNr] = (pulses == 0) ? 0 : Const.TimeResolution * Convert.ToDouble(GetUInt24(data, ix1 + 3)); } else { - WMeterPuls[wmNr] = GetUInt24(data, ix1); + WMeterPuls[wmNr] = Convert.ToInt32(GetUInt24(data, ix1)); EtPulses[wmNr] = EtPulses[0]; ImpulseTime[wmNr] = Ttime; } @@ -185,8 +185,8 @@ namespace TBF.BenchControl.ControlBoard.Uni RegVMoveTime[i] = 10 * GetUInt16(data, offs + (int)Poz.CasKoh + 2*i); } - EtPulses2 = GetUInt24(data, offs + (int)Poz.ETX2); /// Byte 294,295,296 - EtPulses3 = GetUInt24(data, offs + (int)Poz.ETX3); /// Byte 297,298.299 !!!!!!!!!!!!!!! + EtPulses2 = Convert.ToInt32(GetUInt24(data, offs + (int)Poz.ETX2)); /// Byte 294,295,296 + EtPulses3 = Convert.ToInt32(GetUInt24(data, offs + (int)Poz.ETX3)); /// Byte 297,298.299 !!!!!!!!!!!!!!! } } diff --git a/TBF/BenchControl/ControlBoard/Uni/IOutputMessage.cs b/TBF/BenchControl/ControlBoard/Uni/IOutputMessage.cs deleted file mode 100644 index 64963d684..000000000 --- a/TBF/BenchControl/ControlBoard/Uni/IOutputMessage.cs +++ /dev/null @@ -1,12 +0,0 @@ -/// -/// Copyright (c) 2021 Sensus Slovensko a.s. -/// -namespace TBF.BenchControl.ControlBoard.Uni -{ - public interface IOutputMessage - { - int PayloadLen { get; } - byte MessageCode { get; } - byte[] GetMessage(); - } -} diff --git a/TBF/BenchControl/ControlBoard/Uni/OutputMessage.cs b/TBF/BenchControl/ControlBoard/Uni/OutputMessage.cs index fcaeaf169..050f68463 100644 --- a/TBF/BenchControl/ControlBoard/Uni/OutputMessage.cs +++ b/TBF/BenchControl/ControlBoard/Uni/OutputMessage.cs @@ -7,111 +7,74 @@ using Dirichlet.Numerics; namespace TBF.BenchControl.ControlBoard.Uni { - public class OutputMessage : IOutputMessage + public static class OutputMessage { - public int PayloadLen { get { return 38; } } - public byte MessageCode { get { return (byte)' '; } } + public const int PayloadLen = 38; + public const byte MessageCode = (byte)' '; - Command command; - byte startOrStopParams; - UInt32 totalPulsesCount; - UInt32 massPuleseCount; - UInt128 route; - - OutputMessage() - { - command = Command.RequestData; - startOrStopParams = 0; - totalPulsesCount = 0; - massPuleseCount = 0; - } - - public static OutputMessage CreateDataRequestMsg() - { - var msg = new OutputMessage(); - msg.command = Command.RequestData; - return msg; - } - - public static OutputMessage CreateSetFlowMsg(OutputPath devices, float flowLo, float flowHi, int timeOut) - { - var msg = new OutputMessage(); - msg.command = Command.RequestData; - return msg; - } - - public static OutputMessage CreateTestStartCmd(int etalonNr, int regValveNr, int divNr, long totalPulsesCount, long massPulsesCount = -1) - { - var msg = new OutputMessage(); - //msg.command = Command.Start; - //msg.etalonNr = etalonNr; - //msg.regValveNr = regValveNr; - //msg.divNr = divNr; - //msg.totalPulsesCount = totalPulsesCount; - //msg.massPuleseCount = (massPulsesCount >= 0) ? massPulsesCount : totalPulsesCount; - return msg; - } - - public static OutputMessage CreateTestStopCmd() - { - var msg = new OutputMessage(); - msg.command = Command.Stop; - return msg; - } - - public byte[] GetMessage() + public static byte[] GetMessage(Action action, short config) { byte[] message = new byte[PayloadLen + 5]; /// headed 3 bytes, checksum 2 bytes - /// Header (3 bytes) + /// Header + message code (4 bytes) message[0] = Const.STX; message[1] = 1; /// Control board addres message[2] = (byte)PayloadLen; /// Payload length + message[3] = MessageCode; /// Command - message[3] = MessageCode; - message[4] = (byte)command; - message[5] = startOrStopParams; - message[6] = 0; /// nn | (paralelEt << 3); + message[4] = GetCommand(action); + message[5] = action.IsStart() ? GetStartParams(action) : action.IsStop() ? GetStopParams(action) : (byte)0; + message[6] = (action.DivId <= 0) ? (byte)0 : (byte)(action.DivId - 1); + + int totalPulsesCount = (action.TotalPulsesCount < 0) ? 0 : action.TotalPulsesCount; message[7] = (byte)(totalPulsesCount & 0xFF); message[8] = (byte)((totalPulsesCount >> 8) & 0xFF); message[9] = (byte)((totalPulsesCount >> 16) & 0xFF); - message[10] = (byte)(massPuleseCount & 0xFF); - message[11] = (byte)((massPuleseCount >> 8) & 0xFF); - message[12] = (byte)((massPuleseCount >> 16) & 0xFF); + + int massPulsesCount = (action.MassPulsesCount < 0) ? 0 : action.MassPulsesCount; + message[10] = (byte)(massPulsesCount & 0xFF); + message[11] = (byte)((massPulsesCount >> 8) & 0xFF); + message[12] = (byte)((massPulsesCount >> 16) & 0xFF); - ///// Valves - //message[13] = (byte)((route >> 16) & 0xFF); - //message[14] = (byte)((route >> 24) & 0xFF); - //message[15] = (byte)((route >> 32) & 0xFF); - //message[16] = (byte)((route >> 40) & 0xFF); - //message[17] = (byte)((route >> 48) & 0xFF); - //message[18] = (byte)((route >> 56) & 0xFF); - //message[19] = 0; + message[13] = 0; - ///// Frequency converter parameters - //message[20] = 0; - //message[21] = 0; - //message[22] = 0; - //message[23] = 0; - //message[24] = 0; - //message[25] = 0; - //message[26] = 0; - //message[27] = 0; - //message[28] = 0; - //message[29] = 0; + message[14] = (byte)(config & 0xff); + message[15] = (byte)((config >> 8) & 0xff); - //message[30] = (byte)(regValveNrTextBox.Visible ? int.Parse(regValveNrTextBox.Text) : 0); - //message[31] = (byte)GetRegValveMode(); - message[32] = 0; /// reg. v. position - message[33] = 0; /// reg. v. frequency - message[34] = 0; /// reg. v. time ticks - message[35] = 0; /// analog v. regul - message[36] = 0; /// analog v. regul - message[37] = 0; /// analog v. regul - message[38] = 0; /// analog v. regul - message[39] = 0; /// analog v. regul + /// Route + message[16] = ((action.ActionId & ActionID.ChangeRoute) != 0) ? (byte)1 : (byte)0; /// Route change flag + message[17] = (byte)(action.Route & 0xFF); + message[18] = (byte)((action.Route >> 8) & 0xFF); + message[19] = (byte)((action.Route >> 16) & 0xFF); + message[20] = (byte)((action.Route >> 24) & 0xFF); + message[21] = (byte)((action.Route >> 32) & 0xFF); + message[22] = (byte)((action.Route >> 40) & 0xFF); + message[23] = (byte)((action.Route >> 48) & 0xFF); + message[24] = (byte)((action.Route >> 56) & 0xFF); + /// DA2 + message[25] = 0; + message[26] = 0; + + /// Regulation valve + message[27] = (action.RegVId < 0) ? (byte)0 : (byte)action.RegVId; + message[28] = (byte)(action.FlowRegP1 & 0xFF); + message[29] = (byte)((action.FlowRegP1 >> 8) & 0xFF); + message[30] = (byte)(action.FlowRegP2 & 0xFF); + message[31] = (byte)((action.FlowRegP2 >> 8) & 0xFF); + message[32] = action.IsStop() ? (byte)0x20 : action.IsStart() ? (byte)0x42 : (byte)0; /// ZStavReg + + /// DA1 + message[33] = 0; /// PrudParL + message[34] = 0; /// PrudParH + + message[35] = (byte)Math.Max(1, Math.Min(255, action.PID)); /// PIDRV + message[36] = (byte)Math.Max(4, Math.Min(255, action.TolerRV)); /// TolerRV (4..20 mA reg.valve only) + message[37] = (byte)Math.Max(0, Math.Min(255, action.StabTime)); /// StabRV + message[38] = (byte)((action.DivThreshold >> 2) & 0xFF); /// HranAK + + message[39] = 0; message[40] = 0; Debug.Assert(40 == PayloadLen + 2); @@ -124,9 +87,99 @@ namespace TBF.BenchControl.ControlBoard.Uni return message; } - public override string ToString() + + static byte GetCommand(Action action) { - return string.Format("CommandMessage : {0}", command); + int command = 0; + if (action.IsStart()) command |= (int)Command.Start; + if (action.IsStop()) command |= (int)Command.Stop; + return (byte)command; + } + + static byte GetStartParams(Action action) + { + int param = action.FlowMId & (int)StartParam.EtalonMask; + + if (action.IsDivUsed) + param |= (int)StartParam.DiverterStart; + + if (action.IsSyncMethod) + param |= (int)StartParam.SynchroMethod; + else + param |= (int)StartParam.StartStopMethod; + + return (byte)param; + } + + static byte GetStopParams(Action action) + { + int param = 0; + return (byte)param; } } + + + public enum Command : byte + { + RequestData = 0, + Start = 1, + Stop = 2, + GetDiverterTransitionData = 4, + GetScopeAnalyzerData = 7, + ResetScopeAnalyzer = 8, + GetSwitchCounterData = 9, + } + + public enum StartParam : byte + { + EtalonMask = 0x07, + DiverterStart = 0x08, + SynchroMethod = 0x10, + DirectGateStart = 0x20, /// ??? + StartStopMethod = 0x40, + CalibrationMode = 0x80, + } + + public enum StopDevs : byte + { + None = 0, + Reference = 0x01, /// bit 0 + Diverter = 0x02, /// bit 1 + GatePulse = 0x08, /// bit 3 + TimeMeasurement = 0x10, /// bit 4 + BypassDevCoupled2Div = 0x20, /// bit 5 + RegValveRegulation = 0x80, /// bit 7 + All = 0xFF, + } + + public enum TestMethods + { + Diverter = 0x01, /// bit 0: 1=Mass method (diverters are used), 0=Volume method + FixedStart = 0x02, /// bit 1: 1=fixed start method, 0=flying start method + Synchro = 0x04, /// bit 2: 1=Synchro method, 0=Pulse counting + MassAndContinue = 0x10, /// bit 4: 1=Method with mass measurement followed by a volume method + } + + public enum ValveChgFlag : byte + { + DoNotChange = 0, + Change = 1, + SendPressureMeterAddresses = 2, + } + + public enum RegValveMode : byte + { + None = 0, + PulseWidth = 1, /// Pulse width 0.05 .. 2 sec. + TargetPosition = 2, /// Low and high position (=DAC value) limits (0..100%) are specified + TargetFrequency = 3, /// Low and high frequency limits (0..2000Hz,0..2200Hz) are specified + Stop = 4, /// Stop regulation + } + + public enum RegValveState : byte + { + Idle = 0, + PwOrFreqRegul = 2, + DacValueRegul = 3, + } } diff --git a/TBF/BenchControl/ControlBoard/Uni/CBoard.cs b/TBF/BenchControl/ControlBoard/Uni/UniCB.cs similarity index 83% rename from TBF/BenchControl/ControlBoard/Uni/CBoard.cs rename to TBF/BenchControl/ControlBoard/Uni/UniCB.cs index 1bc82e0c8..b525f2b5a 100644 --- a/TBF/BenchControl/ControlBoard/Uni/CBoard.cs +++ b/TBF/BenchControl/ControlBoard/Uni/UniCB.cs @@ -15,16 +15,18 @@ using TBF.BenchControl.Sequences; namespace TBF.BenchControl.ControlBoard.Uni { - public class CBoard : ComponentBase, IControlBoard, SchematicDrawing.IDrawingItCmpntWithMeasuredVal + public class UniCB : ComponentBase, IControlBoard, SchematicDrawing.IDrawingItCmpntWithMeasuredVal { - private static readonly ILog log = LogManager.GetLogger(typeof(CBoard)); - public override string ToString() { return string.Format("CBoard({0})", cBoardCfg != null ? cBoardCfg.ToString(1) : string.Empty); } + private static readonly ILog log = LogManager.GetLogger(typeof(UniCB)); + public override string ToString() { return string.Format("CBoard({0})", cbCfg != null ? cbCfg.ToString(1) : string.Empty); } - /// TBF component configuration - readonly CBoardCfg cBoardCfg; + /// TBF component configuration and useful wrappers + readonly UniCBCfg cbCfg; + string comPort { get { return string.Format("COM{0}", cbCfg.ComPortNr); } } + short config { get { return (short)((cbCfg.DrainValvesCount << 8) + ((cbCfg.DivertersCount - 1) << 3) + cbCfg.RegValvesCount - 4); } } /// IDrawingItCmpnt interface implementation - public SchematicDrawing.IDrawingItem DrawingItem { get { return cBoardCfg as SchematicDrawing.IDrawingItem; } } + public SchematicDrawing.IDrawingItem DrawingItem { get { return cbCfg as SchematicDrawing.IDrawingItem; } } public double MeasuredVal { get { return 0.1; } } @@ -65,10 +67,11 @@ namespace TBF.BenchControl.ControlBoard.Uni } } - /// Wrappers - int comPortNr { get { return cBoardCfg.ComPortNr; } } - int virtValvesRngLo { get { return cBoardCfg.VirtValvesRangeLo; } } - int virtValvesRngHi { get { return cBoardCfg.VirtValvesRangeHi; } } + /// Uni CB state + UInt32 currentOutputs; + bool outputsInitialized; + DateTime lastOutputsChange; + int lastStateMachineTime = 0; /// Propagated from configurations of other components @@ -85,7 +88,7 @@ namespace TBF.BenchControl.ControlBoard.Uni int rcvdBytesCount; /// Count of valid bytes in rcvdData buffer /// Message queue - Queue msgQueue; + Queue scheduledActionQueue; /// Received data public GeneralData Data; @@ -143,7 +146,7 @@ namespace TBF.BenchControl.ControlBoard.Uni /// Constructor for user interfaces (change settings only). /// Initialize(), RunDeviceXY() and StopDevice() methods of the created object will not be called. /// - public CBoard() + public UniCB() { devices = new OutputPath(string.Empty, 0); } @@ -151,7 +154,7 @@ namespace TBF.BenchControl.ControlBoard.Uni /// /// Constructor invoked when starting the test bench and creating components. /// - public CBoard(Generic.IComponentCfg cfg) + public UniCB(Generic.IComponentCfg cfg) : base(cfg) { #if DEBUG @@ -163,10 +166,10 @@ namespace TBF.BenchControl.ControlBoard.Uni Debug.WriteLine(string.Format("{0} ... {1}", e, ((int)e))); } #endif - cBoardCfg = cfg as CBoardCfg; + cbCfg = cfg as UniCBCfg; devices = new OutputPath(string.Empty, 0); - msgQueue = new Queue(); + scheduledActionQueue = new Queue(); Data = new GeneralData(); divTransitionData = null; @@ -182,7 +185,7 @@ namespace TBF.BenchControl.ControlBoard.Uni routeMask = 0; for (int i = 0; i < 128; i++) { - if (i < cBoardCfg.VirtValvesRangeLo || i > cBoardCfg.VirtValvesRangeHi) + if (i < cbCfg.VirtValvesRangeLo || i > cbCfg.VirtValvesRangeHi) { routeMask = routeMask | ((UInt128)1 << i); } @@ -221,13 +224,13 @@ namespace TBF.BenchControl.ControlBoard.Uni /// public void Initialize() { - if (cBoardCfg.DebugLevel != DebugMode.Normal) + if (cbCfg.DebugLevel != DebugMode.Normal) { log.FatalFormat("{0} - Device simulated", Name); return; } - serialPort = new SerialPort(string.Format("COM{0}", comPortNr), 9600, Parity.None, 8, StopBits.One); + serialPort = new SerialPort(comPort, 9600, Parity.None, 8, StopBits.One); serialPort.DtrEnable = true; serialPort.WriteTimeout = 4000; serialPort.ParityReplace = 0xFF; @@ -241,7 +244,7 @@ namespace TBF.BenchControl.ControlBoard.Uni /// public void RunDeviceBefore() { - if (cBoardCfg.DebugLevel != DebugMode.Normal || serialPort == null || !serialPort.IsOpen) return; + if (cbCfg.DebugLevel != DebugMode.Normal || serialPort == null || !serialPort.IsOpen) return; /// Read new received bytes and append them to a buffer int bytesCount = serialPort.BytesToRead; @@ -330,8 +333,9 @@ namespace TBF.BenchControl.ControlBoard.Uni /// public void RunDeviceAfter() { - if (cBoardCfg.DebugLevel != DebugMode.Normal) return; + if (cbCfg.DebugLevel != DebugMode.Normal) return; + /// Make sure the serial port is open if (serialPort == null || !serialPort.IsOpen) { /// Serial port is closed or does not exist => re-open the serial port @@ -339,7 +343,7 @@ namespace TBF.BenchControl.ControlBoard.Uni { if (serialPort == null) { - serialPort = new SerialPort(string.Format("COM{0}", comPortNr), 9600, Parity.None, 8, StopBits.One); + serialPort = new SerialPort(comPort, 9600, Parity.None, 8, StopBits.One); } serialPort.DtrEnable = true; serialPort.WriteTimeout = 4000; @@ -353,18 +357,20 @@ namespace TBF.BenchControl.ControlBoard.Uni } } - IOutputMessage message = (msgQueue.Count > 0) ? msgQueue.Dequeue() : OutputMessage.CreateDataRequestMsg(); + if (Data.Vystupy != (ulong)(benchModelRoute & 0xFFFFFFFFFFUL) || !outputsInitialized || (StateMachine.Time - lastStateMachineTime) >= 3) + { + scheduledActionQueue.Enqueue(Action.ChangeRoute((ulong)(benchModelRoute & 0xFFFFFFFFFFUL))); + } - byte[] outData = message.GetMessage(); + var combinedAction = Action.FetchNonConflictingActions(scheduledActionQueue); + + byte[] outData = OutputMessage.GetMessage(combinedAction, config); if (outData != null && outData.Length > 0) { serialPort.Write(outData, 0, outData.Length); - string s1 = message.ToString(); - string s2 = Telegram.LogTelegram("Message ", outData); - Debug.WriteLine(s1); - Debug.WriteLine(s2); - log.Debug(s1); - log.Debug(s2); + string s = Telegram.LogTelegram("Sent: ", outData); + Debug.WriteLine(s); + log.Debug(s); } ProcessData.UpdateMeasuredValuesAndSetpoints(); @@ -388,11 +394,35 @@ namespace TBF.BenchControl.ControlBoard.Uni /// /// Interface functions /// - public void UpdateUI(string sParam, int iParam, double value) { } public void ClearProcessValues() { } - public double TestTimeWM(int wmNr1) { return 0; } - public int RefPulsesWM(int wmNr1) { return 0; } - public int PulsesWM(int wmNr1) { return 0; } + + public double TestTimeWM(int wmNr1) + { + if (wmNr1 >= 1 && wmNr1 < Data.ImpulseTime.Length) + { + return Data.ImpulseTime[wmNr1]; + } + return 0; + } + + public int RefPulsesWM(int wmNr1) + { + if (wmNr1 >= 1 && wmNr1 < Data.EtPulses.Length) + { + return Data.EtPulses[wmNr1]; + } + return 0; + } + + public int PulsesWM(int wmNr1) + { + if (wmNr1 >= 1 && wmNr1 < Data.WMeterPuls.Length) + { + return Data.WMeterPuls[wmNr1]; + } + return 0; + } + public UInt128 SetValves(UInt128 valvesToOpen, UInt128 valvesToClose, IList extendedValves) { UInt128 oldRoute = benchModelRoute; @@ -411,11 +441,13 @@ namespace TBF.BenchControl.ControlBoard.Uni public IOperation SetFlowOp(double flowLimLo, double flowLimHi, TBF.Boxes.DoubleBox measuredFlow, int timeout) { //var msg = new OutputMessage(Command.Start, ); + // scheduledActionQueue.Enqueue(Action.Stop()); return null; } public IOperation StopFlowRegulationOp() { + //scheduledActionQueue.Enqueue(Action.Stop()); return null; } @@ -461,9 +493,9 @@ namespace TBF.BenchControl.ControlBoard.Uni /// Valve to be opened /// Valve to be closed /// Newly created operation instance reference casted to IOperaton - public IOperation SetValvesOp(IValve valveToOpen, IValve valveToClose) + public IOperation SetValvesOp(IValve valveOpen, IValve valveClose) { - return null; + return new BuiltIn.SetValvesOp(this, valveOpen, valveClose); } /// @@ -473,9 +505,9 @@ namespace TBF.BenchControl.ControlBoard.Uni /// A list of valves to be opened /// A list of valves to be closed /// Newly created operation instance reference casted to IOperaton - public IOperation SetValvesOp(IList valvesToOpen, IList valvesToClose) + public IOperation SetValvesOp(IList valvesOpen, IList valvesClose) { - return null; + return new BuiltIn.SetValvesOp(this, valvesOpen, valvesClose); } /// @@ -485,7 +517,7 @@ namespace TBF.BenchControl.ControlBoard.Uni /// Created operation public IOperation OpenStartValveOp() { - return null; + return new BuiltIn.SetValvesOp(this, true, devices); } /// @@ -495,21 +527,24 @@ namespace TBF.BenchControl.ControlBoard.Uni /// Created operation public IOperation CloseStartValveOp() { - return null; + return new BuiltIn.SetValvesOp(this, false, devices); } #endregion public void DiverterToTank(int divNr1) { + scheduledActionQueue.Enqueue(Action.SwitchDiverter(divNr1, true)); } public void DiverterToSink(int divNr1) { + scheduledActionQueue.Enqueue(Action.SwitchDiverter(divNr1, false)); } public void ReadDiverterTransition(int divNr1) { + /// TODO } } } diff --git a/TBF/BenchControl/ControlBoard/Uni/CBoardCfg.cs b/TBF/BenchControl/ControlBoard/Uni/UniCBCfg.cs similarity index 63% rename from TBF/BenchControl/ControlBoard/Uni/CBoardCfg.cs rename to TBF/BenchControl/ControlBoard/Uni/UniCBCfg.cs index 425fd911f..d7b2c61b9 100644 --- a/TBF/BenchControl/ControlBoard/Uni/CBoardCfg.cs +++ b/TBF/BenchControl/ControlBoard/Uni/UniCBCfg.cs @@ -13,9 +13,9 @@ namespace TBF.BenchControl.ControlBoard.Uni /// /// Holds backup and security options - serializable configuration. /// - public class CBoardCfg : ComponentCfgBase, Generic.IComponentCfg, Config.Entities.IParamsProvider, IDrawingItemWithMeasuredVal + public class UniCBCfg : ComponentCfgBase, Generic.IComponentCfg, Config.Entities.IParamsProvider, IDrawingItemWithMeasuredVal { - public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(CBoardCfg) })[0]; + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(UniCBCfg) })[0]; public override XmlSerializer GetSerializer() { return Serializer; } public IComponentCfgCtrl GetControl(IList cmpntEntities) { return new Configs.ParamsProvider.ComponentCfgCtrl(this, null); } @@ -24,6 +24,9 @@ namespace TBF.BenchControl.ControlBoard.Uni /// Serialized parameters /// public int ComPortNr; + public int DivertersCount; + public int DrainValvesCount; + public int RegValvesCount; public int VirtValvesRangeLo; public int VirtValvesRangeHi; @@ -51,13 +54,13 @@ namespace TBF.BenchControl.ControlBoard.Uni public IList EdgesToSet { get; set; } /// Private parameterless constructor invoked by all other (public) constructors - CBoardCfg() + UniCBCfg() { GNodes = new List(); EdgesToSet = new List(); } - public CBoardCfg(string name, IComponentFactory factory) + public UniCBCfg(string name, IComponentFactory factory) : this() { Shape = Shape.UniCB; @@ -81,6 +84,9 @@ namespace TBF.BenchControl.ControlBoard.Uni string[] paramNames = new string[] { "Serial port number", + "Diverters count (1..5)", + "Drain valves count (0..8)", + "Regulation valves count (4..8)", "Virtual valves range LO [bit#]", "Virtual valves range HI [bit#]", }; @@ -102,8 +108,11 @@ namespace TBF.BenchControl.ControlBoard.Uni switch (i) { case 0: return ComPortNr.ToString(); - case 1: return VirtValvesRangeLo.ToString(); - case 2: return VirtValvesRangeHi.ToString(); + case 1: return DivertersCount.ToString(); + case 2: return DrainValvesCount.ToString(); + case 3: return RegValvesCount.ToString(); + case 4: return VirtValvesRangeLo.ToString(); + case 5: return VirtValvesRangeHi.ToString(); default: return string.Empty; } } @@ -112,9 +121,12 @@ namespace TBF.BenchControl.ControlBoard.Uni { switch (i) { - case 0: ComPortNr = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd; - case 1: VirtValvesRangeLo = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd; - case 2: VirtValvesRangeHi = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd; + case 0: ComPortNr = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd; + case 1: DivertersCount = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd; + case 2: DrainValvesCount = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd; + case 3: RegValvesCount = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd; + case 4: VirtValvesRangeLo = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd; + case 5: VirtValvesRangeHi = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd; default: return CfgUpdateFlags.None; } } @@ -122,18 +134,25 @@ namespace TBF.BenchControl.ControlBoard.Uni public bool ValidateParam(int i, string strValue, out string message) { message = string.Empty; - int dummy; + int n; switch (i) { case 0: - /// Real number between 800 and 1200 kg/m3 expected - if (int.TryParse(strValue, out dummy) && (dummy >= 1) && (dummy <= 1000)) return true; + if (int.TryParse(strValue, out n) && (n >= 1)) return true; break; case 1: + if (int.TryParse(strValue, out n) && (n >= 1) && n <= 5) return true; + break; case 2: - /// Real number above 0 expected - if (int.TryParse(strValue, out dummy) && (dummy >= 0) && dummy <= 127) return true; + if (int.TryParse(strValue, out n) && (n >= 0) && n <= 8) return true; + break; + case 3: + if (int.TryParse(strValue, out n) && (n >= 4) && n <= 8) return true; + break; + case 4: + case 5: + if (int.TryParse(strValue, out n) && (n >= 0) && n <= 127) return true; break; default: message = "Invalid index"; @@ -144,16 +163,19 @@ namespace TBF.BenchControl.ControlBoard.Uni return false; } - void CopyContentTo(CBoardCfg prms) + void CopyContentTo(UniCBCfg prms) { - prms.ComPortNr = this.ComPortNr; - prms.VirtValvesRangeLo = this.VirtValvesRangeLo; - prms.VirtValvesRangeHi = this.VirtValvesRangeHi; + prms.ComPortNr = ComPortNr; + prms.DivertersCount = DivertersCount; + prms.DrainValvesCount = DrainValvesCount; + prms.RegValvesCount = RegValvesCount; + prms.VirtValvesRangeLo = VirtValvesRangeLo; + prms.VirtValvesRangeHi = VirtValvesRangeHi; } public Config.Entities.IParamsProvider Clone() { - var pars = new CBoardCfg(); + var pars = new UniCBCfg(); CopyContentTo(pars); return pars; } diff --git a/TBF/BenchControl/ControlBoard/Uni/ValveMoveMsg.cs b/TBF/BenchControl/ControlBoard/Uni/ValveMoveMsg.cs index a50787f7f..5072a4307 100644 --- a/TBF/BenchControl/ControlBoard/Uni/ValveMoveMsg.cs +++ b/TBF/BenchControl/ControlBoard/Uni/ValveMoveMsg.cs @@ -6,7 +6,7 @@ using System.Diagnostics; namespace TBF.BenchControl.ControlBoard.Uni { - class ValveMoveMsg : IOutputMessage + class ValveMoveMsg { public int PayloadLen { get { return 38; } } public byte MessageCode { get { return 0x20; } } diff --git a/TBF/BenchControl/Modbus/Easytherm/Easytherm.cs b/TBF/BenchControl/Modbus/Easytherm/Easytherm.cs index 319a76a84..fe5d2bd9e 100644 --- a/TBF/BenchControl/Modbus/Easytherm/Easytherm.cs +++ b/TBF/BenchControl/Modbus/Easytherm/Easytherm.cs @@ -76,7 +76,9 @@ namespace TBF.BenchControl.Modbus.Easytherm if (easythermCfg.ReservoirNr > 0 && easythermCfg.ReservoirNr <= 3) { - StateMachine.ControlBoard.UpdateUI("ReservoirTemp", easythermCfg.ReservoirNr, actualTemperature); + // TODO: Reimplement IControlBoard.UpradateUI() + // + // StateMachine.ControlBoard.UpdateUI("ReservoirTemp", easythermCfg.ReservoirNr, actualTemperature); } } } diff --git a/TBF/BenchControl/TbfComponents.cs b/TBF/BenchControl/TbfComponents.cs index aa1d75e04..c810795e8 100644 --- a/TBF/BenchControl/TbfComponents.cs +++ b/TBF/BenchControl/TbfComponents.cs @@ -17,7 +17,7 @@ namespace TBF.BenchControl Factories.Add(new Ambient.Comet.Factory()); Factories.Add(new Ambient.Greco.Factory()); - Factories.Add(new ControlBoard.Papouch.CBoardFactory()); + Factories.Add(new ControlBoard.Papouch.Factory()); Factories.Add(new ControlBoard.Uni.Factory()); Factories.Add(new DataContainer.BackupAndSecurityOptions.Factory()); Factories.Add(new DataContainer.BenchInfo.Factory()); diff --git a/TBF/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs b/TBF/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs index bab1c148e..f8db02766 100644 --- a/TBF/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs +++ b/TBF/BenchControl/TestMethods/Adjustment/AdjustmentSeq.cs @@ -26,7 +26,7 @@ namespace TBF.BenchControl.TestMethods.Adjustment public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); diff --git a/TBF/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs b/TBF/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs index 5bb1a58f1..813762075 100644 --- a/TBF/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs +++ b/TBF/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs @@ -27,7 +27,7 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); diff --git a/TBF/BenchControl/TestMethods/DiverterTest/DiverterTestSeq.cs b/TBF/BenchControl/TestMethods/DiverterTest/DiverterTestSeq.cs index c30897135..7d76fd9ce 100644 --- a/TBF/BenchControl/TestMethods/DiverterTest/DiverterTestSeq.cs +++ b/TBF/BenchControl/TestMethods/DiverterTest/DiverterTestSeq.cs @@ -25,7 +25,7 @@ namespace TBF.BenchControl.TestMethods.DiverterTest public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); diff --git a/TBF/BenchControl/TestMethods/FixedStart/FixedStartSeq.cs b/TBF/BenchControl/TestMethods/FixedStart/FixedStartSeq.cs index 6f57b76cd..afa6adf01 100644 --- a/TBF/BenchControl/TestMethods/FixedStart/FixedStartSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStart/FixedStartSeq.cs @@ -23,7 +23,7 @@ namespace TBF.BenchControl.TestMethods.FixedStart public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); diff --git a/TBF/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs b/TBF/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs index a1ebfe7e0..e54c8fc0c 100644 --- a/TBF/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs @@ -25,8 +25,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Papouch.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Papouch.PapouchCB) && + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); diff --git a/TBF/BenchControl/TestMethods/FixedStartDeferredEval/FixedStartDeferredEvalSeq.cs b/TBF/BenchControl/TestMethods/FixedStartDeferredEval/FixedStartDeferredEvalSeq.cs index 1b072a4af..09a528070 100644 --- a/TBF/BenchControl/TestMethods/FixedStartDeferredEval/FixedStartDeferredEvalSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartDeferredEval/FixedStartDeferredEvalSeq.cs @@ -26,7 +26,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEval public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/FixedStartMassCollAdvancedSeq.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/FixedStartMassCollAdvancedSeq.cs index 29b00cd56..065925b0c 100644 --- a/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/FixedStartMassCollAdvancedSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollAdvanced/FixedStartMassCollAdvancedSeq.cs @@ -23,8 +23,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollAdvanced public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Papouch.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Papouch.PapouchCB) && + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); @@ -865,7 +865,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollAdvanced tstRslt.Buoyancy = buoyancy; tstRslt.VolumeCTV = volumeCTV; /// [l] 1000.0f is because density is in [kg/m3] - if (cBrd is ControlBoard.Papouch.CBoard) + if (cBrd is ControlBoard.Papouch.PapouchCB) { /// Test bench with Papouch control board without reference flow meter tstRslt.VolumeMaster = volumeCTV; /// [l] volume from the master flow meter diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/FixedStartMassCollDeferredEvalSeq.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/FixedStartMassCollDeferredEvalSeq.cs index 6d8d279f9..acba0dd70 100644 --- a/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/FixedStartMassCollDeferredEvalSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollDeferredEval/FixedStartMassCollDeferredEvalSeq.cs @@ -26,7 +26,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollDeferredEval public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs index 5ccb35440..b27fc79b3 100644 --- a/TBF/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs @@ -23,8 +23,8 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Papouch.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Papouch.PapouchCB) && + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); @@ -1027,7 +1027,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection tstRslt.Buoyancy = buoyancy; tstRslt.VolumeCTV = volumeCTV; /// [l] 1000.0f is because density is in [kg/m3] - if (cBrd is ControlBoard.Papouch.CBoard) + if (cBrd is ControlBoard.Papouch.PapouchCB) { /// Test bench with Papouch control board without reference flow meter tstRslt.VolumeMaster = volumeCTV; /// [l] volume from the master flow meter diff --git a/TBF/BenchControl/TestMethods/FixedStartTankCollection/FixedStartTankCollectionSeq.cs b/TBF/BenchControl/TestMethods/FixedStartTankCollection/FixedStartTankCollectionSeq.cs index 595122077..d5d0ed921 100644 --- a/TBF/BenchControl/TestMethods/FixedStartTankCollection/FixedStartTankCollectionSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartTankCollection/FixedStartTankCollectionSeq.cs @@ -24,7 +24,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartTankCollection public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); diff --git a/TBF/BenchControl/TestMethods/FlowAdjustment/FlowAdjustmentSeq.cs b/TBF/BenchControl/TestMethods/FlowAdjustment/FlowAdjustmentSeq.cs index 5aaa1ff77..76fb3fd3d 100644 --- a/TBF/BenchControl/TestMethods/FlowAdjustment/FlowAdjustmentSeq.cs +++ b/TBF/BenchControl/TestMethods/FlowAdjustment/FlowAdjustmentSeq.cs @@ -25,8 +25,8 @@ namespace TBF.BenchControl.TestMethods.FlowAdjustment public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Papouch.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Papouch.PapouchCB) && + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); diff --git a/TBF/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs b/TBF/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs index 1443ea6e6..781db9b9e 100644 --- a/TBF/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs +++ b/TBF/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs @@ -25,7 +25,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); diff --git a/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs b/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs index dbbc90402..7eee3b464 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs @@ -25,7 +25,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); diff --git a/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/FlyingStartMassCollComparativeSeq.cs b/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/FlyingStartMassCollComparativeSeq.cs index 916558331..d02c86096 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/FlyingStartMassCollComparativeSeq.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartMassCollComparative/FlyingStartMassCollComparativeSeq.cs @@ -25,7 +25,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollComparative public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); diff --git a/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/FlyingStartMassCollProlongedSeq.cs b/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/FlyingStartMassCollProlongedSeq.cs index 9eb0660ca..4b20ed341 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/FlyingStartMassCollProlongedSeq.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartMassCollProlonged/FlyingStartMassCollProlongedSeq.cs @@ -23,7 +23,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollProlonged public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); diff --git a/TBF/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs b/TBF/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs index 04ff78422..25c6e1974 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs @@ -25,7 +25,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); diff --git a/TBF/BenchControl/TestMethods/FlyingStartTankCollection/FlyingStartTankCollectionSeq.cs b/TBF/BenchControl/TestMethods/FlyingStartTankCollection/FlyingStartTankCollectionSeq.cs index 104a3409a..44aacf758 100644 --- a/TBF/BenchControl/TestMethods/FlyingStartTankCollection/FlyingStartTankCollectionSeq.cs +++ b/TBF/BenchControl/TestMethods/FlyingStartTankCollection/FlyingStartTankCollectionSeq.cs @@ -23,7 +23,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartTankCollection public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); diff --git a/TBF/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs b/TBF/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs index 0585771e6..bb05bcb64 100644 --- a/TBF/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs +++ b/TBF/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs @@ -26,8 +26,8 @@ namespace TBF.BenchControl.TestMethods.LeakTest public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Papouch.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Papouch.PapouchCB) && + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); diff --git a/TBF/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs b/TBF/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs index 408a34319..cda15c6ab 100644 --- a/TBF/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs +++ b/TBF/BenchControl/TestMethods/PMaxTest/PMaxTestSeq.cs @@ -25,8 +25,8 @@ namespace TBF.BenchControl.TestMethods.PMaxTest public static bool CheckDeviceCaps(Config.Entities.Test test, OutputPath devices, out string message) { if (!(StateMachine.ControlBoard is ControlBoard.Legacy.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Papouch.CBoard) && - !(StateMachine.ControlBoard is ControlBoard.Uni.CBoard)) + !(StateMachine.ControlBoard is ControlBoard.Papouch.PapouchCB) && + !(StateMachine.ControlBoard is ControlBoard.Uni.UniCB)) { /// Control board does not support this method message = string.Format("{0}: {1}", test.Name, Strings.Test_bench_does_not_suport_selected_test_method); diff --git a/TBF/BenchControl/Uni/Diverter/Diverter.cs b/TBF/BenchControl/Uni/Diverter/Diverter.cs index 33f2cb5bd..208a5d62f 100644 --- a/TBF/BenchControl/Uni/Diverter/Diverter.cs +++ b/TBF/BenchControl/Uni/Diverter/Diverter.cs @@ -32,7 +32,7 @@ namespace TBF.BenchControl.Uni.Diverter readonly DiverterCfg diverterCfg; public SchematicDrawing.IDrawingItem DrawingItem { get { return diverterCfg as SchematicDrawing.IDrawingItem; } } - readonly CBoard cBoard; + readonly UniCB cBoard; readonly UInt128 mask; /// derived from bitPosition in the constructor public int DiverterNr { get { return diverterCfg.DivNr1; } } /// 1-based public diverter number @@ -70,7 +70,7 @@ namespace TBF.BenchControl.Uni.Diverter { diverterCfg = cfg as DiverterCfg; - cBoard = TbfComponents.FindComponent(cfg.ParentName, components) as CBoard; + cBoard = TbfComponents.FindComponent(cfg.ParentName, components) as UniCB; if (cBoard == null) throw new Exception("Cannot find " + Name + " parent"); if (cfg.DebugLevel != Config.Entities.DebugMode.Off) diff --git a/TBF/BenchControl/Uni/Diverter/SwitchDiverterOp.cs b/TBF/BenchControl/Uni/Diverter/SwitchDiverterOp.cs index d3b587836..3ef255662 100644 --- a/TBF/BenchControl/Uni/Diverter/SwitchDiverterOp.cs +++ b/TBF/BenchControl/Uni/Diverter/SwitchDiverterOp.cs @@ -5,11 +5,11 @@ namespace TBF.BenchControl.Uni.Diverter { public class SwitchDiverterOp : IOperation { - TBF.BenchControl.ControlBoard.Uni.CBoard cBoard; + TBF.BenchControl.ControlBoard.Uni.UniCB cBoard; bool toTank; int diverterNr; /// 1 .. 5 - public SwitchDiverterOp(TBF.BenchControl.ControlBoard.Uni.CBoard cBoard, bool toTank, int diverterNr) + public SwitchDiverterOp(TBF.BenchControl.ControlBoard.Uni.UniCB cBoard, bool toTank, int diverterNr) { this.cBoard = cBoard; this.toTank = toTank; diff --git a/TBF/BenchControl/Uni/FlowMeter/FlowMeter.cs b/TBF/BenchControl/Uni/FlowMeter/FlowMeter.cs index 07881246b..23e30f48f 100644 --- a/TBF/BenchControl/Uni/FlowMeter/FlowMeter.cs +++ b/TBF/BenchControl/Uni/FlowMeter/FlowMeter.cs @@ -19,7 +19,7 @@ namespace TBF.BenchControl.Uni.FlowMeter readonly FlowMeterCfg flowMeterCfg; public SchematicDrawing.IDrawingItem DrawingItem { get { return flowMeterCfg as SchematicDrawing.IDrawingItem; } } - readonly CBoard cBoard; + readonly UniCB cBoard; public double MeasuredVal { get { return 0.345; } } public string AltString { get { return string.Format("Calibration expires on {0:dd.MM.yyyy}", flowMeterCfg.CalibValidDate); } } @@ -57,7 +57,7 @@ namespace TBF.BenchControl.Uni.FlowMeter { flowMeterCfg = cfg as FlowMeterCfg; - cBoard = TbfComponents.FindComponent(cfg.ParentName, components) as CBoard; + cBoard = TbfComponents.FindComponent(cfg.ParentName, components) as UniCB; if (cBoard == null) throw new Exception(string.Format("Cannot find {0} (a parent of {1})", cfg.ParentName, Name)); log.Warn(this.ToString()); diff --git a/TBF/BenchControl/Uni/RegValve/RegValve.cs b/TBF/BenchControl/Uni/RegValve/RegValve.cs index 2bad86cd3..c1999529c 100644 --- a/TBF/BenchControl/Uni/RegValve/RegValve.cs +++ b/TBF/BenchControl/Uni/RegValve/RegValve.cs @@ -23,7 +23,7 @@ namespace TBF.BenchControl.Uni.RegValve IDictionary dict; public IDictionary Dict { get { return dict; } } - readonly CBoard cBoard; + readonly UniCB cBoard; public ValveCategory Category { get { return regValveCfg.Category; } } public int Idx1 { get { return regValveCfg.Idx1; } } /// 1..7 @@ -134,7 +134,7 @@ namespace TBF.BenchControl.Uni.RegValve { regValveCfg = cfg as RegValveCfg; - this.cBoard = TbfComponents.FindComponent(cfg.ParentName, components) as CBoard; + this.cBoard = TbfComponents.FindComponent(cfg.ParentName, components) as UniCB; if (this.cBoard == null) throw new Exception(string.Format("Cannot find {0} (a parent of {1})", cfg.ParentName, Name)); this.dict = new Dictionary(); diff --git a/TBF/BenchControl/Uni/RegValve/SetFlowOp.cs b/TBF/BenchControl/Uni/RegValve/SetFlowOp.cs index 92d84e114..07e6d28c0 100644 --- a/TBF/BenchControl/Uni/RegValve/SetFlowOp.cs +++ b/TBF/BenchControl/Uni/RegValve/SetFlowOp.cs @@ -19,7 +19,7 @@ namespace TBF.BenchControl.Uni.RegValve } /// Set by the constructor - readonly CBoard cBoard; + readonly UniCB cBoard; readonly RegValve regV; readonly int regulValveNr; readonly IFlowMeter flowMeter; @@ -78,7 +78,7 @@ namespace TBF.BenchControl.Uni.RegValve /// Timeout for the flow setting in [s] /// true = Leave the measurement running after op. stop /// Only Elde.Valve flow are used, other flow on the lists are ignored - public SetFlowOp(CBoard cBoard, IRegulValve regValve, IFlowMeter flowMeter, double targetFlowLo, double targetFlowHi, + public SetFlowOp(UniCB cBoard, IRegulValve regValve, IFlowMeter flowMeter, double targetFlowLo, double targetFlowHi, DoubleBox flowBox, bool reTryCmds, int timeout, bool leaveMeasurementRunning) { this.cBoard = cBoard; @@ -113,7 +113,7 @@ namespace TBF.BenchControl.Uni.RegValve /// Set required water flow - Do not leave the measurement running. /// Events: FlowSet /// - public SetFlowOp(CBoard cBoard, IRegulValve regValve, IFlowMeter flowMeter, double targetFlowLo, double targetFlowHi, + public SetFlowOp(UniCB cBoard, IRegulValve regValve, IFlowMeter flowMeter, double targetFlowLo, double targetFlowHi, DoubleBox flowbox, bool reTryCmds, int timeout) : this(cBoard, regValve, flowMeter, targetFlowLo, targetFlowHi, flowbox, reTryCmds, timeout, false) { @@ -123,7 +123,7 @@ namespace TBF.BenchControl.Uni.RegValve /// Set required water flow - No timeout. /// Events: FlowSet /// - public SetFlowOp(CBoard cBoard, IRegulValve regValve, IFlowMeter flowMeter, double targetFlowLo, double targetFlowHi, + public SetFlowOp(UniCB cBoard, IRegulValve regValve, IFlowMeter flowMeter, double targetFlowLo, double targetFlowHi, DoubleBox flowbox, bool reTryCmds) : this(cBoard, regValve, flowMeter, targetFlowLo, targetFlowHi, flowbox, reTryCmds, int.MaxValue, false) { diff --git a/TBF/BenchControl/Uni/RegValve/SetRegValvePositionOp.cs b/TBF/BenchControl/Uni/RegValve/SetRegValvePositionOp.cs index 42e5908db..e75ef9c6a 100644 --- a/TBF/BenchControl/Uni/RegValve/SetRegValvePositionOp.cs +++ b/TBF/BenchControl/Uni/RegValve/SetRegValvePositionOp.cs @@ -32,7 +32,7 @@ namespace TBF.BenchControl.Uni.RegValve OpState opState; /// Set by the constructor - readonly CBoard cBoard; + readonly UniCB cBoard; readonly RegValve regV; readonly int regValveNr; readonly float posLoPct; @@ -54,7 +54,7 @@ namespace TBF.BenchControl.Uni.RegValve /// Upper limit of the position to be achieved /// Timeout in sec. for setting the flow /// Only Elde.Valve flow are used, other flow on the lists are ignored - public SetRegValvePositionOp(CBoard cBoard, RegValve regValve, float posLoPct, float posHiPct, int timeout) + public SetRegValvePositionOp(UniCB cBoard, RegValve regValve, float posLoPct, float posHiPct, int timeout) { this.cBoard = cBoard; if (this.cBoard == null) throw new ArgumentNullException("ctrlBoard"); @@ -75,7 +75,7 @@ namespace TBF.BenchControl.Uni.RegValve /// Set required water flow - no timeout. /// Events: FlowSet /// - public SetRegValvePositionOp(CBoard cBoard, RegValve regValve, float posLoPct, float posHiPct) + public SetRegValvePositionOp(UniCB cBoard, RegValve regValve, float posLoPct, float posHiPct) : this(cBoard, regValve, posLoPct, posHiPct, int.MaxValue) { } diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index d8a69ca20..c613c261c 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("3.1.1599.0")] -[assembly: AssemblyFileVersion("3.1.1599.0")] +[assembly: AssemblyVersion("3.1.1601.0")] +[assembly: AssemblyFileVersion("3.1.1601.0")] diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index 47a24ea03..928e9ccd2 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -217,23 +217,23 @@ - - + + UserControl CBoardCfgCtrl.cs - - - + + + + - diff --git a/UniControlBoardTest/UniCBTestDlg.cs b/UniControlBoardTest/UniCBTestDlg.cs index 6ba24d4d0..0d7912bff 100644 --- a/UniControlBoardTest/UniCBTestDlg.cs +++ b/UniControlBoardTest/UniCBTestDlg.cs @@ -13,17 +13,17 @@ namespace UniControlBoardTest { private static readonly ILog log = LogManager.GetLogger(typeof(UniCBTestDlg)); - readonly CBoardCfg cBoardCfg; + readonly UniCBCfg cBoardCfg; Timer timer; - CBoard cBoard; + UniCB cBoard; bool connected; public UniCBTestDlg() { InitializeComponent(); - cBoardCfg = new CBoardCfg("CB", new Factory()); + cBoardCfg = new UniCBCfg("CB", new Factory()); /// Display serial port nr. n UI serialPortTextBox.Text = Program.LocalSettings.SerialPortNr.ToString(); @@ -102,7 +102,7 @@ namespace UniControlBoardTest try { cBoardCfg.ComPortNr = comPortNr; - cBoard = new CBoard(cBoardCfg as TBF.BenchControl.Generic.IComponentCfg); + cBoard = new UniCB(cBoardCfg as TBF.BenchControl.Generic.IComponentCfg); cBoard.Initialize(); PortConnected(); }