From 6c181cdb6706d94e1a97be9cdb250c5c3b7d9de6 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Sun, 19 Sep 2021 14:36:42 +0200 Subject: [PATCH] TBF.Data initialization on TBF start-up (also in case IsRealBench = false), ver. 3.1.1736 --- TBF/Properties/AssemblyInfo.cs | 4 ++-- TBF/UI/MainWnd.cs | 31 ++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 6daac0800..503f85ebe 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.1734.0")] -[assembly: AssemblyFileVersion("3.1.1734.0")] +[assembly: AssemblyVersion("3.1.1736.0")] +[assembly: AssemblyFileVersion("3.1.1736.0")] diff --git a/TBF/UI/MainWnd.cs b/TBF/UI/MainWnd.cs index cb6d76ae1..57357fc6e 100644 --- a/TBF/UI/MainWnd.cs +++ b/TBF/UI/MainWnd.cs @@ -87,7 +87,7 @@ namespace TBF.UI #endif /// DB entities of components loaded in the MainWnd constructor - IList cmptnEntities; + IList cmpntEntities; /// @@ -136,12 +136,33 @@ namespace TBF.UI { /// Load the list of components from the database var session = TBF.DB.CreateSession(DBKind.Config); - cmptnEntities = session.QueryOver().OrderBy(x => x.ItemNr).Asc.List(); + cmpntEntities = session.QueryOver().OrderBy(x => x.ItemNr).Asc.List(); } catch (Exception) { MessageBox.Show(Strings.Failed_to_load_components, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - cmptnEntities = new List(); + cmpntEntities = new List(); + } + + /// + /// Set TBF.Data members when there is a BenchInfo or an iPerlBenchInfo component + /// + foreach (var cmpnt in cmpntEntities) + { + if (cmpnt.ClassName == "DataContainer.BenchInfo") + { + var cfg = new TBF.Rig.DataContainer.BenchInfo.Factory().CmpntCfgFromCmpntEntity(cmpnt) + as TBF.Rig.DataContainer.BenchInfo.ComponentCfg; + TBF.Data.SetData(cfg.WaterMetersCount, cfg.CompoundMetersCount, cfg.LinesCount); + break; + } + else if (cmpnt.ClassName == "DataContainer.iPerlBenchInfo") + { + var cfg = new TBF.Rig.DataContainer.iPerlBenchInfo.Factory().CmpntCfgFromCmpntEntity(cmpnt) + as TBF.Rig.DataContainer.iPerlBenchInfo.ComponentCfg; + TBF.Data.SetData(cfg.WaterMetersCount, cfg.CompoundMetersCount, cfg.LinesCount); + break; + } } Rig.StateMachine.MachineState = TBF.DB.CurrentBench.IsRealBench ? Rig.MachineState.StartingUp : Rig.MachineState.Disabled; @@ -151,7 +172,7 @@ namespace TBF.UI try { /// Initialize the control board, etc. - Rig.StateMachine.InitializeBoardEtc(cmptnEntities); + Rig.StateMachine.InitializeBoardEtc(cmpntEntities); /// Check remote and local configuration DB compatibility string msg; @@ -362,7 +383,7 @@ namespace TBF.UI string[] edgesLcfg = null; string[] edgesXLcfg = null; /// - var schDrawingCmpnts = TBF.DB.CurrentBench.IsRealBench ? Rig.StateMachine.Components : TBF.Rig.TbfComponents.LoadComponentsFromDB(cmptnEntities); + var schDrawingCmpnts = TBF.DB.CurrentBench.IsRealBench ? Rig.StateMachine.Components : TBF.Rig.TbfComponents.LoadComponentsFromDB(cmpntEntities); foreach (var component in schDrawingCmpnts) { TBF.Rig.Generic.IComponentCfg cmpCfg = component.Cfg;