2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
2019-07-09 08:49:13 +00:00
|
|
|
|
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
|
2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
|
|
|
|
|
using System.Collections.Generic;
|
2015-12-04 16:17:20 +00:00
|
|
|
|
using Config.Entities;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
using TBF.BenchControl.Generic;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl
|
|
|
|
|
|
{
|
|
|
|
|
|
public static class TbfComponents
|
|
|
|
|
|
{
|
2014-12-29 15:00:27 +00:00
|
|
|
|
public readonly static IList<IComponentFactory> Factories;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
static TbfComponents()
|
|
|
|
|
|
{
|
|
|
|
|
|
Factories = new List<IComponentFactory>();
|
|
|
|
|
|
|
2019-09-18 07:09:00 +00:00
|
|
|
|
Factories.Add(new DataContainers.BackupAndSecurityOptions.ComponentFactory());
|
|
|
|
|
|
Factories.Add(new DataContainers.BenchInfo.Extended.ComponentFactory());
|
|
|
|
|
|
Factories.Add(new DataContainers.BenchInfo.iPerl.ComponentFactory());
|
|
|
|
|
|
Factories.Add(new DataContainers.Buoyancy.ComponentFactory());
|
|
|
|
|
|
Factories.Add(new DataContainers.Density.ComponentFactory());
|
2018-12-03 07:14:15 +00:00
|
|
|
|
Factories.Add(new Elde.ControlBoardFactory());
|
2017-05-04 14:31:40 +00:00
|
|
|
|
Factories.Add(new Elde.CoverTest.Factory());
|
|
|
|
|
|
Factories.Add(new DataEntry.Combined.EntryFormFactory());
|
2016-10-11 11:05:40 +00:00
|
|
|
|
Factories.Add(new DataEntry.HeatMeters6.Factory());
|
|
|
|
|
|
Factories.Add(new DataEntry.HeatMeters12.Factory());
|
2019-04-16 04:41:40 +00:00
|
|
|
|
Factories.Add(new DataEntry.Fewa.Factory());
|
|
|
|
|
|
Factories.Add(new DataEntry.Fewa.FactoryNoStartEnd());
|
|
|
|
|
|
Factories.Add(new DataEntry.Munich3.EntryFormFactory());
|
2014-07-28 07:54:35 +00:00
|
|
|
|
Factories.Add(new DataEntry.Munich.EntryFormFactory());
|
2015-08-24 07:33:13 +00:00
|
|
|
|
Factories.Add(new DataEntry.iPerl.EntryFormFactory());
|
2019-01-15 20:51:11 +00:00
|
|
|
|
Factories.Add(new DataEntry.Single.Factory());
|
|
|
|
|
|
Factories.Add(new DataEntry.Single.FactoryNoStartEnd());
|
|
|
|
|
|
Factories.Add(new DataEntry.Standard6.Factory());
|
2017-03-10 13:59:29 +00:00
|
|
|
|
Factories.Add(new DataEntry.Standard6.FactoryNoStartEnd());
|
|
|
|
|
|
Factories.Add(new DataEntry.Standard12.Factory());
|
|
|
|
|
|
Factories.Add(new DataEntry.Standard12.FactoryNoStartEnd());
|
|
|
|
|
|
Factories.Add(new DataEntry.Standard24.Factory());
|
|
|
|
|
|
Factories.Add(new DataEntry.Standard24.FactoryNoStartEnd());
|
|
|
|
|
|
Factories.Add(new DataEntry.Standard48.Factory());
|
|
|
|
|
|
Factories.Add(new DataEntry.Standard48.FactoryNoStartEnd());
|
2017-07-27 07:59:55 +00:00
|
|
|
|
Factories.Add(new DataEntry.StandardCamera.Factory());
|
2019-01-16 13:52:20 +00:00
|
|
|
|
Factories.Add(new RegisterReaders.KPackE.DataEntryForRadio.Factory()); /// DataEntry for KPackE radio
|
|
|
|
|
|
Factories.Add(new Dummy.Balance.Factory());
|
2016-12-09 11:18:22 +00:00
|
|
|
|
Factories.Add(new Dummy.Diverter.Factory());
|
2017-01-25 15:15:11 +00:00
|
|
|
|
Factories.Add(new Dummy.FlowMeter.Factory());
|
|
|
|
|
|
Factories.Add(new Dummy.RegulValve.Factory());
|
|
|
|
|
|
Factories.Add(new Dummy.Valve.Factory());
|
|
|
|
|
|
Factories.Add(new Elde.Diverter.DiverterFactory());
|
2015-02-01 15:20:27 +00:00
|
|
|
|
Factories.Add(new Elde.FlowMeter.FlowMeterFactory());
|
2019-05-10 15:47:11 +00:00
|
|
|
|
Factories.Add(new Elde.FlowMeterDewa.Factory());
|
|
|
|
|
|
Factories.Add(new Elde.FlowMeterTwins.FlowMeterFactory());
|
2017-12-18 12:35:29 +00:00
|
|
|
|
Factories.Add(new Elde.FlowMeterTriplet.FlowMeterFactory());
|
2016-10-06 11:57:32 +00:00
|
|
|
|
Factories.Add(new TestMethods.Adjustment.Factory());
|
2018-09-18 13:25:31 +00:00
|
|
|
|
Factories.Add(new TestMethods.ChangeFlowDirection.Factory());
|
2016-10-06 11:57:32 +00:00
|
|
|
|
Factories.Add(new TestMethods.CombinedWithDetection.TestMethodFactory());
|
2019-05-06 10:14:57 +00:00
|
|
|
|
Factories.Add(new TestMethods.Counter.Factory());
|
2019-07-09 08:49:13 +00:00
|
|
|
|
Factories.Add(new TestMethods.DiverterTest.Factory());
|
2019-10-01 11:45:21 +00:00
|
|
|
|
Factories.Add(new TestMethods.Dummy.Factory());
|
2016-11-30 13:30:32 +00:00
|
|
|
|
Factories.Add(new TestMethods.Endurance.Factory());
|
2018-03-22 20:03:13 +00:00
|
|
|
|
Factories.Add(new TestMethods.FixedStart.Single.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FixedStart.Compound.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FixedStart.HeatMeters.Factory());
|
2019-11-12 13:13:52 +00:00
|
|
|
|
Factories.Add(new TestMethods.FixedStartDeferredEval.Single.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FixedStartDeferredEval.Compound.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FixedStartDeferredEval.HeatMeters.Factory());
|
2017-11-22 11:12:04 +00:00
|
|
|
|
Factories.Add(new TestMethods.FixedStartMassCollection.Single.Factory());
|
2016-08-17 10:24:24 +00:00
|
|
|
|
Factories.Add(new TestMethods.FixedStartMassCollection.Compound.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FixedStartMassCollection.HeatMeters.Factory());
|
2019-11-12 13:13:52 +00:00
|
|
|
|
Factories.Add(new TestMethods.FixedStartMassCollDeferredEval.Single.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FixedStartMassCollDeferredEval.Compound.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FixedStartMassCollDeferredEval.HeatMeters.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FixedStartTankCollection.Single.Factory());
|
2018-10-22 16:14:47 +00:00
|
|
|
|
Factories.Add(new TestMethods.FixedStartTankCollection.Compound.Factory());
|
2016-08-17 10:24:24 +00:00
|
|
|
|
Factories.Add(new TestMethods.FlyingStart.Single.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FlyingStart.Compound.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FlyingStart.HeatMeters.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FlyingStartMassCollection.Single.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FlyingStartMassCollection.Compound.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FlyingStartMassCollection.HeatMeters.Factory());
|
2018-11-20 13:53:59 +00:00
|
|
|
|
Factories.Add(new TestMethods.FlyingStartMassCollComparative.Single.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FlyingStartMassCollComparative.Compound.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FlyingStartMassCollComparative.HeatMeters.Factory());
|
2018-01-16 16:23:38 +00:00
|
|
|
|
Factories.Add(new TestMethods.FlyingStartMassCollProlonged.Single.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FlyingStartMassCollProlonged.Compound.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FlyingStartMassCollProlonged.HeatMeters.Factory());
|
2018-01-15 15:53:27 +00:00
|
|
|
|
Factories.Add(new TestMethods.FlyingStartFirstRepetWithMassColl.Single.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FlyingStartFirstRepetWithMassColl.Compound.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FlyingStartFirstRepetWithMassColl.HeatMeters.Factory());
|
2018-10-22 16:14:47 +00:00
|
|
|
|
Factories.Add(new TestMethods.FlyingStartTankCollection.Single.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.FlyingStartTankCollection.Compound.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.GrabImage.Factory());
|
2017-07-23 18:40:57 +00:00
|
|
|
|
Factories.Add(new TestMethods.LeakTest.TestMethodFactory());
|
2017-02-16 17:17:10 +00:00
|
|
|
|
Factories.Add(new TestMethods.LiveStream.Factory());
|
2019-12-19 07:23:58 +00:00
|
|
|
|
Factories.Add(new TestMethods.ManualEntry.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.OuterLoop.Start.Factory());
|
2016-12-10 11:13:45 +00:00
|
|
|
|
Factories.Add(new TestMethods.OuterLoop.End.Factory());
|
|
|
|
|
|
Factories.Add(new TestMethods.PMaxTest.TestMethodFactory());
|
2018-07-17 12:16:46 +00:00
|
|
|
|
Factories.Add(new TestMethods.PulsesTest.Factory());
|
2018-09-12 12:19:18 +00:00
|
|
|
|
Factories.Add(new TestMethods.PulsesTestManual.Factory());
|
2019-08-15 06:59:51 +00:00
|
|
|
|
Factories.Add(new TestMethods.Q2CorrectionFromHistory.Factory());
|
2018-10-10 12:03:48 +00:00
|
|
|
|
Factories.Add(new TestMethods.SensitivityTest.Factory());
|
2016-10-06 11:57:32 +00:00
|
|
|
|
Factories.Add(new TestMethods.iPerlCommunication.TestMethodFactory()); /// iPerlCommunication
|
2017-01-14 15:11:11 +00:00
|
|
|
|
Factories.Add(new TestMethods.RoiDetection.RoiDetectionFactory());
|
2016-10-06 11:57:32 +00:00
|
|
|
|
Factories.Add(new DataEntry.WMStates.EntryFormFactory());
|
2015-04-16 20:06:42 +00:00
|
|
|
|
Factories.Add(new Ambient.Comet.Factory());
|
|
|
|
|
|
Factories.Add(new Ambient.Greco.Factory());
|
2018-09-14 10:13:15 +00:00
|
|
|
|
Factories.Add(new Hart.Common.Factory());
|
|
|
|
|
|
Factories.Add(new Hart.Nivotrack.Factory());
|
2018-10-22 16:14:47 +00:00
|
|
|
|
Factories.Add(new Keithley.Multimeter_2010_RS232.Factory()); /// Keithley.Multimeter_2010_RS232
|
2016-06-23 14:39:56 +00:00
|
|
|
|
Factories.Add(new Keithley.TempMeter.Factory()); /// Keithley.TempMeter
|
2015-07-31 08:45:50 +00:00
|
|
|
|
Factories.Add(new MettlerToledo.Standard.BalanceFactory()); /// MettlerToledo Balance
|
2016-04-20 13:58:48 +00:00
|
|
|
|
Factories.Add(new MettlerToledo.Standard.BalanceOldFactory()); /// MettlerToledoBalanceOld
|
|
|
|
|
|
Factories.Add(new MettlerToledo.Standard.BalanceNewFactory()); /// MettlerToledoBalanceSN
|
2015-07-31 08:45:50 +00:00
|
|
|
|
Factories.Add(new MettlerToledo.Multi.BalanceFactory()); /// MettlerToledo-Multi
|
2017-09-28 13:24:10 +00:00
|
|
|
|
Factories.Add(new Modbus.CometAmbient.Factory()); /// Modbus.CometAmbient.Ambient
|
|
|
|
|
|
Factories.Add(new Modbus.Common.Factory()); /// Modbus
|
2017-02-10 12:43:41 +00:00
|
|
|
|
Factories.Add(new Modbus.Easytherm.Factory()); /// Modbus.Easytherm
|
|
|
|
|
|
Factories.Add(new Modbus.PressureMeter.Meret.Factory()); /// Modbus.PressureMeter.Meret - Meret pressure meter connected via modbus
|
|
|
|
|
|
Factories.Add(new Modbus.QuidoRS.Factory()); /// Modbus.QuidoRS
|
|
|
|
|
|
Factories.Add(new Modbus.TankSelector.Factory()); /// Modbus.TankSelector
|
2018-09-13 08:17:00 +00:00
|
|
|
|
Factories.Add(new Modbus.UltrasoundLevelMeter.Factory());
|
2016-12-29 11:30:31 +00:00
|
|
|
|
Factories.Add(new Network.Adapter.Factory());
|
|
|
|
|
|
Factories.Add(new Network.Camera.CLP1611.Factory());
|
2017-04-06 10:32:46 +00:00
|
|
|
|
Factories.Add(new Network.Camera.Display.Factory());
|
2017-01-14 13:20:10 +00:00
|
|
|
|
Factories.Add(new Network.Camera.Roi.Factory());
|
2017-07-27 09:17:47 +00:00
|
|
|
|
Factories.Add(new Network.Camera.RoiForFixedStart.Factory());
|
2018-02-20 09:45:58 +00:00
|
|
|
|
Factories.Add(new Network.Comet.Ambient.Factory());
|
2018-08-28 08:12:39 +00:00
|
|
|
|
Factories.Add(new Output.DB.ProductionTracing.Factory());
|
2019-07-10 13:41:02 +00:00
|
|
|
|
Factories.Add(new Output.DB.SaveDiverterCorrections.Factory());
|
2018-02-06 11:53:42 +00:00
|
|
|
|
Factories.Add(new Output.DB.SaveFlowmeterCorrections.Factory());
|
2018-09-11 11:39:33 +00:00
|
|
|
|
Factories.Add(new Output.DB.SensusOracle.Factory());
|
2018-01-26 08:18:06 +00:00
|
|
|
|
Factories.Add(new Output.FileWriters.Basic.FactorySingle());
|
2017-02-15 22:06:16 +00:00
|
|
|
|
Factories.Add(new Output.FileWriters.Basic.FactoryCompound());
|
|
|
|
|
|
Factories.Add(new Output.FileWriters.Basic.FactoryHeatMeters());
|
2019-04-26 08:09:26 +00:00
|
|
|
|
Factories.Add(new Output.FileWriters.Elde.FactorySingle());
|
2017-02-15 22:06:16 +00:00
|
|
|
|
Factories.Add(new Output.FileWriters.Enhanced.FactorySingle());
|
|
|
|
|
|
Factories.Add(new Output.FileWriters.Enhanced.FactoryCompound());
|
|
|
|
|
|
Factories.Add(new Output.FileWriters.Enhanced.FactoryHeatMeters());
|
2017-07-23 09:53:27 +00:00
|
|
|
|
Factories.Add(new Output.FileWriters.ImageArchiver.Factory());
|
2018-09-05 09:05:08 +00:00
|
|
|
|
Factories.Add(new Output.FileWriters.IperlLogger.Factory());
|
|
|
|
|
|
Factories.Add(new Output.FileWriters.OneFilePerMeter.FactorySingle());
|
2017-07-23 09:53:27 +00:00
|
|
|
|
Factories.Add(new Output.FileWriters.OneFilePerMeter.FactoryCompound());
|
|
|
|
|
|
Factories.Add(new Output.FileWriters.OneFilePerMeter.FactoryHeatMeters());
|
2017-02-15 22:06:16 +00:00
|
|
|
|
Factories.Add(new Output.FileWriters.Xml.FactorySingle());
|
|
|
|
|
|
Factories.Add(new Output.FileWriters.Xml.FactoryCompound());
|
|
|
|
|
|
Factories.Add(new Output.FileWriters.Xml.FactoryHeatMeters());
|
2018-03-19 08:27:57 +00:00
|
|
|
|
Factories.Add(new Output.FileWriters.XmlBatch.FactorySingle());
|
|
|
|
|
|
Factories.Add(new Output.Printers.Enhanced.FactorySingle());
|
2017-05-04 14:31:40 +00:00
|
|
|
|
Factories.Add(new Output.Printers.Enhanced.FactoryCompound());
|
|
|
|
|
|
Factories.Add(new Output.Printers.Enhanced.FactoryHeatMeters());
|
2019-01-13 11:30:02 +00:00
|
|
|
|
Factories.Add(new Output.Printers.Label.Factory()); /// Label printer
|
2018-04-09 11:22:29 +00:00
|
|
|
|
Factories.Add(new Output.Printers.Munich.PrinterFactory());
|
|
|
|
|
|
Factories.Add(new Output.Printers.OnePerMeter.FactorySingle());
|
2017-11-15 10:49:20 +00:00
|
|
|
|
Factories.Add(new Output.Printers.OnePerMeter.FactoryCompound());
|
|
|
|
|
|
Factories.Add(new Output.Printers.OnePerMeter.FactoryHeatMeters());
|
2017-09-21 06:59:08 +00:00
|
|
|
|
Factories.Add(new Output.Printers.Zapiska.FactorySingle());
|
|
|
|
|
|
Factories.Add(new Output.Printers.Zapiska.FactoryCompound());
|
|
|
|
|
|
Factories.Add(new Output.Printers.Zapiska.FactoryHeatMeters());
|
2017-07-23 09:53:27 +00:00
|
|
|
|
Factories.Add(new Elde.PressureMeter.PressureMeterFactory());
|
2015-05-21 15:48:27 +00:00
|
|
|
|
Factories.Add(new Elde.PressureMeterInternal.PressureMeterFactory());
|
2014-07-28 07:54:35 +00:00
|
|
|
|
Factories.Add(new Elde.Pump.PumpFactory());
|
2015-02-16 12:36:22 +00:00
|
|
|
|
Factories.Add(new Danfoss.VLT2800.PumpFactory());
|
2014-07-28 07:54:35 +00:00
|
|
|
|
Factories.Add(new Elde.PumpWithFM.PumpFactory());
|
2015-01-11 04:06:18 +00:00
|
|
|
|
Factories.Add(new Elde.PumpTandem.PumpFactory());
|
2017-08-16 11:43:02 +00:00
|
|
|
|
Factories.Add(new Elde.RegisterReader.Factory()); /// 'RegisterReader'
|
|
|
|
|
|
Factories.Add(new Elde.FixedStartRegisterReader.RegisterReaderFactory()); /// 'RegisterReader for standing start/stop'
|
|
|
|
|
|
Factories.Add(new TestMethods.iPerlCommunication.iPerlHead.Factory()); /// 'RegisterReader for iPerl'
|
2018-05-30 16:29:46 +00:00
|
|
|
|
Factories.Add(new RegisterReaders.SerialStream.Factory()); /// 'RegisterReader for generic serial stream'
|
2019-01-16 13:52:20 +00:00
|
|
|
|
Factories.Add(new RegisterReaders.KPackE.RegisterReader.Factory()); /// KPackE register reader
|
|
|
|
|
|
Factories.Add(new RegisterReaders.KPackE.Radio.Factory()); /// Radio for KPackE register readers
|
2018-05-30 16:29:46 +00:00
|
|
|
|
Factories.Add(new Elde.RegulValve.RegulValveFactory());
|
2017-07-27 07:09:06 +00:00
|
|
|
|
Factories.Add(new Elde.RegulValveCoax.Factory());
|
2015-02-03 06:48:48 +00:00
|
|
|
|
Factories.Add(new Elde.RegulValveTandem.RegulValveTandemFactory());
|
2015-02-01 15:20:27 +00:00
|
|
|
|
Factories.Add(new Elde.TempMeter.TempMeterFactory());
|
2015-05-21 15:48:27 +00:00
|
|
|
|
Factories.Add(new Elde.TempMeterInternal.TempMeterFactory());
|
2018-10-03 10:34:59 +00:00
|
|
|
|
Factories.Add(new Elde.TempMeterMeret.Factory()); /// Meret temp. meter connected to control board Modbus
|
|
|
|
|
|
Factories.Add(new Elde.Valve.ValveFactory());
|
2015-07-01 13:28:28 +00:00
|
|
|
|
Factories.Add(new Elde.ValveEx.ValveFactory());
|
2018-10-22 16:14:47 +00:00
|
|
|
|
Factories.Add(new Various.ErrorFlags.Factory());
|
2019-05-15 12:04:40 +00:00
|
|
|
|
Factories.Add(new Various.Evaporation.Factory());
|
2018-10-22 16:14:47 +00:00
|
|
|
|
Factories.Add(new Various.TankWithLevelMsrmnt.Factory());
|
|
|
|
|
|
Factories.Add(new WaterMeters.Munich.WaterMeterFactory()); /// 'WaterMeters.Munich'
|
2017-08-16 11:43:02 +00:00
|
|
|
|
Factories.Add(new WaterMeters.WaterMeter.WaterMeterFactory()); /// 'WaterMeter'
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Get a component factory given the component name
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="className">Component class name</param>
|
|
|
|
|
|
/// <returns>Component factory instance</returns>
|
|
|
|
|
|
public static IComponentFactory CmpntFactoryFromClassName(string className)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var factory in Factories)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (factory.ClassName.Equals(className)) return factory;
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-09-16 10:04:08 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Get a component configuration given a component DB entity
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="entity">DB entity</param>
|
|
|
|
|
|
/// <returns>An appropriate component configuration or null if factory was not found</returns>
|
2015-12-04 16:17:20 +00:00
|
|
|
|
public static IComponentCfg CmpntCfgFromCmpntEntity(Component entity)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2014-09-16 10:04:08 +00:00
|
|
|
|
IComponentFactory cmpntFactory = CmpntFactoryFromClassName(entity.ClassName);
|
2018-07-16 08:26:17 +00:00
|
|
|
|
if (cmpntFactory == null) return null;
|
|
|
|
|
|
|
|
|
|
|
|
try { return cmpntFactory.CmpntCfgFromCmpntEntity(entity); }
|
|
|
|
|
|
catch { return null; }
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-01-16 12:34:40 +00:00
|
|
|
|
|
|
|
|
|
|
public static string CurrentlyLoadedComponentName;
|
|
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Load component entities from the database and convert them to TBF components
|
|
|
|
|
|
/// derived from IComponent with mutual references.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="session">NHibernate DB session</param>
|
|
|
|
|
|
/// <returns>A list of TBF Components</returns>
|
|
|
|
|
|
public static IList<IComponent> LoadComponentsFromDB(NHibernate.ISession session)
|
|
|
|
|
|
{
|
2017-01-16 12:34:40 +00:00
|
|
|
|
CurrentlyLoadedComponentName = string.Empty;
|
|
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
foreach (var factory in Factories) factory.ResetStaticProperties();
|
|
|
|
|
|
|
|
|
|
|
|
/// Load the list of components from the database
|
2016-12-02 11:52:30 +00:00
|
|
|
|
IList<Component> cmptnEntities = session.QueryOver<Component>()
|
|
|
|
|
|
.OrderBy(x => x.ItemNr).Asc
|
|
|
|
|
|
.List();
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
/// Convert database entities to TBF components
|
|
|
|
|
|
IList<IComponent> components = new List<BenchControl.Generic.IComponent>();
|
|
|
|
|
|
foreach (var entity in cmptnEntities)
|
|
|
|
|
|
{
|
2017-01-16 12:34:40 +00:00
|
|
|
|
CurrentlyLoadedComponentName = entity.Name;
|
|
|
|
|
|
|
2014-09-16 10:04:08 +00:00
|
|
|
|
IComponentFactory cmpntFactory = BenchControl.TbfComponents.CmpntFactoryFromClassName(entity.ClassName);
|
|
|
|
|
|
if (cmpntFactory == null) continue;
|
|
|
|
|
|
|
2016-08-05 12:32:36 +00:00
|
|
|
|
IComponent cmpnt = cmpntFactory.GetComponent(cmpntFactory.CmpntCfgFromCmpntEntity(entity), components);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-12-31 12:46:33 +00:00
|
|
|
|
///
|
2014-07-28 07:54:35 +00:00
|
|
|
|
/// Inherit DebugMode from the parent (if any)
|
2014-12-31 12:46:33 +00:00
|
|
|
|
///
|
2015-12-04 16:17:20 +00:00
|
|
|
|
if ((cmpnt.Cfg.DebugLevel == DebugMode.Inherit) &&
|
2014-08-15 18:50:42 +00:00
|
|
|
|
(cmpnt.Cfg is IChildComponentCfg) &&
|
2014-07-28 07:54:35 +00:00
|
|
|
|
!string.IsNullOrEmpty(cmpnt.Cfg.ParentName))
|
|
|
|
|
|
{
|
2014-08-15 18:50:42 +00:00
|
|
|
|
bool inherited = false;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
foreach (var par in components)
|
|
|
|
|
|
{
|
2014-08-15 18:50:42 +00:00
|
|
|
|
if (par.Cfg.Name.Equals(cmpnt.Cfg.ParentName))
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Parent found, inherit the debug mode
|
|
|
|
|
|
cmpnt.Cfg.DebugLevel = par.Cfg.DebugLevel;
|
|
|
|
|
|
inherited = true;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
2014-08-15 18:50:42 +00:00
|
|
|
|
if (!inherited)
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Applied when the parent is (most likely) in DebugMode.Off
|
2015-12-04 16:17:20 +00:00
|
|
|
|
cmpnt.Cfg.DebugLevel = DebugMode.Off;
|
2014-08-15 18:50:42 +00:00
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2015-12-04 16:17:20 +00:00
|
|
|
|
if (cmpnt.Cfg.DebugLevel != DebugMode.Off) components.Add(cmpnt);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-01-16 12:34:40 +00:00
|
|
|
|
CurrentlyLoadedComponentName = string.Empty;
|
|
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
return components;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Get a reference to a component with a given name from a list of components.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="name">Component name</param>
|
|
|
|
|
|
/// <param name="components">A list of components</param>
|
|
|
|
|
|
/// <returns>Matching component or null</returns>
|
|
|
|
|
|
public static IComponent FindComponent(string name, IList<IComponent> components)
|
|
|
|
|
|
{
|
2015-01-02 18:14:19 +00:00
|
|
|
|
if (string.IsNullOrEmpty(name)) return null;
|
|
|
|
|
|
foreach (var cmpnt in components)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cmpnt.Cfg.Name.Equals(name)) return cmpnt;
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2015-01-02 18:14:19 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
public static IComponent FindComponent(string name)
|
|
|
|
|
|
{
|
|
|
|
|
|
return FindComponent(name, StateMachine.Components);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|