Change all DUT's variable names and references after merge with MBP-138
This commit is contained in:
@@ -83,7 +83,7 @@ END_IF]]></ST>
|
||||
// This ACT will restore the position of an incremental axis on startup with the act position it read before losing power.
|
||||
// It checks the type of axis, 0=incremental, and that the axis was stationary at shut down.
|
||||
// Because 0 equates to incremental we also need to check that the data is valid, otherwise by default it would restore all axes.
|
||||
// By default an axis will not restore the position unless it is set to opt-in, i.e. gvl.aAxes[GVL.iAxis].config.eRestorePosition is non-zero.
|
||||
// By default an axis will not restore the position unless it is set to opt-in, i.e. gvl.aAxes[GVL.iAxis].stConfig.eRestorePosition is non-zero.
|
||||
// This needs to be initialised somewhere in TwinCAT code otherwise it will not be available at start up.
|
||||
// A restore will only be performed on a loss of power, this code shouldn't make any changes on a reset cold, a rest origin or a download.
|
||||
// There is a enum to allow for different types of restore modes, currently only one is implemented.
|
||||
@@ -116,7 +116,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN
|
||||
aFbRestorePosition[GVL.iAxis](
|
||||
Axis := gvl.aAxes[GVL.iAxis].Axis,
|
||||
Execute := ,
|
||||
Position := aAxesPersistent[GVL.iAxis].iPositionAtShutdown);
|
||||
Position := aAxesPersistent[GVL.iAxis].fPositionAtShutdown);
|
||||
END_FOR
|
||||
|
||||
CASE eStartUp OF
|
||||
@@ -159,7 +159,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN
|
||||
// Execute position restore by setting aFbRestorePosition.execute = TRUE
|
||||
FOR GVL.iAxis:= 1 TO gvl_app.nAxisNum DO
|
||||
IF aFbReadEncRefSys[GVL.iAxis].Valid = TRUE AND aFbReadEncRefSys[GVL.iAxis].Value = 0 AND NOT(aAxesPersistent[GVL.iAxis].bMovingAtShutdown) THEN
|
||||
IF GVL.aAxes[GVL.iAxis].config.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN
|
||||
IF GVL.aAxes[GVL.iAxis].stConfig.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN
|
||||
aFbRestorePosition[GVL.iAxis].Execute := TRUE;
|
||||
END_IF
|
||||
END_IF
|
||||
@@ -172,7 +172,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN
|
||||
// bPositionRestoreDone will never get set to TRUE and will take up cycle time
|
||||
FOR GVL.iAxis:= 1 TO gvl_app.nAxisNum DO
|
||||
IF aFbReadEncRefSys[GVL.iAxis].Valid = TRUE AND aFbReadEncRefSys[GVL.iAxis].Value = 0 AND NOT(aAxesPersistent[GVL.iAxis].bMovingAtShutdown) THEN
|
||||
IF GVL.aAxes[GVL.iAxis].config.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN
|
||||
IF GVL.aAxes[GVL.iAxis].stConfig.eRestorePosition = E_RestorePosition.RestoreWithoutHome THEN
|
||||
IF NOT aFbRestorePosition[GVL.iAxis].Done THEN
|
||||
RETURN;
|
||||
END_IF
|
||||
@@ -195,7 +195,7 @@ END_IF]]></ST>
|
||||
<Action Name="STORE_PERSISTENT" Id="{cb5c9254-2e5f-47b1-9baa-10e728a961b0}" FolderPath="POSITION_RECOVERY\">
|
||||
<Implementation>
|
||||
<ST><![CDATA[FOR GVL.iAxis:= 1 TO gvl_app.nAxisNum DO
|
||||
aAxesPersistent[GVL.iAxis].iPositionAtShutdown := gvl.aAxes[GVL.iAxis].Axis.NcToPlc.ActPos;
|
||||
aAxesPersistent[GVL.iAxis].fPositionAtShutdown := gvl.aAxes[GVL.iAxis].Axis.NcToPlc.ActPos;
|
||||
IF gvl.aAxes[GVL.iAxis].Axis.NcToPlc.ActVelo <> 0 THEN
|
||||
aAxesPersistent[GVL.iAxis].bMovingAtShutdown := TRUE;
|
||||
ELSE
|
||||
|
||||
@@ -15,7 +15,7 @@ VAR_INPUT
|
||||
iAxisIndex: INT; // The idex of the axis to action the method on.
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[GVL.aAxes[iAxisIndex].control.bEnable := TRUE;]]></ST>
|
||||
<ST><![CDATA[GVL.aAxes[iAxisIndex].stControl.bEnable := TRUE;]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="mExecute" Id="{010bd927-5568-40db-a7c5-fcfe995a5cb1}">
|
||||
@@ -24,7 +24,7 @@ VAR_INPUT
|
||||
iAxisIndex: INT; // The idex of the axis to action the method on.
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[GVL.aAxes[iAxisIndex].control.bExecute := TRUE;]]></ST>
|
||||
<ST><![CDATA[GVL.aAxes[iAxisIndex].stControl.bExecute := TRUE;]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="mPrepareDefaultMove" Id="{c23244d5-896c-49ad-8d8a-19390856e4dc}">
|
||||
@@ -36,17 +36,17 @@ END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Prepare an axis so it is ready to action a move using target defaults when executed.
|
||||
|
||||
GVL.aAxes[iAxisIndex].control.bEnable := TRUE;
|
||||
GVL.aAxes[iAxisIndex].control.eCommand := E_MotionFunctions.eMoveAbsolute;
|
||||
GVL.aAxes[iAxisIndex].stControl.bEnable := TRUE;
|
||||
GVL.aAxes[iAxisIndex].stControl.eCommand := E_MotionFunctions.eMoveAbsolute;
|
||||
|
||||
GVL.aAxes[iAxisIndex].inputs.bLimitBwd := TRUE;
|
||||
GVL.aAxes[iAxisIndex].inputs.bLimitFwd := TRUE;
|
||||
GVL.aAxes[iAxisIndex].stInputs.bLimitBwd := TRUE;
|
||||
GVL.aAxes[iAxisIndex].stInputs.bLimitFwd := TRUE;
|
||||
|
||||
GVL.aAxes[iAxisIndex].config.fVelocity := tcUNIT_GVL.fDEFAULT_TARGET_VELOCITY;
|
||||
GVL.aAxes[iAxisIndex].config.fAcceleration := tcUNIT_GVL.fDEFAULT_TARGET_ACCELERATION;
|
||||
GVL.aAxes[iAxisIndex].config.fDeceleration := tcUNIT_GVL.fDEFAULT_TARGET_DECCELERATION;
|
||||
GVL.aAxes[iAxisIndex].config.fOverride := tcUNIT_GVL.fDEFAULT_TARGET_OVERRIDE;
|
||||
GVL.aAxes[iAxisIndex].config.fPosition := tcUNIT_GVL.fDEFAULT_POSITION;]]></ST>
|
||||
GVL.aAxes[iAxisIndex].stConfig.fVelocity := tcUNIT_GVL.fDEFAULT_TARGET_VELOCITY;
|
||||
GVL.aAxes[iAxisIndex].stConfig.fAcceleration := tcUNIT_GVL.fDEFAULT_TARGET_ACCELERATION;
|
||||
GVL.aAxes[iAxisIndex].stConfig.fDeceleration := tcUNIT_GVL.fDEFAULT_TARGET_DECCELERATION;
|
||||
GVL.aAxes[iAxisIndex].stConfig.fOverride := tcUNIT_GVL.fDEFAULT_TARGET_OVERRIDE;
|
||||
GVL.aAxes[iAxisIndex].stConfig.fPosition := tcUNIT_GVL.fDEFAULT_POSITION;]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="mPrepareMove" Id="{97bd5417-d0a1-4d32-8732-16310a863fcc}">
|
||||
@@ -63,16 +63,16 @@ END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Prepare the axis so it is ready to action a move when executed for a given motion strategy.
|
||||
|
||||
GVL.aAxes[iAxisIndex].control.bEnable := FALSE;
|
||||
GVL.aAxes[iAxisIndex].control.eCommand := eMotionStrategy;
|
||||
GVL.aAxes[iAxisIndex].stControl.bEnable := FALSE;
|
||||
GVL.aAxes[iAxisIndex].stControl.eCommand := eMotionStrategy;
|
||||
|
||||
GVL.aAxes[iAxisIndex].inputs.bLimitBwd := TRUE;
|
||||
GVL.aAxes[iAxisIndex].inputs.bLimitFwd := TRUE;
|
||||
GVL.aAxes[iAxisIndex].stInputs.bLimitBwd := TRUE;
|
||||
GVL.aAxes[iAxisIndex].stInputs.bLimitFwd := TRUE;
|
||||
|
||||
GVL.aAxes[iAxisIndex].config.fVelocity := fTargetVelocity;
|
||||
GVL.aAxes[iAxisIndex].config.fAcceleration := fTargetAcceleration;
|
||||
GVL.aAxes[iAxisIndex].config.fDeceleration := fTargetDeceleration;
|
||||
GVL.aAxes[iAxisIndex].config.fPosition := fTargetPosition;]]></ST>
|
||||
GVL.aAxes[iAxisIndex].stConfig.fVelocity := fTargetVelocity;
|
||||
GVL.aAxes[iAxisIndex].stConfig.fAcceleration := fTargetAcceleration;
|
||||
GVL.aAxes[iAxisIndex].stConfig.fDeceleration := fTargetDeceleration;
|
||||
GVL.aAxes[iAxisIndex].stConfig.fPosition := fTargetPosition;]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="mSetAxisDefaults" Id="{5b9336be-4414-4858-a614-0fdb2847e171}">
|
||||
@@ -84,34 +84,34 @@ END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Set PLC default values for the axis. Note: Status values can take multiple cycles to updated. This is not an instant reset.
|
||||
|
||||
IF GVL.aAxes[iAxisIndex].status.bBusy THEN
|
||||
GVL.aAxes[iAxisIndex].control.bStop := TRUE;
|
||||
IF GVL.aAxes[iAxisIndex].stStatus.bBusy THEN
|
||||
GVL.aAxes[iAxisIndex].stControl.bStop := TRUE;
|
||||
END_IF
|
||||
IF GVL.aAxes[iAxisIndex].status.bError THEN
|
||||
GVL.aAxes[iAxisIndex].control.bReset := TRUE;
|
||||
IF GVL.aAxes[iAxisIndex].stStatus.bError THEN
|
||||
GVL.aAxes[iAxisIndex].stControl.bReset := TRUE;
|
||||
END_IF
|
||||
IF NOT GVL.aAxes[iAxisIndex].control.bEnable AND GVL.aAxes[iAxisIndex].control.bStop THEN
|
||||
GVL.aAxes[iAxisIndex].control.bStop := FALSE;
|
||||
IF NOT GVL.aAxes[iAxisIndex].stControl.bEnable AND GVL.aAxes[iAxisIndex].stControl.bStop THEN
|
||||
GVL.aAxes[iAxisIndex].stControl.bStop := FALSE;
|
||||
END_IF
|
||||
|
||||
GVL.aAxes[iAxisIndex].control.bEnable := FALSE;
|
||||
GVL.aAxes[iAxisIndex].control.bExecute := FALSE;
|
||||
GVL.aAxes[iAxisIndex].control.bReset := FALSE;
|
||||
GVL.aAxes[iAxisIndex].control.bJogFwd := FALSE;
|
||||
GVL.aAxes[iAxisIndex].control.bJogBwd := FALSE;
|
||||
GVL.aAxes[iAxisIndex].control.bStop := FALSE;
|
||||
GVL.aAxes[iAxisIndex].control.eCommand := E_MotionFunctions.eMoveAbsolute;
|
||||
GVL.aAxes[iAxisIndex].stControl.bEnable := FALSE;
|
||||
GVL.aAxes[iAxisIndex].stControl.bExecute := FALSE;
|
||||
GVL.aAxes[iAxisIndex].stControl.bReset := FALSE;
|
||||
GVL.aAxes[iAxisIndex].stControl.bJogFwd := FALSE;
|
||||
GVL.aAxes[iAxisIndex].stControl.bJogBwd := FALSE;
|
||||
GVL.aAxes[iAxisIndex].stControl.bStop := FALSE;
|
||||
GVL.aAxes[iAxisIndex].stControl.eCommand := E_MotionFunctions.eMoveAbsolute;
|
||||
|
||||
GVL.aAxes[iAxisIndex].config.fVelocity := 0.0;
|
||||
GVL.aAxes[iAxisIndex].config.fAcceleration := 0.0;
|
||||
GVL.aAxes[iAxisIndex].config.fDeceleration := 0.0;
|
||||
GVL.aAxes[iAxisIndex].config.fPosition := 0;
|
||||
GVL.aAxes[iAxisIndex].config.fOverride := 0.0;
|
||||
GVL.aAxes[iAxisIndex].config.nHomeSeq := 0;
|
||||
GVL.aAxes[iAxisIndex].stConfig.fVelocity := 0.0;
|
||||
GVL.aAxes[iAxisIndex].stConfig.fAcceleration := 0.0;
|
||||
GVL.aAxes[iAxisIndex].stConfig.fDeceleration := 0.0;
|
||||
GVL.aAxes[iAxisIndex].stConfig.fPosition := 0;
|
||||
GVL.aAxes[iAxisIndex].stConfig.fOverride := 0.0;
|
||||
GVL.aAxes[iAxisIndex].stConfig.nHomeSeq := 0;
|
||||
|
||||
GVL.aAxes[iAxisIndex].inputs.bLimitBwd := FALSE;
|
||||
GVL.aAxes[iAxisIndex].inputs.bLimitFwd := FALSE;
|
||||
GVL.aAxes[iAxisIndex].inputs.bHomeSensor := FALSE;]]></ST>
|
||||
GVL.aAxes[iAxisIndex].stInputs.bLimitBwd := FALSE;
|
||||
GVL.aAxes[iAxisIndex].stInputs.bLimitFwd := FALSE;
|
||||
GVL.aAxes[iAxisIndex].stInputs.bHomeSensor := FALSE;]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<LineIds Name="FB_tcUNIT_common">
|
||||
|
||||
@@ -34,7 +34,7 @@ ExpectedResult := TRUE;
|
||||
fbCommon.mPrepareDefaultMove(iTargetAxis);
|
||||
fbCommon.mExecute(iTargetAxis);
|
||||
|
||||
Result := GVL.aAxes[iTargetAxis].status.bBusy;
|
||||
Result := GVL.aAxes[iTargetAxis].stStatus.bBusy;
|
||||
|
||||
IF nCycle > nMaxCycles OR ExpectedResult = Result THEN
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
@@ -62,14 +62,14 @@ END_VAR]]></Declaration>
|
||||
// a previous test. Therefore if we execute a move we should just check it's moved
|
||||
// from the initial location not some initial default.
|
||||
|
||||
InitialValue := GVL.aAxes[iTargetAxis].config.fPosition;
|
||||
InitialValue := GVL.aAxes[iTargetAxis].stConfig.fPosition;
|
||||
ExpectedResult := InitialValue + 10;
|
||||
GVL.aAxes[iTargetAxis].config.fPosition := ExpectedResult;
|
||||
GVL.aAxes[iTargetAxis].stConfig.fPosition := ExpectedResult;
|
||||
|
||||
GVL.aAxes[iTargetAxis].control.eCommand := E_MotionFunctions.eMoveAbsolute;
|
||||
GVL.aAxes[iTargetAxis].control.bExecute := TRUE;
|
||||
GVL.aAxes[iTargetAxis].stControl.eCommand := E_MotionFunctions.eMoveAbsolute;
|
||||
GVL.aAxes[iTargetAxis].stControl.bExecute := TRUE;
|
||||
|
||||
Result := GVL.aAxes[iTargetAxis].status.fActPosition;
|
||||
Result := GVL.aAxes[iTargetAxis].stStatus.fActPosition;
|
||||
|
||||
IF nCycle > nCycleMax OR ExpectedResult = Result THEN
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
@@ -96,7 +96,7 @@ END_VAR]]></Declaration>
|
||||
ExpectedResult := tcUNIT_gvl.fDEFAULT_TARGET_ACCELERATION;
|
||||
fbCommon.mPrepareDefaultMove(iTargetAxis);
|
||||
|
||||
Result := GVL.aAxes[1].config.fAcceleration;
|
||||
Result := GVL.aAxes[1].stConfig.fAcceleration;
|
||||
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
Actual := Result,
|
||||
@@ -119,9 +119,9 @@ END_VAR]]></Declaration>
|
||||
// example of test that requires multiple cycles to complete. Due to stateful behaviour of the axis structure.
|
||||
|
||||
ExpectedResult := TRUE;
|
||||
GVL.aAxes[1].control.bEnable := ExpectedResult;
|
||||
GVL.aAxes[1].stControl.bEnable := ExpectedResult;
|
||||
|
||||
Result := GVL.aAxes[iTargetAxis].status.bEnabled;
|
||||
Result := GVL.aAxes[iTargetAxis].stStatus.bEnabled;
|
||||
|
||||
IF nCycle > nMaxCycles OR ExpectedResult = Result THEN
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
@@ -148,11 +148,11 @@ END_VAR]]></Declaration>
|
||||
|
||||
// Example of using a tcUNIT assert for a specific type (in this case LREAL).
|
||||
|
||||
InitialValue := GVL.aAxes[iTargetAxis].config.fVelocity;
|
||||
InitialValue := GVL.aAxes[iTargetAxis].stConfig.fVelocity;
|
||||
ExpectedResult := InitialValue + 0.5;
|
||||
GVL.aAxes[iTargetAxis].config.fVelocity := ExpectedResult;
|
||||
GVL.aAxes[iTargetAxis].stConfig.fVelocity := ExpectedResult;
|
||||
|
||||
Result := GVL.aAxes[iTargetAxis].config.fVelocity;
|
||||
Result := GVL.aAxes[iTargetAxis].stConfig.fVelocity;
|
||||
|
||||
AssertEquals_LREAL(Expected := ExpectedResult,
|
||||
Actual := Result,
|
||||
@@ -176,9 +176,9 @@ END_VAR]]></Declaration>
|
||||
|
||||
ExpectedResult := TRUE;
|
||||
|
||||
GVL.aAxes[iTargetAxis].inputs.bLimitFwd := TRUE;
|
||||
GVL.aAxes[iTargetAxis].stInputs.bLimitFwd := TRUE;
|
||||
|
||||
Result := GVL.aAxes[iTargetAxis].status.bFwEnabled;
|
||||
Result := GVL.aAxes[iTargetAxis].stStatus.bFwEnabled;
|
||||
|
||||
IF nCycle > nMaxCycles OR ExpectedResult = Result THEN
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
|
||||
Reference in New Issue
Block a user