Everything works OK after serious changes:

- all components, componentCfg-s and parameter providers use base classes
 - less boilerplate code, simpler access to test/procedure parameters from code
 - CreateTestParams(test), CreateProcedureParams(procedure) methods added
 - TestBenchSim class is made static, it is not inheritted by any device anymore
This commit is contained in:
Milan Hanajik
2015-01-02 12:51:27 +01:00
parent 752719bd62
commit 94de991bf6
126 changed files with 1117 additions and 1629 deletions
@@ -8,8 +8,8 @@ namespace TBF.BenchControl.Elde
{
public int ComPortNr;
/// Parameterless constructor
public ControlBoardCfg()
/// Private parameterless constructor invoked by all other (public) constructors
ControlBoardCfg()
{
Name = "CB";
ParentName = string.Empty;
@@ -24,7 +24,7 @@ namespace TBF.BenchControl.Elde
public string ToString(int i)
{
return string.Format("Name={0}, ComPortNr={1}", Name, ComPortNr);
return string.Format("Name={0}, Com{1}", Name, ComPortNr);
}
}
}
@@ -8,26 +8,12 @@ using log4net;
namespace TBF.BenchControl.Elde
{
public class ControlBoardDev : IComponent, IDevice, IValveControl
public class ControlBoardDev : ComponentBase, IDevice, IValveControl
{
/// <summary>
/// Info:
/// Warn:
/// Error:
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(ControlBoardDev));
public override string ToString()
{
return string.Format("ControlBoardDev: Name={0}, ComPort={1}", controlBoardCfg.Name, controlBoardCfg.ComPortNr);
}
public static void ResetStaticProperties() { }
ControlBoardCfg controlBoardCfg;
public Generic.IComponentCfg Cfg { get { return controlBoardCfg; } }
public string Name { get { return controlBoardCfg.Name; } }
public override string ToString() { return string.Format("ControlBoard({0})", Cfg.ToString(1)); }
readonly ControlBoardCfg controlBoardCfg;
///
/// Reference to the control board component
@@ -159,9 +145,10 @@ namespace TBF.BenchControl.Elde
/// Constructor
/// </summary>
public ControlBoardDev(ControlBoardCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
if (cfg == null) throw new ArgumentNullException("cfg");
this.controlBoardCfg = cfg;
controlBoardCfg = cfg;
#if FUZHOU300 || PT200IL
FMFreq = new float[6] { 0, 0, 0, 0, 0, 0 }; /// Nr. of pumps: Fuzhou150=2, Fuzhou300,PT200IL=6
#else
@@ -169,7 +156,9 @@ namespace TBF.BenchControl.Elde
#endif
emergencyStop = false;
previousEmergencyStop = false;
}
log.Debug(this.ToString());
}
/// <summary>
/// Specific pre-initialization for control board only
@@ -7,10 +7,6 @@ namespace TBF.BenchControl.Elde
public class ControlBoardFactory : IComponentFactory
{
public string ClassName { get { return "ControlBoard"; } }
public bool HasProcedureParams { get { return false; } }
public bool HasTestParams { get { return false; } }
public IParamsProvider GetTestParams(Entities.ComponentTest testParams) { return null; }
public IParamsProvider GetProcedureParams(Entities.ComponentProcedure procedureParams) { return null; }
/// <summary>Max. number of components of this class in the system</summary>
public int MaxCount { get { return 1; } }
@@ -5,7 +5,7 @@ using log4net;
namespace TBF.BenchControl.Elde
{
public class ControlComSim : TestBenchSim, IControlCom
public class ControlComSim : IControlCom
{
private static readonly ILog log = LogManager.GetLogger(typeof(ControlComSim));
public override string ToString() { return string.Format("ControlComSim"); }
@@ -149,7 +149,7 @@ namespace TBF.BenchControl.Elde
this.cmd = cmd;
this.refFlowmtrNr = refFlowmtrNr;
this.route = route;
RouteSim = route;
TestBenchSim.RouteSim = route;
this.totalRefPulses = totalRefPulses;
this.testMethods = testMethods;
this.filterConstant = filterConstant;
@@ -201,7 +201,7 @@ namespace TBF.BenchControl.Elde
public void RunDeviceBefore()
{
base.RunDevice(regulValveNo, refFlowmtrNr, statusP);
TestBenchSim.RunDevice(regulValveNo, refFlowmtrNr, statusP);
log.DebugFormat("refFreq=", referenceFreq);
@@ -217,14 +217,14 @@ namespace TBF.BenchControl.Elde
case Command.Start:
if ((testMethods & TestMethods.Diverter) == TestMethods.Diverter)
{
SetSimDiverter(true);
TestBenchSim.SetSimDiverter(true);
}
break;
case Command.Stop:
if ((testMethods & TestMethods.Diverter) == TestMethods.Diverter)
{
SetSimDiverter(false);
TestBenchSim.SetSimDiverter(false);
}
break;
}
@@ -233,12 +233,12 @@ namespace TBF.BenchControl.Elde
{
case RegulValveMode.TargetFrequency:
float targetFlow = ((regulValveValue[0] + regulValveValue[1]) / 2.0f) * (Qnom / 2000.0f);
UpdateSimFlow(targetFlow);
TestBenchSim.UpdateSimFlow(targetFlow);
//if (referenceFreq < valveValue[0]) referenceFreq += ((float)rand.Next(20) + 10.0f) / 2.0f;
//else if (referenceFreq > valveValue[1]) referenceFreq -= ((float)rand.Next(20) + 10.0f) / 2.0f;
//else referenceFreq += ((float)rand.Next(10) - 5.0f) / 2.0f;
referenceFreq = GetSimFlow() * 2000.0f / Qnom;
referenceFreq = TestBenchSim.GetSimFlow() * 2000.0f / Qnom;
if (referenceFreq < 0) referenceFreq = 0;
if (referenceFreq > 2500) referenceFreq = 2500;
break;
@@ -270,7 +270,7 @@ namespace TBF.BenchControl.Elde
for (int i = 1; i < Program.WMsCount; i++)
{
const float wmPulsesPerLiter = 10.0f;
wMeterPulsesF[i] += errFactor[i] * pwFactor * ((float)rand.Next(100) + 450.0f) * wmPulsesPerLiter * GetSimFlow() / 1800.0f;
wMeterPulsesF[i] += errFactor[i] * pwFactor * ((float)rand.Next(100) + 450.0f) * wmPulsesPerLiter * TestBenchSim.GetSimFlow() / 1800.0f;
wMeterPulses[i] = (int)wMeterPulsesF[i];
}
@@ -283,7 +283,7 @@ namespace TBF.BenchControl.Elde
if (stopTest)
{
SetSimDiverter(false);
TestBenchSim.SetSimDiverter(false);
statusP = (statusP | StatusP.TestCompleted);
statusP = (statusP & ~StatusP.TestInProgress);
}
@@ -4,34 +4,25 @@ using log4net;
namespace TBF.BenchControl.Elde.Diverter
{
public class Diverter : Generic.IComponent, GenericDevices.IDiverter
public class Diverter : ComponentBase, GenericDevices.IDiverter
{
/// <summary>
/// Info: StartMassMeasurement() and "Balance response = .., Mass = ..."
/// Warn: Start measurement when busy is true
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(Diverter));
public override string ToString()
{
return string.Format("Diverter({0},{1})", Name, diverterCfg.BitPosition);
}
public override string ToString() { return string.Format("Diverter({0})", Cfg.ToString(1)); }
public static void ResetStaticProperties() { }
private readonly DiverterCfg diverterCfg;
public Generic.IComponentCfg Cfg { get { return diverterCfg; } }
public string Name { get { return diverterCfg.Name; } }
readonly DiverterCfg diverterCfg;
readonly ControlBoardDev controlBoard;
readonly ulong mask; /// derived from bitPosition in the constructor
public bool State
{
get { return (controlBoard.Route & mask) != 0; }
}
public Diverter(DiverterCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
if (cfg == null) throw new ArgumentNullException("cfg");
this.diverterCfg = cfg;
diverterCfg = cfg;
controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
@@ -41,10 +32,5 @@ namespace TBF.BenchControl.Elde.Diverter
log.Debug(this.ToString());
}
public bool State
{
get { return (controlBoard.Route & mask) != 0; }
}
}
}
@@ -8,8 +8,8 @@ namespace TBF.BenchControl.Elde.Diverter
{
public int BitPosition;
/// Parameterless constructor
public DiverterCfg()
/// Private parameterless constructor invoked by all other (public) constructors
DiverterCfg()
{
Name = "Div";
ParentName = "CB";
@@ -25,6 +25,7 @@ namespace TBF.BenchControl.Elde.Diverter
public string ToString(int i)
{
return string.Format("Name={0}, Parent={1}, Bit={2}",
Name,
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
BitPosition);
}
@@ -9,10 +9,6 @@ namespace TBF.BenchControl.Elde.Diverter
public class DiverterFactory : IComponentFactory
{
public string ClassName { get { return "Diverter"; } }
public bool HasProcedureParams { get { return false; } }
public bool HasTestParams { get { return false; } }
public IParamsProvider GetTestParams(Entities.ComponentTest testParams) { return null; }
public IParamsProvider GetProcedureParams(Entities.ComponentProcedure procedureParams) { return null; }
/// <summary>Max. number of components of this class in the system</summary>
public int MaxCount { get { return 5; } }
@@ -7,17 +7,23 @@ using TBF.Resources;
namespace TBF.BenchControl.Elde.FixedStartRegisterReader
{
public class RRProcedureParams : IParamsProvider, IProcedureParams
public class RRProcedureParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
{
public float PulsesPerLtr; /// Target low limit of the flow increase or decrease
public override void InitializeAll()
{
PulsesPerLtr = 1.0f;
}
string[] paramNames = new string[]
{
Strings.PulsesPerLtr,
};
public string ParamName(int i) { return paramNames[i]; }
public override string ParamName(int i) { return paramNames[i]; }
public override int ParamsCount() { return paramNames.Length; }
public string ToString(int i)
public override string ToString(int i)
{
switch (i)
{
@@ -25,14 +31,6 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader
default: return string.Empty;
}
}
/// <summary>
/// Parameterless constructor - sets default values of parameters.
/// </summary>
public RRProcedureParams()
{
PulsesPerLtr = 1.0f;
}
/// Retrieves parameters from UI controls
public void UpdateParam(int i, string strValue)
@@ -64,92 +62,34 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader
return false;
}
#region Boilerplate code
public int ParamsCount() { return paramNames.Length; }
public override string ToString()
public override void UpdateProcedureParams(Entities.ComponentProcedure dbEntity)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < ParamsCount(); i++)
{
if (i != 0) sb.Append("; ");
sb.Append(ParamName(i));
sb.Append("=");
sb.Append(ToString(i));
}
return sb.ToString();
}
[XmlIgnore]
public Entities.ComponentProcedure ProcedureParamsEntity { get { return procedureParamsEntity; } }
Entities.ComponentProcedure procedureParamsEntity;
[XmlIgnore]
public string ComponentName { get { return componentName; } }
string componentName;
[XmlIgnore]
public Entities.Procedure Procedure { get { return procedure; } }
Entities.Procedure procedure;
public RRProcedureParams(Entities.ComponentProcedure procedureParamsEntity, string componentName, Entities.Procedure procedure)
: this()
{
this.procedureParamsEntity = procedureParamsEntity;
this.componentName = componentName;
this.procedure = procedure;
}
public TBF.Entities.ComponentProcedure ToDbEntity(IComponent component, Entities.Procedure procedure)
{
using (var writer = new StringWriter())
{
/// Serialize this class with parameters
(new XmlSerializer(GetType())).Serialize(writer, this);
/// Create and return the ComponentProcedure entity
TBF.Entities.ComponentProcedure entity = new TBF.Entities.ComponentProcedure();
entity.CmpntName = component.Cfg.Name;
entity.Parameters = writer.ToString();
entity.Procedure = procedure;
return entity;
}
}
public void UpdateDbEntity()
{
using (var writer = new StringWriter())
{
/// Serialize this class and update the entity
(new XmlSerializer(GetType())).Serialize(writer, this);
procedureParamsEntity.Parameters = writer.ToString();
procedureParamsEntity.CmpntName = componentName;
procedureParamsEntity.Procedure = procedure;
}
}
public static IParamsProvider GetProcedureParams(Entities.ComponentProcedure procedureParamsEntity)
{
if (procedureParamsEntity == null) return new RRProcedureParams();
RRProcedureParams procedureParams;
if (dbEntity == null) return;
try
{
procedureParams = (RRProcedureParams)(new XmlSerializer(typeof(RRProcedureParams)))
.Deserialize(new StringReader(procedureParamsEntity.Parameters));
RRProcedureParams tmp = (RRProcedureParams)(new XmlSerializer(typeof(RRProcedureParams)))
.Deserialize(new StringReader(dbEntity.Parameters));
procedureParamsEntity = dbEntity;
componentName = dbEntity.CmpntName;
procedure = dbEntity.Procedure;
PulsesPerLtr = tmp.PulsesPerLtr;
}
catch
{
procedureParams = new RRProcedureParams();
}
procedureParams.procedureParamsEntity = procedureParamsEntity;
procedureParams.componentName = procedureParamsEntity.CmpntName;
procedureParams.procedure = procedureParamsEntity.Procedure;
return procedureParams;
}
#endregion
public RRProcedureParams()
{
}
public RRProcedureParams(Entities.ComponentProcedure procedureParamsEntity, string componentName, Entities.Procedure procedure)
{
this.procedureParamsEntity = procedureParamsEntity;
this.componentName = componentName;
}
}
}
@@ -7,35 +7,22 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader
{
public class RegisterReader : ComponentBase, GenericDevices.IRegisterReader
{
/// <summary>
/// Info: StartMassMeasurement() and "Balance response = .., Mass = ..."
/// Warn: Start measurement when busy is true
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(RegisterReader));
public override string ToString()
{
return string.Format("Register({0})", Name);
}
public override string ToString() { return string.Format("FixedStartRegisterReader({0})", Cfg.ToString(1)); }
readonly RegisterReaderCfg registerReaderCfg;
public float BeginWMState;
public float EndWMState;
public static void ResetStaticProperties() { }
public float PulsesPerLtr
{
get
{
return (ProcedureParams is RRProcedureParams) ? (ProcedureParams as RRProcedureParams).PulsesPerLtr : 0;
}
}
public float PulsesPerLtr { get { return registerReaderCfg.ProcParams.PulsesPerLtr; } }
public readonly ControlBoardDev ControlBoard;
public RegisterReader(RegisterReaderCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
if (cfg == null) throw new ArgumentNullException("cfg");
registerReaderCfg = cfg;
ControlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
@@ -7,11 +7,23 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader
{
public class RegisterReaderCfg : ComponentCfgBase, Generic.IChildComponentCfg
{
/// Parameterless constructor
public RegisterReaderCfg()
/// <summary> Procedure parameters </summary>
[XmlIgnore]
public RRProcedureParams ProcParams;
public override IParamsProvider GetProcedureParams() { return ProcParams; }
public override IParamsProvider CreateProcedureParams(Entities.Procedure procedure)
{
RRProcedureParams procParams = new RRProcedureParams();
procParams.UpdateProcedureParams(Name, procedure);
return procParams;
}
/// Private parameterless constructor invoked by all other (public) constructors
RegisterReaderCfg()
{
Name = "DummyRR";
ParentName = "CB";
ProcParams = new RRProcedureParams();
}
public RegisterReaderCfg(IComponentFactory factory)
@@ -64,7 +64,6 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader
{
CfgVerifyFlags flags = CfgVerifyFlags.None;
int dummy;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{
flags |= CfgVerifyFlags.Error;
@@ -30,17 +30,6 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader
return ComponentCfgBase.CreateFromDbEntity(typeof(RegisterReaderCfg), component, this);
}
public bool HasProcedureParams { get { return true; } }
///
public IParamsProvider GetProcedureParams(Entities.ComponentProcedure procedureParams)
{
return RRProcedureParams.GetProcedureParams(procedureParams);
}
public bool HasTestParams { get { return false; } }
///
public IParamsProvider GetTestParams(Entities.ComponentTest testParams) { return null; }
public void ResetStaticProperties() { RegisterReader.ResetStaticProperties(); }
}
}
@@ -5,33 +5,20 @@ using TBF.Boxes;
namespace TBF.BenchControl.Elde.FlowMeter
{
public class FlowMeter : Generic.IComponent, GenericDevices.IFlowMeter
public class FlowMeter : ComponentBase, GenericDevices.IFlowMeter
{
/// <summary>
/// Info: StartMassMeasurement() and "Balance response = .., Mass = ..."
/// Warn: Start measurement when busy is true
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(FlowMeter));
public override string ToString()
{
return string.Format("FlowMeter: Name={0}, Idx1={1}", Name, Idx1);
}
public override string ToString() { return string.Format("FlowMeter({0})", Cfg.ToString(1)); }
public static void ResetStaticProperties() { }
readonly FlowMeterCfg flowMeterCfg;
FlowMeterCfg flowMeterCfg;
public Generic.IComponentCfg Cfg { get { return flowMeterCfg; } }
public string Name { get { return flowMeterCfg.Name; } }
public int Idx1 { get { return flowMeterCfg.Idx1; } }
public IList<Entities.MeasurementCorrection> Corrections { get { return flowMeterCfg.Corrections; } }
public readonly ControlBoardDev ControlBoard;
public float NominalFlow { get { return nominalFlow; } }
readonly float nominalFlow;
public float NominalFlow { get { return flowMeterCfg.NominalFlow; } }
public float LtrPerPulse { get { return nominalFlow / 7200.0f; } }
public float LtrPerPulse { get { return flowMeterCfg.NominalFlow / 7200.0f; } }
public float LtrPerPulseCorrected(float flow)
{
@@ -42,15 +29,14 @@ namespace TBF.BenchControl.Elde.FlowMeter
public FlowMeter(FlowMeterCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
if (cfg == null) throw new ArgumentNullException("cfg");
this.flowMeterCfg = cfg;
flowMeterCfg = cfg;
ControlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
nominalFlow = cfg.NominalFlow;
ControlBoard.EtCalib[Idx1] = NominalFlow;
ControlBoard.EtCalib[Idx1] = flowMeterCfg.NominalFlow;
/// Prepare data for SendCalibData() control board component method
@@ -9,9 +9,9 @@ namespace TBF.BenchControl.Elde.FlowMeter
{
public int Idx1; /// 1..5
public float NominalFlow; /// Nominal flow in m3/h at output frequency 2000 Hz
/// Parameterless constructor
public FlowMeterCfg()
/// Private parameterless constructor invoked by all other (public) constructors
FlowMeterCfg()
{
Name = "FlowMeter";
ParentName = "CB";
@@ -9,10 +9,6 @@ namespace TBF.BenchControl.Elde.FlowMeter
public class FlowMeterFactory : IComponentFactory
{
public string ClassName { get { return "FlowMeter"; } }
public bool HasProcedureParams { get { return false; } }
public bool HasTestParams { get { return false; } }
public IParamsProvider GetTestParams(Entities.ComponentTest testParams) { return null; }
public IParamsProvider GetProcedureParams(Entities.ComponentProcedure procedureParams) { return null; }
/// <summary>Max. number of components of this class in the system</summary>
public int MaxCount { get { return 7; } }
@@ -5,26 +5,12 @@ using TBF.Boxes;
namespace TBF.BenchControl.Elde.FlowMeterTwins
{
public class FlowMeter : Generic.IComponent, GenericDevices.IFlowMeter
public class FlowMeter : ComponentBase, GenericDevices.IFlowMeter
{
/// <summary>
/// Info: StartMassMeasurement() and "Balance response = .., Mass = ..."
/// Warn: Start measurement when busy is true
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(FlowMeter));
public override string ToString()
{
return string.Format("FlowMeter: Name={0}", Name);
}
public override string ToString() { return string.Format("FlowMeterTwins({0})", Cfg.ToString(1)); }
public static void ResetStaticProperties() { }
FlowMeterCfg flowMeterCfg;
public Generic.IComponentCfg Cfg { get { return flowMeterCfg; } }
public string Name { get { return flowMeterCfg.Name; } }
public IList<Entities.MeasurementCorrection> Corrections { get { return flowMeterCfg.Corrections; } }
readonly FlowMeterCfg flowMeterCfg;
public int Idx1 { get { return 0; } }
@@ -32,11 +18,10 @@ namespace TBF.BenchControl.Elde.FlowMeterTwins
public readonly TBF.BenchControl.Elde.FlowMeter.FlowMeter FlowMeter1;
public readonly TBF.BenchControl.Elde.FlowMeter.FlowMeter FlowMeter2;
public float NominalFlow { get { return nominalFlow; } }
readonly float nominalFlow;
public float NominalFlow { get { return flowMeterCfg.NominalFlow; } }
/// The nominal flowed of a pair of flow meters is reached at 4000Hz
public float LtrPerPulse { get { return nominalFlow / 14400.0f; } }
public float LtrPerPulse { get { return flowMeterCfg.NominalFlow / 14400.0f; } }
/// Calculates the average of values of two flowmeters. Assumes the flow is divided evenly.
public float LtrPerPulseCorrected(float flow)
@@ -47,9 +32,9 @@ namespace TBF.BenchControl.Elde.FlowMeterTwins
public FlowMeter(FlowMeterCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
if (cfg == null) throw new ArgumentNullException("cfg");
this.flowMeterCfg = cfg;
flowMeterCfg = cfg;
ControlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
@@ -60,8 +45,7 @@ namespace TBF.BenchControl.Elde.FlowMeterTwins
FlowMeter2 = (TBF.BenchControl.Elde.FlowMeter.FlowMeter)TbfComponents.FindComponent(flowMeterCfg.FlowMeter2, components);
if (FlowMeter2 == null) throw new Exception("Cannot find FlowMeter2 component");
nominalFlow = cfg.NominalFlow;
ControlBoard.EtCalib[Idx1] = NominalFlow;
ControlBoard.EtCalib[Idx1] = flowMeterCfg.NominalFlow;
/// Prepare data for SendCalibData() control board component method
@@ -10,9 +10,9 @@ namespace TBF.BenchControl.Elde.FlowMeterTwins
public float NominalFlow; /// Nominal flow in m3/h at output frequency 2000 Hz
public string FlowMeter1; /// Name of the flow meter 1 component
public string FlowMeter2; /// Name of the flow meter 2 component
/// Parameterless constructor
public FlowMeterCfg()
/// Private parameterless constructor invoked by all other (public) constructors
FlowMeterCfg()
{
Name = "FlowMeterTwins";
ParentName = "CB";
@@ -9,10 +9,6 @@ namespace TBF.BenchControl.Elde.FlowMeterTwins
public class FlowMeterFactory : IComponentFactory
{
public string ClassName { get { return "FlowMeterTwins"; } }
public bool HasProcedureParams { get { return false; } }
public bool HasTestParams { get { return false; } }
public IParamsProvider GetTestParams(Entities.ComponentTest testParams) { return null; }
public IParamsProvider GetProcedureParams(Entities.ComponentProcedure procedureParams) { return null; }
/// <summary>Max. number of components of this class in the system</summary>
public int MaxCount { get { return 1; } }
@@ -6,25 +6,12 @@ using TBF.Boxes;
namespace TBF.BenchControl.Elde.PressureMeter
{
public class PressureMeter : IComponent, GenericDevices.IPressureMeter
public class PressureMeter : ComponentBase, GenericDevices.IPressureMeter
{
/// <summary>
/// Info: StartMassMeasurement() and "Balance response = .., Mass = ..."
/// Warn: Start measurement when busy is true
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(PressureMeter));
public override string ToString()
{
return string.Format("PressureMeter: Name={0}, Idx0={1}", Name, Idx0);
}
public static void ResetStaticProperties() { }
public override string ToString() { return string.Format("PressureMeter({0})", Cfg.ToString(1)); }
readonly PressureMeterCfg pressureMeterCfg;
public Generic.IComponentCfg Cfg { get { return pressureMeterCfg; } }
public string Name { get { return pressureMeterCfg.Name; } }
public IList<Entities.MeasurementCorrection> Corrections { get { return pressureMeterCfg.Corrections; } }
public readonly ControlBoardDev ControlBoard;
@@ -32,9 +19,9 @@ namespace TBF.BenchControl.Elde.PressureMeter
public readonly byte RS485Address; /// 0..255
public PressureMeter(PressureMeterCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
if (cfg == null) throw new ArgumentNullException("cfg");
this.pressureMeterCfg = cfg;
pressureMeterCfg = cfg;
ControlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
@@ -9,9 +9,9 @@ namespace TBF.BenchControl.Elde.PressureMeter
{
public int Idx0; /// 0..3
public byte RS485Address; /// 0..255
/// Parameterless constructor
public PressureMeterCfg()
/// Private parameterless constructor invoked by all other (public) constructors
PressureMeterCfg()
{
Name = "PressureMeter";
ParentName = "CB";
@@ -9,10 +9,6 @@ namespace TBF.BenchControl.Elde.PressureMeter
public class PressureMeterFactory : IComponentFactory
{
public string ClassName { get { return "PressureMeter"; } }
public bool HasProcedureParams { get { return false; } }
public bool HasTestParams { get { return false; } }
public IParamsProvider GetTestParams(Entities.ComponentTest testParams) { return null; }
public IParamsProvider GetProcedureParams(Entities.ComponentProcedure procedureParams) { return null; }
/// <summary>Max. number of components of this class in the system</summary>
public int MaxCount { get { return 5; } }
@@ -4,25 +4,13 @@ using log4net;
namespace TBF.BenchControl.Elde.Pump
{
public class Pump : Generic.IComponent, GenericDevices.IPump, GenericDevices.IValve
public class Pump : ComponentBase, GenericDevices.IPump, GenericDevices.IValve
{
/// <summary>
/// Info: StartMassMeasurement() and "Balance response = .., Mass = ..."
/// Warn: Start measurement when busy is true
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(Pump));
public override string ToString()
{
return string.Format("Pump(name={0}, bit={1})", Name, bitPosition);
}
public static void ResetStaticProperties() { }
private readonly PumpCfg pumpCfg;
public Generic.IComponentCfg Cfg { get { return pumpCfg; } }
public string Name { get { return pumpCfg.Name; } }
public override string ToString() { return string.Format("Pump({0})", Cfg.ToString(1)); }
readonly PumpCfg pumpCfg;
public int Delay { get { return pumpCfg.Delay; } }
public ValveCategory Category { get { return ValveCategory.Feeding; } } /// Pump category is Feeding
@@ -39,15 +27,15 @@ namespace TBF.BenchControl.Elde.Pump
public Pump(PumpCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
if (cfg == null) throw new ArgumentNullException("cfg");
this.pumpCfg = cfg;
pumpCfg = cfg;
controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
this.bitPosition = cfg.BitPosition;
this.Mask = (((ulong)1) << bitPosition);
bitPosition = pumpCfg.BitPosition;
Mask = (((ulong)1) << pumpCfg.BitPosition);
log.Debug(this.ToString());
}
@@ -9,8 +9,8 @@ namespace TBF.BenchControl.Elde.Pump
public int BitPosition;
public int Delay;
/// Parameterless constructor
public PumpCfg()
/// Private parameterless constructor invoked by all other (public) constructors
PumpCfg()
{
Name = "Pump";
ParentName = "CB";
@@ -6,10 +6,6 @@ namespace TBF.BenchControl.Elde.Pump
public class PumpFactory : IComponentFactory
{
public string ClassName { get { return "Pump"; } }
public bool HasProcedureParams { get { return false; } }
public bool HasTestParams { get { return false; } }
public IParamsProvider GetTestParams(Entities.ComponentTest testParams) { return null; }
public IParamsProvider GetProcedureParams(Entities.ComponentProcedure procedureParams) { return null; }
/// <summary>Max. number of components of this class in the system</summary>
public int MaxCount { get { return int.MaxValue; } }
@@ -7,17 +7,24 @@ using TBF.Resources;
namespace TBF.BenchControl.Elde.PumpWithFM
{
public class FMPumpTestParams : IParamsProvider, ITestParams
public class FMPumpTestParams : TestParamsBase, IParamsProvider, ITestParams
{
public float Power; /// Target=terminal flow durning detection when increasing or decreasing the flow
public override void InitializeAll()
{
Power = 50.0f;
}
string[] paramNames = new string[]
{
Strings.PowerPct,
};
public string ParamName(int i) { return paramNames[i]; }
public override string ParamName(int i) { return paramNames[i]; }
public override int ParamsCount() { return paramNames.Length; }
public string ToString(int i)
public override string ToString(int i)
{
switch (i)
{
@@ -54,98 +61,35 @@ namespace TBF.BenchControl.Elde.PumpWithFM
return false;
}
#region Boilerplate code
public int ParamsCount() { return paramNames.Length; }
public override string ToString()
public override void UpdateTestParams(Entities.ComponentTest dbEntity)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < ParamsCount(); i++)
if (dbEntity == null) return;
try
{
FMPumpTestParams tmp = (FMPumpTestParams)(new XmlSerializer(typeof(FMPumpTestParams)))
.Deserialize(new StringReader(dbEntity.Parameters));
testParamsEntity = dbEntity;
componentName = dbEntity.CmpntName;
test = dbEntity.Test;
Power = tmp.Power;
}
catch
{
if (i != 0) sb.Append("; ");
sb.Append(ParamName(i));
sb.Append("=");
sb.Append(ToString(i));
}
return sb.ToString();
}
[XmlIgnore]
public Entities.ComponentTest TestParamsEntity { get { return testParamsEntity; } }
Entities.ComponentTest testParamsEntity;
[XmlIgnore]
public string ComponentName { get { return componentName; } }
string componentName;
[XmlIgnore]
public Entities.Test Test { get { return test; } }
Entities.Test test;
/// Parameterless constructor
public FMPumpTestParams()
{
Power = 50.0f;
}
public FMPumpTestParams(Entities.ComponentTest testParamsEntity, string componentName, Entities.Test test)
: this()
{
this.testParamsEntity = testParamsEntity;
this.componentName = componentName;
this.test = test;
}
public TBF.Entities.ComponentTest ToDbEntity(IComponent component, Entities.Test test)
{
using (var writer = new StringWriter())
{
/// Serialize this class with parameters
(new XmlSerializer(GetType())).Serialize(writer, this);
/// Create and return the ComponentTest entity
TBF.Entities.ComponentTest entity = new TBF.Entities.ComponentTest();
entity.CmpntName = component.Cfg.Name;
entity.Parameters = writer.ToString();
entity.Test = test;
return entity;
}
}
public void UpdateDbEntity()
{
using (var writer = new StringWriter())
{
/// Serialize this class and update the entity
(new XmlSerializer(GetType())).Serialize(writer, this);
testParamsEntity.Parameters = writer.ToString();
testParamsEntity.CmpntName = componentName;
testParamsEntity.Test = test;
}
}
public static IParamsProvider GetTestParams(Entities.ComponentTest testParamsEntity)
{
if (testParamsEntity == null) return new FMPumpTestParams();
FMPumpTestParams testParams;
try
{
testParams = (FMPumpTestParams)(new XmlSerializer(typeof(FMPumpTestParams)))
.Deserialize(new StringReader(testParamsEntity.Parameters));
}
catch
{
testParams = new FMPumpTestParams();
}
testParams.testParamsEntity = testParamsEntity;
testParams.componentName = testParamsEntity.CmpntName;
testParams.test = testParamsEntity.Test;
return testParams;
}
#endregion
}
}
@@ -6,24 +6,14 @@ namespace TBF.BenchControl.Elde.PumpWithFM
{
public class Pump : ComponentBase, GenericDevices.IPumpFM, GenericDevices.IValve, IOperation
{
/// <summary>
/// Info: StartMassMeasurement() and "Balance response = .., Mass = ..."
/// Warn: Start measurement when busy is true
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(Pump));
public override string ToString()
{
return string.Format("Pump(name={0}, bit={1}, idx={2})", Name, bitPosition, FMIndex);
}
private static readonly ILog log = LogManager.GetLogger(typeof(Pump));
public override string ToString() { return string.Format("PumpWithFM({0})", Cfg.ToString(1)); }
public static void ResetStaticProperties() { }
public int Delay { get { return (Cfg as PumpCfg).Delay; } }
readonly PumpCfg pumpCfg;
public int Delay { get { return pumpCfg.Delay; } }
public ValveCategory Category { get { return ValveCategory.Feeding; } } /// Pump category is Feeding
public float Power { get { return (TestParams is FMPumpTestParams) ? (TestParams as FMPumpTestParams).Power : 0; } }
public float Power { get { return pumpCfg.TestParams.Power; } }
public GenericDevices.IValve CoupledTo { get { return null; } }
public bool InvertCouple { get { return false; } }
public int LagOpening { get { return 0; } }
@@ -45,14 +35,14 @@ namespace TBF.BenchControl.Elde.PumpWithFM
public Pump(PumpCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
if (cfg == null) throw new ArgumentNullException("cfg");
pumpCfg = cfg;
controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
this.bitPosition = cfg.BitPosition;
this.Mask = (((ulong)1) << bitPosition);
this.FMIndex = cfg.FMIndex;
bitPosition = pumpCfg.BitPosition;
Mask = (((ulong)1) << pumpCfg.BitPosition);
FMIndex = pumpCfg.FMIndex;
log.Debug(this.ToString());
}
@@ -10,14 +10,26 @@ namespace TBF.BenchControl.Elde.PumpWithFM
public int FMIndex;
public int Delay;
/// Parameterless constructor
public PumpCfg()
/// <summary> Test parameters </summary>
[XmlIgnore]
public FMPumpTestParams TestParams;
public override IParamsProvider GetTestParams() { return TestParams; }
public override IParamsProvider CreateTestParams(Entities.Test test)
{
FMPumpTestParams testParams = new FMPumpTestParams();
testParams.UpdateTestParams(Name, test);
return testParams;
}
/// Private parameterless constructor invoked by all other (public) constructors
PumpCfg()
{
Name = "Pump";
ParentName = "CB";
BitPosition = 0;
FMIndex = 0;
Delay = 1;
TestParams = new FMPumpTestParams();
}
public PumpCfg(IComponentFactory factory)
@@ -6,13 +6,6 @@ namespace TBF.BenchControl.Elde.PumpWithFM
public class PumpFactory : IComponentFactory
{
public string ClassName { get { return "PumpWithFM"; } }
public bool HasProcedureParams { get { return false; } }
public bool HasTestParams { get { return true; } }
public IParamsProvider GetProcedureParams(Entities.ComponentProcedure procedureParams) { return null; }
public IParamsProvider GetTestParams(Entities.ComponentTest testParams)
{
return FMPumpTestParams.GetTestParams(testParams);
}
/// <summary>Max. number of components of this class in the system</summary>
public int MaxCount { get { return int.MaxValue; } }
@@ -7,17 +7,23 @@ using TBF.Resources;
namespace TBF.BenchControl.Elde.RegisterReader
{
public class RRProcedureParams : IParamsProvider, IProcedureParams
public class RRProcedureParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
{
public float PulsesPerLtr; /// Target low limit of the flow increase or decrease
public override void InitializeAll()
{
PulsesPerLtr = 1.0f;
}
string[] paramNames = new string[]
{
Strings.PulsesPerLtr,
};
public string ParamName(int i) { return paramNames[i]; }
public override string ParamName(int i) { return paramNames[i]; }
public override int ParamsCount() { return paramNames.Length; }
public string ToString(int i)
public override string ToString(int i)
{
switch (i)
{
@@ -25,14 +31,6 @@ namespace TBF.BenchControl.Elde.RegisterReader
default: return string.Empty;
}
}
/// <summary>
/// Parameterless constructor - sets default values of parameters.
/// </summary>
public RRProcedureParams()
{
PulsesPerLtr = 1.0f;
}
/// Retrieves parameters from UI controls
public void UpdateParam(int i, string strValue)
@@ -64,92 +62,35 @@ namespace TBF.BenchControl.Elde.RegisterReader
return false;
}
#region Boilerplate code
public int ParamsCount() { return paramNames.Length; }
public override string ToString()
public override void UpdateProcedureParams(Entities.ComponentProcedure dbEntity)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < ParamsCount(); i++)
if (dbEntity == null) return;
try
{
if (i != 0) sb.Append("; ");
sb.Append(ParamName(i));
sb.Append("=");
sb.Append(ToString(i));
RRProcedureParams tmp = (RRProcedureParams)(new XmlSerializer(typeof(RRProcedureParams)))
.Deserialize(new StringReader(dbEntity.Parameters));
procedureParamsEntity = dbEntity;
componentName = dbEntity.CmpntName;
procedure = dbEntity.Procedure;
PulsesPerLtr = tmp.PulsesPerLtr;
}
return sb.ToString();
catch
{
}
}
public RRProcedureParams()
{
}
[XmlIgnore]
public Entities.ComponentProcedure ProcedureParamsEntity { get { return procedureParamsEntity; } }
Entities.ComponentProcedure procedureParamsEntity;
[XmlIgnore]
public string ComponentName { get { return componentName; } }
string componentName;
[XmlIgnore]
public Entities.Procedure Procedure { get { return procedure; } }
Entities.Procedure procedure;
public RRProcedureParams(Entities.ComponentProcedure procedureParamsEntity, string componentName, Entities.Procedure procedure)
: this()
{
this.procedureParamsEntity = procedureParamsEntity;
this.componentName = componentName;
this.procedure = procedure;
}
public TBF.Entities.ComponentProcedure ToDbEntity(IComponent component, Entities.Procedure procedure)
{
using (var writer = new StringWriter())
{
/// Serialize this class with parameters
(new XmlSerializer(GetType())).Serialize(writer, this);
/// Create and return the ComponentProcedure entity
TBF.Entities.ComponentProcedure entity = new TBF.Entities.ComponentProcedure();
entity.CmpntName = component.Cfg.Name;
entity.Parameters = writer.ToString();
entity.Procedure = procedure;
return entity;
}
}
public void UpdateDbEntity()
{
using (var writer = new StringWriter())
{
/// Serialize this class and update the entity
(new XmlSerializer(GetType())).Serialize(writer, this);
procedureParamsEntity.Parameters = writer.ToString();
procedureParamsEntity.CmpntName = componentName;
procedureParamsEntity.Procedure = procedure;
}
}
public static IParamsProvider GetProcedureParams(Entities.ComponentProcedure procedureParamsEntity)
{
if (procedureParamsEntity == null) return new RRProcedureParams();
RRProcedureParams procedureParams;
try
{
procedureParams = (RRProcedureParams)(new XmlSerializer(typeof(RRProcedureParams)))
.Deserialize(new StringReader(procedureParamsEntity.Parameters));
}
catch
{
procedureParams = new RRProcedureParams();
}
procedureParams.procedureParamsEntity = procedureParamsEntity;
procedureParams.componentName = procedureParamsEntity.CmpntName;
procedureParams.procedure = procedureParamsEntity.Procedure;
return procedureParams;
}
#endregion
}
}
@@ -7,40 +7,25 @@ namespace TBF.BenchControl.Elde.RegisterReader
{
public class RegisterReader : ComponentBase, GenericDevices.IRegisterReader
{
/// <summary>
/// Info: StartMassMeasurement() and "Balance response = .., Mass = ..."
/// Warn: Start measurement when busy is true
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(RegisterReader));
public override string ToString()
{
return string.Format("Register({0},{1})", Name, Position);
}
public override string ToString() { return string.Format("RegisterReader({0})", Cfg.ToString(1)); }
public static void ResetStaticProperties() { }
readonly RegisterReaderCfg registerReaderCfg;
public float PulsesPerLtr
{
get
{
return (ProcedureParams is RRProcedureParams) ? (ProcedureParams as RRProcedureParams).PulsesPerLtr : 0;
}
}
public int Position { get { return registerReaderCfg.Position; } } /// 1 .. inf
public float PulsesPerLtr { get { return registerReaderCfg.ProcParams.PulsesPerLtr; } }
public readonly ControlBoardDev ControlBoard;
public readonly int Position; /// 1 .. inf
public RegisterReader(RegisterReaderCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
if (cfg == null) throw new ArgumentNullException("cfg");
registerReaderCfg = cfg;
ControlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
Position = cfg.Position;
/// Prepare data for SendCalibData() control board component method
log.Debug(this.ToString());
@@ -8,13 +8,25 @@ namespace TBF.BenchControl.Elde.RegisterReader
public class RegisterReaderCfg : ComponentCfgBase, Generic.IChildComponentCfg
{
public int Position; /// 1..nrWaterMeters
/// Parameterless constructor
public RegisterReaderCfg()
/// <summary> Procedure parameters </summary>
[XmlIgnore]
public RRProcedureParams ProcParams;
public override IParamsProvider GetProcedureParams() { return ProcParams; }
public override IParamsProvider CreateProcedureParams(Entities.Procedure procedure)
{
RRProcedureParams procParams = new RRProcedureParams();
procParams.UpdateProcedureParams(Name, procedure);
return procParams;
}
/// Private parameterless constructor invoked by all other (public) constructors
RegisterReaderCfg()
{
Name = "Sick";
ParentName = "CB";
Position = 1;
ProcParams = new RRProcedureParams();
}
public RegisterReaderCfg(IComponentFactory factory)
@@ -30,17 +30,6 @@ namespace TBF.BenchControl.Elde.RegisterReader
return ComponentCfgBase.CreateFromDbEntity(typeof(RegisterReaderCfg), component, this);
}
public bool HasProcedureParams { get { return true; } }
///
public IParamsProvider GetProcedureParams(Entities.ComponentProcedure procedureParams)
{
return RRProcedureParams.GetProcedureParams(procedureParams);
}
public bool HasTestParams { get { return false; } }
///
public IParamsProvider GetTestParams(Entities.ComponentTest testParams) { return null; }
public void ResetStaticProperties() { RegisterReader.ResetStaticProperties(); }
}
}
@@ -19,9 +19,6 @@ namespace TBF.BenchControl.Elde.RegulValve
readonly int regulValveNr;
readonly float timePulseSec;
/// Process values
bool firstRun;
/// <summary>
/// Set required water flow.
/// Events: FlowSet, FlowTimeOut
@@ -49,7 +46,6 @@ namespace TBF.BenchControl.Elde.RegulValve
/// <summary>Start this operation</summary>
public void Start()
{
firstRun = true;
float positionPct = controlBoard.RValvePosition(regulValveNr);
log.WarnFormat("RV#={0}, actPos={1}%", regulValveNr, positionPct.ToString("F1"));
@@ -6,35 +6,23 @@ using TBF.Boxes;
namespace TBF.BenchControl.Elde.RegulValve
{
public class RegulValve : IComponent, GenericDevices.IRegulValve
public class RegulValve : ComponentBase, GenericDevices.IRegulValve
{
/// <summary>
/// Info: StartMassMeasurement() and "Balance response = .., Mass = ..."
/// Warn: Start measurement when busy is true
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(RegulValve));
public override string ToString()
{
return string.Format("RegulationValve({0},{1})", Name, Idx1);
}
public override string ToString() { return string.Format("RegulValve({0})", Cfg.ToString(1)); }
public static void ResetStaticProperties() { }
public RegulValveCfg RegulValveCfg;
public Generic.IComponentCfg Cfg { get { return RegulValveCfg; } }
public string Name { get { return Cfg.Name; } }
public readonly RegulValveCfg RegulValveCfg;
IDictionary<float, float> dict;
public IDictionary<float, float> Dict { get { return dict; } }
readonly ControlBoardDev controlBoard;
public readonly int Idx1; /// 1..7
public readonly int DacValueClosed; /// 0..1023
public readonly int DacValueOpen; /// 0..1023
public readonly int StableTime; /// 0=200ms, step=50ms, max. 1500ms (max.26)
public readonly int FlowStableSec; /// 0..60 sec
public int Idx1 { get { return RegulValveCfg.Idx1; } } /// 1..7
public int DacValueClosed { get { return RegulValveCfg.DacValueClosed; } } /// 0..1023
public int DacValueOpen { get { return RegulValveCfg.DacValueOpen; } } /// 0..1023
public int StableTime { get { return RegulValveCfg.StableTime; } } /// 0=200ms, step=50ms, max. 1500ms (max.26)
public int FlowStableSec { get { return RegulValveCfg.FlowStableSec; } } /// 0..60 sec
///
public float Position
{
@@ -42,19 +30,13 @@ namespace TBF.BenchControl.Elde.RegulValve
}
public RegulValve(RegulValveCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
if (cfg == null) throw new ArgumentNullException("cfg");
this.RegulValveCfg = cfg;
RegulValveCfg = cfg;
controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
this.Idx1 = cfg.Idx1;
this.DacValueClosed = cfg.DacValueClosed;
this.DacValueOpen = cfg.DacValueOpen;
this.StableTime = cfg.StableTime;
this.FlowStableSec = cfg.FlowStableSec;
this.dict = new Dictionary<float, float>();
this.controlBoard.RegValveCalib[Idx1 - 1, 0] = (uint)DacValueClosed;
@@ -20,8 +20,8 @@ namespace TBF.BenchControl.Elde.RegulValve
/// </summary>
public int StableTime { get { return (StableTimeMs - 200) / 50; } }
/// Parameterless constructor
public RegulValveCfg()
/// Private parameterless constructor invoked by all other (public) constructors
RegulValveCfg()
{
Name = "RegulationValve";
ParentName = "CB";
@@ -6,10 +6,6 @@ namespace TBF.BenchControl.Elde.RegulValve
public class RegulValveFactory : IComponentFactory
{
public string ClassName { get { return "RegulationValve"; } }
public bool HasProcedureParams { get { return false; } }
public bool HasTestParams { get { return false; } }
public IParamsProvider GetTestParams(Entities.ComponentTest testParams) { return null; }
public IParamsProvider GetProcedureParams(Entities.ComponentProcedure procedureParams) { return null; }
/// <summary>Max. number of components of this class in the system</summary>
public int MaxCount { get { return 5; } }
@@ -6,49 +6,30 @@ using TBF.Boxes;
namespace TBF.BenchControl.Elde.TempMeter
{
public class TempMeter : IComponent, GenericDevices.ITempMeter
public class TempMeter : ComponentBase, GenericDevices.ITempMeter
{
/// <summary>
/// Info: StartMassMeasurement() and "Balance response = .., Mass = ..."
/// Warn: Start measurement when busy is true
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(TempMeter));
public override string ToString()
{
return string.Format("TempMeter({0},{1})", Name, Idx0);
}
public override string ToString() { return string.Format("TempMeter({0})", Cfg.ToString(1)); }
public static void ResetStaticProperties() { }
TempMeterCfg tempMeterCfg;
public Generic.IComponentCfg Cfg { get { return tempMeterCfg; } }
public string Name { get { return tempMeterCfg.Name; } }
readonly TempMeterCfg tempMtrCfg;
public readonly ControlBoardDev ControlBoard;
public readonly int Idx0; /// 0..7
public readonly float A1;
public readonly float A2;
public readonly float A3;
public readonly float A4;
public readonly float A5;
public int Idx0 { get { return tempMtrCfg.Idx0; } } /// 0..7
public float A1 { get { return tempMtrCfg.A1; } }
public float A2 { get { return tempMtrCfg.A2; } }
public float A3 { get { return tempMtrCfg.A3; } }
public float A4 { get { return tempMtrCfg.A4; } }
public float A5 { get { return tempMtrCfg.A5; } }
public TempMeter(TempMeterCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
if (cfg == null) throw new ArgumentNullException("cfg");
this.tempMeterCfg = cfg;
tempMtrCfg = cfg;
ControlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent");
Idx0 = cfg.Idx0;
A1 = cfg.A1;
A2 = cfg.A2;
A3 = cfg.A3;
A4 = cfg.A4;
A5 = cfg.A5;
/// Prepare data for SendCalibData() control board component method
ControlBoard.TempCalibData[Idx0, 0] = A1;
ControlBoard.TempCalibData[Idx0, 1] = A2;
@@ -15,8 +15,8 @@ namespace TBF.BenchControl.Elde.TempMeter
public float A4;
public float A5;
/// Parameterless constructor
public TempMeterCfg()
/// Private parameterless constructor invoked by all other (public) constructors
TempMeterCfg()
{
Name = "TempMeter";
ParentName = "CB";
@@ -6,10 +6,6 @@ namespace TBF.BenchControl.Elde.TempMeter
public class TempMeterFactory : IComponentFactory
{
public string ClassName { get { return "TempMeter"; } }
public bool HasProcedureParams { get { return false; } }
public bool HasTestParams { get { return false; } }
public IParamsProvider GetTestParams(Entities.ComponentTest testParams) { return null; }
public IParamsProvider GetProcedureParams(Entities.ComponentProcedure procedureParams) { return null; }
/// <summary>Max. number of components of this class in the system</summary>
public int MaxCount { get { return 8; } }
@@ -5,32 +5,22 @@ using TBF.BenchControl.GenericDevices;
namespace TBF.BenchControl.Elde.Valve
{
public class Valve : GenericDevices.ValveBase, Generic.IComponent, IValve
public class Valve : GenericDevices.ValveBase, IValve
{
/// <summary>
/// Info: StartMassMeasurement() and "Balance response = .., Mass = ..."
/// Warn: Start measurement when busy is true
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(Valve));
public override string ToString()
{
return string.Format("Valve({0},{1},{2})", Name, bitPosition, (CoupledTo != null ? CoupledTo.Cfg.Name : "-"));
}
public static void ResetStaticProperties() { }
public override string ToString() { return string.Format("Valve({0})", Cfg.ToString(1)); }
readonly ValveCfg valveCfg;
public Generic.IComponentCfg Cfg { get { return valveCfg; } }
readonly IValve coupledTo;
readonly ControlBoardDev controlBoard;
readonly int bitPosition; /// 0 .. 63
public string Name { get { return valveCfg.Name; } }
public ValveCategory Category { get { return valveCfg.Category; } }
public int Delay { get { return valveCfg.OpenCloseTime; } }
public bool Inverted { get { return valveCfg.Inverted; } }
public IValve CoupledTo { get { return coupledTo; } }
readonly IValve coupledTo;
public bool InvertCouple { get { return valveCfg.InvertCouple; } }
public int LagOpening { get { return valveCfg.LagOpening; } }
public int LagClosing { get { return valveCfg.LagClosing; } }
@@ -39,20 +29,22 @@ namespace TBF.BenchControl.Elde.Valve
public Valve(ValveCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
if (cfg == null) throw new ArgumentNullException("cfg");
this.valveCfg = cfg;
valveCfg = cfg;
controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
if (bitPosition < 0 || bitPosition >= 64) throw new ArgumentOutOfRangeException("position");
this.bitPosition = cfg.BitPosition;
this.Mask = (((ulong)1) << bitPosition);
if (valveCfg.BitPosition < 0 || valveCfg.BitPosition >= 64)
{
throw new ArgumentOutOfRangeException("position");
}
this.Mask = (((ulong)1) << valveCfg.BitPosition);
if (cfg.CoupledToName != null)
{
this.coupledTo = (IValve)TbfComponents.FindComponent(cfg.CoupledToName, components);
coupledTo = (IValve)TbfComponents.FindComponent(cfg.CoupledToName, components);
}
log.Debug(this.ToString());
@@ -17,8 +17,8 @@ namespace TBF.BenchControl.Elde.Valve
public int LagClosing; /// Delay (referred to the master valve) when closing this valve in [s]
/// Negative values of delays mean an earlier function of the coupled valve.
/// Parameterless constructor
public ValveCfg()
/// Private parameterless constructor invoked by all other (public) constructors
ValveCfg()
{
Name = "V";
ParentName = "CB";
@@ -6,10 +6,6 @@ namespace TBF.BenchControl.Elde.Valve
public class ValveFactory : IComponentFactory
{
public string ClassName { get { return "Valve"; } }
public bool HasProcedureParams { get { return false; } }
public bool HasTestParams { get { return false; } }
public IParamsProvider GetTestParams(Entities.ComponentTest testParams) { return null; }
public IParamsProvider GetProcedureParams(Entities.ComponentProcedure procedureParams) { return null; }
/// <summary>Max. number of components of this class in the system</summary>
public int MaxCount { get { return int.MaxValue; } }