Test suite and examples for tc_mca_std_lib solution
This commit is contained in:
@@ -7,7 +7,7 @@ VAR_GLOBAL
|
||||
END_VAR
|
||||
|
||||
VAR_GLOBAL CONSTANT
|
||||
axisNum : UINT:=0;
|
||||
axisNum : UINT:=1;
|
||||
//axisCoupleMax : UINT:=4;
|
||||
END_VAR]]></Declaration>
|
||||
</GVL>
|
||||
|
||||
@@ -140,7 +140,6 @@ END_IF]]></ST>
|
||||
<Implementation>
|
||||
<ST><![CDATA[//
|
||||
(* Program any sequence, safety or feature (if necessary) application specific in thsi section*)
|
||||
|
||||
//]]></ST>
|
||||
</Implementation>
|
||||
</Action>
|
||||
@@ -310,7 +309,6 @@ END_FOR]]></ST>
|
||||
<LineIds Name="MAIN.PROG">
|
||||
<LineId Id="2" Count="0" />
|
||||
<LineId Id="1" Count="0" />
|
||||
<LineId Id="5" Count="0" />
|
||||
<LineId Id="3" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="MAIN.RESTORE_POSITIONS">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.0">
|
||||
<POU Name="FB_tcUNIT_common" Id="{0f757d3d-99b7-46eb-bdc6-03aa126689f4}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[// tcUNIT Common function block: Contains helper methods for tcUNIT
|
||||
<Declaration><![CDATA[// tcUNIT Common function block: Contains helper methods for tcUNIT.
|
||||
FUNCTION_BLOCK FB_tcUNIT_common
|
||||
|
||||
VAR
|
||||
@@ -9,170 +9,150 @@ END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="Cycle" Id="{664ce267-e020-4cb0-b408-882e70cdbead}">
|
||||
<Declaration><![CDATA[METHOD Cycle : BOOL
|
||||
<Method Name="mEnableAxis" Id="{12e91532-7139-4c17-998e-4c670b584b9d}">
|
||||
<Declaration><![CDATA[METHOD mEnableAxis : BOOL
|
||||
VAR_INPUT
|
||||
iCycles: INT; // Number of cycles to process
|
||||
END_VAR
|
||||
|
||||
VAR
|
||||
i: INT := 0;
|
||||
iAxisIndex: INT; // The idex of the axis to action the method on
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[WHILE i < iCycles DO
|
||||
i := i + 1;
|
||||
END_WHILE]]></ST>
|
||||
<ST><![CDATA[GVL.axes[iAxisIndex].control.bEnable := TRUE;
|
||||
]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="Execute" Id="{010bd927-5568-40db-a7c5-fcfe995a5cb1}">
|
||||
<Declaration><![CDATA[METHOD Execute : BOOL
|
||||
VAR_IN_OUT
|
||||
Axis: ST_AxisStruct; // The axis to set execute TRUE
|
||||
<Method Name="mExecute" Id="{010bd927-5568-40db-a7c5-fcfe995a5cb1}">
|
||||
<Declaration><![CDATA[METHOD mExecute : BOOL
|
||||
VAR_INPUT
|
||||
iAxisIndex: INT; // The idex of the axis to action the method on.
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[Axis.control.bExecute := TRUE;
|
||||
|
||||
Cycle(1); // Cycle the PLC to ensure the values have been set and results can be taken]]></ST>
|
||||
<ST><![CDATA[GVL.axes[iAxisIndex].control.bExecute := TRUE;
|
||||
]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="PrepareDefaultMove" Id="{4fe16ff1-3a9f-464c-997c-83ca1a3b1d50}">
|
||||
<Declaration><![CDATA[METHOD PrepareDefaultMove : BOOL
|
||||
VAR_IN_OUT
|
||||
Axis: ST_AxisStruct; // The axis to be driven
|
||||
END_VAR
|
||||
<Method Name="mPrepareDefaultMove" Id="{c23244d5-896c-49ad-8d8a-19390856e4dc}">
|
||||
<Declaration><![CDATA[METHOD mPrepareDefaultMove
|
||||
|
||||
VAR_INPUT
|
||||
MotionStrategy: MotionFunctions; // The motion strategy to be used in the move
|
||||
END_VAR]]></Declaration>
|
||||
iAxisIndex: INT; // The idex of the axis to action the method on.
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Prepare an axis so it is ready to action a move using target defaults when executed
|
||||
<ST><![CDATA[// Prepare an axis so it is ready to action a move using target defaults when executed.
|
||||
|
||||
Axis.control.bEnable := TRUE;
|
||||
Axis.control.eCommand := MotionStrategy;
|
||||
GVL.axes[iAxisIndex].control.bEnable := TRUE;
|
||||
GVL.axes[iAxisIndex].control.eCommand := MotionFunctions.MoveAbsolute;
|
||||
|
||||
Axis.inputs.bLimitBwd := TRUE;
|
||||
Axis.inputs.bLimitFwd := TRUE;
|
||||
GVL.axes[iAxisIndex].inputs.bLimitBwd := TRUE;
|
||||
GVL.axes[iAxisIndex].inputs.bLimitFwd := TRUE;
|
||||
|
||||
Axis.config.fVelocity := tcUNIT_GVL.fDEFAULT_TARGET_VELOCITY;
|
||||
Axis.config.fAcceleration := tcUNIT_GVL.fDEFAULT_TARGET_ACCELERATION;
|
||||
Axis.config.fDeceleration := tcUNIT_GVL.fDEFAULT_TARGET_DECCELERATION;
|
||||
Axis.config.fOverride := tcUNIT_GVL.fDEFAULT_TARGET_OVERRIDE;
|
||||
|
||||
// Drive up and down the axis during tests over a range of (-target, target.)
|
||||
IF Axis.config.fPosition = tcUNIT_GVL.fDEFAULT_POSITION THEN
|
||||
Axis.config.fPosition := tcUNIT_GVL.fDEFAULT_TARGET_POSITION * -1;
|
||||
ELSE Axis.config.fPosition := tcUNIT_GVL.fDEFAULT_POSITION;
|
||||
END_IF
|
||||
|
||||
Cycle(1); // Cycle the PLC to ensure the values have been set and results can be taken]]></ST>
|
||||
GVL.axes[iAxisIndex].config.fVelocity := tcUNIT_GVL.fDEFAULT_TARGET_VELOCITY;
|
||||
GVL.axes[iAxisIndex].config.fAcceleration := tcUNIT_GVL.fDEFAULT_TARGET_ACCELERATION;
|
||||
GVL.axes[iAxisIndex].config.fDeceleration := tcUNIT_GVL.fDEFAULT_TARGET_DECCELERATION;
|
||||
GVL.axes[iAxisIndex].config.fOverride := tcUNIT_GVL.fDEFAULT_TARGET_OVERRIDE;
|
||||
GVL.axes[iAxisIndex].config.fPosition := tcUNIT_GVL.fDEFAULT_POSITION;]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="PrepareMove" Id="{589a25a0-6147-4b15-99b0-2e3d988c1f1b}">
|
||||
<Declaration><![CDATA[METHOD PrepareMove : BOOL
|
||||
VAR_IN_OUT
|
||||
Axis: ST_AxisStruct; // The axis to be driven
|
||||
END_VAR
|
||||
<Method Name="mPrepareMove" Id="{97bd5417-d0a1-4d32-8732-16310a863fcc}">
|
||||
<Declaration><![CDATA[METHOD mPrepareMove
|
||||
|
||||
VAR_INPUT
|
||||
iAxisIndex: INT; // The idex of the axis to action the method on.
|
||||
fTargetVelocity: LREAL;
|
||||
fTargetAcceleration: LREAL;
|
||||
fTargetDeceleration: LREAL;
|
||||
fTargetPosition: LREAL;
|
||||
eMotionStrategy: MotionFunctions;
|
||||
eMotionStrategy: MotionFunctions; // The desired MotionFunctions motion strategy.
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Prepare an axis so it is ready to action a move when executed
|
||||
<ST><![CDATA[// Prepare the axis so it is ready to action a move when executed for a given motion strategy.
|
||||
|
||||
Axis.control.bEnable := FALSE;
|
||||
Axis.control.eCommand := eMotionStrategy;
|
||||
GVL.axes[iAxisIndex].control.bEnable := FALSE;
|
||||
GVL.axes[iAxisIndex].control.eCommand := eMotionStrategy;
|
||||
|
||||
Axis.inputs.bLimitBwd := TRUE;
|
||||
Axis.inputs.bLimitFwd := TRUE;
|
||||
GVL.axes[iAxisIndex].inputs.bLimitBwd := TRUE;
|
||||
GVL.axes[iAxisIndex].inputs.bLimitFwd := TRUE;
|
||||
|
||||
Axis.config.fVelocity := fTargetVelocity;
|
||||
Axis.config.fAcceleration := fTargetAcceleration;
|
||||
Axis.config.fDeceleration := fTargetDeceleration;
|
||||
Axis.config.fPosition := fTargetPosition;
|
||||
|
||||
Cycle(1); // Cycle the PLC to ensure the values have been set and results can be taken]]></ST>
|
||||
GVL.axes[iAxisIndex].config.fVelocity := fTargetVelocity;
|
||||
GVL.axes[iAxisIndex].config.fAcceleration := fTargetAcceleration;
|
||||
GVL.axes[iAxisIndex].config.fDeceleration := fTargetDeceleration;
|
||||
GVL.axes[iAxisIndex].config.fPosition := fTargetPosition;
|
||||
]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="SetDefaults" Id="{ec904510-9ac0-4de0-a743-94bb6933a54f}">
|
||||
<Declaration><![CDATA[METHOD SetDefaults : BOOL
|
||||
VAR_IN_OUT
|
||||
Axis: ST_AxisStruct; // The Axis to set defaults
|
||||
<Method Name="mSetAxisDefaults" Id="{5b9336be-4414-4858-a614-0fdb2847e171}">
|
||||
<Declaration><![CDATA[METHOD mSetAxisDefaults
|
||||
|
||||
VAR_INPUT
|
||||
iAxisIndex: INT; // The idex of the axis to action the method on.
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Set PLC default values for the provided axis
|
||||
<ST><![CDATA[// Set PLC default values for the axis. Note: Status values can take multiple cycles to updated. This is not an instant reset.
|
||||
|
||||
Axis.control.bEnable := FALSE;
|
||||
Axis.control.bExecute := FALSE;
|
||||
Axis.control.bReset := FALSE;
|
||||
Axis.control.bJogFwd := FALSE;
|
||||
Axis.control.bJogBwd := FALSE;
|
||||
Axis.control.bStop := FALSE;
|
||||
Axis.control.eCommand := MotionFunctions.MoveAbsolute;
|
||||
IF GVL.axes[iAxisIndex].status.bBusy THEN
|
||||
GVL.axes[iAxisIndex].control.bStop := TRUE;
|
||||
END_IF
|
||||
IF GVL.axes[iAxisIndex].status.bError THEN
|
||||
GVL.axes[iAxisIndex].control.bReset := TRUE;
|
||||
END_IF
|
||||
IF NOT GVL.axes[iAxisIndex].control.bEnable AND GVL.axes[iAxisIndex].control.bStop THEN
|
||||
GVL.axes[iAxisIndex].control.bStop := FALSE;
|
||||
END_IF
|
||||
|
||||
Axis.config.fVelocity := 0.0;
|
||||
Axis.config.fAcceleration := 0.0;
|
||||
Axis.config.fDeceleration := 0.0;
|
||||
Axis.config.fPosition := 0;
|
||||
Axis.config.fOverride := 0.0;
|
||||
Axis.config.nHomeSeq := 0;
|
||||
GVL.axes[iAxisIndex].control.bEnable := FALSE;
|
||||
GVL.axes[iAxisIndex].control.bExecute := FALSE;
|
||||
GVL.axes[iAxisIndex].control.bReset := FALSE;
|
||||
GVL.axes[iAxisIndex].control.bJogFwd := FALSE;
|
||||
GVL.axes[iAxisIndex].control.bJogBwd := FALSE;
|
||||
GVL.axes[iAxisIndex].control.bStop := FALSE;
|
||||
GVL.axes[iAxisIndex].control.eCommand := MotionFunctions.MoveAbsolute;
|
||||
|
||||
Axis.inputs.bLimitBwd := FALSE;
|
||||
Axis.inputs.bLimitFwd := FALSE;
|
||||
Axis.inputs.bEncLAtch := FALSE;
|
||||
Axis.inputs.bHomeSensor := FALSE;
|
||||
GVL.axes[iAxisIndex].config.fVelocity := 0.0;
|
||||
GVL.axes[iAxisIndex].config.fAcceleration := 0.0;
|
||||
GVL.axes[iAxisIndex].config.fDeceleration := 0.0;
|
||||
GVL.axes[iAxisIndex].config.fPosition := 0;
|
||||
GVL.axes[iAxisIndex].config.fOverride := 0.0;
|
||||
GVL.axes[iAxisIndex].config.nHomeSeq := 0;
|
||||
|
||||
Cycle(1); // Cycle the PLC to ensure the values have been set and results can be taken]]></ST>
|
||||
GVL.axes[iAxisIndex].inputs.bLimitBwd := FALSE;
|
||||
GVL.axes[iAxisIndex].inputs.bLimitFwd := FALSE;
|
||||
GVL.axes[iAxisIndex].inputs.bEncLAtch := FALSE;
|
||||
GVL.axes[iAxisIndex].inputs.bHomeSensor := FALSE;
|
||||
]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<LineIds Name="FB_tcUNIT_common">
|
||||
<LineId Id="9" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_tcUNIT_common.Cycle">
|
||||
<LineIds Name="FB_tcUNIT_common.mEnableAxis">
|
||||
<LineId Id="5" Count="0" />
|
||||
<LineId Id="10" Count="1" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_tcUNIT_common.Execute">
|
||||
<LineId Id="5" Count="0" />
|
||||
<LineId Id="8" Count="0" />
|
||||
<LineId Id="7" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_tcUNIT_common.PrepareDefaultMove">
|
||||
<LineId Id="122" Count="3" />
|
||||
<LineId Id="133" Count="0" />
|
||||
<LineId Id="126" Count="5" />
|
||||
<LineId Id="17" Count="0" />
|
||||
<LineId Id="145" Count="0" />
|
||||
<LineId Id="140" Count="2" />
|
||||
<LineId Id="144" Count="0" />
|
||||
<LineId Id="143" Count="0" />
|
||||
<LineId Id="147" Count="0" />
|
||||
<LineId Id="146" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_tcUNIT_common.PrepareMove">
|
||||
<LineId Id="122" Count="3" />
|
||||
<LineId Id="134" Count="0" />
|
||||
<LineId Id="126" Count="6" />
|
||||
<LineId Id="135" Count="1" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_tcUNIT_common.SetDefaults">
|
||||
<LineId Id="7" Count="0" />
|
||||
<LineId Id="14" Count="0" />
|
||||
<LineId Id="30" Count="5" />
|
||||
<LineId Id="9" Count="0" />
|
||||
<LineId Id="20" Count="0" />
|
||||
<LineId Id="10" Count="1" />
|
||||
<LineId Id="17" Count="0" />
|
||||
<LineId Id="12" Count="0" />
|
||||
<LineId Id="21" Count="0" />
|
||||
<LineId Id="24" Count="0" />
|
||||
<LineId Id="18" Count="0" />
|
||||
<LineId Id="15" Count="1" />
|
||||
<LineId Id="22" Count="1" />
|
||||
<LineId Id="36" Count="1" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_tcUNIT_common.mExecute">
|
||||
<LineId Id="5" Count="0" />
|
||||
<LineId Id="7" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_tcUNIT_common.mPrepareDefaultMove">
|
||||
<LineId Id="6" Count="0" />
|
||||
<LineId Id="38" Count="0" />
|
||||
<LineId Id="8" Count="1" />
|
||||
<LineId Id="39" Count="0" />
|
||||
<LineId Id="11" Count="6" />
|
||||
<LineId Id="19" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_tcUNIT_common.mPrepareMove">
|
||||
<LineId Id="17" Count="11" />
|
||||
<LineId Id="5" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_tcUNIT_common.mSetAxisDefaults">
|
||||
<LineId Id="6" Count="0" />
|
||||
<LineId Id="41" Count="0" />
|
||||
<LineId Id="34" Count="1" />
|
||||
<LineId Id="31" Count="0" />
|
||||
<LineId Id="44" Count="1" />
|
||||
<LineId Id="43" Count="0" />
|
||||
<LineId Id="36" Count="2" />
|
||||
<LineId Id="7" Count="19" />
|
||||
<LineId Id="5" Count="0" />
|
||||
</LineIds>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
@@ -1,12 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.0">
|
||||
<GVL Name="tcUNIT_GVL" Id="{4b23d6c9-6a88-40b7-9bf4-d55c4dfd4246}">
|
||||
<Declaration><![CDATA[// tcUNIT_GVL: Global variables used in tcUNIT tests
|
||||
<Declaration><![CDATA[// tcUNIT_GVL: Global variables used in tcUNIT tests.
|
||||
{attribute 'qualified_only'}
|
||||
VAR_GLOBAL CONSTANT
|
||||
iNumberOfAxes: INT := 1;
|
||||
|
||||
// Constants for axis defaults
|
||||
// Constants for axis defaults.
|
||||
fDEFAULT_VELOCITY: LREAL := 0.0;
|
||||
fDEFAULT_ACCELERATION: LREAL := 0.0;
|
||||
fDEFAULT_DECCELERATION: LREAL := 0.0;
|
||||
@@ -17,11 +15,9 @@ fDEFAULT_TARGET_ACCELERATION: LREAL := 0.5;
|
||||
fDEFAULT_TARGET_DECCELERATION: LREAL := 0.5;
|
||||
fDEFAULT_TARGET_POSITION: LREAL := 10.0;
|
||||
fDEFAULT_TARGET_OVERRIDE: LREAL := 100;
|
||||
|
||||
END_VAR
|
||||
|
||||
VAR_GLOBAL
|
||||
iAxis: INT;
|
||||
END_VAR]]></Declaration>
|
||||
</GVL>
|
||||
</TcPlcObject>
|
||||
@@ -6,18 +6,83 @@
|
||||
FUNCTION_BLOCK FB_Axis_TEST EXTENDS tcUnit.FB_TestSuite
|
||||
VAR
|
||||
fbCommon: FB_tcUNIT_common;
|
||||
Axis: POINTER TO ST_AxisStruct := ADR(GVL.axes[1]);
|
||||
iTargetAxis: INT := 1; // The <index> of the axis within GVL.axes[<index>] to test against.
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Declare methods defined in the FB_Axis_TEST POU to be included (executed) in the test suite
|
||||
SetAxisEnabled();
|
||||
SetAxisMoving();
|
||||
SetAxisAcceleration();
|
||||
SetAxisPosition();
|
||||
SetAxisVelocity();]]></ST>
|
||||
SetAxisControl_Enabled();
|
||||
CheckAxisStatus_Moving();
|
||||
SetAxisConfig_Acceleration();
|
||||
CheckAxisStatus_NewPosition();
|
||||
SetAxisControl_Velocity();
|
||||
SetAxisInputs_bLimitFwd();]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="SetAxisAcceleration" Id="{2efd2402-6ad3-455d-a703-347847c98522}">
|
||||
<Declaration><![CDATA[METHOD SetAxisAcceleration
|
||||
<Method Name="CheckAxisStatus_Moving" Id="{f7dcf822-91ec-4555-918f-e2487353578a}">
|
||||
<Declaration><![CDATA[METHOD CheckAxisStatus_Moving
|
||||
VAR
|
||||
Result: BOOL;
|
||||
ExpectedResult: BOOL;
|
||||
|
||||
nCycle: UINT;
|
||||
nMaxCycles: UINT := 30;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('test_GIVEN_new_axis_position_WHEN_execute_move_THEN_axis_moves');
|
||||
|
||||
ExpectedResult := TRUE;
|
||||
|
||||
fbCommon.mPrepareDefaultMove(iTargetAxis);
|
||||
fbCommon.mExecute(iTargetAxis);
|
||||
|
||||
Result := GVL.axes[iTargetAxis].status.bBusy;
|
||||
|
||||
IF nCycle > nMaxCycles OR ExpectedResult = Result THEN
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
Actual := Result,
|
||||
Message := 'Axis is not moving.');
|
||||
TEST_FINISHED();
|
||||
ELSE
|
||||
nCycle := nCycle + 1;
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="CheckAxisStatus_NewPosition" Id="{604b9446-af57-41db-afac-f53f5b12cc2c}">
|
||||
<Declaration><![CDATA[METHOD CheckAxisStatus_NewPosition
|
||||
VAR
|
||||
InitialValue: LREAL;
|
||||
Result: LREAL;
|
||||
ExpectedResult: LREAL;
|
||||
nCycle: UINT;
|
||||
nCycleMax: UINT := 100;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('test_GIVEN_new_axis_position_set_WHEN_executed_THEN_axis_moves_to_new_position');
|
||||
|
||||
// Since the axis has state; a test might begin the position at some location set by
|
||||
// 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.axes[iTargetAxis].config.fPosition;
|
||||
ExpectedResult := InitialValue + 10;
|
||||
GVL.axes[iTargetAxis].config.fPosition := ExpectedResult;
|
||||
|
||||
GVL.axes[iTargetAxis].control.eCommand := MotionFunctions.MoveAbsolute;
|
||||
GVL.axes[iTargetAxis].control.bExecute := TRUE;
|
||||
|
||||
Result := GVL.axes[iTargetAxis].status.fActPosition;
|
||||
|
||||
IF nCycle > nCycleMax OR ExpectedResult = Result THEN
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
Actual := Result,
|
||||
Message := 'fPosition of the axis is different.');
|
||||
TEST_FINISHED();
|
||||
ELSE
|
||||
nCycle := nCycle + 1;
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="SetAxisConfig_Acceleration" Id="{2efd2402-6ad3-455d-a703-347847c98522}">
|
||||
<Declaration><![CDATA[METHOD SetAxisConfig_Acceleration
|
||||
VAR
|
||||
InitialValue: LREAL;
|
||||
Result: LREAL;
|
||||
@@ -26,105 +91,51 @@ END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('test_GIVEN_new_axis_acceleration_set_WHEN_executed_THEN_new_axis_acceleration_set');
|
||||
|
||||
// example of direct GVL axis reference
|
||||
// example of direct GVL axis reference for assert.
|
||||
|
||||
ExpectedResult := tcUNIT_gvl.fDEFAULT_TARGET_ACCELERATION;
|
||||
fbCommon.PrepareDefaultMove(GVL.Axes[1], MotionFunctions.MoveAbsolute);
|
||||
fbCommon.mPrepareDefaultMove(iTargetAxis);
|
||||
|
||||
Result := GVL.Axes[1].config.fAcceleration;
|
||||
Result := GVL.axes[1].config.fAcceleration;
|
||||
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
Actual := Result,
|
||||
Message := 'fAcceleration of the axis is different.');
|
||||
|
||||
fbCommon.SetDefaults(GVL.Axes[1]);
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="SetAxisEnabled" Id="{749049e6-6152-4a23-ac76-75883bd089b7}">
|
||||
<Declaration><![CDATA[METHOD SetAxisEnabled
|
||||
<Method Name="SetAxisControl_Enabled" Id="{749049e6-6152-4a23-ac76-75883bd089b7}">
|
||||
<Declaration><![CDATA[METHOD SetAxisControl_Enabled
|
||||
VAR
|
||||
Result: BOOL;
|
||||
ExpectedResult: BOOL;
|
||||
i: INT;
|
||||
nCycle: UINT;
|
||||
nMaxCycles: UINT := 30;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('test_GIVEN_prepare_default_move_WHEN_move_prepared_THEN_axis_enabled');
|
||||
|
||||
// example of pointer reference to axis structure
|
||||
// example of test that requires multiple cycles to complete. Due to stateful behaviour of the axis structure.
|
||||
|
||||
ExpectedResult := TRUE;
|
||||
GVL.axes[1].control.bEnable := ExpectedResult;
|
||||
|
||||
fbCommon.PrepareDefaultMove(Axis^, MotionFunctions.MoveAbsolute);
|
||||
|
||||
Result := Axis^.status.bEnabled;
|
||||
|
||||
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
Actual := Result,
|
||||
Message := 'Axis is not enabled.');
|
||||
|
||||
fbCommon.SetDefaults(Axis^);
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="SetAxisMoving" Id="{f7dcf822-91ec-4555-918f-e2487353578a}">
|
||||
<Declaration><![CDATA[METHOD SetAxisMoving
|
||||
VAR
|
||||
Result: BOOL;
|
||||
ExpectedResult: BOOL;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('test_GIVEN_new_axis_position_WHEN_execute_move_THEN_axis_moves');
|
||||
|
||||
ExpectedResult := TRUE;
|
||||
|
||||
fbCommon.PrepareDefaultMove(GVL.Axes[1], MotionFunctions.MoveAbsolute);
|
||||
fbCommon.Execute(GVL.Axes[1]);
|
||||
|
||||
IF GVL.Axes[1].control.bEnable THEN
|
||||
Result := GVL.Axes[1].status.bBusy;
|
||||
Result := GVL.axes[iTargetAxis].status.bEnabled;
|
||||
|
||||
IF nCycle > nMaxCycles OR ExpectedResult = Result THEN
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
Actual := Result,
|
||||
Message := 'Axis is not moving.');
|
||||
Message := 'Axis is not enabled.');
|
||||
TEST_FINISHED();
|
||||
ELSE
|
||||
nCycle := nCycle + 1;
|
||||
END_IF
|
||||
|
||||
fbCommon.SetDefaults(GVL.Axes[1]);
|
||||
TEST_FINISHED();]]></ST>
|
||||
]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="SetAxisPosition" Id="{604b9446-af57-41db-afac-f53f5b12cc2c}">
|
||||
<Declaration><![CDATA[METHOD SetAxisPosition
|
||||
VAR
|
||||
InitialValue: LREAL;
|
||||
Result: LREAL;
|
||||
ExpectedResult: LREAL;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('test_GIVEN_new_axis_position_set_WHEN_executed_THEN_new_axis_position_set');
|
||||
|
||||
InitialValue := Axis^.config.fPosition;
|
||||
ExpectedResult := InitialValue + 10;
|
||||
Axis^.config.fPosition := ExpectedResult;
|
||||
|
||||
Axis^.control.eCommand := MotionFunctions.MoveAbsolute;
|
||||
Axis^.control.bExecute := TRUE;
|
||||
|
||||
Result := Axis^.config.fPosition;
|
||||
|
||||
fbCommon.Cycle(2);
|
||||
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
Actual := Result,
|
||||
Message := 'fPosition of the axis is different.');
|
||||
|
||||
//fbCommon.SetDefaults(GVL.Axes[1]);
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="SetAxisVelocity" Id="{f87270b6-fb94-4214-bb13-17f22f6ab8f5}">
|
||||
<Declaration><![CDATA[METHOD SetAxisVelocity
|
||||
<Method Name="SetAxisControl_Velocity" Id="{f87270b6-fb94-4214-bb13-17f22f6ab8f5}">
|
||||
<Declaration><![CDATA[METHOD SetAxisControl_Velocity
|
||||
VAR
|
||||
InitialValue: LREAL;
|
||||
Result: LREAL;
|
||||
@@ -133,98 +144,96 @@ END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('test_GIVEN_new_axis_velocity_set_WHEN_executed_THEN_new_axis_velocity_set');
|
||||
|
||||
InitialValue := GVL.Axes[1].config.fVelocity;
|
||||
InitialValue := GVL.axes[iTargetAxis].config.fVelocity;
|
||||
ExpectedResult := InitialValue + 0.5;
|
||||
GVL.Axes[1].config.fVelocity := ExpectedResult;
|
||||
GVL.Axes[iTargetAxis].config.fVelocity := ExpectedResult;
|
||||
|
||||
GVL.Axes[1].control.eCommand := MotionFunctions.MoveAbsolute;
|
||||
GVL.Axes[1].control.bExecute := TRUE;
|
||||
GVL.Axes[iTargetAxis].control.eCommand := MotionFunctions.MoveAbsolute;
|
||||
GVL.Axes[iTargetAxis].control.bExecute := TRUE;
|
||||
|
||||
Result := GVL.Axes[1].config.fVelocity;
|
||||
Result := GVL.axes[iTargetAxis].config.fVelocity;
|
||||
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
Actual := Result,
|
||||
Message := 'fVelocity of the axis is different.');
|
||||
|
||||
fbCommon.SetDefaults(GVL.Axes[1]);
|
||||
TEST_FINISHED();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="SetAxisInputs_bLimitFwd" Id="{6304c3b1-9e72-403e-9ae2-a5609b1efe92}">
|
||||
<Declaration><![CDATA[METHOD SetAxisInputs_bLimitFwd
|
||||
VAR
|
||||
Result: BOOL;
|
||||
ExpectedResult: BOOL;
|
||||
|
||||
nCycle: UINT;
|
||||
nMaxCycles: UINT := 30;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TEST('test_GIVEN_prepare_default_move_WHEN_bFwEnabled_prepared_enabled_THEN_bFwEnable_enabled');
|
||||
|
||||
ExpectedResult := TRUE;
|
||||
|
||||
GVL.axes[iTargetAxis].inputs.bLimitFwd := TRUE;
|
||||
|
||||
Result := GVL.axes[iTargetAxis].status.bFwEnabled;
|
||||
|
||||
IF nCycle > nMaxCycles OR ExpectedResult = Result THEN
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
Actual := Result,
|
||||
Message := 'Axis bLimitFwd is not enabled.');
|
||||
TEST_FINISHED();
|
||||
ELSE
|
||||
nCycle := nCycle + 1;
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<LineIds Name="FB_Axis_TEST">
|
||||
<LineId Id="37" Count="0" />
|
||||
<LineId Id="34" Count="0" />
|
||||
<LineId Id="38" Count="1" />
|
||||
<LineId Id="12" Count="0" />
|
||||
<LineId Id="40" Count="0" />
|
||||
<LineId Id="48" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_Axis_TEST.SetAxisAcceleration">
|
||||
<LineIds Name="FB_Axis_TEST.CheckAxisStatus_Moving">
|
||||
<LineId Id="127" Count="16" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_Axis_TEST.CheckAxisStatus_NewPosition">
|
||||
<LineId Id="121" Count="21" />
|
||||
<LineId Id="56" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_Axis_TEST.SetAxisConfig_Acceleration">
|
||||
<LineId Id="5" Count="0" />
|
||||
<LineId Id="50" Count="1" />
|
||||
<LineId Id="9" Count="0" />
|
||||
<LineId Id="13" Count="0" />
|
||||
<LineId Id="30" Count="0" />
|
||||
<LineId Id="57" Count="0" />
|
||||
<LineId Id="23" Count="0" />
|
||||
<LineId Id="22" Count="0" />
|
||||
<LineId Id="25" Count="3" />
|
||||
<LineId Id="43" Count="0" />
|
||||
<LineId Id="29" Count="0" />
|
||||
<LineId Id="25" Count="4" />
|
||||
<LineId Id="24" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_Axis_TEST.SetAxisEnabled">
|
||||
<LineIds Name="FB_Axis_TEST.SetAxisControl_Enabled">
|
||||
<LineId Id="144" Count="16" />
|
||||
<LineId Id="107" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_Axis_TEST.SetAxisControl_Velocity">
|
||||
<LineId Id="5" Count="0" />
|
||||
<LineId Id="10" Count="0" />
|
||||
<LineId Id="61" Count="11" />
|
||||
<LineId Id="74" Count="0" />
|
||||
<LineId Id="24" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_Axis_TEST.SetAxisInputs_bLimitFwd">
|
||||
<LineId Id="24" Count="0" />
|
||||
<LineId Id="41" Count="1" />
|
||||
<LineId Id="26" Count="0" />
|
||||
<LineId Id="25" Count="0" />
|
||||
<LineId Id="11" Count="0" />
|
||||
<LineId Id="23" Count="0" />
|
||||
<LineId Id="29" Count="0" />
|
||||
<LineId Id="12" Count="0" />
|
||||
<LineId Id="34" Count="0" />
|
||||
<LineId Id="15" Count="5" />
|
||||
<LineId Id="14" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_Axis_TEST.SetAxisMoving">
|
||||
<LineId Id="5" Count="0" />
|
||||
<LineId Id="10" Count="0" />
|
||||
<LineId Id="13" Count="0" />
|
||||
<LineId Id="57" Count="2" />
|
||||
<LineId Id="61" Count="1" />
|
||||
<LineId Id="67" Count="1" />
|
||||
<LineId Id="65" Count="1" />
|
||||
<LineId Id="63" Count="1" />
|
||||
<LineId Id="56" Count="0" />
|
||||
<LineId Id="29" Count="0" />
|
||||
<LineId Id="24" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_Axis_TEST.SetAxisPosition">
|
||||
<LineId Id="5" Count="0" />
|
||||
<LineId Id="10" Count="0" />
|
||||
<LineId Id="9" Count="0" />
|
||||
<LineId Id="13" Count="1" />
|
||||
<LineId Id="32" Count="0" />
|
||||
<LineId Id="31" Count="0" />
|
||||
<LineId Id="30" Count="0" />
|
||||
<LineId Id="23" Count="0" />
|
||||
<LineId Id="22" Count="0" />
|
||||
<LineId Id="42" Count="1" />
|
||||
<LineId Id="25" Count="3" />
|
||||
<LineId Id="41" Count="0" />
|
||||
<LineId Id="29" Count="0" />
|
||||
<LineId Id="24" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_Axis_TEST.SetAxisVelocity">
|
||||
<LineId Id="5" Count="0" />
|
||||
<LineId Id="10" Count="0" />
|
||||
<LineId Id="9" Count="0" />
|
||||
<LineId Id="13" Count="1" />
|
||||
<LineId Id="32" Count="0" />
|
||||
<LineId Id="31" Count="0" />
|
||||
<LineId Id="30" Count="0" />
|
||||
<LineId Id="23" Count="0" />
|
||||
<LineId Id="22" Count="0" />
|
||||
<LineId Id="25" Count="0" />
|
||||
<LineId Id="41" Count="4" />
|
||||
<LineId Id="24" Count="0" />
|
||||
<LineId Id="48" Count="2" />
|
||||
<LineId Id="67" Count="0" />
|
||||
<LineId Id="19" Count="0" />
|
||||
<LineId Id="58" Count="6" />
|
||||
<LineId Id="57" Count="0" />
|
||||
</LineIds>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
@@ -369,14 +369,14 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PlaceholderResolution Include="Tc2_MC2">
|
||||
<Resolution>Tc2_MC2, * (Beckhoff Automation GmbH)</Resolution>
|
||||
<Resolution>Tc2_MC2, 3.3.28.0 (Beckhoff Automation GmbH)</Resolution>
|
||||
</PlaceholderResolution>
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<PlcProjectOptions>
|
||||
<XmlArchive>
|
||||
<Data>
|
||||
<o xml:space="preserve" t="OptionKey">
|
||||
<Data>
|
||||
<o xml:space="preserve" t="OptionKey">
|
||||
<v n="Name">"<ProjectRoot>"</v>
|
||||
<d n="SubKeys" t="Hashtable" ckt="String" cvt="OptionKey">
|
||||
<v>{192FAD59-8248-4824-A8DE-9177C94C195A}</v>
|
||||
@@ -427,15 +427,15 @@
|
||||
</d>
|
||||
<d n="Values" t="Hashtable" />
|
||||
</o>
|
||||
</Data>
|
||||
<TypeList>
|
||||
<Type n="Boolean">System.Boolean</Type>
|
||||
<Type n="Hashtable">System.Collections.Hashtable</Type>
|
||||
<Type n="Int32">System.Int32</Type>
|
||||
<Type n="OptionKey">{54dd0eac-a6d8-46f2-8c27-2f43c7e49861}</Type>
|
||||
<Type n="String">System.String</Type>
|
||||
</TypeList>
|
||||
</XmlArchive>
|
||||
</Data>
|
||||
<TypeList>
|
||||
<Type n="Boolean">System.Boolean</Type>
|
||||
<Type n="Hashtable">System.Collections.Hashtable</Type>
|
||||
<Type n="Int32">System.Int32</Type>
|
||||
<Type n="OptionKey">{54dd0eac-a6d8-46f2-8c27-2f43c7e49861}</Type>
|
||||
<Type n="String">System.String</Type>
|
||||
</TypeList>
|
||||
</XmlArchive>
|
||||
</PlcProjectOptions>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Refactors>
|
||||
<Renames>
|
||||
<RenamedSymbol>
|
||||
<Type guid="749049e6-6152-4a23-ac76-75883bd089b7">SetAxisControl_Enabled</Type>
|
||||
<From>i</From>
|
||||
<To>nCycle</To>
|
||||
</RenamedSymbol>
|
||||
<RenamedSymbol>
|
||||
<Type guid="749049e6-6152-4a23-ac76-75883bd089b7">SetAxisControl_Enabled</Type>
|
||||
<From>iMaxCount</From>
|
||||
<To>nMaxCycles</To>
|
||||
</RenamedSymbol>
|
||||
<RenamedSymbol>
|
||||
<Type guid="604b9446-af57-41db-afac-f53f5b12cc2c">CheckAxisStatus_NewPosition</Type>
|
||||
<From>iCount</From>
|
||||
<To>nCycle</To>
|
||||
</RenamedSymbol>
|
||||
<RenamedSymbol>
|
||||
<Type guid="604b9446-af57-41db-afac-f53f5b12cc2c">CheckAxisStatus_NewPosition</Type>
|
||||
<From>iMaxCount</From>
|
||||
<To>nCycleMax</To>
|
||||
</RenamedSymbol>
|
||||
</Renames>
|
||||
</Refactors>
|
||||
Reference in New Issue
Block a user