Update refrences from GVL variable aAxes to astAxes

This commit is contained in:
Federico Rojas
2020-03-23 15:13:51 +01:00
parent a8e4f88884
commit 5399e85127
3 changed files with 70 additions and 71 deletions
+15 -16
View File
@@ -43,7 +43,7 @@ AXES();]]></ST>
<Action Name="AXES" Id="{7eb32732-9b53-4934-8cd9-20ba971dd8ff}">
<Implementation>
<ST><![CDATA[FOR GVL.iAxis := 1 TO GVL_APP.nAxisNum DO
afbAxes[GVL.iAxis](stAxisStruct := GVL.aAxes[GVL.iAxis]);
afbAxes[GVL.iAxis](stAxisStruct := GVL.astAxes[GVL.iAxis]);
END_FOR]]></ST>
</Implementation>
</Action>
@@ -80,8 +80,7 @@ END_IF]]></ST>
</Action>
<Action Name="RESTORE_POSITIONS" Id="{0c7ee537-7bd9-4833-b428-c17cbb57e893}" FolderPath="POSITION_RECOVERY\">
<Implementation>
<ST><![CDATA[
//This ACT will restore the position of an incremental axis on startup with the act position it read before losing power.
<ST><![CDATA[//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[iAxes].stConfig.eRestorePosition is non-zero.
@@ -104,7 +103,7 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN
//Result stored in Value, 0=Inc 1=Abs, execute set during the case statement
FOR iAxes := 1 TO GVL_APP.nAxisNum DO
afbReadEncRefSys[iAxes](
Axis := GVL.aAxes[iAxes].Axis,
Axis := GVL.astAxes[iAxes].Axis,
Enable := bExecuteReadEncRefSys,
ParameterNumber := MC_AxisParameter.AxisEncoderReferenceSystem,
ReadMode := E_READMODE.READMODE_ONCE);
@@ -113,8 +112,8 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN
//Cycle through set position function blocks for each axis
FOR iAxes := 1 TO GVL_APP.nAxisNum DO
afbRestorePosition[iAxes](
Axis := GVL.aAxes[iAxes].Axis,
Position := aAxesPersistent[iAxes].fPositionAtShutdown);
Axis := GVL.astAxes[iAxes].Axis,
Position := astAxesPersistent[iAxes].fPositionAtShutdown);
END_FOR
CASE eStartUp OF
@@ -156,8 +155,8 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN
eExecuteRestore:
//Execute position restore by setting afbRestorePosition.execute = TRUE
FOR iAxes := 1 TO GVL_APP.nAxisNum DO
IF afbReadEncRefSys[iAxes].Valid = TRUE AND afbReadEncRefSys[iAxes].Value = 0 AND NOT(aAxesPersistent[iAxes].bMovingAtShutdown) THEN
IF GVL.aAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN
IF afbReadEncRefSys[iAxes].Valid = TRUE AND afbReadEncRefSys[iAxes].Value = 0 AND NOT(astAxesPersistent[iAxes].bMovingAtShutdown) THEN
IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN
afbRestorePosition[iAxes].Execute := TRUE;
END_IF
END_IF
@@ -169,8 +168,8 @@ IF bRestoreExecute AND NOT bPositionRestoreDone THEN
//Nothing actually happens if the restore is not done, the code just returns from here each cycle and the
//bPositionRestoreDone will never get set to TRUE and will take up cycle time
FOR iAxes := 1 TO GVL_APP.nAxisNum DO
IF afbReadEncRefSys[iAxes].Valid = TRUE AND afbReadEncRefSys[iAxes].Value = 0 AND NOT(aAxesPersistent[iAxes].bMovingAtShutdown) THEN
IF GVL.aAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN
IF afbReadEncRefSys[iAxes].Valid = TRUE AND afbReadEncRefSys[iAxes].Value = 0 AND NOT(astAxesPersistent[iAxes].bMovingAtShutdown) THEN
IF GVL.astAxes[iAxes].stConfig.eRestorePosition = E_RestorePosition.eRestoreWithoutHome THEN
IF NOT afbRestorePosition[iAxes].Done THEN
RETURN;
END_IF
@@ -193,13 +192,13 @@ END_IF]]></ST>
<Action Name="STORE_PERSISTENT" Id="{cb5c9254-2e5f-47b1-9baa-10e728a961b0}" FolderPath="POSITION_RECOVERY\">
<Implementation>
<ST><![CDATA[FOR iAxes := 1 TO GVL_APP.nAxisNum DO
aAxesPersistent[iAxes].fPositionAtShutdown := GVL.aAxes[iAxes].Axis.NcToPlc.ActPos;
IF GVL.aAxes[iAxes].Axis.NcToPlc.ActVelo <> 0 THEN
aAxesPersistent[iAxes].bMovingAtShutdown := TRUE;
astAxesPersistent[iAxes].fPositionAtShutdown := GVL.astAxes[iAxes].Axis.NcToPlc.ActPos;
IF GVL.astAxes[iAxes].Axis.NcToPlc.ActVelo <> 0 THEN
astAxesPersistent[iAxes].bMovingAtShutdown := TRUE;
ELSE
aAxesPersistent[iAxes].bMovingAtShutdown := FALSE;
astAxesPersistent[iAxes].bMovingAtShutdown := FALSE;
END_IF
aAxesPersistent[iAxes].bMovingAtShutdown := aAxesPersistent[iAxes].bMovingAtShutdown OR GVL.aAxes[iAxes].Axis.Status.Moving;
astAxesPersistent[iAxes].bMovingAtShutdown := astAxesPersistent[iAxes].bMovingAtShutdown OR GVL.astAxes[iAxes].Axis.Status.Moving;
END_FOR]]></ST>
</Implementation>
</Action>
@@ -225,7 +224,7 @@ END_FOR]]></ST>
<LineId Id="2" Count="0" />
</LineIds>
<LineIds Name="MAIN.RESTORE_POSITIONS">
<LineId Id="352" Count="106" />
<LineId Id="567" Count="105" />
<LineId Id="1" Count="0" />
</LineIds>
<LineIds Name="MAIN.STORE_PERSISTENT">
@@ -16,7 +16,7 @@ VAR_INPUT
iAxisIndex: UINT; // The idex of the axis to action the method on.
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[GVL.aAxes[iAxisIndex].stControl.bEnable := TRUE;]]></ST>
<ST><![CDATA[GVL.astAxes[iAxisIndex].stControl.bEnable := TRUE;]]></ST>
</Implementation>
</Method>
<Method Name="mExecute" Id="{010bd927-5568-40db-a7c5-fcfe995a5cb1}">
@@ -25,7 +25,7 @@ VAR_INPUT
iAxisIndex: UINT; // The idex of the axis to action the method on.
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[GVL.aAxes[iAxisIndex].stControl.bExecute := TRUE;]]></ST>
<ST><![CDATA[GVL.astAxes[iAxisIndex].stControl.bExecute := TRUE;]]></ST>
</Implementation>
</Method>
<Method Name="mPrepareDefaultMove" Id="{c23244d5-896c-49ad-8d8a-19390856e4dc}">
@@ -37,17 +37,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].stControl.bEnable := TRUE;
GVL.aAxes[iAxisIndex].stControl.eCommand := E_MotionFunctions.eMoveAbsolute;
GVL.astAxes[iAxisIndex].stControl.bEnable := TRUE;
GVL.astAxes[iAxisIndex].stControl.eCommand := E_MotionFunctions.eMoveAbsolute;
GVL.aAxes[iAxisIndex].stInputs.bLimitBwd := TRUE;
GVL.aAxes[iAxisIndex].stInputs.bLimitFwd := TRUE;
GVL.astAxes[iAxisIndex].stInputs.bLimitBwd := TRUE;
GVL.astAxes[iAxisIndex].stInputs.bLimitFwd := TRUE;
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>
GVL.astAxes[iAxisIndex].stConfig.fVelocity := tcUNIT_GVL.fDEFAULT_TARGET_VELOCITY;
GVL.astAxes[iAxisIndex].stConfig.fAcceleration := tcUNIT_GVL.fDEFAULT_TARGET_ACCELERATION;
GVL.astAxes[iAxisIndex].stConfig.fDeceleration := tcUNIT_GVL.fDEFAULT_TARGET_DECCELERATION;
GVL.astAxes[iAxisIndex].stConfig.fOverride := tcUNIT_GVL.fDEFAULT_TARGET_OVERRIDE;
GVL.astAxes[iAxisIndex].stConfig.fPosition := tcUNIT_GVL.fDEFAULT_POSITION;]]></ST>
</Implementation>
</Method>
<Method Name="mPrepareMove" Id="{97bd5417-d0a1-4d32-8732-16310a863fcc}">
@@ -64,16 +64,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].stControl.bEnable := FALSE;
GVL.aAxes[iAxisIndex].stControl.eCommand := eMotionStrategy;
GVL.astAxes[iAxisIndex].stControl.bEnable := FALSE;
GVL.astAxes[iAxisIndex].stControl.eCommand := eMotionStrategy;
GVL.aAxes[iAxisIndex].stInputs.bLimitBwd := TRUE;
GVL.aAxes[iAxisIndex].stInputs.bLimitFwd := TRUE;
GVL.astAxes[iAxisIndex].stInputs.bLimitBwd := TRUE;
GVL.astAxes[iAxisIndex].stInputs.bLimitFwd := TRUE;
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>
GVL.astAxes[iAxisIndex].stConfig.fVelocity := fTargetVelocity;
GVL.astAxes[iAxisIndex].stConfig.fAcceleration := fTargetAcceleration;
GVL.astAxes[iAxisIndex].stConfig.fDeceleration := fTargetDeceleration;
GVL.astAxes[iAxisIndex].stConfig.fPosition := fTargetPosition;]]></ST>
</Implementation>
</Method>
<Method Name="mSetAxisDefaults" Id="{5b9336be-4414-4858-a614-0fdb2847e171}">
@@ -85,34 +85,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].stStatus.bBusy THEN
GVL.aAxes[iAxisIndex].stControl.bStop := TRUE;
IF GVL.astAxes[iAxisIndex].stStatus.bBusy THEN
GVL.astAxes[iAxisIndex].stControl.bStop := TRUE;
END_IF
IF GVL.aAxes[iAxisIndex].stStatus.bError THEN
GVL.aAxes[iAxisIndex].stControl.bReset := TRUE;
IF GVL.astAxes[iAxisIndex].stStatus.bError THEN
GVL.astAxes[iAxisIndex].stControl.bReset := TRUE;
END_IF
IF NOT GVL.aAxes[iAxisIndex].stControl.bEnable AND GVL.aAxes[iAxisIndex].stControl.bStop THEN
GVL.aAxes[iAxisIndex].stControl.bStop := FALSE;
IF NOT GVL.astAxes[iAxisIndex].stControl.bEnable AND GVL.astAxes[iAxisIndex].stControl.bStop THEN
GVL.astAxes[iAxisIndex].stControl.bStop := FALSE;
END_IF
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.astAxes[iAxisIndex].stControl.bEnable := FALSE;
GVL.astAxes[iAxisIndex].stControl.bExecute := FALSE;
GVL.astAxes[iAxisIndex].stControl.bReset := FALSE;
GVL.astAxes[iAxisIndex].stControl.bJogFwd := FALSE;
GVL.astAxes[iAxisIndex].stControl.bJogBwd := FALSE;
GVL.astAxes[iAxisIndex].stControl.bStop := FALSE;
GVL.astAxes[iAxisIndex].stControl.eCommand := E_MotionFunctions.eMoveAbsolute;
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.eHomeSeq := 0;
GVL.astAxes[iAxisIndex].stConfig.fVelocity := 0.0;
GVL.astAxes[iAxisIndex].stConfig.fAcceleration := 0.0;
GVL.astAxes[iAxisIndex].stConfig.fDeceleration := 0.0;
GVL.astAxes[iAxisIndex].stConfig.fPosition := 0;
GVL.astAxes[iAxisIndex].stConfig.fOverride := 0.0;
GVL.astAxes[iAxisIndex].stConfig.eHomeSeq := 0;
GVL.aAxes[iAxisIndex].stInputs.bLimitBwd := FALSE;
GVL.aAxes[iAxisIndex].stInputs.bLimitFwd := FALSE;
GVL.aAxes[iAxisIndex].stInputs.bHomeSensor := FALSE;]]></ST>
GVL.astAxes[iAxisIndex].stInputs.bLimitBwd := FALSE;
GVL.astAxes[iAxisIndex].stInputs.bLimitFwd := FALSE;
GVL.astAxes[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].stStatus.bBusy;
Result := GVL.astAxes[iTargetAxis].stStatus.bBusy;
IF nCycle > nMaxCycles OR ExpectedResult = Result THEN
AssertEquals(Expected := ExpectedResult,
@@ -63,14 +63,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].stConfig.fPosition;
InitialValue := GVL.astAxes[iTargetAxis].stConfig.fPosition;
ExpectedResult := InitialValue + 10;
GVL.aAxes[iTargetAxis].stConfig.fPosition := ExpectedResult;
GVL.astAxes[iTargetAxis].stConfig.fPosition := ExpectedResult;
GVL.aAxes[iTargetAxis].stControl.eCommand := E_MotionFunctions.eMoveAbsolute;
GVL.aAxes[iTargetAxis].stControl.bExecute := TRUE;
GVL.astAxes[iTargetAxis].stControl.eCommand := E_MotionFunctions.eMoveAbsolute;
GVL.astAxes[iTargetAxis].stControl.bExecute := TRUE;
Result := GVL.aAxes[iTargetAxis].stStatus.fActPosition;
Result := GVL.astAxes[iTargetAxis].stStatus.fActPosition;
IF nCycle > nCycleMax OR ExpectedResult = Result THEN
AssertEquals(Expected := ExpectedResult,
@@ -97,7 +97,7 @@ END_VAR]]></Declaration>
ExpectedResult := tcUNIT_gvl.fDEFAULT_TARGET_ACCELERATION;
fbCommon.mPrepareDefaultMove(iTargetAxis);
Result := GVL.aAxes[iTargetAxis].stConfig.fAcceleration;
Result := GVL.astAxes[iTargetAxis].stConfig.fAcceleration;
AssertEquals(Expected := ExpectedResult,
Actual := Result,
@@ -121,9 +121,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[iTargetAxis].stControl.bEnable := ExpectedResult;
GVL.astAxes[iTargetAxis].stControl.bEnable := ExpectedResult;
Result := GVL.aAxes[iTargetAxis].stStatus.bEnabled;
Result := GVL.astAxes[iTargetAxis].stStatus.bEnabled;
IF nCycle > nMaxCycles OR ExpectedResult = Result THEN
AssertEquals(Expected := ExpectedResult,
@@ -150,11 +150,11 @@ END_VAR]]></Declaration>
// Example of using a tcUNIT assert for a specific type (in this case LREAL).
InitialValue := GVL.aAxes[iTargetAxis].stConfig.fVelocity;
InitialValue := GVL.astAxes[iTargetAxis].stConfig.fVelocity;
ExpectedResult := InitialValue + 0.5;
GVL.aAxes[iTargetAxis].stConfig.fVelocity := ExpectedResult;
GVL.astAxes[iTargetAxis].stConfig.fVelocity := ExpectedResult;
Result := GVL.aAxes[iTargetAxis].stConfig.fVelocity;
Result := GVL.astAxes[iTargetAxis].stConfig.fVelocity;
AssertEquals_LREAL(Expected := ExpectedResult,
Actual := Result,
@@ -178,9 +178,9 @@ END_VAR]]></Declaration>
ExpectedResult := TRUE;
GVL.aAxes[iTargetAxis].stInputs.bLimitFwd := TRUE;
GVL.astAxes[iTargetAxis].stInputs.bLimitFwd := TRUE;
Result := GVL.aAxes[iTargetAxis].stStatus.bFwEnabled;
Result := GVL.astAxes[iTargetAxis].stStatus.bFwEnabled;
IF nCycle > nMaxCycles OR ExpectedResult = Result THEN
AssertEquals(Expected := ExpectedResult,