DiverterEdge[] initialization for SendCalibData() fn fixed, version 1.6.147.

This commit is contained in:
Milan Hanajik
2015-11-27 16:41:40 +01:00
parent 910d5d58dc
commit ee1afaa78b
3 changed files with 46 additions and 5 deletions
@@ -266,6 +266,12 @@ namespace TBF.BenchControl.Elde
/// <summary>Initialize this device</summary> /// <summary>Initialize this device</summary>
public void Initialize() public void Initialize()
{ {
DiverterEdge = new uint[BenchControl.Elde.Diverter.Diverter.DivertersCount];
for (int i = 0; i < BenchControl.Elde.Diverter.Diverter.DivertersCount; i++)
{
DiverterEdge[i] = (uint)BenchControl.Elde.Diverter.Diverter.DiverterLevelsPct[i];
}
controlCom.SendCalibData(RegValveCalib, controlCom.SendCalibData(RegValveCalib,
MeretRS485Address, MeretRS485Address,
controlBoardCfg.ComPortNr, controlBoardCfg.ComPortNr,
@@ -12,6 +12,23 @@ namespace TBF.BenchControl.Elde.Diverter
private static readonly ILog log = LogManager.GetLogger(typeof(Diverter)); private static readonly ILog log = LogManager.GetLogger(typeof(Diverter));
public override string ToString() { return string.Format("Diverter({0})", Cfg.ToString(1)); } public override string ToString() { return string.Format("Diverter({0})", Cfg.ToString(1)); }
/// <summary>
/// Enumeration of balances via static fields and methods
/// </summary>
static int nextIdx = 0;
public static new void ResetStaticProperties()
{
nextIdx = 0;
}
public static int DivertersCount { get { return nextIdx; } }
public static GenericDevices.IDiverter[] Diverters;
public static int[] DiverterLevelsPct;
///
protected int diverterNr; /// 0-based balance number
readonly DiverterCfg diverterCfg; readonly DiverterCfg diverterCfg;
readonly ControlBoardDev controlBoard; readonly ControlBoardDev controlBoard;
readonly ulong mask; /// derived from bitPosition in the constructor readonly ulong mask; /// derived from bitPosition in the constructor
@@ -37,9 +54,27 @@ namespace TBF.BenchControl.Elde.Diverter
if (cfg.BitPosition < 0 || cfg.BitPosition >= 64) throw new ArgumentOutOfRangeException("position"); if (cfg.BitPosition < 0 || cfg.BitPosition >= 64) throw new ArgumentOutOfRangeException("position");
this.mask = (((ulong)1) << cfg.BitPosition); this.mask = (((ulong)1) << cfg.BitPosition);
/// Prepare data for SendCalibData() control board component method
controlBoard.DiverterEdge[0] = (uint)diverterCfg.StartingLevel;
controlBoard.DiverterEdge[1] = (uint)diverterCfg.StoppingLevel; diverterNr = nextIdx++;
///
if (Diverters == null || Diverters.Length < nextIdx)
{
GenericDevices.IDiverter[] divertersSoFar = Diverters;
int[] levelsSoFar = DiverterLevelsPct;
Diverters = new GenericDevices.IDiverter[nextIdx];
DiverterLevelsPct = new int[nextIdx];
if (divertersSoFar != null)
{
for (int i = 0; i < divertersSoFar.Length; i++)
{
Diverters[i] = divertersSoFar[i];
DiverterLevelsPct[i] = levelsSoFar[i];
}
}
Diverters[nextIdx - 1] = this;
DiverterLevelsPct[nextIdx - 1] = diverterCfg.StartingLevel;
}
log.Debug(this.ToString()); log.Debug(this.ToString());
} }
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number // Build Number
// Revision // Revision
// //
[assembly: AssemblyVersion("1.6.146.1")] [assembly: AssemblyVersion("1.6.147.1")]
[assembly: AssemblyFileVersion("1.6.146.1")] [assembly: AssemblyFileVersion("1.6.147.1")]