TBF.Data initialization on TBF start-up (also in case IsRealBench = false), ver. 3.1.1736

This commit is contained in:
Milan Hanajik
2021-09-19 14:45:02 +02:00
parent a0aea713b0
commit 6c181cdb67
2 changed files with 28 additions and 7 deletions
+2 -2
View File
@@ -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")]
+26 -5
View File
@@ -87,7 +87,7 @@ namespace TBF.UI
#endif
/// DB entities of components loaded in the MainWnd constructor
IList<Config.Entities.Component> cmptnEntities;
IList<Config.Entities.Component> cmpntEntities;
/// <summary>
@@ -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<Config.Entities.Component>().OrderBy(x => x.ItemNr).Asc.List();
cmpntEntities = session.QueryOver<Config.Entities.Component>().OrderBy(x => x.ItemNr).Asc.List();
}
catch (Exception)
{
MessageBox.Show(Strings.Failed_to_load_components, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
cmptnEntities = new List<Config.Entities.Component>();
cmpntEntities = new List<Config.Entities.Component>();
}
///
/// 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;