Skip to content

Commit

Permalink
Auto-update from Github Actions Workflow
Browse files Browse the repository at this point in the history
Deployed from commit b9ecaa7 (refs/heads/master)
  • Loading branch information
github-actions committed Feb 10, 2024
1 parent c91d5bb commit f886fc4
Show file tree
Hide file tree
Showing 10 changed files with 596 additions and 44 deletions.
239 changes: 239 additions & 0 deletions master/_sources/lcls-twincat-motion_Library_source.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17238,6 +17238,7 @@ FB_StatesInputHandler
bInit: BOOL;
nQueuedGoal: UINT;
bNewMove: BOOL;
nCachedStart: UINT;
END_VAR
VAR CONSTANT
IDLE: UINT := 0;
Expand All @@ -17249,6 +17250,7 @@ FB_StatesInputHandler
bInit := TRUE;
stUserInput.nSetValue := 0;
nCurrGoal := nStartingState;
nCachedStart := nStartingState;
bExecMove := FALSE;
nState := IDLE;
bNewMove := FALSE;
Expand All @@ -17269,6 +17271,10 @@ FB_StatesInputHandler
ELSIF bMoveBusy THEN
// We're moving but used to be idle -> switch to GOING
nState := GOING;
ELSIF nStartingState <> nCachedStart THEN
// Usually a late position init, sometimes a live change in encoder offset
// The state changed without a move, so we need to partially reinitialize.
nCurrGoal := nStartingState;
END_IF
GOING:
IF bNewMove THEN
Expand All @@ -17290,6 +17296,9 @@ FB_StatesInputHandler
bExecMove := FALSE;
END_IF

// Detect if the set/start position updates without a move
nCachedStart := nStartingState;

// Help us detect if there is an EPICS put before the next cycle
stUserInput.nSetValue := 0;
stUserInput.bReset := FALSE;
Expand Down Expand Up @@ -17742,6 +17751,234 @@ Related:
* `ST_MotionStage`_


FB_TestStateInitTiming
^^^^^^^^^^^^^^^^^^^^^^

::

FUNCTION_BLOCK FB_TestStateInitTiming EXTENDS TcUnit.FB_TestSuite
VAR
stMotionStage: ST_MotionStage;
fbMotionStageSim: FB_MotionStageSim;
END_VAR
fbMotionStageSim(
stMotionStage:=stMotionStage,
nEnableMode:=E_StageEnableMode.DURING_MOTION,
);

PassiveReinit();

END_FUNCTION_BLOCK

METHOD PassiveReinit : BOOL
VAR_INPUT
END_VAR
VAR_INST
fbStateSetup: FB_StateSetupHelper;
stDefault: ST_PositionState := (
fDelta := 0.5,
fVelocity := 3,
bMoveOk := TRUE,
bValid := TRUE
);
eEnumSet: UINT;
eEnumGet: UINT;
stEpicsToPlc: ST_StateEpicsToPlc;
stPlcToEpics: ST_StatePlcToEpics;
fbCore: FB_PositionStateND_Core;
astMotionStageMax: ARRAY[1..MotionConstants.MAX_STATE_MOTORS] OF ST_MotionStage;
astPositionStateMax: ARRAY[1..MotionConstants.MAX_STATE_MOTORS] OF ARRAY[1..GeneralConstants.MAX_STATES] OF ST_PositionState;

mcSetPos: MC_SetPosition;
nCheckStep: UINT := 0;
nFurthestStep: UINT;

nLastState: UINT;
nTransitionState: UINT := 99;
nDoneState: UINT := 99;
timer: TON;

nSetPosErrCount: UINT := 0;
nSetPosErrorID: UDINT;
END_VAR
TEST('PassiveReinit');

// State setup
fbStateSetup(stPositionState:=stDefault, bSetDefault:=TRUE);
fbStateSetup(stPositionState:=astPositionStateMax[1][1], sName:='ONE', fPosition:=10);
fbStateSetup(stPositionState:=astPositionStateMax[1][2], sName:='TWO', fPosition:=20);

