Various changes done when adding new components (parents, etc.)

This commit is contained in:
Milan Hanajik 2021-02-24 15:27:35 +01:00
parent 878e7be9fa
commit a9d6fa631c
11 changed files with 29 additions and 31 deletions

View File

@ -122,7 +122,9 @@ namespace TBF.BenchControl.MettlerToledo.Standard
public void Initialize()
{
base.Initalize();
if (balanceCfg.DebugLevel == DebugMode.Simulate) return;
base.Initalize();
if (balanceCfg.CalibValidDate != DateTime.MinValue && balanceCfg.CalibValidDate.Date < DateTime.Now.Date)
{
@ -133,8 +135,6 @@ namespace TBF.BenchControl.MettlerToledo.Standard
msrmntState = MsrmntState.Failed; /// Data not valid yet
MsrmntTime = 0;
if (balanceCfg.DebugLevel == DebugMode.Simulate) return;
stringBuilder = new StringBuilder(40);
string comPortName = "COM" + balanceCfg.ComPortNr.ToString();
serialPort = new SerialPort(comPortName, balanceCfg.BaudRate, balanceCfg.Parity, balanceCfg.DataBits, balanceCfg.StopBits);

View File

@ -148,8 +148,13 @@ namespace TBF.BenchControl.Modbus.PumpFM.DanfossVLT
modbus = (GenericDevices.IModbus)TbfComponents.FindComponent(cfg.ParentName, components);
if (modbus == null) throw new Exception("Cannot find " + Name + " parent");
controlBoard = TbfComponents.FindComponent("CB", components) as IControlBoard; /// TODO: replace "CB"
if (controlBoard == null) throw new Exception("Cannot find a control board");
controlBoard = null;
foreach (var name in new string[] { "CB", "UniCB" })
{
if ((controlBoard = TbfComponents.FindComponent(name, components) as IControlBoard) != null)
break;
}
if (controlBoard == null) throw new Exception("Cannot find a control board");
bitNr = pumpCfg.BitNr;
Mask = (((UInt128)1) << bitNr);

View File

@ -19,14 +19,14 @@ namespace TBF.BenchControl.Modbus.TempMeter.Groch
readonly TempMeterCfg tempMtrCfg;
public SchematicDrawing.IDrawingItem DrawingItem { get { return tempMtrCfg as SchematicDrawing.IDrawingItem; } }
public readonly CBoard ControlBoard;
readonly Common.Modbus modbus;
public int Idx0 { get { return tempMtrCfg.Idx0; } } /// 0..15
public double A1 { get { return tempMtrCfg.A1; } }
public double A2 { get { return tempMtrCfg.A2; } }
public double A3 { get { return tempMtrCfg.A3; } }
public double A4 { get { return tempMtrCfg.A4; } }
public double A5 { get { return tempMtrCfg.A5; } }
int Idx0 { get { return tempMtrCfg.Idx0; } } /// 0..15
double A1 { get { return tempMtrCfg.A1; } }
double A2 { get { return tempMtrCfg.A2; } }
double A3 { get { return tempMtrCfg.A3; } }
double A4 { get { return tempMtrCfg.A4; } }
double A5 { get { return tempMtrCfg.A5; } }
public TempMeter()
{
@ -37,15 +37,8 @@ namespace TBF.BenchControl.Modbus.TempMeter.Groch
{
tempMtrCfg = cfg as TempMeterCfg;
ControlBoard = (CBoard)TbfComponents.FindComponent(cfg.ParentName, components);
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
/// Prepare data for SendCalibData() control board component method
ControlBoard.TempCalibData[Idx0, 0] = (float)A1;
ControlBoard.TempCalibData[Idx0, 1] = (float)A2;
ControlBoard.TempCalibData[Idx0, 2] = (float)A3;
ControlBoard.TempCalibData[Idx0, 3] = (float)A4;
ControlBoard.TempCalibData[Idx0, 4] = (float)A5;
modbus = TbfComponents.FindComponent(cfg.ParentName, components) as Common.Modbus;
if (modbus == null) throw new Exception("Cannot find " + Name + " parent");
log.Warn(this.ToString());
}
@ -86,7 +79,7 @@ namespace TBF.BenchControl.Modbus.TempMeter.Groch
{
if (Cfg.DebugLevel == Config.Entities.DebugMode.Normal)
{
return Config.Formulas.CorrectedValue((double)ControlBoard.Temperature(Idx0), Corrections);
return 0; // Config.Formulas.CorrectedValue((double)ControlBoard.Temperature(Idx0), Corrections);
}
else if (Cfg.DebugLevel == Config.Entities.DebugMode.Simulate)
{

View File

@ -43,7 +43,7 @@ namespace TBF.BenchControl.Modbus.TempMeter.Groch
{
foreach (var cmpnt in parent.CmpntEntities)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is ControlBoard.Legacy.ControlBoardFactory)
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Modbus.Common.Factory)
{
parentNameComboBox.Items.Add(cmpnt.Name);
}

View File

@ -67,7 +67,7 @@ namespace TBF.BenchControl.Uni.Diverter
Factory = factory;
Name = "Div";
ParentName = "CB";
ParentName = "UniCB";
DivNr1 = 1;
BitNr = 0;
AdcNr = 5; /// Div1: AdcNr=5 , Div2: AdcNr=6

View File

@ -8,7 +8,7 @@ namespace TBF.BenchControl.Uni.Diverter
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(17); } }
public string ClassName { get { return this.GetType().Namespace.Substring(17 + 4); } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { Diverter.ResetStaticProperties(); }

View File

@ -8,7 +8,7 @@ namespace TBF.BenchControl.Uni.FlowMeter
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(17); } }
public string ClassName { get { return this.GetType().Namespace.Substring(17 + 4); } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { FlowMeter.ResetStaticProperties(); }

View File

@ -252,7 +252,7 @@ namespace TBF.BenchControl.Uni.FlowMeter
Factory = factory;
Name = "FlowMeter";
ParentName = "CB";
ParentName = "UniCB";
Idx1 = 1;
NominalFlow = 1;
}

View File

@ -8,7 +8,7 @@ namespace TBF.BenchControl.Uni.RegValve
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(17); } }
public string ClassName { get { return this.GetType().Namespace.Substring(17 + 4); } }
public override string ToString() { return ClassName; }
public void ResetStaticProperties() { RegValve.ResetStaticProperties(); }

