Added std_lib unit tests
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,21 @@
|
||||
<?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="CNcSafTaskDef" SubType="0">
|
||||
<NC>
|
||||
<SafTask Priority="4" CycleTime="20000" AmsPort="501" IoAtBegin="true">
|
||||
<Name>NC-Task 1 SAF</Name>
|
||||
<Vars VarGrpType="1" InsertType="1">
|
||||
<Name>Inputs</Name>
|
||||
</Vars>
|
||||
<Vars VarGrpType="2" InsertType="1">
|
||||
<Name>Outputs</Name>
|
||||
</Vars>
|
||||
<Image Id="1" AddrType="1" ImageType="1">
|
||||
<Name>Image</Name>
|
||||
</Image>
|
||||
</SafTask>
|
||||
<SvbTask Priority="8" CycleTime="100000" AmsPort="511">
|
||||
<Name>NC-Task 1 SVB</Name>
|
||||
</SvbTask>
|
||||
<Axis File="tcUNIT_virtual_axis.xti" Id="1"/>
|
||||
</NC>
|
||||
</TcSmItem>
|
||||
@@ -873,7 +873,7 @@ External Setpoint Generation:
|
||||
</Relations>
|
||||
</DataType>
|
||||
</DataTypes>
|
||||
<Project ProjectGUID="{9CF97348-B9D3-4938-B1F2-5F0B0B6AA66A}" TargetNetId="5.54.104.144.1.1" Target64Bit="true" ShowHideConfigurations="#x106">
|
||||
<Project ProjectGUID="{9CF97348-B9D3-4938-B1F2-5F0B0B6AA66A}" Target64Bit="true" ShowHideConfigurations="#x106">
|
||||
<System>
|
||||
<Licenses>
|
||||
<Target>
|
||||
@@ -889,6 +889,9 @@ External Setpoint Generation:
|
||||
</Task>
|
||||
</Tasks>
|
||||
</System>
|
||||
<Motion>
|
||||
<NC File="NC.xti"/>
|
||||
</Motion>
|
||||
<Plc>
|
||||
<Project GUID="{F935F1DE-0753-4702-B418-1DC0ED040A4D}" Name="tc_epicscommodule" PrjFilePath="tc_epicscommodule\tc_epicscommodule.plcproj" TmcFilePath="tc_epicscommodule\tc_epicscommodule.tmc" ReloadTmc="true" AmsPort="851" FileArchiveSettings="#x000e" SymbolicMapping="true">
|
||||
<Instance Id="#x08502000" TcSmClass="TComPlcObjDef" KeepUnrestoredLinks="2" TmcPath="tc_epicscommodule\tc_epicscommodule.tmc">
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
<PouCall>
|
||||
<Name>MAIN</Name>
|
||||
</PouCall>
|
||||
<PouCall>
|
||||
<Name>tcUNIT_STD_LIB_RUN</Name>
|
||||
</PouCall>
|
||||
<TaskFBGuid>{26d89752-95b4-4b52-80c0-c79242bc34d7}</TaskFBGuid>
|
||||
<Fb_init>{137c4fd1-c794-4dee-a041-b4fea1d22866}</Fb_init>
|
||||
<Fb_exit>{2478772d-357b-433f-886f-15340bef9bdf}</Fb_exit>
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.0">
|
||||
<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;
|
||||
Axis: POINTER TO ST_AxisStruct := ADR(GVL.axes[1]);
|
||||
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>
|
||||
</Implementation>
|
||||
<Method Name="SetAxisAcceleration" Id="{2efd2402-6ad3-455d-a703-347847c98522}">
|
||||
<Declaration><![CDATA[METHOD SetAxisAcceleration
|
||||
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
|
||||
|
||||
ExpectedResult := tcUNIT_gvl.fDEFAULT_TARGET_ACCELERATION;
|
||||
fbCommon.PrepareDefaultMove(GVL.Axes[1], MotionFunctions.MoveAbsolute);
|
||||
|
||||
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
|
||||
VAR
|
||||
Result: BOOL;
|
||||
ExpectedResult: BOOL;
|
||||
i: INT;
|
||||
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
|
||||
|
||||
ExpectedResult := TRUE;
|
||||
|
||||
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;
|
||||
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
Actual := Result,
|
||||
Message := 'Axis is not moving.');
|
||||
END_IF
|
||||
|
||||
fbCommon.SetDefaults(GVL.Axes[1]);
|
||||
TEST_FINISHED();]]></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
|
||||
VAR
|
||||
InitialValue: LREAL;
|
||||
Result: LREAL;
|
||||
ExpectedResult: LREAL;
|
||||
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;
|
||||
ExpectedResult := InitialValue + 0.5;
|
||||
GVL.Axes[1].config.fVelocity := ExpectedResult;
|
||||
|
||||
GVL.Axes[1].control.eCommand := MotionFunctions.MoveAbsolute;
|
||||
GVL.Axes[1].control.bExecute := TRUE;
|
||||
|
||||
Result := GVL.Axes[1].config.fVelocity;
|
||||
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
Actual := Result,
|
||||
Message := 'fVelocity of the axis is different.');
|
||||
|
||||
fbCommon.SetDefaults(GVL.Axes[1]);
|
||||
TEST_FINISHED();]]></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" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_Axis_TEST.SetAxisAcceleration">
|
||||
<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="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="24" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_Axis_TEST.SetAxisEnabled">
|
||||
<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" />
|
||||
</LineIds>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.0">
|
||||
<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
|
||||
fbFB_Axis: 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>
|
||||
@@ -29,6 +29,15 @@
|
||||
<Compile Include="POUs\MAIN.TcPOU">
|
||||
<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\tcUNIT_GVL.TcGVL">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\DUTs\RestorePosition.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@@ -229,6 +238,12 @@
|
||||
<Compile Include="tc_mca_std_lib\POUs\VISUs\visuTextLinks.TcTLO">
|
||||
<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>
|
||||
@@ -236,6 +251,9 @@
|
||||
<ItemGroup>
|
||||
<Folder Include="DUTs" />
|
||||
<Folder Include="GVLs" />
|
||||
<Folder Include="Test" />
|
||||
<Folder Include="Test\app_tests" />
|
||||
<Folder Include="Test\common" />
|
||||
<Folder Include="tc_mca_std_lib" />
|
||||
<Folder Include="tc_mca_std_lib\DUTs" />
|
||||
<Folder Include="tc_mca_std_lib\GVLs" />
|
||||
@@ -256,6 +274,7 @@
|
||||
<Folder Include="tc_mca_std_lib\POUs\ErrorHandling" />
|
||||
<Folder Include="tc_mca_std_lib\POUs\Motion\Homing" />
|
||||
<Folder Include="tc_mca_std_lib\POUs\VISUs" />
|
||||
<Folder Include="Test\standard_library_tests" />
|
||||
<Folder Include="VISUs" />
|
||||
<Folder Include="POUs" />
|
||||
</ItemGroup>
|
||||
@@ -334,6 +353,10 @@
|
||||
<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>
|
||||
@@ -346,7 +369,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PlaceholderResolution Include="Tc2_MC2">
|
||||
<Resolution>Tc2_MC2, 3.3.28.0 (Beckhoff Automation GmbH)</Resolution>
|
||||
<Resolution>Tc2_MC2, * (Beckhoff Automation GmbH)</Resolution>
|
||||
</PlaceholderResolution>
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Refactors>
|
||||
<Renames>
|
||||
<RenamedType>
|
||||
<Type guid="1cbcbdc6-2eff-474d-81ad-52783ff4b2a4">TCUNIT_RUN</Type>
|
||||
<From>tcUNIT_STD_LIB_1</From>
|
||||
<To>tcUNIT_APP_RUN</To>
|
||||
</RenamedType>
|
||||
<RenamedSymbol>
|
||||
<Type guid="589a25a0-6147-4b15-99b0-2e3d988c1f1b">PrepareMove</Type>
|
||||
<From>motionStrategy</From>
|
||||
<To>eMotionStrategy</To>
|
||||
</RenamedSymbol>
|
||||
<RenamedType>
|
||||
<Type guid="677fcae4-9d84-425e-8fcd-8e3d3a1985e8">TCUNIT_STD_LIB_1</Type>
|
||||
<From>tcUNIT_STD_LIB_1</From>
|
||||
<To>tcUNIT_APP_RUN</To>
|
||||
</RenamedType>
|
||||
</Renames>
|
||||
</Refactors>
|
||||
Reference in New Issue
Block a user