// Run the state FB every cycle
astMotionStageMax[1] := stMotionStage;
fbCore(
astMotionStageMax:=astMotionStageMax,
astPositionStateMax:=astPositionStateMax,
stEpicsToPlc:=stEpicsToPlc,
stPlcToEpics:=stPlcToEpics,
eEnumSet:=eEnumSet,
eEnumGet:=eEnumGet,
bEnable:=TRUE,
nActiveMotorCount:=1,
);
stMotionStage := astMotionStageMax[1];

// Check and adjust different things as we go
CASE nCheckStep OF
0: // State begins at "Unknown", nCurrGoal begins at "Unknown"
AssertEquals_UINT(
Expected:=0,
Actual:=eEnumGet,
Message:='Did not start in unknown state',
);
AssertEquals_UINT(
Expected:=0,
Actual:=fbCore.nCurrGoal,
Message:='Did not start with nCurrGoal unknown',
);
mcSetPos(
Axis:=stMotionStage.Axis,
Execute:=FALSE,
);
nCheckStep := 1;
1: // Set the current position to ONE/10
mcSetPos(
Axis:=stMotionStage.Axis,
Execute:=TRUE,
Position:=10,
);
IF mcSetPos.Done THEN
mcSetPos(
Axis:=stMotionStage.Axis,
Execute:=FALSE,
);
nCheckStep := 2;
ELSIF mcSetPos.Error THEN
nSetPosErrCount := nSetPosErrCount + 1;
nSetPosErrorID := mcSetPos.ErrorID;
nCheckStep := 0;
END_IF
2: // Without a move, the state and goal should both change to "ONE" if the position updates
AssertEquals_UINT(
Expected:=1,
Actual:=eEnumGet,
Message:='Read state did not change to ONE after setpos',
);
AssertEquals_UINT(
Expected:=1,
Actual:=fbCore.nCurrGoal,
Message:='nCurrGoal did not change to ONE after setpos',
);
// Verify: no move requested
AssertEquals_LREAL(
Expected:=0,
Actual:=stMotionStage.fPosition,
Delta:=0.001,
Message:='Set pos routine 1 actually gave us a move!',
);
nCheckStep := 3;
3: // Same as before, but to 20/TWO
mcSetPos(
Axis:=stMotionStage.Axis,
Execute:=TRUE,
Position:=20,
);
IF mcSetPos.Done THEN
mcSetPos(
Axis:=stMotionStage.Axis,
Execute:=FALSE,
);
nCheckStep := 4;
END_IF
4:
AssertEquals_UINT(
Expected:=2,
Actual:=eEnumGet,
Message:='Read state did not change to TWO after setpos',
);
AssertEquals_UINT(
Expected:=2,
Actual:=fbCore.nCurrGoal,
Message:='nCurrGoal did not change to TWO after setpos',
);
// Verify: no move requested
AssertEquals_LREAL(
Expected:=0,
Actual:=stMotionStage.fPosition,
Delta:=0.001,
Message:='Set pos routine 2 actually gave us a move!',
);
nCheckStep := 5;
5: // Triggering a move should change the goal to the new state, without updating the readback
eEnumSet := 1;
nLastState := 2;
nCheckStep := 6;
6:
AssertEquals_UINT(
Expected:=1,
Actual:=fbCore.nCurrGoal,
Message:='nCurrGoal did not change to ONE in move',
);
// Looking for a readback transition 2 -> 0 -> 1
// Record the next two transitions
IF eEnumGet <> nLastState and nTransitionState = 99 THEN
nTransitionState := eEnumGet;
ELSIF eEnumGet <> nLastState and nDoneState = 99 THEN
nDoneState := eEnumGet;
END_IF
nLastState := eEnumGet;
IF stPlcToEpics.bDone THEN
AssertEquals_UINT(
Expected:=0,
Actual:=nTransitionState,
Message:='State did not transition 2 -> 0 in move',
);
AssertEquals_UINT(
Expected:=1,
Actual:=nDoneState,
Message:='State did not transition 2 -> 0 -> 1 in move',
);
nCheckStep := 7;
END_IF
7: // The readback and curr goal should match after the move, then end test suite
AssertEquals_UINT(
Expected:=1,
Actual:=eEnumGet,
Message:='Read state did not change to ONE after move',
);
AssertEquals_UINT(
Expected:=1,
Actual:=fbCore.nCurrGoal,
Message:='nCurrGoal did not stay at ONE after move',
);
AssertFalse(
Condition:=timer.Q,
Message:='Timeout in test',
);
TEST_FINISHED();
END_CASE