View File

@ -69,7 +69,7 @@ namespace TBF.BenchControl.Uni.RegValve
Name = name;
Factory = factory;
ParentName = "CB";
ParentName = "UniCB";
Category = ValveCategory.Output;
Idx1 = 1;
AdcValueClosed = 100;

View File

@ -740,13 +740,13 @@ namespace TBF.UI.Bench.Components
else if (cfg is BenchControl.Modbus.TempMeter.Groch.TempMeterCfg)
{
(cfg as IChildComponentCfg).ParentName = "CB";
(cfg as BenchControl.Elde.TempMeter.TempMeterCfg).Idx0 = zeroBasedIdx;
(cfg as BenchControl.Modbus.TempMeter.Groch.TempMeterCfg).Idx0 = zeroBasedIdx;
return true;
}
else if (cfg is BenchControl.Modbus.PressureMeter.Meret.PressureMeterCfg)
{
(cfg as IChildComponentCfg).ParentName = "CB";
(cfg as BenchControl.Elde.PressureMeter.PressureMeterCfg).Idx0 = zeroBasedIdx;
(cfg as BenchControl.Modbus.PressureMeter.Meret.PressureMeterCfg).ModbusAddress = (byte)(zeroBasedIdx + 1);
return true;
}
else if (cfg is BenchControl.RegisterReaders.PulsesFromUniCB.RRCfg)