Added tcUNIT, including helper functions and app test folder, to generic structure
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.0">
|
||||
<POU Name="tcUNIT_APP_RUN" Id="{1cbcbdc6-2eff-474d-81ad-52783ff4b2a4}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[// tcUNIT: Add this program to PLC tasks in order to run tcUNIT tests against the declared POU test suites below
|
||||
PROGRAM tcUNIT_APP_RUN
|
||||
VAR
|
||||
// Declare application POU tests to be run
|
||||
// e.g. fbNonLinearSlitMove: FB_NonLinearSlitMove_Test
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TcUnit.RUN();
|
||||
]]></ST>
|
||||
</Implementation>
|
||||
<LineIds Name="tcUNIT_APP_RUN">
|
||||
<LineId Id="45" Count="0" />
|
||||
<LineId Id="43" Count="0" />
|
||||
</LineIds>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
187
solution/tc_project_app/tcUNIT/common/FB_tcUNIT_common.TcPOU
Normal file
187
solution/tc_project_app/tcUNIT/common/FB_tcUNIT_common.TcPOU
Normal file
@@ -0,0 +1,187 @@
|
||||
<?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
|
||||
FUNCTION_BLOCK FB_tcUNIT_common
|
||||
VAR
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="Cycle" Id="{664ce267-e020-4cb0-b408-882e70cdbead}">
|
||||
<Declaration><![CDATA[METHOD Cycle : BOOL
|
||||
VAR_INPUT
|
||||
iCycles: INT; // Number of cycles to process
|
||||
END_VAR
|
||||
|
||||
VAR
|
||||
i: INT := 0;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[WHILE i < iCycles DO
|
||||
i := i + 1;
|
||||
END_WHILE
|
||||
]]></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
|
||||
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>
|
||||
</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
|
||||
|
||||
VAR_INPUT
|
||||
MotionStrategy: MotionFunctions; // The motion strategy to be used in the move
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<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;
|
||||
|
||||
Axis.inputs.bLimitBwd := TRUE;
|
||||
Axis.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>
|
||||
</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 action a pre-execute move
|
||||
END_VAR
|
||||
|
||||
VAR_INPUT
|
||||
fTargetVelocity: LREAL;
|
||||
fTargetAcceleration: LREAL;
|
||||
fTargetDeceleration: LREAL;
|
||||
fTargetPosition: LREAL;
|
||||
eMotionStrategy: MotionFunctions;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Prepare an axis so it is ready to action a move when executed
|
||||
|
||||
Axis.control.bEnable := FALSE;
|
||||
Axis.control.eCommand := eMotionStrategy;
|
||||
|
||||
Axis.inputs.bLimitBwd := TRUE;
|
||||
Axis.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>
|
||||
</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 be returned to a default state
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Set PLC default values for the provided axis
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
Axis.inputs.bLimitBwd := FALSE;
|
||||
Axis.inputs.bLimitFwd := FALSE;
|
||||
Axis.inputs.bEncLAtch := FALSE;
|
||||
Axis.inputs.bHomeSensor := FALSE;
|
||||
|
||||
Cycle(1); // Cycle the PLC to ensure the values have been set and results can be taken
|
||||
]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<LineIds Name="FB_tcUNIT_common">
|
||||
<LineId Id="9" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_tcUNIT_common.Cycle">
|
||||
<LineId Id="5" Count="0" />
|
||||
<LineId Id="10" Count="2" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_tcUNIT_common.Execute">
|
||||
<LineId Id="5" Count="0" />
|
||||
<LineId Id="8" Count="0" />
|
||||
<LineId Id="7" Count="0" />
|
||||
<LineId Id="9" 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" />
|
||||
<LineId Id="138" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_tcUNIT_common.PrepareMove">
|
||||
<LineId Id="159" Count="13" />
|
||||
<LineId Id="17" Count="0" />
|
||||
</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" />
|
||||
<LineId Id="28" Count="0" />
|
||||
</LineIds>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
28
solution/tc_project_app/tcUNIT/common/tcUNIT_GVL.TcGVL
Normal file
28
solution/tc_project_app/tcUNIT/common/tcUNIT_GVL.TcGVL
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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
|
||||
{attribute 'qualified_only'}
|
||||
VAR_GLOBAL CONSTANT
|
||||
iNumberOfAxes: INT := 1;
|
||||
|
||||
// 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;
|
||||
|
||||
END_VAR
|
||||
|
||||
VAR_GLOBAL
|
||||
iAxis: INT;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
</GVL>
|
||||
</TcPlcObject>
|
||||
15
solution/tc_project_app/tc_project_app.tmcRefac
Normal file
15
solution/tc_project_app/tc_project_app.tmcRefac
Normal file
@@ -0,0 +1,15 @@
|
||||
<?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>
|
||||
</Renames>
|
||||
</Refactors>
|
||||
Reference in New Issue
Block a user