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
@@ -122,7 +122,9 @@ namespace TBF.BenchControl.MettlerToledo.Standard
public void Initialize() public void Initialize()
{ {
base.Initalize(); if (balanceCfg.DebugLevel == DebugMode.Simulate) return;
base.Initalize();
if (balanceCfg.CalibValidDate != DateTime.MinValue && balanceCfg.CalibValidDate.Date < DateTime.Now.Date) 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 msrmntState = MsrmntState.Failed; /// Data not valid yet
MsrmntTime = 0; MsrmntTime = 0;
if (balanceCfg.DebugLevel == DebugMode.Simulate) return;
stringBuilder = new StringBuilder(40); stringBuilder = new StringBuilder(40);
string comPortName = "COM" + balanceCfg.ComPortNr.ToString(); string comPortName = "COM" + balanceCfg.ComPortNr.ToString();
serialPort = new SerialPort(comPortName, balanceCfg.BaudRate, balanceCfg.Parity, balanceCfg.DataBits, balanceCfg.StopBits); serialPort = new SerialPort(comPortName, balanceCfg.BaudRate, balanceCfg.Parity, balanceCfg.DataBits, balanceCfg.StopBits);
@@ -148,8 +148,13 @@ namespace TBF.BenchControl.Modbus.PumpFM.DanfossVLT
modbus = (GenericDevices.IModbus)TbfComponents.FindComponent(cfg.ParentName, components); modbus = (GenericDevices.IModbus)TbfComponents.FindComponent(cfg.ParentName, components);
if (modbus == null) throw new Exception("Cannot find " + Name + " parent"); if (modbus == null) throw new Exception("Cannot find " + Name + " parent");
controlBoard = TbfComponents.FindComponent("CB", components) as IControlBoard; /// TODO: replace "CB" controlBoard = null;
if (controlBoard == null) throw new Exception("Cannot find a control board"); 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; bitNr = pumpCfg.BitNr;
Mask = (((UInt128)1) << bitNr); Mask = (((UInt128)1) << bitNr);
@@ -19,14 +19,14 @@ namespace TBF.BenchControl.Modbus.TempMeter.Groch
readonly TempMeterCfg tempMtrCfg; readonly TempMeterCfg tempMtrCfg;
public SchematicDrawing.IDrawingItem DrawingItem { get { return tempMtrCfg as SchematicDrawing.IDrawingItem; } } 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 int Idx0 { get { return tempMtrCfg.Idx0; } } /// 0..15
public double A1 { get { return tempMtrCfg.A1; } } double A1 { get { return tempMtrCfg.A1; } }
public double A2 { get { return tempMtrCfg.A2; } } double A2 { get { return tempMtrCfg.A2; } }
public double A3 { get { return tempMtrCfg.A3; } } double A3 { get { return tempMtrCfg.A3; } }
public double A4 { get { return tempMtrCfg.A4; } } double A4 { get { return tempMtrCfg.A4; } }
public double A5 { get { return tempMtrCfg.A5; } } double A5 { get { return tempMtrCfg.A5; } }
public TempMeter() public TempMeter()
{ {
@@ -37,15 +37,8 @@ namespace TBF.BenchControl.Modbus.TempMeter.Groch
{ {
tempMtrCfg = cfg as TempMeterCfg; tempMtrCfg = cfg as TempMeterCfg;
ControlBoard = (CBoard)TbfComponents.FindComponent(cfg.ParentName, components); modbus = TbfComponents.FindComponent(cfg.ParentName, components) as Common.Modbus;
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent"); if (modbus == 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;
log.Warn(this.ToString()); log.Warn(this.ToString());
} }
@@ -86,7 +79,7 @@ namespace TBF.BenchControl.Modbus.TempMeter.Groch
{ {
if (Cfg.DebugLevel == Config.Entities.DebugMode.Normal) 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) else if (Cfg.DebugLevel == Config.Entities.DebugMode.Simulate)
{ {
@@ -43,7 +43,7 @@ namespace TBF.BenchControl.Modbus.TempMeter.Groch
{ {
foreach (var cmpnt in parent.CmpntEntities) 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); parentNameComboBox.Items.Add(cmpnt.Name);
} }
+1 -1
View File
@@ -67,7 +67,7 @@ namespace TBF.BenchControl.Uni.Diverter
Factory = factory; Factory = factory;
Name = "Div"; Name = "Div";
ParentName = "CB"; ParentName = "UniCB";
DivNr1 = 1; DivNr1 = 1;
BitNr = 0; BitNr = 0;
AdcNr = 5; /// Div1: AdcNr=5 , Div2: AdcNr=6 AdcNr = 5; /// Div1: AdcNr=5 , Div2: AdcNr=6
+1 -1
View File
@@ -8,7 +8,7 @@ namespace TBF.BenchControl.Uni.Diverter
{ {
public class Factory : IComponentFactory 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 override string ToString() { return ClassName; }
public void ResetStaticProperties() { Diverter.ResetStaticProperties(); } public void ResetStaticProperties() { Diverter.ResetStaticProperties(); }
+1 -1
View File
@@ -8,7 +8,7 @@ namespace TBF.BenchControl.Uni.FlowMeter
{ {
public class Factory : IComponentFactory 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 override string ToString() { return ClassName; }
public void ResetStaticProperties() { FlowMeter.ResetStaticProperties(); } public void ResetStaticProperties() { FlowMeter.ResetStaticProperties(); }
@@ -252,7 +252,7 @@ namespace TBF.BenchControl.Uni.FlowMeter
Factory = factory; Factory = factory;
Name = "FlowMeter"; Name = "FlowMeter";
ParentName = "CB"; ParentName = "UniCB";
Idx1 = 1; Idx1 = 1;
NominalFlow = 1; NominalFlow = 1;
} }
+1 -1
View File
@@ -8,7 +8,7 @@ namespace TBF.BenchControl.Uni.RegValve
{ {
public class Factory : IComponentFactory 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 override string ToString() { return ClassName; }
public void ResetStaticProperties() { RegValve.ResetStaticProperties(); } public void ResetStaticProperties() { RegValve.ResetStaticProperties(); }
+1 -1
View File
@@ -69,7 +69,7 @@ namespace TBF.BenchControl.Uni.RegValve
Name = name; Name = name;
Factory = factory; Factory = factory;
ParentName = "CB"; ParentName = "UniCB";
Category = ValveCategory.Output; Category = ValveCategory.Output;
Idx1 = 1; Idx1 = 1;
AdcValueClosed = 100; AdcValueClosed = 100;
@@ -740,13 +740,13 @@ namespace TBF.UI.Bench.Components
else if (cfg is BenchControl.Modbus.TempMeter.Groch.TempMeterCfg) else if (cfg is BenchControl.Modbus.TempMeter.Groch.TempMeterCfg)
{ {
(cfg as IChildComponentCfg).ParentName = "CB"; (cfg as IChildComponentCfg).ParentName = "CB";
(cfg as BenchControl.Elde.TempMeter.TempMeterCfg).Idx0 = zeroBasedIdx; (cfg as BenchControl.Modbus.TempMeter.Groch.TempMeterCfg).Idx0 = zeroBasedIdx;
return true; return true;
} }
else if (cfg is BenchControl.Modbus.PressureMeter.Meret.PressureMeterCfg) else if (cfg is BenchControl.Modbus.PressureMeter.Meret.PressureMeterCfg)
{ {
(cfg as IChildComponentCfg).ParentName = "CB"; (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; return true;
} }
else if (cfg is BenchControl.RegisterReaders.PulsesFromUniCB.RRCfg) else if (cfg is BenchControl.RegisterReaders.PulsesFromUniCB.RRCfg)