timer(IN:=TRUE, PT:=T#5s);
IF timer.Q THEN
nCheckStep := 7;
END_IF
IF nCheckStep < 7 AND nFurthestStep < nCheckStep THEN
nFurthestStep := nCheckStep;
END_IF
END_METHOD


Related:
* `E_StageEnableMode`_
* `FB_MotionStageSim`_
* `FB_PositionStateND_Core`_
* `FB_StateSetupHelper`_
* `MotionConstants`_
* `ST_MotionStage`_
* `ST_PositionState`_
* `ST_StateEpicsToPlc`_
* `ST_StatePlcToEpics`_


FB_WriteFloatParameter
^^^^^^^^^^^^^^^^^^^^^^

Expand Down Expand Up @@ -17968,6 +18205,7 @@ PRG_TEST
fb_StatePMPSEnablesND_Test: FB_StatePMPSEnablesND_Test;
fb_PositionStatePMPSND_Test: FB_PositionStatePMPSND_Test;
fb_StateSetupHelper_Test: FB_StateSetupHelper_Test;
fb_TestStateInitTiming: FB_TestStateInitTiming;
END_VAR
TcUnit.RUN();

Expand All @@ -17992,4 +18230,5 @@ Related:
* `FB_StatePMPSEnables_Test`_
* `FB_StateSetupHelper_Test`_
* `FB_TestHelperSetAndMove_Test`_
* `FB_TestStateInitTiming`_

4 changes: 2 additions & 2 deletions master/_sources/lcls-twincat-motion_Library_summary.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Settings
- Value
- Description
* - AMS Net ID
- 172.21.148.148.1.1
- 172.21.148.81.1.1
-
* - Target IP address
- 172.21.148.148
- 172.21.148.81
- Based on AMS Net ID by convention
* - AMS Port
- 851
Expand Down
2 changes: 2 additions & 0 deletions master/_sources/lcls-twincat-motion_links.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Links
Library Instance, PlcTask Inputs^PRG_TEST.fb_PositionStateRead_Test.stMotionStage.Axis.NcToPlc, TINC^NC-Task 1 SAF^Axes^Axis_PositionStateRead_Test, Outputs^ToPlc
Library Instance, PlcTask Inputs^PRG_TEST.fb_StatePMPSEnables_Test.stMotionStage.Axis.NcToPlc, TINC^NC-Task 1 SAF^Axes^Axis_StatePMPSEnable_Test, Outputs^ToPlc
Library Instance, PlcTask Inputs^PRG_TEST.fb_TestHelperSetAndMove_Test.stMotionStage.Axis.NcToPlc, TINC^NC-Task 1 SAF^Axes^Axis_TestHelperSetAndMove_Test, Outputs^ToPlc
Library Instance, PlcTask Inputs^PRG_TEST.fb_TestStateInitTiming.stMotionStage.Axis.NcToPlc, TINC^NC-Task 1 SAF^Axes^Axis_TestStateInitTiming, Outputs^ToPlc
Library Instance, PlcTask Outputs^PRG_TEST.fb_AtPositionState_Test.stMotionStage.Axis.PlcToNc, TINC^NC-Task 1 SAF^Axes^Axis_AtPositionState_Test, Inputs^FromPlc
Library Instance, PlcTask Outputs^PRG_TEST.fb_NCErrorFFO_Test.stMotionStage.Axis.PlcToNc, TINC^NC-Task 1 SAF^Axes^Axis_NCErrorFFO_Test, Inputs^FromPlc
Library Instance, PlcTask Outputs^PRG_TEST.fb_PositionStateMoveND_Test.astMotionStage[1].Axis.PlcToNc, TINC^NC-Task 1 SAF^Axes^Axis_PositionStateMoveND_Test_1, Inputs^FromPlc
Expand All @@ -47,4 +48,5 @@ Links
Library Instance, PlcTask Outputs^PRG_TEST.fb_PositionStateRead_Test.stMotionStage.Axis.PlcToNc, TINC^NC-Task 1 SAF^Axes^Axis_PositionStateRead_Test, Inputs^FromPlc
Library Instance, PlcTask Outputs^PRG_TEST.fb_StatePMPSEnables_Test.stMotionStage.Axis.PlcToNc, TINC^NC-Task 1 SAF^Axes^Axis_StatePMPSEnable_Test, Inputs^FromPlc
Library Instance, PlcTask Outputs^PRG_TEST.fb_TestHelperSetAndMove_Test.stMotionStage.Axis.PlcToNc, TINC^NC-Task 1 SAF^Axes^Axis_TestHelperSetAndMove_Test, Inputs^FromPlc
Library Instance, PlcTask Outputs^PRG_TEST.fb_TestStateInitTiming.stMotionStage.Axis.PlcToNc, TINC^NC-Task 1 SAF^Axes^Axis_TestStateInitTiming, Inputs^FromPlc
OutputSrc, PRG_TEST.fb_StatePMPSLimits_Test.stMotionStage.Axis.PlcToNc, TINC^NC-Task 1 SAF^Axes^Axis_StatePMPSLimits_Test, Inputs^FromPlc
19 changes: 19 additions & 0 deletions master/_sources/lcls-twincat-motion_nc.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ NC Settings
:header: Axis ID, Name
:align: center

1, Axis_TestStateInitTiming
3, Axis_PositionStateRead_Test
4, Axis_AtPositionState_Test
5, Axis_TestHelperSetAndMove_Test
Expand All @@ -29,6 +30,24 @@ NC Settings



Axis 1: Axis_TestStateInitTiming
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. csv-table::
:header: Setting, Value
:align: center

Axis ID, 1
Name, Axis_TestStateInitTiming
AxisFolder, Unit Test Axes
AxisType, 1
CreateSymbols, true
Enc:EncType, 1
Id, 1
OtherSettings:AllowMotionCmdToSlave, true



Axis 3: Axis_PositionStateRead_Test
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
2 changes: 2 additions & 0 deletions master/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ <h1>lcls-twincat-motion<a class="headerlink" href="#lcls-twincat-motion" title="
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="lcls-twincat-motion_nc.html">NC Settings</a><ul>
<li class="toctree-l2"><a class="reference internal" href="lcls-twincat-motion_nc.html#axis-1-axis-teststateinittiming">Axis 1: Axis_TestStateInitTiming</a></li>
<li class="toctree-l2"><a class="reference internal" href="lcls-twincat-motion_nc.html#axis-3-axis-positionstateread-test">Axis 3: Axis_PositionStateRead_Test</a></li>
<li class="toctree-l2"><a class="reference internal" href="lcls-twincat-motion_nc.html#axis-4-axis-atpositionstate-test">Axis 4: Axis_AtPositionState_Test</a></li>
<li class="toctree-l2"><a class="reference internal" href="lcls-twincat-motion_nc.html#axis-5-axis-testhelpersetandmove-test">Axis 5: Axis_TestHelperSetAndMove_Test</a></li>
Expand Down Expand Up @@ -315,6 +316,7 @@ <h1>lcls-twincat-motion<a class="headerlink" href="#lcls-twincat-motion" title="
<li class="toctree-l2"><a class="reference internal" href="lcls-twincat-motion_Library_source.html#fb-terminalerror">FB_TerminalError</a></li>
<li class="toctree-l2"><a class="reference internal" href="lcls-twincat-motion_Library_source.html#fb-testhelpersetandmove">FB_TestHelperSetAndMove</a></li>
<li class="toctree-l2"><a class="reference internal" href="lcls-twincat-motion_Library_source.html#fb-testhelpersetandmove-test">FB_TestHelperSetAndMove_Test</a></li>
<li class="toctree-l2"><a class="reference internal" href="lcls-twincat-motion_Library_source.html#fb-teststateinittiming">FB_TestStateInitTiming</a></li>
<li class="toctree-l2"><a class="reference internal" href="lcls-twincat-motion_Library_source.html#fb-writefloatparameter">FB_WriteFloatParameter</a></li>
<li class="toctree-l2"><a class="reference internal" href="lcls-twincat-motion_Library_source.html#fb-writeparameterinnc-v1-00">FB_WriteParameterInNc_v1_00</a></li>
<li class="toctree-l2"><a class="reference internal" href="lcls-twincat-motion_Library_source.html#prg-test">PRG_TEST</a></li>
Expand Down
Loading

0 comments on commit f886fc4

Please sign in to comment.