ulong --> UInt128 in all 'route' related variables, ver. 2.12.419

This commit is contained in:
Milan Hanajik
2016-12-12 17:39:12 +01:00
parent a782d3960a
commit dd62310e59
20 changed files with 78 additions and 65 deletions
@@ -10,6 +10,7 @@ using log4net;
using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.Boxes;
using Dirichlet.Numerics;
namespace TBF.BenchControl.Danfoss.VLT2800
{
@@ -94,7 +95,7 @@ namespace TBF.BenchControl.Danfoss.VLT2800
readonly Elde.ControlBoardDev controlBoard;
readonly int bitPosition; /// 0 .. 63
public readonly ulong Mask; /// derived from bitPosition in the constructor
public readonly UInt128 Mask; /// derived from bitPosition in the constructor
public bool State
{
@@ -125,8 +126,8 @@ namespace TBF.BenchControl.Danfoss.VLT2800
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
bitPosition = pumpCfg.BitPosition;
Mask = (((ulong)1) << bitPosition);
Mask |= (((ulong)1) << (bitPosition + 1));
Mask = (((UInt128)1) << bitPosition);
Mask |= (((UInt128)1) << (bitPosition + 1));
log.Debug(this.ToString());
}
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
@@ -161,10 +161,10 @@ namespace TBF.BenchControl.Danfoss.VLT2800
message += Environment.NewLine + "'Delay' is not valid";
}
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64)
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 128)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Bit Position' should be between 0 and 63";
message += Environment.NewLine + "'Bit Position' should be between 0 and 127";
}
if (!protocolComboBox.Items.Contains(protocolComboBox.Text))
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Text;
@@ -110,10 +110,10 @@ namespace TBF.BenchControl.Elde
/// <summary> State of valves sent out - buffered by the last SendCommand() </summary>
public ulong Route { get { return benchModelRoute; } }
public UInt128 Route { get { return benchModelRoute; } }
ulong valvesToInvert; /// Route = valesToInvert ^ RequiredRouteWithoutInvertedVlaves
readonly ulong routeMask; /// This mask masks out virtual valves, routeMask is set in the constructor
UInt128 valvesToInvert; /// Route = valesToInvert ^ RequiredRouteWithoutInvertedVlaves
readonly UInt128 routeMask; /// This mask masks out virtual valves, routeMask is set in the constructor
///
/// Initialization data updated by constructors of children components
@@ -126,6 +126,9 @@ namespace TBF.BenchControl.Elde
#if DN100 || FUZHOU150 || FUZHOU300 || PT200IL || PUCHONG_PT200 || GENESIS
public byte[] MeretRS485Address = new byte[4];
public float[] EtCalib = new float[6] { 1, 1, 1, 1, 1, 1 };
#elif GENESIS
public byte[] MeretRS485Address = new byte[4];
public float[] EtCalib = new float[7] { 1, 1, 1, 1, 1, 1, 1 };
#elif MUNICH || TORINO50 || BADGER_MALA_TRAT || TORUN_PT50_2015 || CEVAK_PT40_272 || IPERLST || IPERLST_SPECIAL || MURES_PT40 || FUZHOU_40 || SLM_50
public byte[] MeretRS485Address = new byte[4];
public float[] EtCalib = new float[5] { 1, 1, 1, 1, 1 };
@@ -150,7 +153,7 @@ namespace TBF.BenchControl.Elde
bool sendCommandFlag;
Command cmd;
int refNr;
ulong benchModelRoute;
UInt128 benchModelRoute;
int totalRefPulses;
int massRefPulses;
TestMethods testMethods;
@@ -244,7 +247,7 @@ namespace TBF.BenchControl.Elde
{
if (i < controlBoardCfg.VirtualValvesRangeLo || i > controlBoardCfg.VirtualValvesRangeHi)
{
routeMask = routeMask | ((ulong)1 << i);
routeMask = routeMask | ((UInt128)1 << i);
}
}
@@ -269,7 +272,7 @@ namespace TBF.BenchControl.Elde
#else /// all newer benches
ControlComponent_Torino2015.UserControl1 ctrlBrdComponent,
#endif
ulong valvesToInvert,
UInt128 valvesToInvert,
double[] tankCapacities)
{
this.valvesToInvert = valvesToInvert;
@@ -433,7 +436,7 @@ namespace TBF.BenchControl.Elde
/// <param name="regConst">Coefficient used to control reg. valves (1..100)</param>
/// <param name="shortImp">0 = default value, 1 = spec. processing of very short pulses</param>
/// <param name="stopDevs">What to stop</param>
public void SendCommand(Command cmd, int refFlowmtrNr, ulong route,
public void SendCommand(Command cmd, int refFlowmtrNr, UInt128 route,
int totalRefPulses, int massRefPulses, TestMethods testMethods,
float filterConstant, int regConst, int shortImp, StopDevs stopDevs)
{
@@ -457,9 +460,9 @@ namespace TBF.BenchControl.Elde
/// <param name="valvesToOpen">'ulong' with bits of valves to open set to '1'</param>
/// <param name="valvesToClose">'ulong' with bits of valves to close set to '1'</param>
/// <returns>'ulong' with bits of valves that have changed set to '1'</returns>
public ulong SetValves(ulong valvesToOpen, ulong valvesToClose, IList<Elde.ValveEx.Valve> extendedValves)
public UInt128 SetValves(UInt128 valvesToOpen, UInt128 valvesToClose, IList<Elde.ValveEx.Valve> extendedValves)
{
ulong oldRoute = benchModelRoute;
UInt128 oldRoute = benchModelRoute;
benchModelRoute = (((benchModelRoute ^ valvesToInvert) | valvesToOpen) & (~valvesToClose)) ^ valvesToInvert;
foreach (var extV in extendedValves) extV.UpdateRoute(ref benchModelRoute);
log.DebugFormat("SetValves(x,x), new route = {0}", Utils.ShowRoute(benchModelRoute));
@@ -471,9 +474,9 @@ namespace TBF.BenchControl.Elde
/// Set Route to value returned by RRoute. Take virtual valves into account.
/// </summary>
/// <returns>'ulong' with bits of valves that have changed set to '1'</returns>
public ulong SyncRoute()
public UInt128 SyncRoute()
{
ulong oldRoute = benchModelRoute;
UInt128 oldRoute = benchModelRoute;
benchModelRoute = (RRoute & routeMask) | (benchModelRoute & (~routeMask));
log.DebugFormat("SyncRoute(), new route = {0}", Utils.ShowRoute(benchModelRoute));
return oldRoute ^ benchModelRoute;
@@ -44,7 +44,7 @@ namespace TBF.BenchControl.Elde
public float Temperature(int tmpNr0) { return ctrlBrdComponent.temperature[tmpNr0]; }
public RegulValveState RegulValveState(int rvNr1) { return (RegulValveState)ctrlBrdComponent.rValveStatus[rvNr1 - 1]; }
#if GENESIS
public UInt128 RRoute { get { return ctrlBrdComponent.rRoute; } }
public UInt128 RRoute { get { return ((UInt128)ctrlBrdComponent.rRoute << 64) | (UInt128)ctrlBrdComponent.rRoute; } }
#else
public UInt128 RRoute { get { return ctrlBrdComponent.rRoute; } }
#endif
@@ -315,7 +315,7 @@ namespace TBF.BenchControl.Elde
filterConstant, fmFreq, (uint)regConst, (uint)shortImp, (uint)stopDevs);
#elif GENESIS
uint[] pulsesArr = new uint[] { (uint)totalRefPulses, (uint)massRefPulses };
ctrlBrdComponent.SendCommand((uint)cmd, (byte)refFlowMeterNr, (ulong)route, 0, pulsesArr, (uint)testMethods,
ctrlBrdComponent.SendCommand((uint)cmd, (byte)refFlowMeterNr, (ulong)(route & (UInt128)0xFFFFFFFFFFFFFFFF), (ulong)(route >> 64), pulsesArr, (uint)testMethods,
filterConstant, fmFreq, (uint)regConst, (uint)shortImp, (uint)stopDevs);
#else /// if IPERLST || IPERLST_SPECIAL || MALTA_WSD25 || SLM_50 || SLM_END || WARSAW_END
uint[] pulsesArr = new uint[] { (uint)totalRefPulses, (uint)massRefPulses };
@@ -1,9 +1,10 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using log4net;
using Dirichlet.Numerics;
namespace TBF.BenchControl.Elde.Diverter
{
@@ -31,7 +32,7 @@ namespace TBF.BenchControl.Elde.Diverter
readonly DiverterCfg diverterCfg;
readonly ControlBoardDev controlBoard;
readonly ulong mask; /// derived from bitPosition in the constructor
readonly UInt128 mask; /// derived from bitPosition in the constructor
public int AdcNr { get { return diverterCfg.AdcNr; } }
public bool State
@@ -52,7 +53,7 @@ namespace TBF.BenchControl.Elde.Diverter
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
if (diverterCfg.BitPosition < 0 || diverterCfg.BitPosition >= 64) throw new ArgumentOutOfRangeException("position");
this.mask = (((ulong)1) << diverterCfg.BitPosition);
this.mask = (((UInt128)1) << diverterCfg.BitPosition);
@@ -108,10 +108,10 @@ namespace TBF.BenchControl.Elde.Diverter
message += Environment.NewLine + "Invalid 'Parent Name'";
}
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy > 63)
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy > 127)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Bit Position' should be between 0 and 63";
message += Environment.NewLine + "'Bit Position' should be between 0 and 127";
}
if (!int.TryParse(adcNrTextBox.Text, out dummy) || dummy < 0 || dummy > 15)
@@ -16,7 +16,7 @@ namespace TBF.BenchControl.Elde.FlowMeter
///
/// Serialized parameters
///
public int Idx1; /// 1..5
public int Idx1; /// 1..7
public float NominalFlow; /// Nominal flow in m3/h at output frequency 2000 Hz
/// Calibration info serialized parameters displayed in Metrology tab page
@@ -1,8 +1,9 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using Dirichlet.Numerics;
using log4net;
namespace TBF.BenchControl.Elde.Pump
@@ -27,9 +28,9 @@ namespace TBF.BenchControl.Elde.Pump
readonly ControlBoardDev controlBoard;
readonly int bitPosition; /// 0 .. 63
readonly int bitPosition; /// 0 .. 127
public readonly ulong Mask; /// derived from bitPosition in the constructor
public readonly UInt128 Mask; /// derived from bitPosition in the constructor
public Pump()
@@ -45,7 +46,7 @@ namespace TBF.BenchControl.Elde.Pump
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
bitPosition = pumpCfg.BitPosition;
Mask = (((ulong)1) << pumpCfg.BitPosition);
Mask = (((UInt128)1) << pumpCfg.BitPosition);
log.Debug(this.ToString());
}
@@ -98,10 +98,10 @@ namespace TBF.BenchControl.Elde.Pump
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'";
}
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64)
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 128)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Bit Position' should be between 0 and 63";
message += Environment.NewLine + "'Bit Position' should be between 0 and 127";
}
if (!int.TryParse(delayTextBox.Text, out dummy) || dummy < 0 || dummy >= 300 || (dummy % StateMachine.Period) != 0)
{
@@ -3,6 +3,7 @@
///
using System;
using System.Collections.Generic;
using Dirichlet.Numerics;
using log4net;
namespace TBF.BenchControl.Elde.PumpTandem
@@ -37,9 +38,9 @@ namespace TBF.BenchControl.Elde.PumpTandem
}
readonly ulong mask1;
readonly ulong mask2;
public ulong Mask { get { return mask1 | mask2; } } /// derived from masks of two pumps
readonly UInt128 mask1;
readonly UInt128 mask2;
public UInt128 Mask { get { return mask1 | mask2; } } /// derived from masks of two pumps
public Pump()
@@ -1,8 +1,9 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using Dirichlet.Numerics;
using log4net;
namespace TBF.BenchControl.Elde.PumpWithFM
@@ -25,7 +26,7 @@ namespace TBF.BenchControl.Elde.PumpWithFM
readonly int bitPosition; /// 0 .. 63
int FMIndex; /// 0 .. FMPumpsCount-1
public readonly ulong Mask; /// derived from bitPosition in the constructor
public readonly UInt128 Mask; /// derived from bitPosition in the constructor
public bool State
{
@@ -60,7 +61,7 @@ namespace TBF.BenchControl.Elde.PumpWithFM
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
bitPosition = pumpCfg.BitPosition;
Mask = (((ulong)1) << pumpCfg.BitPosition);
Mask = (((UInt128)1) << pumpCfg.BitPosition);
FMIndex = pumpCfg.FMIndex;
log.Debug(this.ToString());
@@ -101,10 +101,10 @@ namespace TBF.BenchControl.Elde.PumpWithFM
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'";
}
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64)
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 128)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Bit Position' should be between 0 and 63";
message += Environment.NewLine + "'Bit Position' should be between 0 and 127";
}
if (!int.TryParse(fmIndexTextBox.Text, out dummy) || dummy < 0)
{
@@ -1,10 +1,11 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.BenchControl.GenericDevices;
using Dirichlet.Numerics;
namespace TBF.BenchControl.Elde.Valve
{
@@ -20,8 +21,8 @@ namespace TBF.BenchControl.Elde.Valve
public int TimeSec; /// Relative time in [s] from the start of the operation
public IList<IValve> VOpen; /// List of valves to open in this point of time
public IList<IValve> VClose; /// List of valves to close in this point of time
public ulong MasksOpen; /// OR-ed bitmasks of valves to open in this point of time
public ulong MasksClose; /// OR-ed bitmasks of valves to close in this point of time
public UInt128 MasksOpen; /// OR-ed bitmasks of valves to open in this point of time
public UInt128 MasksClose; /// OR-ed bitmasks of valves to close in this point of time
public SwitchPoint(int time, IList<IValve> vOpen, IList<IValve> vClose)
{
@@ -35,7 +36,7 @@ namespace TBF.BenchControl.Elde.Valve
/// </summary>
/// <param name="changed">'ulong' with bits of valves that were actually changed set ot '1'</param>
/// <returns>Delay in [s]</returns>
public int MaxDelay(ulong changed)
public int MaxDelay(UInt128 changed)
{
int max = 0;
foreach (var vlv in VOpen)
@@ -209,7 +210,7 @@ namespace TBF.BenchControl.Elde.Valve
/// <summary>Start this operation</summary>
public void Start()
{
ulong changed = controlBoard.SetValves(switchPoints[0].MasksOpen, switchPoints[0].MasksClose, StateMachine.ExtendedValves);
UInt128 changed = controlBoard.SetValves(switchPoints[0].MasksOpen, switchPoints[0].MasksClose, StateMachine.ExtendedValves);
swStartTime = StateMachine.Time;
maxDelayTime = switchPoints[0].MaxDelay(changed);
nextIx = 1;
@@ -229,7 +230,7 @@ namespace TBF.BenchControl.Elde.Valve
if (StateMachine.Time >= swStartTime + switchPoints[nextIx].TimeSec)
{
ulong changed = controlBoard.SetValves(switchPoints[nextIx].MasksOpen, switchPoints[nextIx].MasksClose, StateMachine.ExtendedValves);
UInt128 changed = controlBoard.SetValves(switchPoints[nextIx].MasksOpen, switchPoints[nextIx].MasksClose, StateMachine.ExtendedValves);
int nextDelay = switchPoints[nextIx].MaxDelay(changed);
if (switchPoints[nextIx].TimeSec + nextDelay > maxDelayTime)
@@ -1,8 +1,9 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using Dirichlet.Numerics;
using log4net;
using TBF.BenchControl.GenericDevices;
@@ -28,7 +29,7 @@ namespace TBF.BenchControl.Elde.Valve
public int LagOpening { get { return valveCfg.LagOpening; } }
public int LagClosing { get { return valveCfg.LagClosing; } }
public readonly ulong Mask; /// derived from bitPosition in the constructor
public readonly UInt128 Mask; /// derived from bitPosition in the constructor
public int BitPosition { get { return valveCfg.BitPosition; } }
@@ -45,11 +46,11 @@ namespace TBF.BenchControl.Elde.Valve
controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
if (valveCfg.BitPosition < 0 || valveCfg.BitPosition >= 64)
if (valveCfg.BitPosition < 0 || valveCfg.BitPosition >= 128)
{
throw new ArgumentOutOfRangeException("position");
}
this.Mask = (((ulong)1) << valveCfg.BitPosition);
this.Mask = (((UInt128)1) << valveCfg.BitPosition);
if (valveCfg.CoupledToName != null)
{
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
@@ -144,10 +144,10 @@ namespace TBF.BenchControl.Elde.Valve
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Coupled To'";
}
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64)
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 128)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Bit Position' should be between 0 and 63";
message += Environment.NewLine + "'Bit Position' should be between 0 and 127";
}
if (!int.TryParse(openCloseTimeTextBox.Text, out dummy) || dummy < 0 || dummy > 300 || (dummy % StateMachine.Period) != 0)
{
@@ -1,10 +1,11 @@
///
/// Copyright (c) 2015 Sensus Metering Systems
/// Copyright (c) 2015-2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.BenchControl.GenericDevices;
using Dirichlet.Numerics;
namespace TBF.BenchControl.Elde.ValveEx
{
@@ -15,7 +16,7 @@ namespace TBF.BenchControl.Elde.ValveEx
readonly ValveCfg valveCfg;
public readonly ulong Mask; /// derived from bitPosition in the constructor
public readonly UInt128 Mask; /// derived from bitPosition in the constructor
///
public readonly IValve[] InputValves;
@@ -31,11 +32,11 @@ namespace TBF.BenchControl.Elde.ValveEx
//controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
//if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
if (valveCfg.BitPosition < 0 || valveCfg.BitPosition >= 64)
if (valveCfg.BitPosition < 0 || valveCfg.BitPosition >= 128)
{
throw new ArgumentOutOfRangeException("position");
}
this.Mask = (((ulong)1) << valveCfg.BitPosition);
this.Mask = (((UInt128)1) << valveCfg.BitPosition);
InputValves = new IValve[valveCfg.InputValvesCount];
InputValves[0] = TbfComponents.FindComponent(valveCfg.Input1, components) as IValve;
@@ -50,7 +51,7 @@ namespace TBF.BenchControl.Elde.ValveEx
log.Debug(this.ToString());
}
public void UpdateRoute(ref ulong route)
public void UpdateRoute(ref UInt128 route)
{
bool output;
@@ -125,10 +125,10 @@ namespace TBF.BenchControl.Elde.ValveEx
CfgUpdateFlags flags = CfgUpdateFlags.None;
int dummy;
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64)
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 128)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Bit Position' should be between 0 and 63";
message += Environment.NewLine + "'Bit Position' should be between 0 and 127";
}
if (!logicalOpComboBox.Items.Contains(logicalOpComboBox.Text))
{
@@ -13,6 +13,7 @@ using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.BenchControl.GenericDevices;
using TBF.BenchControl.Sequences;
using Dirichlet.Numerics;
namespace TBF.BenchControl
{
@@ -217,7 +218,7 @@ namespace TBF.BenchControl
SequenceBase.PumpsWithFM = new List<IPumpFM>();
SequenceBase.WaterMeters = new List<IWaterMeter>();
SequenceBase.Cameras = new List<ICamera>();
ulong valvesToInvert = 0;
UInt128 valvesToInvert = 0;
foreach (var cmpnt in components)
{
if (cmpnt is Elde.ControlBoardDev) ControlBoard = cmpnt as Elde.ControlBoardDev;