IScaleOrTank.ScaleNr eliminated.

This commit is contained in:
Milan Hanajik
2021-04-02 15:12:29 +02:00
parent 8a846a774f
commit e4da4929e4
2 changed files with 25 additions and 42 deletions
-5
View File
@@ -12,11 +12,6 @@ namespace TBF.Rig.GenericDevices
/// </summary> /// </summary>
public interface IScaleOrTank : IComponent public interface IScaleOrTank : IComponent
{ {
/// <summary>
/// Balance number: 0-based index required for communication with the Elde component
/// </summary>
int ScaleNr { get; }
/// <summary> /// <summary>
/// Balance water tank capacity in kg or ltr /// Balance water tank capacity in kg or ltr
/// </summary> /// </summary>
+25 -37
View File
@@ -232,7 +232,6 @@ namespace TBF.Rig
/// Find all balances (to initialize tank capacities in the control board) /// Find all balances (to initialize tank capacities in the control board)
/// Find the control board /// Find the control board
IList<IScaleOrTank> tanks = new List<IScaleOrTank>();
UInt128 valvesToInvert = 0; UInt128 valvesToInvert = 0;
foreach (var cmpnt in components) foreach (var cmpnt in components)
{ {
@@ -284,26 +283,12 @@ namespace TBF.Rig
if (cmpnt is ITestMethod && cmpnt.ClassName == "TestMethods.OuterLoop.Start") LoopStartNames.Add(cmpnt.Name); if (cmpnt is ITestMethod && cmpnt.ClassName == "TestMethods.OuterLoop.Start") LoopStartNames.Add(cmpnt.Name);
if (cmpnt is ITestMethod && cmpnt.ClassName == "TestMethods.OuterLoop.End") LoopEndNames.Add(cmpnt.Name); if (cmpnt is ITestMethod && cmpnt.ClassName == "TestMethods.OuterLoop.End") LoopEndNames.Add(cmpnt.Name);
if (cmpnt is IScaleOrTank)
{
IScaleOrTank tank = cmpnt as IScaleOrTank;
tanks.Add(tank);
if ((tank.ScaleNr == 0) && (Tank1 == null)) Tank1 = tank;
else if ((tank.ScaleNr == 1) && (Tank2 == null)) Tank2 = tank;
else if ((tank.ScaleNr == 2) && (Tank3 == null)) Tank3 = tank;
}
BuiltIn.Valve.Valve plainValve = (cmpnt as BuiltIn.Valve.Valve); BuiltIn.Valve.Valve plainValve = (cmpnt as BuiltIn.Valve.Valve);
if ((plainValve != null) && plainValve.Inverted) valvesToInvert |= plainValve.Mask; if ((plainValve != null) && plainValve.Inverted) valvesToInvert |= plainValve.Mask;
cmpnt.StartChangeHandler(); /// Start handling parameter change events cmpnt.StartChangeHandler(); /// Start handling parameter change events
} }
/// Create an array with tank capacities
double[] tankCapacities = new double[tanks.Count];
for (int i = 0; i < tankCapacities.Length; i++) tankCapacities[i] = tanks[i].Capacity;
/// Pre-initialize the control board (= buffer the arguments ctrlBrdComponent, tankCapacities) /// Pre-initialize the control board (= buffer the arguments ctrlBrdComponent, tankCapacities)
if (ControlBoard == null) if (ControlBoard == null)
{ {
@@ -362,29 +347,32 @@ namespace TBF.Rig
} }
} }
if (cmpnt is IScaleOrTank) if (cmpnt is IScaleOrTank)
{ {
IScaleOrTank tank = cmpnt as IScaleOrTank; IScaleOrTank tank = cmpnt as IScaleOrTank;
if ((tank.ScaleNr == 0) && (DrainValve1 == null)) if (Tank1 == null)
{ {
DrainValve1 = tank.DrainValve; Tank1 = tank;
log.WarnFormat("InitializeBoardEtc() ... Scale1={0} Draining valve1={1}", DrainValve1 = tank.DrainValve;
tank.Name, (DrainValve1 != null) ? DrainValve1.Name : "---"); log.WarnFormat("InitializeBoardEtc() ... Scale1={0} Draining valve1={1}",
} tank.Name, (DrainValve1 != null) ? DrainValve1.Name : "---");
else if ((tank.ScaleNr == 1) && (DrainValve2 == null)) }
{ else if (Tank2 == null)
DrainValve2 = tank.DrainValve; {
log.WarnFormat("InitializeBoardEtc() ... Scale2={0} Draining valve2={1}", Tank2 = tank;
tank.Name, (DrainValve2 != null) ? DrainValve2.Name : "---"); DrainValve2 = tank.DrainValve;
} log.WarnFormat("InitializeBoardEtc() ... Scale2={0} Draining valve2={1}",
else if ((tank.ScaleNr == 2) && (DrainValve3 == null)) tank.Name, (DrainValve2 != null) ? DrainValve2.Name : "---");
{ }
DrainValve3 = tank.DrainValve; else if (Tank3 == null)
log.WarnFormat("InitializeBoardEtc() ... Scale3={0} Draining valve3={1}", {
tank.Name, (DrainValve3 != null) ? DrainValve3.Name : "---"); Tank3 = tank;
} DrainValve3 = tank.DrainValve;
} log.WarnFormat("InitializeBoardEtc() ... Scale3={0} Draining valve3={1}",
tank.Name, (DrainValve3 != null) ? DrainValve3.Name : "---");
}
}
} }
if (anyComponentIsInSimulMode) if (anyComponentIsInSimulMode)