Uni : Buffering of the last combined action arguments, ver. 3.1.1618
This commit is contained in:
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
|||||||
// Build Number
|
// Build Number
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("3.1.1617.0")]
|
[assembly: AssemblyVersion("3.1.1618.0")]
|
||||||
[assembly: AssemblyFileVersion("3.1.1617.0")]
|
[assembly: AssemblyFileVersion("3.1.1618.0")]
|
||||||
|
|||||||
@@ -492,29 +492,33 @@ namespace TBF.Rig.ControlBoard.Uni
|
|||||||
}
|
}
|
||||||
|
|
||||||
///----------------------------------------------------------------------------------------------
|
///----------------------------------------------------------------------------------------------
|
||||||
void SetArgs(Action action)
|
public void SetArgs(Action action, ActionID actionId)
|
||||||
{
|
{
|
||||||
ActionId |= action.ActionId;
|
switch (actionId)
|
||||||
|
|
||||||
switch (action.ActionId)
|
|
||||||
{
|
{
|
||||||
case ActionID.ChangeRoute: SetChangeRouteArgs(action); return;
|
case ActionID.ChangeRoute: SetChangeRouteArgs(action); return;
|
||||||
case ActionID.MeasureFlow: SetMeasureFlowArgs(action); return;
|
case ActionID.MeasureFlow: SetMeasureFlowArgs(action); return;
|
||||||
case ActionID.SetFlow: SetSetFlowArgs(action); return;
|
case ActionID.SetFlow: SetSetFlowArgs(action); return;
|
||||||
case ActionID.StartTest: SetStartTestArgs(action); return;
|
case ActionID.StartTest: SetStartTestArgs(action); return;
|
||||||
case ActionID.Stop: SetStopArgs(action); return;
|
case ActionID.Stop: SetStopArgs(action); return;
|
||||||
case ActionID.RegVlvIncrMove: SetRegVlvIncrMoveArgs(action); return;
|
case ActionID.RegVlvIncrMove: SetRegVlvIncrMoveArgs(action); return;
|
||||||
case ActionID.RegVlvMoveToPos: SetRegVlvMoveToPosArgs(action); return;
|
case ActionID.RegVlvMoveToPos: SetRegVlvMoveToPosArgs(action); return;
|
||||||
case ActionID.RegVlvStop: SetRegVlvStopArgs(action); return;
|
case ActionID.RegVlvStop: SetRegVlvStopArgs(action); return;
|
||||||
case ActionID.SwitchDiverter: SetSwitchDiverterArgs(action); return;
|
case ActionID.SwitchDiverter: SetSwitchDiverterArgs(action); return;
|
||||||
case ActionID.DelayStartOrStop: SetDelayStartOrStopArgs(action); return;
|
case ActionID.DelayStartOrStop: SetDelayStartOrStopArgs(action); return;
|
||||||
case ActionID.GetDiverterTransitionData: SetGetDiverterTransitionDataArgs(action); return;
|
case ActionID.GetDiverterTransitionData: SetGetDiverterTransitionDataArgs(action); return;
|
||||||
case ActionID.GetScopeAnalyzerData: SetGetScopeAnalyzerDataArgs(action); return;
|
case ActionID.GetScopeAnalyzerData: SetGetScopeAnalyzerDataArgs(action); return;
|
||||||
case ActionID.ResetScopeAnalyzer: SetResetScopeAnalyzerArgs(action); return;
|
case ActionID.ResetScopeAnalyzer: SetResetScopeAnalyzerArgs(action); return;
|
||||||
case ActionID.GetSwitchCounterData: SetGetSwitchCounterDataArgs(action); return;
|
case ActionID.GetSwitchCounterData: SetGetSwitchCounterDataArgs(action); return;
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void SetArgs(Action action)
|
||||||
|
{
|
||||||
|
ActionId |= action.ActionId;
|
||||||
|
SetArgs(action, action.ActionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check whether new action arguments are compatible with alredy collected arguments
|
/// Check whether new action arguments are compatible with alredy collected arguments
|
||||||
|
|||||||
@@ -15,8 +15,22 @@ namespace TBF.Rig.ControlBoard.Uni
|
|||||||
public const int PayloadLen = 38;
|
public const int PayloadLen = 38;
|
||||||
public const byte MessageCode = (byte)' ';
|
public const byte MessageCode = (byte)' ';
|
||||||
|
|
||||||
|
|
||||||
|
static Action arguments = new Action();
|
||||||
|
///
|
||||||
|
static void FetchArguments(Action combinedAction)
|
||||||
|
{
|
||||||
|
foreach (var aId in (ActionID[])Enum.GetValues(typeof(ActionID)))
|
||||||
|
{
|
||||||
|
if ((combinedAction.ActionId & aId) != 0) arguments.SetArgs(combinedAction, aId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static byte[] GetMessage(Action action, short config, ulong bitsToInvert)
|
public static byte[] GetMessage(Action action, short config, ulong bitsToInvert)
|
||||||
{
|
{
|
||||||
|
FetchArguments(action);
|
||||||
|
|
||||||
byte[] message = new byte[PayloadLen + 5]; /// headed 3 bytes, checksum 2 bytes
|
byte[] message = new byte[PayloadLen + 5]; /// headed 3 bytes, checksum 2 bytes
|
||||||
|
|
||||||
/// Header + message code (4 bytes)
|
/// Header + message code (4 bytes)
|
||||||
@@ -28,14 +42,14 @@ namespace TBF.Rig.ControlBoard.Uni
|
|||||||
/// Command
|
/// Command
|
||||||
message[4] = GetCommand(action);
|
message[4] = GetCommand(action);
|
||||||
message[5] = action.IsStart() ? GetStartParams(action) : action.IsStop() ? GetStopParams(action) : (byte)0;
|
message[5] = action.IsStart() ? GetStartParams(action) : action.IsStop() ? GetStopParams(action) : (byte)0;
|
||||||
message[6] = (action.DivId <= 0) ? (byte)0 : (byte)(action.DivId - 1);
|
message[6] = (arguments.DivId <= 0) ? (byte)0 : (byte)(arguments.DivId - 1);
|
||||||
|
|
||||||
int totalPulsesCount = (action.TotalPulsesCount < 0) ? 0 : action.TotalPulsesCount;
|
int totalPulsesCount = (arguments.TotalPulsesCount < 0) ? 0 : arguments.TotalPulsesCount;
|
||||||
message[7] = (byte)(totalPulsesCount & 0xFF);
|
message[7] = (byte)(totalPulsesCount & 0xFF);
|
||||||
message[8] = (byte)((totalPulsesCount >> 8) & 0xFF);
|
message[8] = (byte)((totalPulsesCount >> 8) & 0xFF);
|
||||||
message[9] = (byte)((totalPulsesCount >> 16) & 0xFF);
|
message[9] = (byte)((totalPulsesCount >> 16) & 0xFF);
|
||||||
|
|
||||||
int massPulsesCount = (action.MassPulsesCount < 0) ? 0 : action.MassPulsesCount;
|
int massPulsesCount = (arguments.MassPulsesCount < 0) ? 0 : arguments.MassPulsesCount;
|
||||||
message[10] = (byte)(massPulsesCount & 0xFF);
|
message[10] = (byte)(massPulsesCount & 0xFF);
|
||||||
message[11] = (byte)((massPulsesCount >> 8) & 0xFF);
|
message[11] = (byte)((massPulsesCount >> 8) & 0xFF);
|
||||||
message[12] = (byte)((massPulsesCount >> 16) & 0xFF);
|
message[12] = (byte)((massPulsesCount >> 16) & 0xFF);
|
||||||
@@ -46,7 +60,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
|||||||
message[15] = (byte)((config >> 8) & 0xff);
|
message[15] = (byte)((config >> 8) & 0xff);
|
||||||
|
|
||||||
/// Route
|
/// Route
|
||||||
ulong routeOut = action.Route ^ bitsToInvert;
|
ulong routeOut = arguments.Route ^ bitsToInvert;
|
||||||
message[16] = ((action.ActionId & ActionID.ChangeRoute) != 0) ? (byte)1 : (byte)0; /// Route change flag
|
message[16] = ((action.ActionId & ActionID.ChangeRoute) != 0) ? (byte)1 : (byte)0; /// Route change flag
|
||||||
message[17] = (byte)(routeOut & 0xFF);
|
message[17] = (byte)(routeOut & 0xFF);
|
||||||
message[18] = (byte)((routeOut >> 8) & 0xFF);
|
message[18] = (byte)((routeOut >> 8) & 0xFF);
|
||||||
@@ -72,11 +86,11 @@ namespace TBF.Rig.ControlBoard.Uni
|
|||||||
/// DA1
|
/// DA1
|
||||||
message[33] = 0; /// PrudParL
|
message[33] = 0; /// PrudParL
|
||||||
message[34] = 0; /// PrudParH
|
message[34] = 0; /// PrudParH
|
||||||
|
|
||||||
message[35] = (byte)Math.Max(1, Math.Min(255, action.PID)); /// PIDRV
|
message[35] = (byte)Math.Max(1, Math.Min(255, arguments.PID)); /// PIDRV
|
||||||
message[36] = 0; // (byte)Math.Max(4, Math.Min(255, action.TolerRV)); /// TolerRV (4..20 mA reg.valve only)
|
message[36] = 0; // (byte)Math.Max(4, Math.Min(255, action.TolerRV)); /// TolerRV (4..20 mA reg.valve only)
|
||||||
message[37] = (byte)Math.Max(0, Math.Min(255, action.StabTime)); /// StabRV
|
message[37] = (byte)Math.Max(0, Math.Min(255, arguments.StabTime)); /// StabRV
|
||||||
message[38] = (byte)((action.DivThreshold >> 2) & 0xFF);
|
message[38] = (byte)((arguments.DivThreshold >> 2) & 0xFF);
|
||||||
|
|
||||||
message[39] = 0;
|
message[39] = 0;
|
||||||
message[40] = 0;
|
message[40] = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user