From 71517b6cdb2419a7833105f5b8868db97d480582 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Wed, 10 Nov 2021 14:03:10 +0100 Subject: [PATCH] TBF.Rig.DataEntry.Double24 --- TBF/BenchControl/StateMachine.cs | 857 ++++++++++++++++++ .../BenchInfo/Extended/ComponentCfg.cs | 15 +- .../CycleBeginningForm.Designer.cs | 34 +- .../{Fewa => Double24}/CycleBeginningForm.cs | 59 +- .../CycleBeginningForm.resx | 737 ++++++++------- .../CycleEndForm.Designer.cs | 2 +- .../{Fewa => Double24}/CycleEndForm.cs | 4 +- .../{Fewa => Double24}/CycleEndForm.resx | 0 .../DataEntry/{Fewa => Double24}/EntryForm.cs | 4 +- TBF/Rig/DataEntry/Double24/EntryFormCfg.cs | 206 +++++ .../{Fewa => Double24}/EntryFormNoStartEnd.cs | 41 +- .../DataEntry/{Fewa => Double24}/Factory.cs | 8 +- .../{Fewa => Double24}/FactoryNoStartEnd.cs | 8 +- .../{Fewa => Double24}/TestStartEndForm.cs | 4 +- .../TestStartEndForm.designer.cs | 2 +- .../{Fewa => Double24}/TestStartEndForm.resx | 0 TBF/Rig/DataEntry/Fewa/EntryFormCfg.cs | 45 - TBF/Rig/DataEntry/Fewa/EntryFormCfgCtrl.cs | 84 -- .../Fewa/EntryFormCfgCtrl.designer.cs | 114 --- TBF/Rig/DataEntry/Fewa/EntryFormCfgCtrl.resx | 120 --- TBF/Rig/TbfComponents.cs | 4 +- TBF/TBF.csproj | 37 +- 22 files changed, 1627 insertions(+), 758 deletions(-) create mode 100644 TBF/BenchControl/StateMachine.cs rename TBF/Rig/DataEntry/{Fewa => Double24}/CycleBeginningForm.Designer.cs (97%) rename TBF/Rig/DataEntry/{Fewa => Double24}/CycleBeginningForm.cs (93%) rename TBF/Rig/DataEntry/{Fewa => Double24}/CycleBeginningForm.resx (92%) rename TBF/Rig/DataEntry/{Fewa => Double24}/CycleEndForm.Designer.cs (99%) rename TBF/Rig/DataEntry/{Fewa => Double24}/CycleEndForm.cs (98%) rename TBF/Rig/DataEntry/{Fewa => Double24}/CycleEndForm.resx (100%) rename TBF/Rig/DataEntry/{Fewa => Double24}/EntryForm.cs (73%) create mode 100644 TBF/Rig/DataEntry/Double24/EntryFormCfg.cs rename TBF/Rig/DataEntry/{Fewa => Double24}/EntryFormNoStartEnd.cs (83%) rename TBF/Rig/DataEntry/{Fewa => Double24}/Factory.cs (63%) rename TBF/Rig/DataEntry/{Fewa => Double24}/FactoryNoStartEnd.cs (62%) rename TBF/Rig/DataEntry/{Fewa => Double24}/TestStartEndForm.cs (99%) rename TBF/Rig/DataEntry/{Fewa => Double24}/TestStartEndForm.designer.cs (99%) rename TBF/Rig/DataEntry/{Fewa => Double24}/TestStartEndForm.resx (100%) delete mode 100644 TBF/Rig/DataEntry/Fewa/EntryFormCfg.cs delete mode 100644 TBF/Rig/DataEntry/Fewa/EntryFormCfgCtrl.cs delete mode 100644 TBF/Rig/DataEntry/Fewa/EntryFormCfgCtrl.designer.cs delete mode 100644 TBF/Rig/DataEntry/Fewa/EntryFormCfgCtrl.resx diff --git a/TBF/BenchControl/StateMachine.cs b/TBF/BenchControl/StateMachine.cs new file mode 100644 index 000000000..db7c3c54f --- /dev/null +++ b/TBF/BenchControl/StateMachine.cs @@ -0,0 +1,857 @@ +/// +/// Copyright (c) 2013-2021 Sensus Slovensko a.s. +/// +using System; +using System.Text; +using System.Threading; +using System.Collections.Generic; +using log4net; +using NHibernate; +using Common; +using Config.Entities; +using TBF.BenchControl.Generic; +using TBF.BenchControl.GenericDevices; +using TBF.BenchControl.Sequences; +using Dirichlet.Numerics; +using TBF.Resources; + +namespace TBF.BenchControl +{ + public enum MachineState + { + Undefined = 0, + Disabled, + StartingUp, /// Start-up: Initialize() of all devices + start of the worker thread + FailedToStart, /// Most likely Initialize() of any device thrown an exception + Running, /// RunDeviceBefore() and RunDeviceAfter() of all devices, Start()/Run()/Stop() of operations + ShuttingDown, /// Shutdown: StopDevice() and StopDevice2() of all devices + Off, /// Off after the shutdown + } + + + /// + /// This class controls real test bench behavior. + /// It is based on a state machine + /// + public static class StateMachine + { + private static readonly ILog log = LogManager.GetLogger(typeof(StateMachine)); + private static readonly ILog wlog = LogManager.GetLogger(typeof(StateMachine)); + + /// Private devices and components + static IList components; /// list of all components + static IList devices; /// list of devices + /// + /// Bench paths + static IList feedingPaths; + static IList benchPaths; + static IList outputPaths; + static IList metersPaths; + static IList heatMetersPaths; + public static IList TransitionSequences; + public static IList TransitionSteps; + + /// Public components + public static Elde.ControlBoardDev ControlBoard; + public static GenericDevices.IAmbient Ambient; + public static IOperation BenchWaitingOp; + public static IOperation BenchErrorOp; + public static GenericDevices.IScaleOrTank Tank1; + public static GenericDevices.IScaleOrTank Tank2; + public static GenericDevices.IScaleOrTank Tank3; + public static GenericDevices.IValve DrainValve1; + public static GenericDevices.IValve DrainValve2; + public static GenericDevices.IValve DrainValve3; + public static IList MasterValves; /// list of directly controlled valves + public static IList CoupledValves; /// list of coupled valves + public static IList ExtendedValves; /// list of extended valves + + public static IList LoopStartNames; + public static IList LoopEndNames; + + /// Time and synchronization +#if TURA_IPERL || TURA_IPERL_NEW + public const int Period = 2; /// State machine period in sec. +#else + public const int Period = 1; /// State machine period in sec. +#endif + + static DateTime startDateTime; /// DateTime of time instance when the state machine worker thread starts + static int currentTimeSec; /// Time from the start of the state machine in seconds + + public static MachineState MachineState; /// see enum MachineState for explanation + + /// Worker thread and database session + static Thread workerThread; + + static IList states; /// list of states + + public static DateTime CycleStartTimeStamp; + + public static IList DefaultValvesOpen + { + get + { + return GenericDevices.ValveBase.Merge( + Utils.ValvesOpen((feedingPaths != null && feedingPaths.Count > 0) ? feedingPaths[0] : null), + Utils.ValvesOpen((benchPaths != null && benchPaths.Count > 0) ? benchPaths[0] : null), + Utils.ValvesOpen((outputPaths != null && outputPaths.Count > 0) ? outputPaths[0] : null) + ); + } + } + + public static IList DefaultValvesClose + { + get + { + return GenericDevices.ValveBase.Merge( + Utils.ValvesClose((feedingPaths != null && feedingPaths.Count > 0) ? feedingPaths[0] : null), + Utils.ValvesClose((benchPaths != null && benchPaths.Count > 0) ? benchPaths[0] : null), + Utils.ValvesClose((outputPaths != null && outputPaths.Count > 0) ? outputPaths[0] : null) + ); + } + } + + /// + /// Loaded by LoadProcedure() or IOperation LoadProcedureOp(...) + /// + public static Procedure Procedure; /// Procedure + public static TestInstance[] TestInstances; /// Tests + public static bool IsRemoteProcedure; + + + /// Hardware devices connected to the PC controlling the bench. + public static IList Components { get { return components; } } + public static IList Devices { get { return devices; } } + + /// + /// DateTime of time instance when the state machine worker thread starts + /// + public static DateTime StartDateTime { get { return startDateTime; } } + + /// + /// Current state name + /// + public static int Time + { + get { return currentTimeSec; } + set { currentTimeSec = value; } + } + + /// + /// Constructor + /// + static StateMachine() + { + devices = new List(); + states = new List(); + currentTimeSec = 0; + } + + /// + /// Add a device to the state machine. + /// + /// Device + public static void AddDevice(IDevice device) + { + if (device != null && !devices.Contains(device)) devices.Add(device); + } + + /// + /// Add a state to the state machine. + /// In this way a sequence can be created programtically. + /// + /// State + public static void AddState(State state) + { + if (state != null && !states.Contains(state)) states.Add(state); + } + + /// + /// Remove the state from the state machine. + /// + /// State + public static void RemoveState(State state) + { + if (state != null && state != State.CurrentState && states.Contains(state)) states.Remove(state); + } + + /// + /// Get a state from a label + /// + /// + /// The matching state or null + static State GetStateFromLabel(string label) + { + if (label == null) return null; + + foreach (State state in states) + { + if (state.Label != null && state.Label.Equals(label)) return state; + } + return null; + } + + /// + /// Start the state machine in the state 'label' in a desired mode of operation. + /// This method is called in the UI thread and creates a new state machine thread. + /// This method call should be embedded in: try { StateMachine.Start(...); } catch { } + /// to handle configuration problems. Calls CreateDevices(mode) and CreateStates(). + /// + /// Mode of operation + /// A copy of bench data used by the state machine + /// Identifies the initial state +#if DN100 + public static void InitializeBoardEtc(ControlCom2VB.ControlCom2panel ctrlBrdComponent) +#elif FUZHOU_150 || MUNICH + public static void InitializeBoardEtc(ControlComponent3Munich.UserControl1 ctrlBrdComponent) +#elif FUZHOU_300 + public static void InitializeBoardEtc(ControlComponent3F300.UserControl1 ctrlBrdComponent) +#elif BERLIN || GELSENWASSER || GENESIS || IZRAEL_200 || PETERSBURG_200 || PUCHONG_200 || SLM_150 + public static void InitializeBoardEtc(ControlComponent_Izrael2014.UserControl1 ctrlBrdComponent) +#else /// all newer benches + public static void InitializeBoardEtc(ControlComponent_Torino2015.UserControl1 ctrlBrdComponent) +#endif + { + /// Load the list of components (entities) from the database. + /// Then create the components (derived from IComponent). + components = BenchControl.TbfComponents.LoadComponentsFromDB(TBF.DB.CreateSession(Common.DBKind.Config)); + MasterValves = GenericDevices.ValveBase.MasterValves(components); + CoupledValves = GenericDevices.ValveBase.CoupledValves(components); + ExtendedValves = GenericDevices.ValveBase.ExtendedValves(components); + + /// Find all balances (to initialize tank capacities in the control board) + /// Find the control board + IList tanks = new List(); + ProcessData.IperlHeads = new List(); + SequenceBase.FlowMeters = new List(); + SequenceBase.RegulValves = new List(); + SequenceBase.FeedingRegulValves = new List(); + SequenceBase.OutputRegulValves = new List(); + SequenceBase.PumpsWithFM = new List(); + SequenceBase.WaterMeters = new List(); + SequenceBase.Cameras = new List(); + LoopStartNames = new List(); + LoopEndNames = new List(); + UInt128 valvesToInvert = 0; + foreach (var cmpnt in components) + { + if (cmpnt is Elde.ControlBoardDev) ControlBoard = cmpnt as Elde.ControlBoardDev; + if (cmpnt is IBenchInfo) ProcessData.BenchInfo = cmpnt as IBenchInfo; + if (cmpnt is IErrorFlags) ProcessData.ErrorFlagsComp = cmpnt as IErrorFlags; + if (cmpnt is IStatisticsMonitoring) ProcessData.StatisticsMonitoringComp = cmpnt as IStatisticsMonitoring; + + if ((cmpnt is Output.DB.SensusOracle.Database) && (ProcessData.OracleDB == null)) + { + /// The 1st Oracle database component found --> store the reference + ProcessData.OracleDB = cmpnt as Output.DB.SensusOracle.Database; + } + if ((cmpnt is Output.DB.ProductionTracing.Tracing) && (ProcessData.TracingDB == null)) + { + /// The 1st production tracing database component found --> store the reference + ProcessData.TracingDB = cmpnt as Output.DB.ProductionTracing.Tracing; + } + + if (cmpnt is TestMethods.iPerlCommunication.iPerlHead.IperlHead) + { + ProcessData.IperlHeads.Add(cmpnt as TestMethods.iPerlCommunication.iPerlHead.IperlHead); + } + if (cmpnt is IFlowMeter) SequenceBase.FlowMeters.Add(cmpnt as IFlowMeter); + if ((cmpnt is IRegValve) && !(cmpnt is BenchControl.Elde.RegulValveTandem.RegulValveTandem)) + { + IRegValve rv = cmpnt as IRegValve; + SequenceBase.RegulValves.Add(rv); + if (rv.Category == ValveCategory.Feeding) SequenceBase.FeedingRegulValves.Add(rv); + if (rv.Category == ValveCategory.Output) SequenceBase.OutputRegulValves.Add(rv); + } + if (cmpnt is IPumpFM && !(cmpnt is Elde.PumpTandem.Pump)) + { + SequenceBase.PumpsWithFM.Add(cmpnt as IPumpFM); + } + if (cmpnt is IWaterMeter) SequenceBase.WaterMeters.Add(cmpnt as IWaterMeter); + if (cmpnt is ICamera) SequenceBase.Cameras.Add(cmpnt as ICamera); + if (cmpnt is GenericDevices.IAmbient) Ambient = cmpnt as GenericDevices.IAmbient; + + if (cmpnt is GenericDevices.IParallelOutput && cmpnt.Name.ToLower().Contains("tower")) + { + BenchWaitingOp = (cmpnt as GenericDevices.IParallelOutput).ShowBenchWaitingOp(); + BenchErrorOp = (cmpnt as GenericDevices.IParallelOutput).ShowBenchErrorOp(); + } + + if (cmpnt is ITestMethod && cmpnt.ClassName == "TestMethods.OuterLoop.Start") LoopStartNames.Add(cmpnt.Name); + if (cmpnt is ITestMethod && cmpnt.ClassName == "TestMethods.OuterLoop.End") LoopEndNames.Add(cmpnt.Name); + + if (cmpnt is IScaleOrTank) + { + IScaleOrTank tank = cmpnt as IScaleOrTank; + tanks.Add(tank); + if (Tank1 == null) Tank1 = tank; + else if (Tank2 == null) Tank2 = tank; + else if (Tank3 == null) Tank3 = tank; + } + + Elde.Valve.Valve eldeValve = (cmpnt as Elde.Valve.Valve); + if ((eldeValve != null) && eldeValve.Inverted) valvesToInvert |= eldeValve.Mask; + } + + /// Pre-initialize the control board (= buffer the arguments ctrlBrdComponent, tankCapacities) + if (ControlBoard != null) + { + /// Create an array with tank capacities from 'tanks' list + double[] tankCapacities = new double[tanks.Count]; + for (int i = 0; i < tankCapacities.Length; i++) tankCapacities[i] = tanks[i].Capacity; + + ControlBoard.InitializeEldeComponent(ctrlBrdComponent, valvesToInvert, tankCapacities); + } + else + { + throw new Exception("Control board component is missing"); + } + } + + + public static string CurrentlyInitializedComponentName; + /// + public static string InitializeComponents() + { + CurrentlyInitializedComponentName = "-"; + + bool anyComponentIsInSimulMode = false; + StringBuilder inSimulMode = new StringBuilder(); + + /// Add all devices to the state machine and initialize them + foreach (var cmpnt in components) + { + if (cmpnt.DebugLevel == DebugMode.Simulate) + { + inSimulMode.AppendFormat("{0}{1}", anyComponentIsInSimulMode ? ", " : "", cmpnt.Name); + anyComponentIsInSimulMode = true; + } + + if (cmpnt is IDevice) + { + devices.Add(cmpnt as IDevice); /// Only components that were initialized are added + UiBridge.Bridge.OnActivity(null, cmpnt.Name); /// Info + } + + CurrentlyInitializedComponentName = cmpnt.Name; + cmpnt.Initialize(); + cmpnt.StartChangeHandler(); /// Start handling parameter change events + } + + CurrentlyInitializedComponentName = "---"; + + /// + /// (1) Propagate debug levels from parents to children when necessary + /// (2) Set drain valves DrainValve1, DrainValve2 and DrainValve3 + /// + foreach (var cmpnt in components) + { + if (cmpnt.Cfg is IChildComponentCfg && !string.IsNullOrEmpty(cmpnt.Cfg.ParentName) && + (cmpnt.Cfg.DebugLevel == DebugMode.Inherit || cmpnt.Cfg.DebugLevel == DebugMode.AutoDetect)) + { + foreach (var par in components) + { + if (par.Cfg.Name.Equals(cmpnt.Cfg.ParentName)) { cmpnt.Cfg.DebugLevel = par.Cfg.DebugLevel; break; } + } + } + + if (cmpnt is IScaleOrTank) + { + IScaleOrTank tank = cmpnt as IScaleOrTank; + + if (tank == Tank1 && DrainValve1 == null) + { + DrainValve1 = tank.DrainValve; + log.WarnFormat("InitializeComponents() ... Scale1={0} DrainValve1={1}", + tank.Name, (DrainValve1 != null) ? DrainValve1.Name : "---"); + } + else if (tank == Tank2 && DrainValve2 == null) + { + DrainValve2 = tank.DrainValve; + log.WarnFormat("InitializeComponents() ... Scale2={0} DrainValve2={1}", + tank.Name, (DrainValve2 != null) ? DrainValve2.Name : "---"); + } + else if (tank == Tank3 && DrainValve3 == null) + { + DrainValve3 = tank.DrainValve; + log.WarnFormat("InitializeComponents() ... Scale3={0} DrainValve3={1}", + tank.Name, (DrainValve3 != null) ? DrainValve3.Name : "---"); + } + } + } + + if (anyComponentIsInSimulMode) + return inSimulMode.ToString(); + else + return null; + } + + /// + /// Stop devices that were started by InitializeDevices(). + /// Works correctly also after exeption from InitializeDevices() as only ... + /// ... correctly started devices were added in 'devices' list. + /// + public static void StopDevices() + { + for (int i = devices.Count - 1; i >= 0; i--) + { + var dev = devices[i]; + UiBridge.Bridge.OnActivity(null, string.Format("1. {0}", dev.Name)); /// Info + dev.StopDevice(); + } + } + + /// + /// Stop devices that were started by InitializeDevices(). + /// Works correctly also after exeption from InitializeDevices() as only ... + /// ... correctly started devices were added in 'devices' list. + /// + public static void StopDevices2() + { + for (int i = devices.Count - 1; i >= 0; i--) + { + var dev = devices[i]; + UiBridge.Bridge.OnActivity(null, string.Format("2. {0}", dev.Name)); /// Info + dev.StopDevice2(); + } + } + + /// + /// Checks remote and local configuration DB paths and transitions for compatibility + /// + /// true when DB-s are compatible + public static bool IsRemoteDBCompatible(out string message) + { + IList remoteFeedingPaths; + IList remoteBenchPaths; + IList remoteOutputPaths; + IList remoteMetersPaths; + IList remoteTransitions; + + try + { + ISession remoteSession = TBF.DB.CreateSession(Common.DBKind.RemoteConfig); + remoteFeedingPaths = remoteSession.QueryOver().List(); + remoteBenchPaths = remoteSession.QueryOver().List(); + remoteOutputPaths = remoteSession.QueryOver().List(); + remoteMetersPaths = remoteSession.QueryOver().List(); + remoteTransitions = remoteSession.QueryOver().List(); + } + catch (Exception) + { + message = "Cannot open remote database"; + return false; + } + + ISession localSession = TBF.DB.CreateSession(Common.DBKind.Config); + var localFeedingPaths = localSession.QueryOver().List(); + var localBenchPaths = localSession.QueryOver().List(); + var localOutputPaths = localSession.QueryOver().List(); + var localMetersPaths = localSession.QueryOver().List(); + var localTransitions = localSession.QueryOver().List(); + + string subMsg; + if (!IsCompatible(localFeedingPaths, remoteFeedingPaths, out subMsg)) + { + message = string.Format("Feeding: {0}", subMsg); + return false; + } + + if (!IsCompatible(localBenchPaths, remoteBenchPaths, out subMsg)) + { + message = string.Format("Bench: {0}", subMsg); + return false; + } + + if (!IsCompatible(localOutputPaths, remoteOutputPaths, out subMsg)) + { + message = string.Format("Output: {0}", subMsg); + return false; + } + + if (!IsCompatible(localMetersPaths, remoteMetersPaths, out subMsg)) + { + message = string.Format("Sensors: {0}", subMsg); + return false; + } + + if (!IsCompatible(localTransitions, remoteTransitions, out subMsg)) + { + message = string.Format("Transitions: {0}", subMsg); + return false; + } + + message = string.Empty; + return true; + } + + /// + /// + /// + /// FeedingPath, BenchPath, OutputPath, MetersPath or TransitionSequence + /// Local list of paths or transitions + /// Remote list of paths or transitions + /// Message specifying a cause of incompatibility + /// true when lists are compatible, otherwise false + private static bool IsCompatible(IList localList, IList remoteList, out string message) + { + message = "Local list is empty"; + if ((localList == null) || (localList.Count == 0) || !(localList[0] is IHasName)) return false; + + message = "Remote list is empty"; + if ((remoteList == null) || (remoteList.Count == 0) || !(remoteList[0] is IHasName)) return false; + + /// + /// Each path or transition on a remote list must exist on a local list + /// + foreach (var rItem in remoteList) + { + bool exists = false; + foreach (var lItem in localList) + { + if ((rItem as IHasName).Name == (lItem as IHasName).Name) + { + exists = true; + break; + } + } + + if (!exists) + { + message = string.Format("Remote item {0} does not exist on a local list", (rItem as IHasName).Name); + return false; + } + } + + message = string.Empty; + return true; + } + + + /// + /// Start the state machine + /// + public static void Start() + { + if (MachineState != MachineState.StartingUp) + { + /// Unexpected MachineState (not MachineState.StartingUp) --> prevent worker thread from starting + /// + MachineState = MachineState.FailedToStart; + return; + } + + workerThread = new Thread(Worker); + workerThread.CurrentCulture = Thread.CurrentThread.CurrentCulture; + workerThread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture; + workerThread.Start(); + } + + /// + /// Loads all paths and transitions from the DB. + /// Updates StatMachine.feedingPaths ... StatMachine.meterPaths, StatMachine.TransitionSequences + /// + public static void LoadPathsAndTransitions(ISession session) + { + feedingPaths = session.QueryOver().OrderBy(x => x.ItemNr).Asc.List(); + benchPaths = session.QueryOver().OrderBy(x => x.ItemNr).Asc.List(); + outputPaths = session.QueryOver().OrderBy(x => x.ItemNr).Asc.List(); + metersPaths = session.QueryOver().OrderBy(x => x.ItemNr).Asc.List(); + TransitionSequences = session.QueryOver().OrderBy(x => x.ItemNr).Asc.List(); + TransitionSteps = session.QueryOver().OrderBy(x => x.ItemNr).Asc.List(); +#if HEAT_METERS + heatMetersPaths = session.QueryOver().OrderBy(x => x.ItemNr).Asc.List(); +#endif + } + + /// + /// Loads selected procedure from the DB. + /// Updates StateMachine.Procedure and StateMachine.Tests + /// + public static bool LoadProcedure(ISession session, string procedureName, bool isRemote, IList autoTests = null) + { + Procedure = null; + + IList selectedProcs = session.QueryOver() + .Where(x => (x.ProcedureState == Common.ProcedureState.Active)) + .And(x => (x.Name == procedureName)) + .List(); + if (selectedProcs.Count == 1) + { + IsRemoteProcedure = isRemote; + Procedure = selectedProcs[0]; + TestInstances = selectedProcs[0].UpdateTestInstances(LoopStartNames, LoopEndNames, autoTests); + return true; + } + else + { + return false; + } + } + + public static void LoadProcedureParams(Procedure procedure) + { + foreach (var cmpnt in components) + { + cmpnt.Cfg.LoadProcedureParamsFromDB(procedure); + } + } + + public static void LoadTestParams(Test test) + { + foreach (var cmpnt in components) + { + cmpnt.Cfg.LoadTestParamsFromDB(test); + } + } + + /// + /// Called from the sequence to update paths based on the selected test + /// + /// Selected test + /// + /// + /// + /// + /// Transition sequence entity + /// Transition sequence entity + /// Error message in case of incorrect configuration + /// true when loaded configuration is correct (all four paths are defined !=null, etc.) + public static bool GetPaths(Test test, + bool heatMetersPathRequired, + out FeedingPath pfeed, + out BenchPath pben, + out OutputPath pout, + out MetersPath pmtrs, + out HeatMetersPath phmtrs, + out TransitionSequence transitionBefore, + out TransitionSequence transitionBetween, + out TransitionSequence transitionAfter, + out string errorMsg) + { + ITestMethod tm = TbfComponents.FindComponent(test.Method) as ITestMethod; + bool isHydroTest = (tm != null) ? tm.DoTransitions() : false; + + pfeed = null; + pben = null; + pout = null; + phmtrs = null; + transitionBefore = null; + transitionBetween = null; + transitionAfter = null; + + foreach (var path in feedingPaths) + { + if (test.FeedingPath == path.Name) { pfeed = new FeedingPath(path, components); break; } + } + + foreach (var path in benchPaths) + { + if (test.BenchPath == path.Name) { pben = new BenchPath(path, components); break; } + } + + foreach (var path in outputPaths) + { + if (test.OutputPath == path.Name) { pout = new OutputPath(path, components); break; } + } + + pmtrs = GetMetersPath(test); + + if (isHydroTest && (pfeed == null)) errorMsg = Strings.Cannot_load_feeding_path; + else if (isHydroTest && (pben == null)) errorMsg = Strings.Cannot_load_bench_path; + else if (isHydroTest && (pout == null)) errorMsg = Strings.Cannot_load_output_path; + else if (pmtrs == null) errorMsg = Strings.Cannot_load_sensor_path; + else errorMsg = string.Empty; + if ((isHydroTest && (pfeed == null || pben == null || pout == null)) || (pmtrs == null)) + { + log.ErrorFormat("GetPaths({0},...) returns false, wrong configuration", test.Name); + return false; + } + +#if HEAT_METERS + foreach (var path in heatMetersPaths) + { + if (test.HeatMetersPath == path.Name) { phmtrs = new HeatMetersPath(path, components); break; } + } +#endif + if (heatMetersPathRequired && phmtrs == null) + { + log.ErrorFormat("GetPaths({0},...) returns false, missing heat meters sensors", test.Name); + errorMsg = "Cannot load heat meters sensors"; + return false; + } + + foreach (var tr in TransitionSequences) + { + if (tr.Name == test.TransBefore) transitionBefore = tr; + if (tr.Name == test.TransBetween) transitionBetween = tr; + if (tr.Name == test.TransAfter) transitionAfter = tr; + } + + if (isHydroTest && pout.Scale == null) + { + log.ErrorFormat("GetPaths({0},...) returns false, missing scales in output path {1}", test.Name, test.OutputPath); + errorMsg = string.Format("No balance specified in path {0}", test.OutputPath); + return false; + } + + if (Config.Formulas.RealDensity() < 500.0f || Config.Formulas.RealDensity() > 2000.0f) + { + log.ErrorFormat("GetPaths({0},...) returns false, density was not specified", test.Name); + errorMsg = string.Format("Density was not specified"); + return false; + } + + log.WarnFormat("GetPaths({0},...) returns true, paths loaded OK, isHydroTest={1}", test.Name, isHydroTest); + errorMsg = string.Empty; + return true; + } + + + /// + /// Updates paths based on the selected test + /// + public static MetersPath GetMetersPath(Test test) + { + MetersPath pmtrs = null; + foreach (var path in metersPaths) + { + if (test.MetersPath == path.Name) { pmtrs = new MetersPath(path, components); break; } + } + if (pmtrs != null) + { + int count = Math.Min(TBF.Data.WMsCount, pmtrs.RegisterReaders.Length); + for (int i = 0; i < count; i++) + { + if ((pmtrs.RegisterReaders[i] != null) && + (pmtrs.RegisterReaders[i].Cfg.DebugLevel == DebugMode.DetectedOff)) + { + pmtrs.RegisterReaders[i] = null; + } + } + } + return pmtrs; + } + + + /* + * This is and example sequence of RunDeviceBefore() / RunOperations() / RunDeviceAfter() calls + * as they are executed during normal run from the progran start to the end. + * + foreach (var device in devices) device.RunDeviceBefore(); . . . . . . in StateMachine.Worker() + State.Create(...).AddOperation(...).AddOperation(...).EnterState() . . in the sequence in Execute(...) + + foreach (var device in devices) device.RunDeviceAfter(); . . . . . . . in WaitRunDevsRunOps() + WaitNextTick() (may throw QuitStateMachineException) . . . . . . . . in WaitRunDevsRunOps() + foreach (var device in devices) device.RunDeviceBefore(); . . . . . . in WaitRunDevsRunOps() + IList events = State.RunOperations(); . . . . . . . . . . . . . in WaitRunDevsRunOps() + + foreach (var device in devices) device.RunDeviceAfter(); . . . . . . . in WaitRunDevsRunOps() + WaitNextTick() (may throw QuitStateMachineException) . . . . . . . . in WaitRunDevsRunOps() + foreach (var device in devices) device.RunDeviceBefore(); . . . . . . in WaitRunDevsRunOps() + IList events = State.RunOperations(); . . . . . . . . . . . . . in WaitRunDevsRunOps() + + State.Create(...).AddOperation(...).AddOperation(...).EnterState() . . in the sequence in Execute(...) + + foreach (var device in devices) device.RunDeviceAfter(); . . . . . . . in WaitRunDevsRunOps() + WaitNextTick() (may throw QuitStateMachineException) . . . . . . . . in WaitRunDevsRunOps() + foreach (var device in devices) device.RunDeviceBefore(); . . . . . . in WaitRunDevsRunOps() + IList events = State.RunOperations(); . . . . . . . . . . . . . in WaitRunDevsRunOps() + + foreach (var device in devices) device.RunDeviceAfter(); . . . . . . . in WaitRunDevsRunOps() + WaitNextTick() (assume QuitStateMachineException thrown) . . . . . . in WaitRunDevsRunOps() + State.StopOperations(); . . . . . . . . . . . . . . . . . . . . . . . in StateMachine.Worker() catch() + foreach (var device in devices) device.StopDevice(); . . . . . . . . . in StateMachine.Worker() catch() + */ + + /// + /// Worker thread: calls Start(), Run() and Stop() methods of operations. + /// It uses 'currentState', 'nextState' and 'quitStateMachine' static fields. + /// + static void Worker() + { + MachineState = MachineState.Running; + startDateTime = DateTime.Now; + CycleStartTimeStamp = startDateTime; /// Do not leave CycleStartTimeStamp uninitialized + wlog.InfoFormat(" currentTime = {0}s startDateTime = {1}", currentTimeSec.ToString(), startDateTime.ToString()); + + /// Run all devices for the first time + foreach (var device in devices) device.RunDeviceBefore(); + + SequenceBase.ReferenceFlowmetersCount = SequenceBase.FlowMeters.Count; + SequenceBase.CalibratedLtrPerRefPulse = new double[SequenceBase.ReferenceFlowmetersCount]; + foreach (var flowmtr in SequenceBase.FlowMeters) + { + int ix = flowmtr.Idx1; + if (ix > 0 && ix <= SequenceBase.ReferenceFlowmetersCount) + { + SequenceBase.CalibratedLtrPerRefPulse[ix - 1] = flowmtr.NominalFlow / 7200.0; + } + } + + /// + /// Run the main sequence + /// + (new Sequences.MainSeq()).Execute(); + + StateMachine.MachineState = MachineState.Off; /// Update StateMachine.MachineState + TBF.UiBridge.Bridge.Bench2UI(TBF.UiBridge.ButtonsEtc.Shutdown); /// Let UI know the state machine is shut down now + } + + + /// + /// Do stuff that is repeated in the state execution loops most often + /// + /// List of Event-s returned from the state operations, null == quit + public static IList WaitRunDevsRunOps(bool lastTime = false) + { + Thread.Sleep(100); /// Insert 1/10 sec.delay between RunOperations() and RunDeviceAfter() + + for (int i = devices.Count - 1; i >= 0; i-- ) + { + devices[i].RunDeviceAfter(); + } + + WaitNextTick(); + + if (lastTime) + { + /// + /// Executed when the state machine is being stopped + /// + State.StopOperations(); + return null; + } + + foreach (var device in devices) + { + device.RunDeviceBefore(); + } + + Thread.Sleep(100); /// Insert 1/10 sec.delay between RunDeviceBefore() and RunOperations() + + return State.RunOperations(); /// Returns events from all running operations + /// This is followed by a state change in the sequence + } + + + /// + /// Wait time period - synchronize + /// + /// true when interrupted by 'quitStateMachine', otherwise false + public static void WaitNextTick() + { + int currentTimeSecFromClock = Convert.ToInt32(Math.Round((DateTime.Now - startDateTime).TotalSeconds - 0.2)); + + currentTimeSec = Math.Max(currentTimeSec, currentTimeSecFromClock) + Period; + + DateTime nextTickDateTime = startDateTime + TimeSpan.FromSeconds(currentTimeSec); + + while (DateTime.Now < nextTickDateTime) + { + Thread.Sleep(100); + } + } + } +} diff --git a/TBF/Rig/DataContainers/BenchInfo/Extended/ComponentCfg.cs b/TBF/Rig/DataContainers/BenchInfo/Extended/ComponentCfg.cs index 80ff37fad..0eb591ed4 100644 --- a/TBF/Rig/DataContainers/BenchInfo/Extended/ComponentCfg.cs +++ b/TBF/Rig/DataContainers/BenchInfo/Extended/ComponentCfg.cs @@ -14,12 +14,15 @@ namespace TBF.Rig.DataContainers.BenchInfo.Extended /// /// Holds information identifying the test bench - serializable configuration. /// - public class ComponentCfg : ComponentCfgBase, Generic.IComponentCfg, Config.Entities.IParamsProvider + public class ComponentCfg : ComponentCfgBase, Generic.IComponentCfg, IParamsProvider { public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ComponentCfg) })[0]; public override XmlSerializer GetSerializer() { return Serializer; } - public IComponentCfgCtrl GetControl(IList cmpntEntities) { return new Configs.ParamsProvider.ComponentCfgCtrl(this, null); } + public IComponentCfgCtrl GetControl(IList cmpntEntities) + { + return new Configs.ParamsProvider.ComponentCfgCtrl(this, null); + } /// /// Serialized parameters @@ -151,11 +154,6 @@ namespace TBF.Rig.DataContainers.BenchInfo.Extended public string ToString(int i) { - if (i == -1) - { - return string.Format("{0}: Bench name={1}, Bench Id={2}, Procedures={3}", Name, TestBenchName, TestBenchId, RemoteDBUse.ToDescription()); - } - switch (i) { case 0: return TestBenchName; @@ -175,7 +173,8 @@ namespace TBF.Rig.DataContainers.BenchInfo.Extended case 14: return TempUnit.ToDescription(); case 15: return PressUnit.ToDescription(); case 16: return LenghtUnit.ToDescription(); - default: return string.Empty; + default: + return string.Format("{0}: Bench name={1}, Bench Id={2}, Procedures={3}", Name, TestBenchName, TestBenchId, RemoteDBUse.ToDescription()); } } diff --git a/TBF/Rig/DataEntry/Fewa/CycleBeginningForm.Designer.cs b/TBF/Rig/DataEntry/Double24/CycleBeginningForm.Designer.cs similarity index 97% rename from TBF/Rig/DataEntry/Fewa/CycleBeginningForm.Designer.cs rename to TBF/Rig/DataEntry/Double24/CycleBeginningForm.Designer.cs index 77af28b91..93ea9609b 100644 --- a/TBF/Rig/DataEntry/Fewa/CycleBeginningForm.Designer.cs +++ b/TBF/Rig/DataEntry/Double24/CycleBeginningForm.Designer.cs @@ -1,7 +1,7 @@ /// /// Copyright (c) 2019 Sensus Slovensko a.s. /// -namespace TBF.Rig.DataEntry.Fewa +namespace TBF.Rig.DataEntry.Double24 { partial class CycleBeginningForm { @@ -134,6 +134,10 @@ namespace TBF.Rig.DataEntry.Fewa this.suffixComboBox15 = new System.Windows.Forms.ComboBox(); this.suffixComboBox14 = new System.Windows.Forms.ComboBox(); this.suffixComboBox13 = new System.Windows.Forms.ComboBox(); + this.snLabel = new System.Windows.Forms.Label(); + this.snLabel2 = new System.Windows.Forms.Label(); + this.column2Label = new System.Windows.Forms.Label(); + this.columnm2Label2 = new System.Windows.Forms.Label(); this.orderGroupBox.SuspendLayout(); this.prefixGroupBox.SuspendLayout(); this.SuspendLayout(); @@ -877,11 +881,35 @@ namespace TBF.Rig.DataEntry.Fewa this.suffixComboBox13.TextChanged += new System.EventHandler(this.suffixComboBox13_TextChanged); this.suffixComboBox13.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.suffixComboBox13_KeyPress); // + // snLabel + // + resources.ApplyResources(this.snLabel, "snLabel"); + this.snLabel.Name = "snLabel"; + // + // snLabel2 + // + resources.ApplyResources(this.snLabel2, "snLabel2"); + this.snLabel2.Name = "snLabel2"; + // + // column2Label + // + resources.ApplyResources(this.column2Label, "column2Label"); + this.column2Label.Name = "column2Label"; + // + // columnm2Label2 + // + resources.ApplyResources(this.columnm2Label2, "columnm2Label2"); + this.columnm2Label2.Name = "columnm2Label2"; + // // CycleBeginningForm // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.DarkGray; + this.Controls.Add(this.columnm2Label2); + this.Controls.Add(this.column2Label); + this.Controls.Add(this.snLabel2); + this.Controls.Add(this.snLabel); this.Controls.Add(this.suffixComboBox24); this.Controls.Add(this.suffixComboBox23); this.Controls.Add(this.suffixComboBox22); @@ -1098,5 +1126,9 @@ namespace TBF.Rig.DataEntry.Fewa private System.Windows.Forms.ComboBox suffixComboBox15; private System.Windows.Forms.ComboBox suffixComboBox14; private System.Windows.Forms.ComboBox suffixComboBox13; + private System.Windows.Forms.Label snLabel; + private System.Windows.Forms.Label snLabel2; + private System.Windows.Forms.Label column2Label; + private System.Windows.Forms.Label columnm2Label2; } } \ No newline at end of file diff --git a/TBF/Rig/DataEntry/Fewa/CycleBeginningForm.cs b/TBF/Rig/DataEntry/Double24/CycleBeginningForm.cs similarity index 93% rename from TBF/Rig/DataEntry/Fewa/CycleBeginningForm.cs rename to TBF/Rig/DataEntry/Double24/CycleBeginningForm.cs index 909d21c00..3806ead16 100644 --- a/TBF/Rig/DataEntry/Fewa/CycleBeginningForm.cs +++ b/TBF/Rig/DataEntry/Double24/CycleBeginningForm.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2019 Sensus Slovensko a.s. +/// Copyright (c) 2021 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -7,7 +7,7 @@ using System.Windows.Forms; using log4net; using TBF.Resources; -namespace TBF.Rig.DataEntry.Fewa +namespace TBF.Rig.DataEntry.Double24 { public partial class CycleBeginningForm : Form, GenericDevices.IHasCompleted { @@ -15,12 +15,14 @@ namespace TBF.Rig.DataEntry.Fewa /// Number of water meters public readonly int WMsCount; + readonly EntryFormCfg entryFormCfg; /// To be retrieved after the form is closed public string PurchaseOrder; + public string Prefix; public string[] SNText; - public string[] SN2Text; - string[] suffixText; + public string[] Column2Text; + public string[] suffixText; public bool[] Disabled; /// Set to 'true' when the form closes @@ -31,7 +33,7 @@ namespace TBF.Rig.DataEntry.Fewa int textBoxesCount; Label[] labels; ComboBox[] comboBoxes; - ComboBox[] suffixComboBoxes; + ComboBox[] column2ComboBoxes; CheckBox[] checkBoxes; IList enabledComboBoxes; @@ -56,7 +58,7 @@ namespace TBF.Rig.DataEntry.Fewa comboBox13, comboBox14, comboBox15, comboBox16, comboBox17, comboBox18, comboBox19, comboBox20, comboBox21, comboBox22, comboBox23, comboBox24, }; - suffixComboBoxes = new ComboBox[] + column2ComboBoxes = new ComboBox[] { suffixComboBox1, suffixComboBox2, suffixComboBox3, suffixComboBox4, suffixComboBox5, suffixComboBox6, suffixComboBox7, suffixComboBox8, suffixComboBox9, suffixComboBox10, suffixComboBox11, suffixComboBox12, @@ -80,15 +82,27 @@ namespace TBF.Rig.DataEntry.Fewa /// Constructor /// /// Number of text boxes for serial numbers - public CycleBeginningForm(int waterMetersCount) + public CycleBeginningForm(int waterMetersCount, EntryFormCfg entryFormCfg) : this() { this.WMsCount = waterMetersCount; + this.entryFormCfg = entryFormCfg; + SNText = new string[WMsCount]; - SN2Text = new string[WMsCount]; + Column2Text = new string[WMsCount]; suffixText = new string[WMsCount]; Disabled = new bool[WMsCount]; + if (entryFormCfg.HideOrderSelection) + orderGroupBox.Visible = false; + else + PrepareOrderCombo(orderComboBox); + + if (entryFormCfg.HidePrefix) + prefixGroupBox.Visible = false; + else + PreparePrefixCombo(prefixComboBox); + ShuffleTextBoxes(TBF.Data.WMsCount, TBF.Data.LineSize); //Height = 147 + WaterMetersCount * 90; @@ -114,7 +128,7 @@ namespace TBF.Rig.DataEntry.Fewa { labels[dest] = labels[l * lineSize + l * gap + i]; comboBoxes[dest] = comboBoxes[l * lineSize + l * gap + i]; - suffixComboBoxes[dest] = suffixComboBoxes[l * lineSize + l * gap + i]; + column2ComboBoxes[dest] = column2ComboBoxes[l * lineSize + l * gap + i]; checkBoxes[dest] = checkBoxes[l * lineSize + l * gap + i]; dest++; } @@ -127,21 +141,18 @@ namespace TBF.Rig.DataEntry.Fewa { Localize(); - PrepareOrderCombo(orderComboBox); - PreparePrefixCombo(prefixComboBox); - for (int i = 0; i < textBoxesCount; i++) { if (Program.LocalSettings.LastSNTextsCount == textBoxesCount) { comboBoxes[i].Items.Add((Program.LocalSettings.LastSNTexts[i] == null) ? string.Empty : Program.LocalSettings.LastSNTexts[i]); - suffixComboBoxes[i].Items.Add((Program.LocalSettings.LastAuxSNTexts[i] == null) ? string.Empty : Program.LocalSettings.LastAuxSNTexts[i]); + column2ComboBoxes[i].Items.Add((Program.LocalSettings.LastAuxSNTexts[i] == null) ? string.Empty : Program.LocalSettings.LastAuxSNTexts[i]); } - labels[i].Visible = comboBoxes[i].Visible = suffixComboBoxes[i].Visible = checkBoxes[i].Visible = true; + labels[i].Visible = comboBoxes[i].Visible = column2ComboBoxes[i].Visible = checkBoxes[i].Visible = true; enabledComboBoxes.Add(comboBoxes[i]); - enabledComboBoxes.Add(suffixComboBoxes[i]); + enabledComboBoxes.Add(column2ComboBoxes[i]); } } @@ -149,12 +160,11 @@ namespace TBF.Rig.DataEntry.Fewa { Text = Strings.Data; orderGroupBox.Text = Strings.Purchase_order; - for (int i = 0; i < textBoxesCount; i++) - { - labels[i].Text = Strings.Serial_Number + " " + (i + 1).ToString(); - } + for (int i = 0; i < textBoxesCount; i++) labels[i].Text = (i + 1).ToString(); okButton.Text = Strings.OkBtnText; clearButton.Text = Strings.ClearBtnText; + + column2Label.Text = columnm2Label2.Text = entryFormCfg.Column2Caption; } /// @@ -190,12 +200,13 @@ namespace TBF.Rig.DataEntry.Fewa for (int i = 0; i < Math.Min(WMsCount, textBoxesCount); i++) { SNText[i] = comboBoxes[i].Text; - suffixText[i] = suffixComboBoxes[i].Text; - SN2Text[i] = string.Format("{0}{1}", prefixComboBox.Text, suffixComboBoxes[i].Text); + suffixText[i] = column2ComboBoxes[i].Text; + Column2Text[i] = string.Format("{0}{1}", prefixComboBox.Text, column2ComboBoxes[i].Text); Disabled[i] = !checkBoxes[i].Checked; } - PurchaseOrder = orderComboBox.Text; + PurchaseOrder = entryFormCfg.HideOrderSelection ? string.Empty : orderComboBox.Text; + Prefix = entryFormCfg.HidePrefix ? string.Empty : prefixComboBox.Text; Program.LocalSettings.UpdateHistory(orderComboBox.Text, ref Program.LocalSettings.PurchaseOrderHistory); Program.LocalSettings.UpdateHistory(prefixComboBox.Text, ref Program.LocalSettings.PrefixHistory); Program.LocalSettings.LastSNTexts = SNText; @@ -273,8 +284,8 @@ namespace TBF.Rig.DataEntry.Fewa for (int i = 0; i < Math.Min(WMsCount, textBoxesCount); i++) { if (Program.LocalSettings.LastSNTextsCount > i) comboBoxes[i].Text = Program.LocalSettings.LastSNTexts[i]; - if (Program.LocalSettings.LastAuxSNTextsCount > i) suffixComboBoxes[i].Text = Program.LocalSettings.LastAuxSNTexts[i]; - checkBoxes[i].Checked = !string.IsNullOrEmpty(comboBoxes[i].Text) || !string.IsNullOrEmpty(suffixComboBoxes[i].Text); + if (Program.LocalSettings.LastAuxSNTextsCount > i) column2ComboBoxes[i].Text = Program.LocalSettings.LastAuxSNTexts[i]; + checkBoxes[i].Checked = !string.IsNullOrEmpty(comboBoxes[i].Text) || !string.IsNullOrEmpty(column2ComboBoxes[i].Text); } } diff --git a/TBF/Rig/DataEntry/Fewa/CycleBeginningForm.resx b/TBF/Rig/DataEntry/Double24/CycleBeginningForm.resx similarity index 92% rename from TBF/Rig/DataEntry/Fewa/CycleBeginningForm.resx rename to TBF/Rig/DataEntry/Double24/CycleBeginningForm.resx index 944991c5e..5cda5fcd5 100644 --- a/TBF/Rig/DataEntry/Fewa/CycleBeginningForm.resx +++ b/TBF/Rig/DataEntry/Double24/CycleBeginningForm.resx @@ -126,7 +126,7 @@ Verdana, 14.25pt - 1050, 26 + 942, 26 112, 63 @@ -148,7 +148,16 @@ $this - 99 + 103 + + + 57, 31 + + + 260, 31 + + + 0 orderComboBox @@ -169,7 +178,7 @@ 28, 12 - 397, 82 + 350, 82 0 @@ -187,28 +196,7 @@ $this - 98 - - - 90, 31 - - - 260, 31 - - - 0 - - - orderComboBox - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - orderGroupBox - - - 0 + 102 Top, Right @@ -220,7 +208,7 @@ NoControl - 903, 26 + 795, 26 112, 63 @@ -241,7 +229,7 @@ $this - 97 + 101 True @@ -250,16 +238,16 @@ Verdana, 14.25pt - 24, 127 + 24, 152 - 166, 23 + 22, 23 9 - Serial Number 1 + 1 False @@ -274,13 +262,13 @@ $this - 96 + 100 Verdana, 14.25pt - 225, 124 + 85, 149 163, 31 @@ -301,13 +289,13 @@ $this - 95 + 99 True - 547, 135 + 499, 160 15, 14 @@ -328,7 +316,7 @@ $this - 94 + 98 True @@ -337,7 +325,7 @@ NoControl - 547, 179 + 499, 204 15, 14 @@ -358,13 +346,13 @@ $this - 91 + 95 Verdana, 14.25pt - 225, 168 + 85, 193 163, 31 @@ -385,7 +373,7 @@ $this - 92 + 96 True @@ -397,16 +385,16 @@ NoControl - 24, 171 + 24, 196 - 166, 23 + 22, 23 12 - Serial Number 2 + 2 False @@ -421,7 +409,7 @@ $this - 93 + 97 True @@ -430,7 +418,7 @@ NoControl - 547, 223 + 499, 248 15, 14 @@ -451,13 +439,13 @@ $this - 88 + 92 Verdana, 14.25pt - 225, 212 + 85, 237 163, 31 @@ -478,7 +466,7 @@ $this - 89 + 93 True @@ -490,16 +478,16 @@ NoControl - 24, 215 + 24, 240 - 166, 23 + 22, 23 15 - Serial Number 3 + 3 False @@ -514,7 +502,7 @@ $this - 90 + 94 True @@ -523,7 +511,7 @@ NoControl - 547, 267 + 499, 292 15, 14 @@ -544,13 +532,13 @@ $this - 85 + 89 Verdana, 14.25pt - 225, 256 + 85, 281 163, 31 @@ -571,7 +559,7 @@ $this - 86 + 90 True @@ -583,16 +571,16 @@ NoControl - 24, 259 + 24, 284 - 166, 23 + 22, 23 18 - Serial Number 4 + 4 False @@ -607,7 +595,7 @@ $this - 87 + 91 True @@ -616,7 +604,7 @@ NoControl - 547, 311 + 499, 336 15, 14 @@ -637,13 +625,13 @@ $this - 82 + 86 Verdana, 14.25pt - 225, 300 + 85, 325 163, 31 @@ -664,7 +652,7 @@ $this - 83 + 87 True @@ -676,16 +664,16 @@ NoControl - 24, 303 + 24, 328 - 166, 23 + 22, 23 21 - Serial Number 5 + 5 False @@ -700,7 +688,7 @@ $this - 84 + 88 True @@ -709,7 +697,7 @@ NoControl - 547, 355 + 499, 380 15, 14 @@ -730,13 +718,13 @@ $this - 79 + 83 Verdana, 14.25pt - 225, 344 + 85, 369 163, 31 @@ -757,7 +745,7 @@ $this - 80 + 84 True @@ -769,16 +757,16 @@ NoControl - 24, 347 + 24, 372 - 166, 23 + 22, 23 24 - Serial Number 6 + 6 False @@ -793,7 +781,7 @@ $this - 81 + 85 True @@ -802,7 +790,7 @@ NoControl - 547, 399 + 499, 424 15, 14 @@ -823,13 +811,13 @@ $this - 76 + 80 Verdana, 14.25pt - 225, 388 + 85, 413 163, 31 @@ -850,7 +838,7 @@ $this - 77 + 81 True @@ -862,16 +850,16 @@ NoControl - 24, 391 + 24, 416 - 166, 23 + 22, 23 27 - Serial Number 7 + 7 False @@ -886,7 +874,7 @@ $this - 78 + 82 True @@ -895,7 +883,7 @@ NoControl - 547, 443 + 499, 468 15, 14 @@ -916,13 +904,13 @@ $this - 73 + 77 Verdana, 14.25pt - 225, 432 + 85, 457 163, 31 @@ -943,7 +931,7 @@ $this - 74 + 78 True @@ -955,16 +943,16 @@ NoControl - 24, 435 + 24, 460 - 166, 23 + 22, 23 30 - Serial Number 8 + 8 False @@ -979,7 +967,7 @@ $this - 75 + 79 True @@ -988,7 +976,7 @@ NoControl - 547, 487 + 499, 512 15, 14 @@ -1009,13 +997,13 @@ $this - 70 + 74 Verdana, 14.25pt - 225, 476 + 85, 501 163, 31 @@ -1036,7 +1024,7 @@ $this - 71 + 75 True @@ -1048,16 +1036,16 @@ NoControl - 24, 479 + 24, 504 - 166, 23 + 22, 23 33 - Serial Number 9 + 9 False @@ -1072,7 +1060,7 @@ $this - 72 + 76 True @@ -1081,7 +1069,7 @@ NoControl - 547, 531 + 499, 556 15, 14 @@ -1102,13 +1090,13 @@ $this - 67 + 71 Verdana, 14.25pt - 225, 520 + 85, 545 163, 31 @@ -1129,7 +1117,7 @@ $this - 68 + 72 True @@ -1141,16 +1129,16 @@ NoControl - 24, 523 + 24, 548 - 178, 23 + 34, 23 36 - Serial Number 10 + 10 False @@ -1165,7 +1153,7 @@ $this - 69 + 73 True @@ -1174,7 +1162,7 @@ NoControl - 547, 575 + 499, 600 15, 14 @@ -1195,13 +1183,13 @@ $this - 64 + 68 Verdana, 14.25pt - 225, 564 + 85, 589 163, 31 @@ -1222,7 +1210,7 @@ $this - 65 + 69 True @@ -1234,16 +1222,16 @@ NoControl - 24, 567 + 24, 592 - 178, 23 + 34, 23 39 - Serial Number 11 + 11 False @@ -1258,7 +1246,7 @@ $this - 66 + 70 True @@ -1267,7 +1255,7 @@ NoControl - 547, 619 + 499, 644 15, 14 @@ -1288,13 +1276,13 @@ $this - 61 + 65 Verdana, 14.25pt - 225, 608 + 85, 633 163, 31 @@ -1315,7 +1303,7 @@ $this - 62 + 66 True @@ -1327,16 +1315,16 @@ NoControl - 24, 611 + 24, 636 - 178, 23 + 34, 23 42 - Serial Number 12 + 12 False @@ -1351,7 +1339,7 @@ $this - 63 + 67 True @@ -1360,7 +1348,7 @@ NoControl - 1149, 135 + 1061, 160 15, 14 @@ -1381,13 +1369,13 @@ $this - 58 + 62 Verdana, 14.25pt - 827, 124 + 647, 149 163, 31 @@ -1408,7 +1396,7 @@ $this - 59 + 63 True @@ -1420,16 +1408,16 @@ NoControl - 622, 127 + 582, 152 - 178, 23 + 34, 23 45 - Serial Number 13 + 13 False @@ -1444,7 +1432,7 @@ $this - 60 + 64 True @@ -1453,7 +1441,7 @@ NoControl - 1149, 179 + 1061, 204 15, 14 @@ -1474,13 +1462,13 @@ $this - 55 + 59 Verdana, 14.25pt - 827, 168 + 647, 193 163, 31 @@ -1501,7 +1489,7 @@ $this - 56 + 60 True @@ -1513,16 +1501,16 @@ NoControl - 622, 171 + 582, 196 - 178, 23 + 34, 23 48 - Serial Number 14 + 14 False @@ -1537,7 +1525,7 @@ $this - 57 + 61 True @@ -1546,7 +1534,7 @@ NoControl - 1149, 223 + 1061, 248 15, 14 @@ -1567,13 +1555,13 @@ $this - 52 + 56 Verdana, 14.25pt - 827, 212 + 647, 237 163, 31 @@ -1594,7 +1582,7 @@ $this - 53 + 57 True @@ -1606,16 +1594,16 @@ NoControl - 622, 215 + 582, 240 - 178, 23 + 34, 23 51 - Serial Number 15 + 15 False @@ -1630,7 +1618,7 @@ $this - 54 + 58 True @@ -1639,7 +1627,7 @@ NoControl - 1149, 267 + 1061, 292 15, 14 @@ -1660,13 +1648,13 @@ $this - 49 + 53 Verdana, 14.25pt - 827, 256 + 647, 281 163, 31 @@ -1687,7 +1675,7 @@ $this - 50 + 54 True @@ -1699,16 +1687,16 @@ NoControl - 622, 259 + 582, 284 - 178, 23 + 34, 23 54 - Serial Number 16 + 16 False @@ -1723,7 +1711,7 @@ $this - 51 + 55 True @@ -1732,7 +1720,7 @@ NoControl - 1149, 311 + 1061, 336 15, 14 @@ -1753,13 +1741,13 @@ $this - 46 + 50 Verdana, 14.25pt - 827, 300 + 647, 325 163, 31 @@ -1780,7 +1768,7 @@ $this - 47 + 51 True @@ -1792,16 +1780,16 @@ NoControl - 622, 303 + 582, 328 - 178, 23 + 34, 23 57 - Serial Number 17 + 17 False @@ -1816,7 +1804,7 @@ $this - 48 + 52 True @@ -1825,7 +1813,7 @@ NoControl - 1149, 355 + 1061, 380 15, 14 @@ -1846,13 +1834,13 @@ $this - 43 + 47 Verdana, 14.25pt - 827, 344 + 647, 369 163, 31 @@ -1873,7 +1861,7 @@ $this - 44 + 48 True @@ -1885,16 +1873,16 @@ NoControl - 622, 347 + 582, 372 - 178, 23 + 34, 23 60 - Serial Number 18 + 18 False @@ -1909,7 +1897,7 @@ $this - 45 + 49 True @@ -1918,7 +1906,7 @@ NoControl - 1149, 399 + 1061, 424 15, 14 @@ -1939,13 +1927,13 @@ $this - 40 + 44 Verdana, 14.25pt - 827, 388 + 647, 413 163, 31 @@ -1966,7 +1954,7 @@ $this - 41 + 45 True @@ -1978,16 +1966,16 @@ NoControl - 622, 391 + 582, 416 - 178, 23 + 34, 23 63 - Serial Number 19 + 19 False @@ -2002,7 +1990,7 @@ $this - 42 + 46 True @@ -2011,7 +1999,7 @@ NoControl - 1149, 443 + 1061, 468 15, 14 @@ -2032,13 +2020,13 @@ $this - 37 + 41 Verdana, 14.25pt - 827, 432 + 647, 457 163, 31 @@ -2059,7 +2047,7 @@ $this - 38 + 42 True @@ -2071,16 +2059,16 @@ NoControl - 622, 435 + 582, 460 - 178, 23 + 34, 23 66 - Serial Number 20 + 20 False @@ -2095,7 +2083,7 @@ $this - 39 + 43 True @@ -2104,7 +2092,7 @@ NoControl - 1149, 487 + 1061, 512 15, 14 @@ -2125,13 +2113,13 @@ $this - 34 + 38 Verdana, 14.25pt - 827, 476 + 647, 501 163, 31 @@ -2152,7 +2140,7 @@ $this - 35 + 39 True @@ -2164,16 +2152,16 @@ NoControl - 622, 479 + 582, 504 - 178, 23 + 34, 23 69 - Serial Number 21 + 21 False @@ -2188,7 +2176,7 @@ $this - 36 + 40 True @@ -2197,7 +2185,7 @@ NoControl - 1149, 531 + 1061, 556 15, 14 @@ -2218,13 +2206,13 @@ $this - 31 + 35 Verdana, 14.25pt - 827, 520 + 647, 545 163, 31 @@ -2245,7 +2233,7 @@ $this - 32 + 36 True @@ -2257,16 +2245,16 @@ NoControl - 622, 523 + 582, 548 - 178, 23 + 34, 23 72 - Serial Number 22 + 22 False @@ -2281,7 +2269,7 @@ $this - 33 + 37 True @@ -2290,7 +2278,7 @@ NoControl - 1149, 575 + 1061, 600 15, 14 @@ -2311,13 +2299,13 @@ $this - 28 + 32 Verdana, 14.25pt - 827, 564 + 647, 589 163, 31 @@ -2338,7 +2326,7 @@ $this - 29 + 33 True @@ -2350,16 +2338,16 @@ NoControl - 622, 567 + 582, 592 - 178, 23 + 34, 23 75 - Serial Number 23 + 23 False @@ -2374,7 +2362,7 @@ $this - 30 + 34 True @@ -2383,7 +2371,7 @@ NoControl - 1149, 619 + 1061, 644 15, 14 @@ -2404,13 +2392,13 @@ $this - 25 + 29 Verdana, 14.25pt - 827, 608 + 647, 633 163, 31 @@ -2431,7 +2419,7 @@ $this - 26 + 30 True @@ -2443,16 +2431,16 @@ NoControl - 622, 611 + 582, 636 - 178, 23 + 34, 23 78 - Serial Number 24 + 24 False @@ -2467,7 +2455,16 @@ $this - 27 + 31 + + + 57, 31 + + + 260, 31 + + + 1 prefixComboBox @@ -2485,10 +2482,10 @@ Verdana, 14.25pt - 449, 12 + 403, 12 - 351, 82 + 350, 82 81 @@ -2506,37 +2503,16 @@ $this - 24 - - - 90, 31 - - - 214, 31 - - - 1 - - - prefixComboBox - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - prefixGroupBox - - - 0 + 28 Verdana, 14.25pt - 398, 124 + 258, 149 - 132, 31 + 220, 31 82 @@ -2554,16 +2530,16 @@ $this - 23 + 27 Verdana, 14.25pt - 398, 168 + 258, 193 - 132, 31 + 220, 31 83 @@ -2581,16 +2557,16 @@ $this - 22 + 26 Verdana, 14.25pt - 398, 212 + 258, 237 - 132, 31 + 220, 31 84 @@ -2608,16 +2584,16 @@ $this - 21 + 25 Verdana, 14.25pt - 398, 256 + 258, 281 - 132, 31 + 220, 31 85 @@ -2635,16 +2611,16 @@ $this - 20 + 24 Verdana, 14.25pt - 398, 300 + 258, 325 - 132, 31 + 220, 31 86 @@ -2662,16 +2638,16 @@ $this - 19 + 23 Verdana, 14.25pt - 398, 344 + 258, 369 - 132, 31 + 220, 31 87 @@ -2689,16 +2665,16 @@ $this - 18 + 22 Verdana, 14.25pt - 398, 388 + 258, 413 - 132, 31 + 220, 31 88 @@ -2716,16 +2692,16 @@ $this - 17 + 21 Verdana, 14.25pt - 398, 432 + 258, 457 - 132, 31 + 220, 31 89 @@ -2743,16 +2719,16 @@ $this - 16 + 20 Verdana, 14.25pt - 398, 476 + 258, 501 - 132, 31 + 220, 31 90 @@ -2770,16 +2746,16 @@ $this - 15 + 19 Verdana, 14.25pt - 398, 520 + 258, 545 - 132, 31 + 220, 31 91 @@ -2797,16 +2773,16 @@ $this - 14 + 18 Verdana, 14.25pt - 398, 564 + 258, 589 - 132, 31 + 220, 31 92 @@ -2824,16 +2800,16 @@ $this - 13 + 17 Verdana, 14.25pt - 398, 608 + 258, 633 - 132, 31 + 220, 31 93 @@ -2851,16 +2827,16 @@ $this - 12 + 16 Verdana, 14.25pt - 1000, 608 + 820, 633 - 132, 31 + 220, 31 105 @@ -2878,16 +2854,16 @@ $this - 0 + 4 Verdana, 14.25pt - 1000, 564 + 820, 589 - 132, 31 + 220, 31 104 @@ -2905,16 +2881,16 @@ $this - 1 + 5 Verdana, 14.25pt - 1000, 520 + 820, 545 - 132, 31 + 220, 31 103 @@ -2932,16 +2908,16 @@ $this - 2 + 6 Verdana, 14.25pt - 1000, 476 + 820, 501 - 132, 31 + 220, 31 102 @@ -2959,16 +2935,16 @@ $this - 3 + 7 Verdana, 14.25pt - 1000, 432 + 820, 457 - 132, 31 + 220, 31 101 @@ -2986,16 +2962,16 @@ $this - 4 + 8 Verdana, 14.25pt - 1000, 388 + 820, 413 - 132, 31 + 220, 31 100 @@ -3013,16 +2989,16 @@ $this - 5 + 9 Verdana, 14.25pt - 1000, 344 + 820, 369 - 132, 31 + 220, 31 99 @@ -3040,16 +3016,16 @@ $this - 6 + 10 Verdana, 14.25pt - 1000, 300 + 820, 325 - 132, 31 + 220, 31 98 @@ -3067,16 +3043,16 @@ $this - 7 + 11 Verdana, 14.25pt - 1000, 256 + 820, 281 - 132, 31 + 220, 31 97 @@ -3094,16 +3070,16 @@ $this - 8 + 12 Verdana, 14.25pt - 1000, 212 + 820, 237 - 132, 31 + 220, 31 96 @@ -3121,16 +3097,16 @@ $this - 9 + 13 Verdana, 14.25pt - 1000, 168 + 820, 193 - 132, 31 + 220, 31 95 @@ -3148,16 +3124,16 @@ $this - 10 + 14 Verdana, 14.25pt - 1000, 124 + 820, 149 - 132, 31 + 220, 31 94 @@ -3175,7 +3151,136 @@ $this - 11 + 15 + + + True + + + Verdana, 14.25pt + + + 81, 117 + + + 145, 23 + + + 106 + + + Serial number + + + snLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + True + + + Verdana, 14.25pt + + + NoControl + + + 643, 117 + + + 145, 23 + + + 107 + + + Serial number + + + snLabel2 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + True + + + Verdana, 14.25pt + + + NoControl + + + 254, 117 + + + 143, 23 + + + 108 + + + column2Label + + + column2Label + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + True + + + Verdana, 14.25pt + + + NoControl + + + 816, 117 + + + 173, 23 + + + 109 + + + columnm2Label2 + + + columnm2Label2 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 True @@ -3187,7 +3292,7 @@ True - 1208, 656 + 1094, 686 Batch data diff --git a/TBF/Rig/DataEntry/Fewa/CycleEndForm.Designer.cs b/TBF/Rig/DataEntry/Double24/CycleEndForm.Designer.cs similarity index 99% rename from TBF/Rig/DataEntry/Fewa/CycleEndForm.Designer.cs rename to TBF/Rig/DataEntry/Double24/CycleEndForm.Designer.cs index 1c40b4491..544ee2bf7 100644 --- a/TBF/Rig/DataEntry/Fewa/CycleEndForm.Designer.cs +++ b/TBF/Rig/DataEntry/Double24/CycleEndForm.Designer.cs @@ -1,7 +1,7 @@ /// /// Copyright (c) 2019 Sensus Slovensko a.s. /// -namespace TBF.Rig.DataEntry.Fewa +namespace TBF.Rig.DataEntry.Double24 { partial class CycleEndForm { diff --git a/TBF/Rig/DataEntry/Fewa/CycleEndForm.cs b/TBF/Rig/DataEntry/Double24/CycleEndForm.cs similarity index 98% rename from TBF/Rig/DataEntry/Fewa/CycleEndForm.cs rename to TBF/Rig/DataEntry/Double24/CycleEndForm.cs index ce51f2371..40aadc1e4 100644 --- a/TBF/Rig/DataEntry/Fewa/CycleEndForm.cs +++ b/TBF/Rig/DataEntry/Double24/CycleEndForm.cs @@ -1,12 +1,12 @@ /// -/// Copyright (c) 2019 Sensus Slovensko a.s. +/// Copyright (c) 2021 Sensus Slovensko a.s. /// using System; using System.Windows.Forms; using log4net; using TBF.Resources; -namespace TBF.Rig.DataEntry.Fewa +namespace TBF.Rig.DataEntry.Double24 { public partial class CycleEndForm : Form, GenericDevices.IHasCompleted { diff --git a/TBF/Rig/DataEntry/Fewa/CycleEndForm.resx b/TBF/Rig/DataEntry/Double24/CycleEndForm.resx similarity index 100% rename from TBF/Rig/DataEntry/Fewa/CycleEndForm.resx rename to TBF/Rig/DataEntry/Double24/CycleEndForm.resx diff --git a/TBF/Rig/DataEntry/Fewa/EntryForm.cs b/TBF/Rig/DataEntry/Double24/EntryForm.cs similarity index 73% rename from TBF/Rig/DataEntry/Fewa/EntryForm.cs rename to TBF/Rig/DataEntry/Double24/EntryForm.cs index 0ad0a4e83..481260814 100644 --- a/TBF/Rig/DataEntry/Fewa/EntryForm.cs +++ b/TBF/Rig/DataEntry/Double24/EntryForm.cs @@ -1,9 +1,9 @@ /// -/// Copyright (c) 2019 Sensus Slovensko a.s. +/// Copyright (c) 2021 Sensus Slovensko a.s. /// using TBF.Rig.GenericDevices; -namespace TBF.Rig.DataEntry.Fewa +namespace TBF.Rig.DataEntry.Double24 { public class EntryForm : EntryFormNoStartEnd, IHasWMStatesForm { diff --git a/TBF/Rig/DataEntry/Double24/EntryFormCfg.cs b/TBF/Rig/DataEntry/Double24/EntryFormCfg.cs new file mode 100644 index 000000000..39af0f77f --- /dev/null +++ b/TBF/Rig/DataEntry/Double24/EntryFormCfg.cs @@ -0,0 +1,206 @@ +/// +/// Copyright (c) 2021 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.Xml.Serialization; +using Common; +using Config; +using Config.Entities; +using TBF.Resources; +using TBF.Rig.Generic; + +namespace TBF.Rig.DataEntry.Double24 +{ + public class EntryFormCfg : ComponentCfgBase, Generic.IComponentCfg, IParamsProvider + { + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(EntryFormCfg) })[0]; + public override XmlSerializer GetSerializer() { return Serializer; } + + public IComponentCfgCtrl GetControl(IList cmpntEntities) + { + return new Configs.ParamsProvider.ComponentCfgCtrl(this, null); + } + + /// + /// Serialized parameters + /// + public bool EnterSerialNrsAtTheEnd; + public bool ShowCycleEndForm; + public bool HideOrderSelection; + public bool HidePrefix; + public string Column2Caption; + public Col2Dest Column2Destination; + + /// Private parameterless constructor invoked by all other (public) constructors + EntryFormCfg() { } + + public EntryFormCfg(IComponentFactory factory, string name) + : this() + { + this.Factory = factory; + this.Name = name; + ParentName = string.Empty; + InitializeAll(); + } + + public string ComponentName { get { return Name; } } + + public void InitializeAll() + { + EnterSerialNrsAtTheEnd = false; + ShowCycleEndForm = false; + HideOrderSelection = false; + HidePrefix = true; + Column2Caption = "Radio address"; + Column2Destination = Col2Dest.RadioAddress; + } + + string[] paramNames = new string[] + { + Strings.Enter_SNs_at_the_end, + Strings.Show_cycle_end_form, + "Hide order selection", + "Hide prefix selection", + "Column 2 caption", + "Column 2 destination", + }; + public string ParamName(int i) { return paramNames[i]; } + public int ParamsCount() { return paramNames.Length; } + + public ICollection ParamValues(int i) + { + var list = new List(); + + switch (i) + { + case 0: + case 1: + case 2: + case 3: + return new string[] { Strings.yes, Strings.no }; + case 4: + return null; + case 5: + for (Col2Dest c2d = 0; c2d < Col2Dest.Count; c2d++) list.Add(c2d.ToDescription()); + return list; + default: + return null; + } + } + + public string ToString(int i) + { + switch (i) + { + case 0: + return EnterSerialNrsAtTheEnd ? Strings.yes : Strings.no; + case 1: + return ShowCycleEndForm ? Strings.yes : Strings.no; + case 2: + return HideOrderSelection ? Strings.yes : Strings.no; + case 3: + return HidePrefix ? Strings.yes : Strings.no; + case 4: + return Column2Caption; + case 5: + return Column2Destination.ToDescription(); + default: + return string.Format("Name={0}, Enter SNs at the end={1}, Show cycle end form={2}", Name, EnterSerialNrsAtTheEnd, ShowCycleEndForm); + } + } + + + public CfgUpdateFlags UpdateParam(int i, string str) + { + switch (i) + { + case 0: + EnterSerialNrsAtTheEnd = (str == Strings.yes); + return CfgUpdateFlags.RestartRqrd; + case 1: + ShowCycleEndForm = (str == Strings.yes); + return CfgUpdateFlags.RestartRqrd; + case 2: + HideOrderSelection = (str == Strings.yes); + return CfgUpdateFlags.RestartRqrd; + case 3: + HidePrefix = (str == Strings.yes); + return CfgUpdateFlags.RestartRqrd; + case 4: + Column2Caption = str; + return CfgUpdateFlags.RestartRqrd; + case 5: + for (Col2Dest c2d = 0; c2d < Col2Dest.Count; c2d++) + { + if (str == c2d.ToDescription()) + { + Column2Destination = c2d; + return CfgUpdateFlags.RestartRqrd; + } + } + return CfgUpdateFlags.None; + default: + return CfgUpdateFlags.None; + } + } + + public bool ValidateParam(int i, string str, out string message) + { + switch (i) + { + case 0: + case 1: + case 2: + case 3: + case 5: + message = string.Empty; + if (ParamValues(i).Contains(str)) return true; + break; + case 4: + message = string.Empty; + return true; + default: + message = "Invalid index"; + return false; + } + + message = string.Format(Strings.Invalid_0, ParamName(i)) ; + return false; + } + + void CopyContentTo(EntryFormCfg prms) + { + prms.EnterSerialNrsAtTheEnd = EnterSerialNrsAtTheEnd; + prms.ShowCycleEndForm = ShowCycleEndForm; + prms.HideOrderSelection = HideOrderSelection; + prms.HidePrefix = HidePrefix; + prms.Column2Caption = Column2Caption; + prms.Column2Destination = Column2Destination; + } + + public Config.Entities.IParamsProvider Clone() + { + EntryFormCfg pars = new EntryFormCfg(); + CopyContentTo(pars); + return pars; + } + + public bool UpdateEmbeddedDbEntity() + { + return true; /// =OK, do nothing + } + } + + public enum Col2Dest + { + [Description("Radio address")] RadioAddress, + [Description("Serial nr. Aux")] SerialNrAux, + [Description("Purchase order")] OrderNr, + [Description("Remark")] Remark, +#if ORACLE_DB + [Description("Suffix")] Suffix, +#endif + Count + } +} diff --git a/TBF/Rig/DataEntry/Fewa/EntryFormNoStartEnd.cs b/TBF/Rig/DataEntry/Double24/EntryFormNoStartEnd.cs similarity index 83% rename from TBF/Rig/DataEntry/Fewa/EntryFormNoStartEnd.cs rename to TBF/Rig/DataEntry/Double24/EntryFormNoStartEnd.cs index 23d09cac3..8380c5f6d 100644 --- a/TBF/Rig/DataEntry/Fewa/EntryFormNoStartEnd.cs +++ b/TBF/Rig/DataEntry/Double24/EntryFormNoStartEnd.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2019 Sensus Slovensko a.s. +/// Copyright (c) 2021 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -8,7 +8,7 @@ using Config.Entities; using TBF.Rig; using TBF.Rig.GenericDevices; -namespace TBF.Rig.DataEntry.Fewa +namespace TBF.Rig.DataEntry.Double24 { public class EntryFormNoStartEnd : ComponentBase, IOperation, IDataEntry, IHasCycleBeginForm, IHasCycleEndForm { @@ -123,7 +123,7 @@ namespace TBF.Rig.DataEntry.Fewa /// void OpenBeginningDlg(EntryFormNoStartEnd myRef) { - myRef.modelessDlg = new CycleBeginningForm(TBF.Data.WMsCount); + myRef.modelessDlg = new CycleBeginningForm(TBF.Data.WMsCount, entryFormCfg); modelessDlg.Show(); } /// @@ -199,8 +199,39 @@ namespace TBF.Rig.DataEntry.Fewa { waterMeters[i].Disabled = disabled[i] = dlg.Disabled[i]; waterMeters[i].SerialNr = dlg.SNText[i]; - waterMeters[i].SerialNrAux = dlg.SN2Text[i]; - if (dlg.PurchaseOrder != null) waterMeters[i].PurchaseOrder = dlg.PurchaseOrder; + switch (entryFormCfg.Column2Destination) + { + case Col2Dest.RadioAddress: + waterMeters[i].RadioAddress = dlg.Column2Text[i]; + break; + case Col2Dest.SerialNrAux: + waterMeters[i].SerialNrAux = dlg.Column2Text[i]; + break; + case Col2Dest.OrderNr: + waterMeters[i].PurchaseOrder = dlg.Column2Text[i]; + break; +#if ORACLE_DB + case Col2Dest.Suffix: + waterMeters[i].Suffix = dlg.Column2Text[i]; + break; +#endif + default: + case Col2Dest.Remark: + waterMeters[i].Remark = dlg.Column2Text[i]; + break; + } + + if (!string.IsNullOrEmpty(dlg.PurchaseOrder) && !entryFormCfg.HideOrderSelection) + { + waterMeters[i].PurchaseOrder = dlg.PurchaseOrder; + } + +#if ORACLE_DB + if (!string.IsNullOrEmpty(dlg.Prefix) && !entryFormCfg.HidePrefix) + { + waterMeters[i].Prefix = dlg.PurchaseOrder; + } +#endif } } } diff --git a/TBF/Rig/DataEntry/Fewa/Factory.cs b/TBF/Rig/DataEntry/Double24/Factory.cs similarity index 63% rename from TBF/Rig/DataEntry/Fewa/Factory.cs rename to TBF/Rig/DataEntry/Double24/Factory.cs index 182120770..e5d8ae6f2 100644 --- a/TBF/Rig/DataEntry/Fewa/Factory.cs +++ b/TBF/Rig/DataEntry/Double24/Factory.cs @@ -1,20 +1,20 @@ /// -/// Copyright (c) 2019 Sensus Slovensko a.s. +/// Copyright (c) 2021 Sensus Slovensko a.s. /// using System.Collections.Generic; using TBF.Rig.Generic; -namespace TBF.Rig.DataEntry.Fewa +namespace TBF.Rig.DataEntry.Double24 { public class Factory : IComponentFactory { - public string ClassName { get { return "DataEntry.Fewa"; } } + public string ClassName { get { return GetType().Namespace.Substring(8); } } public IComponent DummyComponent() { return new EntryFormNoStartEnd(); } public IComponent GetComponent(IComponentCfg cfg, IList components) { return new EntryForm(cfg); } - public IComponentCfg DefaultConfig() { return new EntryFormCfg(this); } + public IComponentCfg DefaultConfig() { return new EntryFormCfg(this, GetType().Namespace.Substring(8)); } public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { diff --git a/TBF/Rig/DataEntry/Fewa/FactoryNoStartEnd.cs b/TBF/Rig/DataEntry/Double24/FactoryNoStartEnd.cs similarity index 62% rename from TBF/Rig/DataEntry/Fewa/FactoryNoStartEnd.cs rename to TBF/Rig/DataEntry/Double24/FactoryNoStartEnd.cs index cc9beb214..ad50378a7 100644 --- a/TBF/Rig/DataEntry/Fewa/FactoryNoStartEnd.cs +++ b/TBF/Rig/DataEntry/Double24/FactoryNoStartEnd.cs @@ -1,20 +1,20 @@ /// -/// Copyright (c) 2019 Sensus Slovensko a.s. +/// Copyright (c) 2021 Sensus Slovensko a.s. /// using System.Collections.Generic; using TBF.Rig.Generic; -namespace TBF.Rig.DataEntry.Fewa +namespace TBF.Rig.DataEntry.Double24 { public class FactoryNoStartEnd : IComponentFactory { - public string ClassName { get { return "DataEntry.Fewa.NoStartEnd"; } } + public string ClassName { get { return GetType().Namespace.Substring(8) + "-NoStartEnd"; } } public IComponent DummyComponent() { return new EntryFormNoStartEnd(); } public IComponent GetComponent(IComponentCfg cfg, IList components) { return new EntryFormNoStartEnd(cfg); } - public IComponentCfg DefaultConfig() { return new EntryFormCfg(this); } + public IComponentCfg DefaultConfig() { return new EntryFormCfg(this, GetType().Namespace.Substring(8) + "-NoStartEnd"); } public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { diff --git a/TBF/Rig/DataEntry/Fewa/TestStartEndForm.cs b/TBF/Rig/DataEntry/Double24/TestStartEndForm.cs similarity index 99% rename from TBF/Rig/DataEntry/Fewa/TestStartEndForm.cs rename to TBF/Rig/DataEntry/Double24/TestStartEndForm.cs index afe73bf6c..6362e2700 100644 --- a/TBF/Rig/DataEntry/Fewa/TestStartEndForm.cs +++ b/TBF/Rig/DataEntry/Double24/TestStartEndForm.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2019 Sensus Slovensko a.s. +/// Copyright (c) 2021 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -8,7 +8,7 @@ using log4net; using TBF.Rig.GenericDevices; using TBF.Resources; -namespace TBF.Rig.DataEntry.Fewa +namespace TBF.Rig.DataEntry.Double24 { public partial class TestStartEndForm : Form, GenericDevices.IHasCompleted { diff --git a/TBF/Rig/DataEntry/Fewa/TestStartEndForm.designer.cs b/TBF/Rig/DataEntry/Double24/TestStartEndForm.designer.cs similarity index 99% rename from TBF/Rig/DataEntry/Fewa/TestStartEndForm.designer.cs rename to TBF/Rig/DataEntry/Double24/TestStartEndForm.designer.cs index d6c7ad8c4..2010e05bc 100644 --- a/TBF/Rig/DataEntry/Fewa/TestStartEndForm.designer.cs +++ b/TBF/Rig/DataEntry/Double24/TestStartEndForm.designer.cs @@ -1,7 +1,7 @@ /// /// Copyright (c) 2019 Sensus Slovensko a.s. /// -namespace TBF.Rig.DataEntry.Fewa +namespace TBF.Rig.DataEntry.Double24 { partial class TestStartEndForm { diff --git a/TBF/Rig/DataEntry/Fewa/TestStartEndForm.resx b/TBF/Rig/DataEntry/Double24/TestStartEndForm.resx similarity index 100% rename from TBF/Rig/DataEntry/Fewa/TestStartEndForm.resx rename to TBF/Rig/DataEntry/Double24/TestStartEndForm.resx diff --git a/TBF/Rig/DataEntry/Fewa/EntryFormCfg.cs b/TBF/Rig/DataEntry/Fewa/EntryFormCfg.cs deleted file mode 100644 index 544b45499..000000000 --- a/TBF/Rig/DataEntry/Fewa/EntryFormCfg.cs +++ /dev/null @@ -1,45 +0,0 @@ -/// -/// Copyright (c) 2019 Sensus Slovensko a.s. -/// -using System; -using System.Collections.Generic; -using System.IO; -using System.Xml.Serialization; -using TBF.Rig.Generic; - -namespace TBF.Rig.DataEntry.Fewa -{ - public class EntryFormCfg : ComponentCfgBase, Generic.IComponentCfg - { - public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(EntryFormCfg) })[0]; - public override XmlSerializer GetSerializer() { return Serializer; } - - public IComponentCfgCtrl GetControl(IList cmpntEntities) { return new EntryFormCfgCtrl(); } - - /// - /// Serialized parameters - /// - public bool EnterSerialNrsAtTheEnd; - public bool ShowCycleEndForm; - - /// Private parameterless constructor invoked by all other (public) constructors - EntryFormCfg() - { - Name = "DataEntry-FEWA"; - ParentName = string.Empty; - EnterSerialNrsAtTheEnd = false; - ShowCycleEndForm = false; - } - - public EntryFormCfg(IComponentFactory factory) - : this() - { - this.Factory = factory; - } - - public string ToString(int i) - { - return string.Format("Name={0}, EnterSNsAtTheEnd={1}, ShowEndForm={2}", Name, EnterSerialNrsAtTheEnd, ShowCycleEndForm); - } - } -} diff --git a/TBF/Rig/DataEntry/Fewa/EntryFormCfgCtrl.cs b/TBF/Rig/DataEntry/Fewa/EntryFormCfgCtrl.cs deleted file mode 100644 index 7578ab5ad..000000000 --- a/TBF/Rig/DataEntry/Fewa/EntryFormCfgCtrl.cs +++ /dev/null @@ -1,84 +0,0 @@ -/// -/// Copyright (c) 2019 Sensus Slovensko a.s. -/// -using System; -using System.Windows.Forms; -using Common; -using Config.Entities; -using TBF.Rig.Generic; -using TBF.Resources; - -namespace TBF.Rig.DataEntry.Fewa -{ - public partial class EntryFormCfgCtrl : UserControl, IComponentCfgCtrl - { - public bool ShowMore { get { return false; } } - - EntryFormCfg config; - public IComponentCfg Config - { - get { return config as IComponentCfg; } - set - { - config = value as EntryFormCfg; - Redraw(); - } - } - - public EntryFormCfgCtrl() - { - InitializeComponent(); - } - - private void EntryFormCfgCtrl_Load(object sender, EventArgs e) - { - Localize(); - Redraw(); - } - - void Localize() - { - enterSNsAtTheEndCheckBox.Text = Strings.Enter_SNs_at_the_end; - showEndStateFormCheckBox.Text = Strings.Show_cycle_end_form; - } - - public void Closing() - { - } - - void Redraw() - { - if (config == null) return; /// Control was not loaded, settings were not changed - classNameLabel.Text = config.Factory.ClassName; - nameTextBox.Text = config.Name; - enterSNsAtTheEndCheckBox.Checked = config.EnterSerialNrsAtTheEnd; - showEndStateFormCheckBox.Checked = config.ShowCycleEndForm; - } - - public void Unlock() - { - nameTextBox.Enabled = true; - enterSNsAtTheEndCheckBox.Enabled = true; - showEndStateFormCheckBox.Enabled = true; - } - - public CfgUpdateFlags VerifyCfg(ref string message) - { - CfgUpdateFlags flags = CfgUpdateFlags.None; - return flags; - } - - public CfgUpdateFlags UpdateCfg() - { - CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd; - - if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed - - config.Name = nameTextBox.Text; - config.EnterSerialNrsAtTheEnd = enterSNsAtTheEndCheckBox.Checked; - config.ShowCycleEndForm = showEndStateFormCheckBox.Checked; - - return flags; - } - } -} diff --git a/TBF/Rig/DataEntry/Fewa/EntryFormCfgCtrl.designer.cs b/TBF/Rig/DataEntry/Fewa/EntryFormCfgCtrl.designer.cs deleted file mode 100644 index 276b11601..000000000 --- a/TBF/Rig/DataEntry/Fewa/EntryFormCfgCtrl.designer.cs +++ /dev/null @@ -1,114 +0,0 @@ -/// -/// Copyright (c) 2019 Sensus Slovensko a.s. -/// -namespace TBF.Rig.DataEntry.Fewa -{ - partial class EntryFormCfgCtrl - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.nameTextBox = new System.Windows.Forms.TextBox(); - this.nameLabel = new System.Windows.Forms.Label(); - this.classNameLabel = new System.Windows.Forms.Label(); - this.showEndStateFormCheckBox = new System.Windows.Forms.CheckBox(); - this.enterSNsAtTheEndCheckBox = new System.Windows.Forms.CheckBox(); - this.SuspendLayout(); - // - // nameTextBox - // - this.nameTextBox.Enabled = false; - this.nameTextBox.Location = new System.Drawing.Point(99, 57); - this.nameTextBox.Name = "nameTextBox"; - this.nameTextBox.Size = new System.Drawing.Size(130, 20); - this.nameTextBox.TabIndex = 2; - // - // nameLabel - // - this.nameLabel.AutoSize = true; - this.nameLabel.Location = new System.Drawing.Point(35, 60); - this.nameLabel.Name = "nameLabel"; - this.nameLabel.Size = new System.Drawing.Size(35, 13); - this.nameLabel.TabIndex = 1; - this.nameLabel.Text = "Name"; - // - // classNameLabel - // - this.classNameLabel.AutoSize = true; - this.classNameLabel.Location = new System.Drawing.Point(96, 33); - this.classNameLabel.Name = "classNameLabel"; - this.classNameLabel.Size = new System.Drawing.Size(83, 13); - this.classNameLabel.TabIndex = 0; - this.classNameLabel.Text = "ComonentName"; - // - // showEndStateFormCheckBox - // - this.showEndStateFormCheckBox.AutoSize = true; - this.showEndStateFormCheckBox.Enabled = false; - this.showEndStateFormCheckBox.Location = new System.Drawing.Point(99, 112); - this.showEndStateFormCheckBox.Name = "showEndStateFormCheckBox"; - this.showEndStateFormCheckBox.Size = new System.Drawing.Size(151, 17); - this.showEndStateFormCheckBox.TabIndex = 4; - this.showEndStateFormCheckBox.Text = "Watermeter end state form"; - this.showEndStateFormCheckBox.UseVisualStyleBackColor = true; - // - // enterSNsAtTheEndCheckBox - // - this.enterSNsAtTheEndCheckBox.AutoSize = true; - this.enterSNsAtTheEndCheckBox.Enabled = false; - this.enterSNsAtTheEndCheckBox.Location = new System.Drawing.Point(99, 89); - this.enterSNsAtTheEndCheckBox.Name = "enterSNsAtTheEndCheckBox"; - this.enterSNsAtTheEndCheckBox.Size = new System.Drawing.Size(167, 17); - this.enterSNsAtTheEndCheckBox.TabIndex = 3; - this.enterSNsAtTheEndCheckBox.Text = "Enter serial number at the end"; - this.enterSNsAtTheEndCheckBox.UseVisualStyleBackColor = true; - // - // EntryFormCfgCtrl - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.enterSNsAtTheEndCheckBox); - this.Controls.Add(this.showEndStateFormCheckBox); - this.Controls.Add(this.nameTextBox); - this.Controls.Add(this.nameLabel); - this.Controls.Add(this.classNameLabel); - this.Name = "EntryFormCfgCtrl"; - this.Size = new System.Drawing.Size(300, 200); - this.Load += new System.EventHandler(this.EntryFormCfgCtrl_Load); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TextBox nameTextBox; - private System.Windows.Forms.Label nameLabel; - private System.Windows.Forms.Label classNameLabel; - private System.Windows.Forms.CheckBox showEndStateFormCheckBox; - private System.Windows.Forms.CheckBox enterSNsAtTheEndCheckBox; - } -} diff --git a/TBF/Rig/DataEntry/Fewa/EntryFormCfgCtrl.resx b/TBF/Rig/DataEntry/Fewa/EntryFormCfgCtrl.resx deleted file mode 100644 index 1af7de150..000000000 --- a/TBF/Rig/DataEntry/Fewa/EntryFormCfgCtrl.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/TBF/Rig/TbfComponents.cs b/TBF/Rig/TbfComponents.cs index 7a0c5564c..86f350742 100644 --- a/TBF/Rig/TbfComponents.cs +++ b/TBF/Rig/TbfComponents.cs @@ -25,8 +25,8 @@ namespace TBF.Rig Factories.Add(new Elde.CoverTest.Factory()); Factories.Add(new DataEntry.Combined.EntryFormFactory()); Factories.Add(new DataEntry.DataStream.Factory()); - Factories.Add(new DataEntry.Fewa.Factory()); - Factories.Add(new DataEntry.Fewa.FactoryNoStartEnd()); + Factories.Add(new DataEntry.Double24.Factory()); + Factories.Add(new DataEntry.Double24.FactoryNoStartEnd()); Factories.Add(new DataEntry.HeatMeters6.Factory()); Factories.Add(new DataEntry.HeatMeters12.Factory()); Factories.Add(new DataEntry.Munich3.EntryFormFactory()); diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index 2d8ae417d..f10cdc40e 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -241,33 +241,27 @@ TestStartEndForm.cs - + Form - + CycleBeginningForm.cs - + Form - + CycleEndForm.cs - - - - UserControl - - - EntryFormCfgCtrl.cs - - - - - + + + + + + Form - + TestStartEndForm.cs @@ -2772,16 +2766,13 @@ TestStartEndForm.cs - + CycleBeginningForm.cs - + CycleEndForm.cs - - EntryFormCfgCtrl.cs - - + TestStartEndForm.cs