UniCB : Valve control (route)
This commit is contained in:
@@ -72,7 +72,9 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
|||||||
|
|
||||||
|
|
||||||
/// Propagated from configurations of other components
|
/// Propagated from configurations of other components
|
||||||
UInt128 valvesToInvert;
|
UInt128 benchModelRoute;
|
||||||
|
UInt128 valvesToInvert; /// Route = valesToInvert ^ RequiredRouteWithoutInvertedVlaves
|
||||||
|
readonly UInt128 routeMask; /// This mask masks out virtual valves, routeMask is set in the constructor
|
||||||
|
|
||||||
/// Serial communication
|
/// Serial communication
|
||||||
SerialPort serialPort; /// Seral port or null: Check serialPort.IsOpen before using the serial port
|
SerialPort serialPort; /// Seral port or null: Check serialPort.IsOpen before using the serial port
|
||||||
@@ -94,8 +96,6 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
|||||||
|
|
||||||
public UInt64 State { get { return Data.State; } } /// Control board state
|
public UInt64 State { get { return Data.State; } } /// Control board state
|
||||||
public UInt64 DigitalInputs { get { return Data.Vstupy; } } /// Digital inputs
|
public UInt64 DigitalInputs { get { return Data.Vstupy; } } /// Digital inputs
|
||||||
public UInt128 Route { get { return Data.Vystupy; } } /// Test bench route: states of valves
|
|
||||||
|
|
||||||
public Int16 AnalogInput(int channel)
|
public Int16 AnalogInput(int channel)
|
||||||
{
|
{
|
||||||
if (Data.AnalogInput != null && channel >= 0 && channel < Data.AnalogInput.Length)
|
if (Data.AnalogInput != null && channel >= 0 && channel < Data.AnalogInput.Length)
|
||||||
@@ -104,7 +104,12 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Route: 128-bit word representing the current state of all valves and pumps
|
||||||
|
/// </summary>
|
||||||
|
public UInt128 Route { get { return benchModelRoute; } }
|
||||||
|
|
||||||
/// Values valid during a test
|
/// Values valid during a test
|
||||||
public double RefFrequency { get { return Data.ReferenceFreq[0]; } }
|
public double RefFrequency { get { return Data.ReferenceFreq[0]; } }
|
||||||
|
|
||||||
@@ -174,6 +179,28 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
|||||||
cumulativeSums = new int[BUFFER_SIZE];
|
cumulativeSums = new int[BUFFER_SIZE];
|
||||||
rcvdBytesCount = 0;
|
rcvdBytesCount = 0;
|
||||||
|
|
||||||
|
routeMask = 0;
|
||||||
|
for (int i = 0; i < 128; i++)
|
||||||
|
{
|
||||||
|
if (i < cBoardCfg.VirtValvesRangeLo || i > cBoardCfg.VirtValvesRangeHi)
|
||||||
|
{
|
||||||
|
routeMask = routeMask | ((UInt128)1 << i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TBF.UiBridge.Bridge.RouteChangeHandler += delegate(object sndr, TBF.UiBridge.RouteChangeArgs args)
|
||||||
|
{
|
||||||
|
UInt128 mask = ((UInt128)1) << args.BitNr;
|
||||||
|
if ((benchModelRoute & mask) == 0)
|
||||||
|
{
|
||||||
|
benchModelRoute |= mask;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
benchModelRoute &= (~mask);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
log.Warn(this.ToString());
|
log.Warn(this.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,6 +211,7 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
|||||||
public void SpecifyInvertedValves(UInt128 valvesToInvert)
|
public void SpecifyInvertedValves(UInt128 valvesToInvert)
|
||||||
{
|
{
|
||||||
this.valvesToInvert = valvesToInvert;
|
this.valvesToInvert = valvesToInvert;
|
||||||
|
this.benchModelRoute = valvesToInvert;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IDevice interface
|
#region IDevice interface
|
||||||
@@ -365,7 +393,17 @@ namespace TBF.BenchControl.ControlBoard.Uni
|
|||||||
public double TestTimeWM(int wmNr1) { return 0; }
|
public double TestTimeWM(int wmNr1) { return 0; }
|
||||||
public int RefPulsesWM(int wmNr1) { return 0; }
|
public int RefPulsesWM(int wmNr1) { return 0; }
|
||||||
public int PulsesWM(int wmNr1) { return 0; }
|
public int PulsesWM(int wmNr1) { return 0; }
|
||||||
public UInt128 SetValves(UInt128 valvesToOpen, UInt128 valvesToClose, IList<BuiltIn.ValveEx.Valve> extendedValves) { return 0; }
|
public UInt128 SetValves(UInt128 valvesToOpen, UInt128 valvesToClose, IList<BuiltIn.ValveEx.Valve> extendedValves)
|
||||||
|
{
|
||||||
|
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.RouteToStr(benchModelRoute));
|
||||||
|
UInt128 retVal = oldRoute ^ benchModelRoute;
|
||||||
|
|
||||||
|
log.DebugFormat("{0}.SetValves({1}, {2}) returns {3}", Name, valvesToOpen.ToString("X"), valvesToClose.ToString("X"), retVal.ToString("X"));
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Operations
|
/// Operations
|
||||||
|
|||||||
Reference in New Issue
Block a user