Merged in MBP-173-delete-unit-test-files (pull request #51)

MBP-173 delete unit test files

Approved-by: Harald Kleines
This commit is contained in:
Federico Rojas
2021-02-23 09:39:56 +00:00
11 changed files with 23 additions and 638 deletions
+14 -3
View File
@@ -1,10 +1,10 @@
<?xml version="1.0"?>
<TcSmItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2012/07/TcSmProject" TcSmVersion="1.0" TcVersion="3.1.4023.119" ClassName="CNestedPlcProjDef">
<TcSmItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2012/07/TcSmProject" TcSmVersion="1.0" TcVersion="3.1.4024.11" ClassName="CNestedPlcProjDef">
<Project GUID="{FB261665-FD20-4BF2-97F8-2854C82B752D}" Name="tc_project_app" PrjFilePath="..\..\tc_project_app\tc_project_app.plcproj" TmcFilePath="..\..\tc_project_app\tc_project_app.tmc" ReloadTmc="true" AmsPort="852" FileArchiveSettings="#x000e" SymbolicMapping="true">
<Instance Id="#x08502040" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcPath="tc_project_app\tc_project_app.tmc">
<Name>tc_project_app Instance</Name>
<CLSID ClassFactory="TcPlc30">{08500001-0000-0000-F000-000000000064}</CLSID>
<Vars VarGrpType="2">
<Vars VarGrpType="2" AreaNo="1">
<Name>PlcTask Outputs</Name>
<Var>
<Name>MAIN.bOutput1</Name>
@@ -12,8 +12,19 @@
<Type>BOOL</Type>
</Var>
</Vars>
<Contexts>
<Context>
<Id NeedCalleeCall="true">0</Id>
<Name>PlcTask</Name>
<ManualConfig>
<OTCID>#x02010040</OTCID>
</ManualConfig>
<Priority>10</Priority>
<CycleTime>10000000</CycleTime>
</Context>
</Contexts>
<TaskPouOids>
<TaskPouOid Prio="20" OTCID="#x08502041"/>
<TaskPouOid Prio="10" OTCID="#x08502041"/>
</TaskPouOids>
</Instance>
</Project>
+6 -30
View File
@@ -1,9 +1,12 @@
<?xml version="1.0"?>
<TcSmProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2012/07/TcSmProject" TcSmVersion="1.0" TcVersion="3.1.4024.11">
<Project ProjectGUID="{9CF97348-B9D3-4938-B1F2-5F0B0B6AA66A}" TargetNetId="5.65.73.242.1.1" Target64Bit="true" ShowHideConfigurations="#x106">
<Project ProjectGUID="{9CF97348-B9D3-4938-B1F2-5F0B0B6AA66A}" TargetNetId="5.65.73.242.1.1" AutoPrioManagement="true" ShowHideConfigurations="#x106">
<System>
<Settings>
<IoIdleTask Priority="6"/>
</Settings>
<Tasks>
<Task Id="4" Priority="20" CycleTime="100000" AmsPort="351" AdtTasks="true">
<Task Id="4" Priority="10" CycleTime="100000" AmsPort="351" AdtTasks="true">
<Name>PlcTask</Name>
</Task>
</Tasks>
@@ -12,34 +15,7 @@
<NC File="NC.xti"/>
</Motion>
<Plc>
<Project GUID="{FB261665-FD20-4BF2-97F8-2854C82B752D}" Name="tc_project_app" PrjFilePath="tc_project_app\tc_project_app.plcproj" TmcFilePath="tc_project_app\tc_project_app.tmc" ReloadTmc="true" AmsPort="852" FileArchiveSettings="#x000e" SymbolicMapping="true">
<Instance Id="#x08502040" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcPath="tc_project_app\tc_project_app.tmc">
<Name>tc_project_app Instance</Name>
<CLSID ClassFactory="TcPlc30">{08500001-0000-0000-F000-000000000064}</CLSID>
<Vars VarGrpType="2" AreaNo="1">
<Name>PlcTask Outputs</Name>
<Var>
<Name>MAIN.bOutput1</Name>
<Comment><![CDATA[Outputs: Power for Limit switches and Home Sensors (every 4th output)]]></Comment>
<Type>BOOL</Type>
</Var>
</Vars>
<Contexts>
<Context>
<Id NeedCalleeCall="true">0</Id>
<Name>PlcTask</Name>
<ManualConfig>
<OTCID>#x02010040</OTCID>
</ManualConfig>
<Priority>20</Priority>
<CycleTime>10000000</CycleTime>
</Context>
</Contexts>
<TaskPouOids>
<TaskPouOid Prio="20" OTCID="#x08502041"/>
</TaskPouOids>
</Instance>
</Project>
<Project File="tc_project_app.xti"/>
</Plc>
</Project>
</TcSmProject>
+1 -1
View File
@@ -3,7 +3,7 @@
<Task Name="PlcTask" Id="{96ece0eb-a21b-4000-8986-812071c196ce}">
<!--CycleTime in micro seconds.-->
<CycleTime>10000</CycleTime>
<Priority>20</Priority>
<Priority>10</Priority>
<PouCall>
<Name>MAIN</Name>
</PouCall>
@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.5">
<POU Name="tcUNIT_APP_RUN" Id="{677fcae4-9d84-425e-8fcd-8e3d3a1985e8}" SpecialFunc="None">
<Declaration><![CDATA[(* tcUNIT Tests: Add this program to PLC task in order to run tcUNIT tests against the declared POU test suites.
see https://tcunit.org/ for documentation.*)
PROGRAM tcUNIT_APP_RUN
VAR
(* Declare standard library POU tests to be run
E.g. fbMoveNonLinearSlits: FB_MoveNonLinearSlits_Test;*)
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[TcUnit.RUN();]]></ST>
</Implementation>
<LineIds Name="tcUNIT_APP_RUN">
<LineId Id="45" Count="0" />
</LineIds>
</POU>
</TcPlcObject>
@@ -1,242 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.5">
<POU Name="FB_tcUNIT_common" Id="{0f757d3d-99b7-46eb-bdc6-03aa126689f4}" SpecialFunc="None">
<Declaration><![CDATA[//tcUNIT Common function block: Contains helper methods for tcUNIT.
FUNCTION_BLOCK FB_tcUNIT_common
VAR
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[]]></ST>
</Implementation>
<Method Name="mDisableAxis" Id="{22a3dd98-69f0-4b92-8109-1b0c2fe2344d}">
<Declaration><![CDATA[METHOD mDisableAxis: BOOL
VAR_INPUT
nAxisIndex: UINT; //The idex of the axis to action the method on.
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[GVL.astAxes[nAxisIndex].stControl.bEnable := FALSE;]]></ST>
</Implementation>
</Method>
<Method Name="mEnableAxis" Id="{12e91532-7139-4c17-998e-4c670b584b9d}">
<Declaration><![CDATA[METHOD mEnableAxis: BOOL
VAR_INPUT
nAxisIndex: UINT; //The idex of the axis to action the method on.
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[GVL.astAxes[nAxisIndex].stControl.bEnable := TRUE;]]></ST>
</Implementation>
</Method>
<Method Name="mExecute" Id="{010bd927-5568-40db-a7c5-fcfe995a5cb1}">
<Declaration><![CDATA[METHOD mExecute: BOOL
VAR_INPUT
nAxisIndex: UINT; //The idex of the axis to action the method on.
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[GVL.astAxes[nAxisIndex].stControl.bExecute := TRUE;]]></ST>
</Implementation>
</Method>
<Method Name="mExecute_SetFALSE" Id="{cc074392-b19d-414a-9010-72a4fa4d5f7a}">
<Declaration><![CDATA[METHOD mExecute_SetFALSE: BOOL
VAR_INPUT
nAxisIndex: UINT; //The idex of the axis to action the method on.
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[GVL.astAxes[nAxisIndex].stControl.bExecute := TRUE;]]></ST>
</Implementation>
</Method>
<Method Name="mGearOut" Id="{65c5860b-0759-45a5-a8a4-27fe9453aa76}">
<Declaration><![CDATA[METHOD mGearOut : BOOL
VAR_INPUT
iAxis: UINT; // The idex of the axis to action the method on.
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[GVL.astAxes[iAxis].stControl.eCommand := E_MotionFunctions.eGearOut;]]></ST>
</Implementation>
</Method>
<Method Name="mPrepareDefaultMove" Id="{c23244d5-896c-49ad-8d8a-19390856e4dc}">
<Declaration><![CDATA[METHOD mPrepareDefaultMove
VAR_INPUT
nAxisIndex: UINT; //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.
GVL.astAxes[nAxisIndex].stControl.bEnable := TRUE;
GVL.astAxes[nAxisIndex].stControl.eCommand := E_MotionFunctions.eMoveAbsolute;
GVL.astAxes[nAxisIndex].stInputs.bLimitBwd := TRUE;
GVL.astAxes[nAxisIndex].stInputs.bLimitFwd := TRUE;
GVL.astAxes[nAxisIndex].stConfig.fVelocity := tcUNIT_GVL.fDEFAULT_TARGET_VELOCITY;
GVL.astAxes[nAxisIndex].stConfig.fAcceleration := tcUNIT_GVL.fDEFAULT_TARGET_ACCELERATION;
GVL.astAxes[nAxisIndex].stConfig.fDeceleration := tcUNIT_GVL.fDEFAULT_TARGET_DECCELERATION;
GVL.astAxes[nAxisIndex].stConfig.fOverride := tcUNIT_GVL.fDEFAULT_TARGET_OVERRIDE;
GVL.astAxes[nAxisIndex].stConfig.fPosition := tcUNIT_GVL.fDEFAULT_POSITION;]]></ST>
</Implementation>
</Method>
<Method Name="mPrepareGearInMultiMaster" Id="{b94784af-8414-4f79-a0cd-7d3b82710c1e}">
<Declaration><![CDATA[METHOD mPrepareGearInMultiMaster
VAR_INPUT
nAxisIndex: UINT; // The idex of the axis to action the method on.
astGearAxis: ARRAY[1..4] OF ST_GearAxis;
END_VAR
VAR
i: UINT;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[// Prepare the axis so it is ready to be coupled
GVL.astAxes[nAxisIndex].stControl.eCommand := E_MotionFunctions.eGearInMultiMaster;
FOR i:= 1 TO tcUNIT_GVL.nMAX_MASTERS DO
GVL.astAxes[nAxisIndex].stConfig.astMultiMasterAxis[i].nIndex:=astGearAxis[i].nIndex;
GVL.astAxes[nAxisIndex].stConfig.astMultiMasterAxis[i].fRatio:=astGearAxis[i].fRatio;
END_FOR]]></ST>
</Implementation>
</Method>
<Method Name="mPrepareHome" Id="{29a1cce2-2fc4-48e1-86f6-27b6dd699cd2}">
<Declaration><![CDATA[METHOD mPrepareHome
VAR_INPUT
nAxisIndex: UINT; // The idex of the axis to action the method on.
eHomingRoutine: E_HomingRoutines;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[GVL.astAxes[nAxisIndex].stControl.eCommand := E_MotionFunctions.eHome;
GVL.astAxes[nAxisIndex].stConfig.eHomeSeq:= eHomingRoutine;]]></ST>
</Implementation>
</Method>
<Method Name="mPrepareMove" Id="{97bd5417-d0a1-4d32-8732-16310a863fcc}">
<Declaration><![CDATA[METHOD mPrepareMove
VAR_INPUT
nAxisIndex: UINT; //The idex of the axis to action the method on.
fTargetVelocity: LREAL;
fTargetAcceleration: LREAL;
fTargetDeceleration: LREAL;
fTargetPosition: LREAL;
eMotionStrategy: E_MotionFunctions; //The desired MotionFunctions motion strategy.
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.astAxes[nAxisIndex].stControl.bEnable := FALSE;
GVL.astAxes[nAxisIndex].stControl.eCommand := eMotionStrategy;
GVL.astAxes[nAxisIndex].stInputs.bLimitBwd := TRUE;
GVL.astAxes[nAxisIndex].stInputs.bLimitFwd := TRUE;
GVL.astAxes[nAxisIndex].stConfig.fVelocity := fTargetVelocity;
GVL.astAxes[nAxisIndex].stConfig.fAcceleration := fTargetAcceleration;
GVL.astAxes[nAxisIndex].stConfig.fDeceleration := fTargetDeceleration;
GVL.astAxes[nAxisIndex].stConfig.fPosition := fTargetPosition;]]></ST>
</Implementation>
</Method>
<Method Name="mReset" Id="{59e8bfe4-ab50-4ad3-9095-95e359837091}">
<Declaration><![CDATA[METHOD mReset : BOOL
VAR_INPUT
nAxisIndex: UINT; // The idex of the axis to action the method on.
END_VAR
VAR
iCycles: UINT;
iMaxCycles: UINT := 100;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[GVL.astAxes[nAxisIndex].stControl.bExecute := FALSE;
FOR iCycles:= 1 TO iMaxCycles DO
GVL.astAxes[nAxisIndex].stControl.bReset := TRUE;
IF GVL.astaxes[nAxisIndex].stStatus.bError := FALSE THEN
EXIT;
END_IF
END_FOR]]></ST>
</Implementation>
</Method>
<Method Name="mSetAxisDefaults" Id="{5b9336be-4414-4858-a614-0fdb2847e171}">
<Declaration><![CDATA[METHOD mSetAxisDefaults
VAR_INPUT
nAxisIndex: UINT; //The idex of the axis to action the method on.
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.astAxes[nAxisIndex].stStatus.bBusy THEN
GVL.astAxes[nAxisIndex].stControl.bStop := TRUE;
END_IF
IF GVL.astAxes[nAxisIndex].stStatus.bError THEN
GVL.astAxes[nAxisIndex].stControl.bReset := TRUE;
END_IF
IF NOT GVL.astAxes[nAxisIndex].stControl.bEnable AND GVL.astAxes[nAxisIndex].stControl.bStop THEN
GVL.astAxes[nAxisIndex].stControl.bStop := FALSE;
END_IF
GVL.astAxes[nAxisIndex].stControl.bEnable := FALSE;
GVL.astAxes[nAxisIndex].stControl.bExecute := FALSE;
GVL.astAxes[nAxisIndex].stControl.bReset := FALSE;
GVL.astAxes[nAxisIndex].stControl.bJogFwd := FALSE;
GVL.astAxes[nAxisIndex].stControl.bJogBwd := FALSE;
GVL.astAxes[nAxisIndex].stControl.bStop := FALSE;
GVL.astAxes[nAxisIndex].stControl.eCommand := E_MotionFunctions.eMoveAbsolute;
GVL.astAxes[nAxisIndex].stConfig.fVelocity := 0.0;
GVL.astAxes[nAxisIndex].stConfig.fAcceleration := 0.0;
GVL.astAxes[nAxisIndex].stConfig.fDeceleration := 0.0;
GVL.astAxes[nAxisIndex].stConfig.fPosition := 0;
GVL.astAxes[nAxisIndex].stConfig.fOverride := 0.0;
GVL.astAxes[nAxisIndex].stConfig.eHomeSeq := 0;
GVL.astAxes[nAxisIndex].stInputs.bLimitBwd := FALSE;
GVL.astAxes[nAxisIndex].stInputs.bLimitFwd := FALSE;
GVL.astAxes[nAxisIndex].stInputs.bHomeSensor := FALSE;]]></ST>
</Implementation>
</Method>
<LineIds Name="FB_tcUNIT_common">
<LineId Id="9" Count="0" />
</LineIds>
<LineIds Name="FB_tcUNIT_common.mDisableAxis">
<LineId Id="5" Count="0" />
</LineIds>
<LineIds Name="FB_tcUNIT_common.mEnableAxis">
<LineId Id="5" Count="0" />
</LineIds>
<LineIds Name="FB_tcUNIT_common.mExecute">
<LineId Id="5" Count="0" />
</LineIds>
<LineIds Name="FB_tcUNIT_common.mExecute_SetFALSE">
<LineId Id="5" Count="0" />
</LineIds>
<LineIds Name="FB_tcUNIT_common.mGearOut">
<LineId Id="5" Count="0" />
</LineIds>
<LineIds Name="FB_tcUNIT_common.mPrepareDefaultMove">
<LineId Id="44" Count="11" />
<LineId Id="19" Count="0" />
</LineIds>
<LineIds Name="FB_tcUNIT_common.mPrepareGearInMultiMaster">
<LineId Id="6" Count="0" />
<LineId Id="56" Count="0" />
<LineId Id="72" Count="1" />
<LineId Id="75" Count="0" />
<LineId Id="74" Count="0" />
</LineIds>
<LineIds Name="FB_tcUNIT_common.mPrepareHome">
<LineId Id="6" Count="0" />
<LineId Id="5" Count="0" />
</LineIds>
<LineIds Name="FB_tcUNIT_common.mPrepareMove">
<LineId Id="17" Count="11" />
</LineIds>
<LineIds Name="FB_tcUNIT_common.mReset">
<LineId Id="21" Count="0" />
<LineId Id="7" Count="0" />
<LineId Id="16" Count="4" />
</LineIds>
<LineIds Name="FB_tcUNIT_common.mSetAxisDefaults">
<LineId Id="50" Count="28" />
<LineId Id="26" Count="0" />
</LineIds>
</POU>
</TcPlcObject>
@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.5">
<GVL Name="tcUNIT_GVL" Id="{4b23d6c9-6a88-40b7-9bf4-d55c4dfd4246}">
<Declaration><![CDATA[//tcUNIT_GVL: Global variables used in tcUNIT tests.
{attribute 'qualified_only'}
VAR_GLOBAL CONSTANT
//Constants for axis defaults.
fDEFAULT_VELOCITY: LREAL := 0.0;
fDEFAULT_ACCELERATION: LREAL := 0.0;
fDEFAULT_DECCELERATION: LREAL := 0.0;
fDEFAULT_POSITION: LREAL := 0.0;
fDEFAULT_TARGET_VELOCITY: LREAL := 1.0;
fDEFAULT_TARGET_ACCELERATION: LREAL := 0.5;
fDEFAULT_TARGET_DECCELERATION: LREAL := 0.5;
fDEFAULT_TARGET_POSITION: LREAL := 10.0;
fDEFAULT_TARGET_OVERRIDE: LREAL := 100;
nMAX_MASTERS : UINT := 4;
END_VAR
VAR_GLOBAL
END_VAR]]></Declaration>
</GVL>
</TcPlcObject>
@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.5">
<DUT Name="E_TestStates" Id="{fa5c3f3c-c558-44f1-8e4d-ea57c6a7bb8e}">
<Declaration><![CDATA[{attribute 'qualified_only'}
{attribute 'strict'}
TYPE E_TestStates :
(
eInitialiseTest := 0,
ePreparePreTestConditions := 1,
eExecutePreTestConditions := 2,
ePrepareTest := 3,
eExecuteTest := 4,
eWaitForResults := 5,
ePrepareFinishTest := 6,
eExecuteFinishTest := 7,
eReportFinishedTest := 8
);
END_TYPE
]]></Declaration>
</DUT>
</TcPlcObject>
@@ -1,250 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.5">
<POU Name="FB_Axis_TEST" Id="{3bfca2b4-3b3f-48f2-9900-9d4cd3404e9e}" SpecialFunc="None">
<Declaration><![CDATA[//Test suite for the FB_Axis POU
{attribute 'call_after_init'}
FUNCTION_BLOCK FB_Axis_TEST EXTENDS tcUnit.FB_TestSuite
VAR
fbCommon: FB_tcUNIT_common;
iTargetAxis: UINT := 1; //The <index> of the axis within GVL.astAxes[<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
SetAxisControl_Enabled();
CheckAxisStatus_Moving();
SetAxisConfig_Acceleration();
CheckAxisStatus_NewPosition();
SetAxisControl_Velocity();
SetAxisInputs_bLimitFwd();]]></ST>
</Implementation>
<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.astAxes[iTargetAxis].stStatus.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.astAxes[iTargetAxis].stConfig.fPosition;
ExpectedResult := InitialValue + 10;
GVL.astAxes[iTargetAxis].stConfig.fPosition := ExpectedResult;
GVL.astAxes[iTargetAxis].stControl.eCommand := E_MotionFunctions.eMoveAbsolute;
GVL.astAxes[iTargetAxis].stControl.bExecute := TRUE;
Result := GVL.astAxes[iTargetAxis].stStatus.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;
ExpectedResult: LREAL;
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 for assert.
ExpectedResult := tcUNIT_gvl.fDEFAULT_TARGET_ACCELERATION;
fbCommon.mPrepareDefaultMove(iTargetAxis);
Result := GVL.astAxes[iTargetAxis].stConfig.fAcceleration;
AssertEquals(Expected := ExpectedResult,
Actual := Result,
Message := 'fAcceleration of the axis is different.');
TEST_FINISHED();]]></ST>
</Implementation>
</Method>
<Method Name="SetAxisControl_Enabled" Id="{749049e6-6152-4a23-ac76-75883bd089b7}">
<Declaration><![CDATA[METHOD SetAxisControl_Enabled
VAR
Result: BOOL;
ExpectedResult: BOOL;
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 test that requires multiple cycles to complete. Due to stateful behaviour of the axis structure.
ExpectedResult := TRUE;
GVL.astAxes[iTargetAxis].stControl.bEnable := ExpectedResult;
Result := GVL.astAxes[iTargetAxis].stStatus.bEnabled;
IF nCycle > nMaxCycles OR ExpectedResult = Result THEN
AssertEquals(Expected := ExpectedResult,
Actual := Result,
Message := 'Axis is not enabled.');
TEST_FINISHED();
ELSE
nCycle := nCycle + 1;
END_IF
]]></ST>
</Implementation>
</Method>
<Method Name="SetAxisControl_Velocity" Id="{f87270b6-fb94-4214-bb13-17f22f6ab8f5}">
<Declaration><![CDATA[METHOD SetAxisControl_Velocity
VAR
InitialValue: LREAL;
Result: LREAL;
ExpectedResult: LREAL;
fDelta: REAL := 0.01;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[TEST('test_GIVEN_new_axis_velocity_set_WHEN_executed_THEN_new_axis_velocity_set');
//Example of using a tcUNIT assert for a specific type (in this case LREAL).
InitialValue := GVL.astAxes[iTargetAxis].stConfig.fVelocity;
ExpectedResult := InitialValue + 0.5;
GVL.astAxes[iTargetAxis].stConfig.fVelocity := ExpectedResult;
Result := GVL.astAxes[iTargetAxis].stConfig.fVelocity;
AssertEquals_LREAL(Expected := ExpectedResult,
Actual := Result,
Delta := fDelta,
Message := 'fVelocity of the axis is different.');
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.astAxes[iTargetAxis].stInputs.bLimitFwd := TRUE;
Result := GVL.astAxes[iTargetAxis].stStatus.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.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="57" Count="0" />
<LineId Id="23" Count="0" />
<LineId Id="22" Count="0" />
<LineId Id="25" Count="4" />
<LineId Id="24" Count="0" />
</LineIds>
<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="92" Count="1" />
<LineId Id="10" Count="0" />
<LineId Id="61" Count="2" />
<LineId Id="67" Count="0" />
<LineId Id="69" Count="0" />
<LineId Id="91" Count="0" />
<LineId Id="70" Count="1" />
<LineId Id="80" Count="0" />
<LineId Id="72" Count="0" />
<LineId Id="24" Count="0" />
<LineId Id="86" Count="0" />
</LineIds>
<LineIds Name="FB_Axis_TEST.SetAxisInputs_bLimitFwd">
<LineId Id="24" Count="0" />
<LineId Id="26" Count="0" />
<LineId Id="25" 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>
@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.5">
<POU Name="tcUNIT_STD_LIB_RUN" Id="{5e8cc903-e536-40be-a096-d6b305fbb618}" SpecialFunc="None">
<Declaration><![CDATA[//tcUNIT Standard Library tests: Add program to PLC task in order to run tcUNIT tests against the declared POU test suites
PROGRAM tcUNIT_STD_LIB_RUN
VAR
//Declare standard library POU tests to be run
fbAxisTest: FB_Axis_TEST;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[TcUnit.RUN();]]></ST>
</Implementation>
<LineIds Name="tcUNIT_STD_LIB_RUN">
<LineId Id="45" Count="0" />
</LineIds>
</POU>
</TcPlcObject>
+1 -30
View File
@@ -106,27 +106,6 @@
<Compile Include="tc_mca_std_lib\VISUs\visuTextLinks.TcTLO">
<SubType>Code</SubType>
</Compile>
<Compile Include="Test\app_tests\tcUNIT_APP_RUN.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="Test\common\FB_tcUNIT_common.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="Test\common\FB_tcUNIT_GenericHomingTest.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="Test\common\tcUNIT_GVL.TcGVL">
<SubType>Code</SubType>
</Compile>
<Compile Include="Test\standard_library_tests\E_TestStates.TcDUT">
<SubType>Code</SubType>
</Compile>
<Compile Include="Test\standard_library_tests\FB_Axis_TEST.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="Test\standard_library_tests\tcUNIT_STD_LIB_RUN.TcPOU">
<SubType>Code</SubType>
</Compile>
<Compile Include="Visualization Manager.TcVMO">
<SubType>Code</SubType>
</Compile>
@@ -139,15 +118,11 @@
<Folder Include="POUs\Application Specific\Axes" />
<Folder Include="tc_mca_std_lib\POUs\Motion\Homing" />
<Folder Include="tc_mca_std_lib\VISUs" />
<Folder Include="Test" />
<Folder Include="tc_mca_std_lib" />
<Folder Include="tc_mca_std_lib\DUTs" />
<Folder Include="tc_mca_std_lib\GVLs" />
<Folder Include="tc_mca_std_lib\POUs" />
<Folder Include="tc_mca_std_lib\POUs\Motion" />
<Folder Include="Test\app_tests" />
<Folder Include="Test\common" />
<Folder Include="Test\standard_library_tests" />
<Folder Include="POUs" />
</ItemGroup>
<ItemGroup>
@@ -225,10 +200,6 @@
<DefaultResolution>Tc3_Module, * (Beckhoff Automation GmbH)</DefaultResolution>
<Namespace>Tc3_Module</Namespace>
</PlaceholderReference>
<PlaceholderReference Include="TcUnit">
<DefaultResolution>TcUnit, * (www.tcunit.org)</DefaultResolution>
<Namespace>TcUnit</Namespace>
</PlaceholderReference>
<PlaceholderReference Include="VisuDialogs">
<DefaultResolution>VisuDialogs, * (System)</DefaultResolution>
<Namespace>VisuDialogs</Namespace>
@@ -241,7 +212,7 @@
</ItemGroup>
<ItemGroup>
<PlaceholderResolution Include="Tc2_MC2">
<Resolution>Tc2_MC2, 3.3.28.0 (Beckhoff Automation GmbH)</Resolution>
<Resolution>Tc2_MC2, 3.3.41.0 (Beckhoff Automation GmbH)</Resolution>
</PlaceholderResolution>
</ItemGroup>
<ProjectExtensions>