Merged in MBP-140-code-strict-cleanup (pull request #37)
MBP-140 code strict cleanup
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
<Name>PlcTask Outputs</Name>
|
||||
<Var>
|
||||
<Name>MAIN.bOutput1</Name>
|
||||
<Comment><![CDATA[*****Outputs: Power for Limit switches and Home Sensors (every 4th output)*******]]></Comment>
|
||||
<Comment><![CDATA[Outputs: Power for Limit switches and Home Sensors (every 4th output)]]></Comment>
|
||||
<Type>BOOL</Type>
|
||||
</Var>
|
||||
</Vars>
|
||||
|
||||
@@ -7,7 +7,7 @@ VAR_GLOBAL
|
||||
END_VAR
|
||||
|
||||
VAR_GLOBAL CONSTANT
|
||||
axisNum : UINT:=0;
|
||||
nAXIS_NUM : UINT:=0;
|
||||
END_VAR]]></Declaration>
|
||||
</GVL>
|
||||
</TcPlcObject>
|
||||
@@ -175,6 +175,11 @@
|
||||
<v n="TextDefault">"fPosition"</v>
|
||||
<l n="LanguageTexts" t="ArrayList" />
|
||||
</o>
|
||||
<o>
|
||||
<v n="TextID">"149"</v>
|
||||
<v n="TextDefault">"fRatio"</v>
|
||||
<l n="LanguageTexts" t="ArrayList" />
|
||||
</o>
|
||||
<o>
|
||||
<v n="TextID">"708"</v>
|
||||
<v n="TextDefault">"Free Entries:"</v>
|
||||
@@ -190,11 +195,26 @@
|
||||
<v n="TextDefault">"gearIn"</v>
|
||||
<l n="LanguageTexts" t="ArrayList" />
|
||||
</o>
|
||||
<o>
|
||||
<v n="TextID">"717"</v>
|
||||
<v n="TextDefault">"gearInMultiMaster"</v>
|
||||
<l n="LanguageTexts" t="ArrayList" />
|
||||
</o>
|
||||
<o>
|
||||
<v n="TextID">"300"</v>
|
||||
<v n="TextDefault">"gearOut"</v>
|
||||
<l n="LanguageTexts" t="ArrayList" />
|
||||
</o>
|
||||
<o>
|
||||
<v n="TextID">"566"</v>
|
||||
<v n="TextDefault">"homeSensorNeg"</v>
|
||||
<l n="LanguageTexts" t="ArrayList" />
|
||||
</o>
|
||||
<o>
|
||||
<v n="TextID">"677"</v>
|
||||
<v n="TextDefault">"homeSensorPos"</v>
|
||||
<l n="LanguageTexts" t="ArrayList" />
|
||||
</o>
|
||||
<o>
|
||||
<v n="TextID">"711"</v>
|
||||
<v n="TextDefault">"Inactive:"</v>
|
||||
@@ -235,6 +255,11 @@
|
||||
<v n="TextDefault">"moveVelocity"</v>
|
||||
<l n="LanguageTexts" t="ArrayList" />
|
||||
</o>
|
||||
<o>
|
||||
<v n="TextID">"575"</v>
|
||||
<v n="TextDefault">"nIndex"</v>
|
||||
<l n="LanguageTexts" t="ArrayList" />
|
||||
</o>
|
||||
<o>
|
||||
<v n="TextID">"709"</v>
|
||||
<v n="TextDefault">"Overflows:"</v>
|
||||
|
||||
@@ -3,45 +3,35 @@
|
||||
<POU Name="MAIN" Id="{33eb6f49-7781-4211-a70b-87ada6d80cb7}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[PROGRAM MAIN
|
||||
VAR
|
||||
sVersion: STRING:='1.0.0';
|
||||
i : UINT; //index variable for AXES()
|
||||
aFbAxes: ARRAY [1..gvl_app.axisNum] OF FB_Axis;
|
||||
sVersion: STRING := '1.0.0';
|
||||
afbAxes: ARRAY [1..GVL_APP.nAXIS_NUM] OF FB_Axis;
|
||||
hmiAxisSelection: INT := 1; //Not possible to use local hmi variables for array indexes
|
||||
|
||||
hmiAxisSelection : INT:=1; //Not possible to use local hmi variables for array indexes
|
||||
|
||||
(******Outputs: Power for Limit switches and Home Sensors (every 4th output)********)
|
||||
|
||||
bOutput1 AT %Q*: BOOL:= TRUE;
|
||||
//bOutput2 AT %Q*: BOOL:= TRUE;
|
||||
//bOutput3 AT %Q*: BOOL:= TRUE;
|
||||
//bOutput4 AT %Q*: BOOL:= TRUE;
|
||||
//Outputs: Power for Limit switches and Home Sensors (every 4th output)
|
||||
bOutput1 AT %Q*: BOOL := TRUE;
|
||||
//bOutput5 AT %Q*: BOOL:= TRUE;
|
||||
//bOutput6 AT %Q*: BOOL:= TRUE;
|
||||
//bOutput7 AT %Q*: BOOL:= TRUE;
|
||||
//bOutput8 AT %Q*: BOOL:= TRUE;
|
||||
//bOutput9 AT %Q*: BOOL:= TRUE;
|
||||
//bOutput13 AT %Q*: BOOL:= TRUE;
|
||||
//bOutput17 AT %Q*: BOOL:= TRUE;
|
||||
//bOutput21 AT %Q*: BOOL:= TRUE;
|
||||
//bOutput24 AT %Q*: BOOL:= TRUE;
|
||||
//bOutput28 AT %Q*: BOOL:= TRUE;
|
||||
|
||||
(******Startup, Shutdown and UPS********)
|
||||
fbUPS : FB_S_UPS_CX51x0;
|
||||
eUpsMode : E_S_UPS_Mode := eSUPS_WrPersistData_Shutdown;
|
||||
eStartUp: (ColdStart, ReadAxisFeedbackType, CheckReadDone, ExecuteRestore, CheckRestore, FinishRestore);
|
||||
bPositionRestoreDone : BOOL := FALSE;
|
||||
bRestoreExecute : BOOL := FALSE;
|
||||
bExecuteReadEncRefSys : BOOL := FALSE;
|
||||
iRetry : INT;
|
||||
fbReadEncRefSys : ARRAY [1..gvl_app.axisNum] OF MC_ReadParameter;
|
||||
fbRestorePosition : ARRAY [1..GVL_app.axisNum] OF MC_SetPosition;
|
||||
fbGetDeviceIdentification : FB_GetDeviceIdentification;
|
||||
|
||||
//Startup, Shutdown and UPS
|
||||
fbUPS: FB_S_UPS_CX51x0;
|
||||
eUpsMode: E_S_UPS_Mode := eSUPS_WrPersistData_Shutdown;
|
||||
eStartUp: (eColdStart, eReadAxisFeedbackType, eCheckReadDone, eExecuteRestore, eCheckRestore, eFinishRestore);
|
||||
bPositionRestoreDone: BOOL := FALSE;
|
||||
bRestoreExecute: BOOL := FALSE;
|
||||
bExecuteReadEncRefSys: BOOL := FALSE;
|
||||
nRetry: INT;
|
||||
iAxes : UINT; //index for for loops in Position recovery actions
|
||||
afbReadEncRefSys: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_ReadParameter;
|
||||
afbRestorePosition: ARRAY [1..GVL_APP.nAXIS_NUM] OF MC_SetPosition;
|
||||
fbGetDeviceIdentification: FB_GetDeviceIdentification;
|
||||
END_VAR
|
||||
|
||||
VAR PERSISTENT
|
||||
bRestoreOnStartup : BOOL;
|
||||
bRestoreOnStartup: BOOL;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[POSITION_RECOVERY();
|
||||
@@ -51,31 +41,31 @@ AXES();]]></ST>
|
||||
<Folder Name="POSITION_RECOVERY" Id="{3561f6ef-e145-4ed3-9839-f17334bd2d97}" />
|
||||
<Action Name="AXES" Id="{7eb32732-9b53-4934-8cd9-20ba971dd8ff}">
|
||||
<Implementation>
|
||||
<ST><;
|
||||
<ST><;
|
||||
END_FOR]]></ST>
|
||||
</Implementation>
|
||||
</Action>
|
||||
<Action Name="CHECK_UPS" Id="{f0f28f50-53b8-4f73-b0f5-6d7ce4c1636f}" FolderPath="POSITION_RECOVERY\">
|
||||
<Implementation>
|
||||
<ST><![CDATA[fbUPS(eUpsMode := eUpsMode); (* call UPS-FB instance in first lines of the fastest PLC Task *)
|
||||
<ST><![CDATA[fbUPS(eUpsMode := eUpsMode);
|
||||
|
||||
IF eGlobalSUpsState = eSUPS_PowerFailure THEN
|
||||
(* first cycle of powerfailure *)
|
||||
(* execute code that should only be done once with each powerfailure, i.e. increase powerfailure counter *)
|
||||
bRestoreOnStartup:=TRUE;
|
||||
//first cycle of powerfailure
|
||||
//execute code that should only be done once with each powerfailure, i.e. increase powerfailure counter
|
||||
bRestoreOnStartup := TRUE;
|
||||
STORE_PERSISTENT();
|
||||
RETURN;
|
||||
ELSIF eGlobalSUpsState <> eSUPS_PowerOK THEN
|
||||
(* next cycles of powerfailure *)
|
||||
(* skip regular code execution for the remaining cycles of the powerfailure/writing of persistent data/quick shutdown ... *)
|
||||
//next cycles of powerfailure
|
||||
//skip regular code execution for the remaining cycles of the powerfailure/writing of persistent data/quick shutdown...
|
||||
RETURN;
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Action>
|
||||
<Action Name="POSITION_RECOVERY" Id="{28e203b7-aea5-42d0-980d-12a6841f9d22}" FolderPath="POSITION_RECOVERY\">
|
||||
<Implementation>
|
||||
<ST><![CDATA[fbGetDeviceIdentification(bExecute:=TRUE);
|
||||
<ST><![CDATA[fbGetDeviceIdentification(bExecute := TRUE);
|
||||
IF (fbGetDeviceIdentification.stDevIdent.strHardwareSerialNo <> '0') THEN
|
||||
CHECK_UPS();
|
||||
RESTORE_POSITIONS();
|
||||
@@ -84,137 +74,130 @@ END_IF]]></ST>
|
||||
</Action>
|
||||
<Action Name="PROG" Id="{5d03ebbb-2a47-4890-ad6d-e82daf72dc51}">
|
||||
<Implementation>
|
||||
<ST><![CDATA[//
|
||||
(* Program any sequence, safety or feature (if necessary) application specific in thsi section*)
|
||||
//]]></ST>
|
||||
<ST><![CDATA[//Program any sequence, safety or feature (if necessary) application specific in thsi section]]></ST>
|
||||
</Implementation>
|
||||
</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.
|
||||
// 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.axes[i].config.eRestorePosition is non-zero.
|
||||
// This needs to be initialised somewhere in TwinCAT code otherwise it will not be available at start up.
|
||||
// A restore will only be performed on a loss of power, this code shouldn't make any changes on a reset cold, a rest origin or a download.
|
||||
// There is a enum to allow for different types of restore modes, currently only one is implemented.
|
||||
// 0 'DontRestore'
|
||||
// 1 'RestoreWithoutHome' -restores the position using a set position fb and does not set the home bit in the axis struct.
|
||||
// Note from Beckhoff: "A maximum of 1 MB persistent data can be reliably saved over the entire service life."
|
||||
///#########################################################
|
||||
<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.
|
||||
//This needs to be initialised somewhere in TwinCAT code otherwise it will not be available at start up.
|
||||
//A restore will only be performed on a loss of power, this code shouldn't make any changes on a reset cold, a rest origin or a download.
|
||||
//There is a enum to allow for different types of restore modes, currently only one is implemented.
|
||||
//0 'DontRestore'
|
||||
//1 'RestoreWithoutHome' -restores the position using a set position fb and does not set the home bit in the axis struct.
|
||||
//Note from Beckhoff: "A maximum of 1 MB persistent data can be reliably saved over the entire service life."
|
||||
|
||||
IF bRestoreOnStartup AND eGlobalSUpsState = eSUPS_PowerOK THEN
|
||||
bRestoreOnStartup:=FALSE;
|
||||
bRestoreExecute:=TRUE;
|
||||
bRestoreOnStartup := FALSE;
|
||||
bRestoreExecute := TRUE;
|
||||
END_IF
|
||||
|
||||
// Upon startup bPositionRestoreDone will be set to FALSE, after successfully completing the following code it will be set TRUE
|
||||
// and should stay TRUE for the rest of the time the PLC is operational, thus this routine should only be completed once.
|
||||
//Upon startup bPositionRestoreDone will be set to FALSE, after successfully completing the following code it will be set TRUE
|
||||
//and should stay TRUE for the rest of the time the PLC is operational, thus this routine should only be completed once.
|
||||
IF bRestoreExecute AND NOT bPositionRestoreDone THEN
|
||||
|
||||
// Cycle through function blocks that read the encoder reference system i.e. whether axis is incremental or absolute
|
||||
// Result stored in Value, 0=Inc 1=Abs, execute set during the case statement
|
||||
FOR i:=1 TO gvl_app.axisNum DO
|
||||
fbReadEncRefSys[i](
|
||||
Axis:= gvl.axes[i].Axis,
|
||||
Enable:= bExecuteReadEncRefSys,
|
||||
ParameterNumber:= MC_AxisParameter.AxisEncoderReferenceSystem,
|
||||
Value=>,
|
||||
ReadMode:= E_READMODE.READMODE_ONCE);
|
||||
//Cycle through function blocks that read the encoder reference system i.e. whether axis is incremental or absolute
|
||||
//Result stored in Value, 0=Inc 1=Abs, execute set during the case statement
|
||||
FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO
|
||||
afbReadEncRefSys[iAxes](
|
||||
Axis := GVL.astAxes[iAxes].Axis,
|
||||
Enable := bExecuteReadEncRefSys,
|
||||
ParameterNumber := MC_AxisParameter.AxisEncoderReferenceSystem,
|
||||
ReadMode := E_READMODE.READMODE_ONCE);
|
||||
END_FOR
|
||||
|
||||
// Cycle through set position function blocks for each axis
|
||||
FOR i:=1 TO gvl_app.axisNum DO
|
||||
fbRestorePosition[i](
|
||||
Axis:= gvl.axes[i].Axis,
|
||||
Execute:= ,
|
||||
Position:= axesPersistent[i].iPositionAtShutdown);
|
||||
//Cycle through set position function blocks for each axis
|
||||
FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO
|
||||
afbRestorePosition[iAxes](
|
||||
Axis := GVL.astAxes[iAxes].Axis,
|
||||
Position := astAxesPersistent[iAxes].fPositionAtShutdown);
|
||||
END_FOR
|
||||
|
||||
CASE eStartUp OF
|
||||
ColdStart:
|
||||
// First cycle of the PLC, do nothing just give one cycle for variables to initialise
|
||||
eColdStart:
|
||||
//First cycle of the PLC, do nothing just give one cycle for variables to initialise
|
||||
IF NOT bPositionRestoreDone THEN
|
||||
eStartUp:= ReadAxisFeedbackType;
|
||||
iRetry:=0;
|
||||
eStartUp := eReadAxisFeedbackType;
|
||||
nRetry := 0;
|
||||
END_IF
|
||||
|
||||
ReadAxisFeedbackType:
|
||||
// Exectute the function blocks to read the encoder reference system (0=inc OR 1=ABS)
|
||||
bExecuteReadEncRefSys:=TRUE;
|
||||
eStartUp:=CheckReadDone;
|
||||
eReadAxisFeedbackType:
|
||||
//Exectute the function blocks to read the encoder reference system (0=inc OR 1=ABS)
|
||||
bExecuteReadEncRefSys := TRUE;
|
||||
eStartUp := eCheckReadDone;
|
||||
|
||||
CheckReadDone:
|
||||
// Check the encoder reference system has been read for all axis -> if busy then continue with PLC cycle and check again next time.
|
||||
// If fbReadEncRefSys not started then go back a step.
|
||||
// If any axes result in an error the code will get stuck here, this happens if gvl_app.axisNum is not set correctly
|
||||
FOR i:=1 TO gvl_app.axisNum DO
|
||||
IF fbReadEncRefSys[i].Valid = FALSE THEN
|
||||
IF fbReadEncRefSys[i].Busy = TRUE THEN
|
||||
// Exit MAIN.STARTUP Action and wait till next cycle, needs to cycle through whole program in order for data to update
|
||||
eCheckReadDone:
|
||||
//Check the encoder reference system has been read for all axis -> if busy then continue with PLC cycle and check again next time.
|
||||
//If afbReadEncRefSys not started then go back a step.
|
||||
//If any axes result in an error the code will get stuck here, this happens if GVL_APP.nAxisNum is not set correctly
|
||||
FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO
|
||||
IF afbReadEncRefSys[iAxes].Valid = FALSE THEN
|
||||
IF afbReadEncRefSys[iAxes].Busy = TRUE THEN
|
||||
//Exit MAIN.STARTUP Action and wait till next cycle, needs to cycle through whole program in order for data to update
|
||||
RETURN;
|
||||
ELSE
|
||||
// Sometimes the code gets here and the fbReadEncRefSys[i] misses the rising edge. If the code gets here it means
|
||||
// .valid=FALSE and .busy=FALSE which indicateds the FB probably hasn't started and thus needs to see a rising edge.
|
||||
// Set execute to low, Exit MAIN.STARTUP and go back a step in the CASE statement.
|
||||
bExecuteReadEncRefSys:=FALSE;
|
||||
eStartUp:=ReadAxisFeedbackType;
|
||||
iRetry:=iRetry+1; // counter used for troubleshooting to see how many cycles it takes before fbReadEncRefSys function blocks are read correctly
|
||||
//Sometimes the code gets here and the afbReadEncRefSys[iAxes] misses the rising edge. If the code gets here it means
|
||||
//valid=FALSE and .busy=FALSE which indicateds the FB probably hasn't started and thus needs to see a rising edge.
|
||||
//Set execute to low, Exit MAIN.STARTUP and go back a step in the CASE statement.
|
||||
bExecuteReadEncRefSys := FALSE;
|
||||
eStartUp := eReadAxisFeedbackType;
|
||||
nRetry := nRetry + 1; //counter used for troubleshooting to see how many cycles it takes before afbReadEncRefSys function blocks are read correctly
|
||||
RETURN;
|
||||
END_IF
|
||||
END_IF
|
||||
END_FOR
|
||||
// If the code gets here all axes either have .valid=TRUE for all axes
|
||||
eStartUp:= ExecuteRestore;
|
||||
//If the code gets here all axes either have .valid=TRUE for all axes
|
||||
eStartUp := eExecuteRestore;
|
||||
|
||||
ExecuteRestore:
|
||||
// Execute position restore by setting fbRestorePosition.execute = TRUE
|
||||
FOR i:=1 TO gvl_app.axisNum DO
|
||||
IF fbReadEncRefSys[i].Valid = TRUE AND fbReadEncRefSys[i].Value = 0 AND NOT(axesPersistent[i].bMovingAtShutdown) THEN
|
||||
IF GVL.axes[i].config.eRestorePosition = RestorePosition.RestoreWithoutHome THEN
|
||||
fbRestorePosition[i].Execute:=TRUE;
|
||||
eExecuteRestore:
|
||||
//Execute position restore by setting afbRestorePosition.execute = TRUE
|
||||
FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO
|
||||
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
|
||||
END_FOR
|
||||
eStartUp:= CheckRestore;
|
||||
eStartUp := eCheckRestore;
|
||||
|
||||
CheckRestore:
|
||||
// Check the set position fbs are finished
|
||||
// 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 i:=1 TO gvl_app.axisNum DO
|
||||
IF fbReadEncRefSys[i].Valid = TRUE AND fbReadEncRefSys[i].Value = 0 AND NOT(axesPersistent[i].bMovingAtShutdown) THEN
|
||||
IF GVL.axes[i].config.eRestorePosition = RestorePosition.RestoreWithoutHome THEN
|
||||
IF NOT fbRestorePosition[i].Done THEN
|
||||
eCheckRestore:
|
||||
//Check the set position fbs are finished
|
||||
//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.nAXIS_NUM DO
|
||||
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
|
||||
END_IF
|
||||
END_IF
|
||||
END_FOR
|
||||
eStartUp:= FinishRestore;
|
||||
eStartUp := eFinishRestore;
|
||||
|
||||
FinishRestore:
|
||||
// Remove execute = TRUE for fbRestorePosition
|
||||
FOR i:=1 TO gvl_app.axisNum DO
|
||||
fbRestorePosition[i].Execute:=FALSE;
|
||||
eFinishRestore:
|
||||
//Remove execute = TRUE for afbRestorePosition
|
||||
FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO
|
||||
afbRestorePosition[iAxes].Execute := FALSE;
|
||||
END_FOR
|
||||
bPositionRestoreDone:=TRUE;
|
||||
bRestoreExecute:=FALSE;
|
||||
bPositionRestoreDone := TRUE;
|
||||
bRestoreExecute := FALSE;
|
||||
END_CASE
|
||||
END_IF]]></ST>
|
||||
</Implementation>
|
||||
</Action>
|
||||
<Action Name="STORE_PERSISTENT" Id="{cb5c9254-2e5f-47b1-9baa-10e728a961b0}" FolderPath="POSITION_RECOVERY\">
|
||||
<Implementation>
|
||||
<ST><![CDATA[FOR i:=1 TO gvl_app.axisNum DO
|
||||
axesPersistent[i].iPositionAtShutdown:=gvl.axes[i].Axis.NcToPlc.ActPos;
|
||||
IF gvl.axes[i].Axis.NcToPlc.ActVelo <> 0 THEN
|
||||
axesPersistent[i].bMovingAtShutdown:=TRUE;
|
||||
<ST><![CDATA[FOR iAxes := 1 TO GVL_APP.nAXIS_NUM DO
|
||||
astAxesPersistent[iAxes].fPositionAtShutdown := GVL.astAxes[iAxes].Axis.NcToPlc.ActPos;
|
||||
IF GVL.astAxes[iAxes].Axis.NcToPlc.ActVelo <> 0 THEN
|
||||
astAxesPersistent[iAxes].bMovingAtShutdown := TRUE;
|
||||
ELSE
|
||||
axesPersistent[i].bMovingAtShutdown:=FALSE;
|
||||
astAxesPersistent[iAxes].bMovingAtShutdown := FALSE;
|
||||
END_IF
|
||||
axesPersistent[i].bMovingAtShutdown:=axesPersistent[i].bMovingAtShutdown OR gvl.axes[i].Axis.Status.Moving;
|
||||
astAxesPersistent[iAxes].bMovingAtShutdown := astAxesPersistent[iAxes].bMovingAtShutdown OR GVL.astAxes[iAxes].Axis.Status.Moving;
|
||||
END_FOR]]></ST>
|
||||
</Implementation>
|
||||
</Action>
|
||||
@@ -238,82 +221,9 @@ END_FOR]]></ST>
|
||||
</LineIds>
|
||||
<LineIds Name="MAIN.PROG">
|
||||
<LineId Id="2" Count="0" />
|
||||
<LineId Id="1" Count="0" />
|
||||
<LineId Id="3" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="MAIN.RESTORE_POSITIONS">
|
||||
<LineId Id="99" Count="0" />
|
||||
<LineId Id="94" Count="0" />
|
||||
<LineId Id="98" Count="0" />
|
||||
<LineId Id="213" Count="0" />
|
||||
<LineId Id="101" Count="0" />
|
||||
<LineId Id="233" Count="1" />
|
||||
<LineId Id="102" Count="0" />
|
||||
<LineId Id="215" Count="0" />
|
||||
<LineId Id="214" Count="0" />
|
||||
<LineId Id="109" Count="0" />
|
||||
<LineId Id="95" Count="0" />
|
||||
<LineId Id="236" Count="2" />
|
||||
<LineId Id="240" Count="0" />
|
||||
<LineId Id="239" Count="0" />
|
||||
<LineId Id="206" Count="0" />
|
||||
<LineId Id="208" Count="1" />
|
||||
<LineId Id="207" Count="0" />
|
||||
<LineId Id="100" Count="0" />
|
||||
<LineId Id="91" Count="1" />
|
||||
<LineId Id="2" Count="7" />
|
||||
<LineId Id="96" Count="0" />
|
||||
<LineId Id="10" Count="6" />
|
||||
<LineId Id="18" Count="2" />
|
||||
<LineId Id="177" Count="0" />
|
||||
<LineId Id="21" Count="3" />
|
||||
<LineId Id="171" Count="0" />
|
||||
<LineId Id="25" Count="0" />
|
||||
<LineId Id="178" Count="0" />
|
||||
<LineId Id="26" Count="1" />
|
||||
<LineId Id="170" Count="0" />
|
||||
<LineId Id="29" Count="0" />
|
||||
<LineId Id="179" Count="0" />
|
||||
<LineId Id="163" Count="0" />
|
||||
<LineId Id="212" Count="0" />
|
||||
<LineId Id="152" Count="0" />
|
||||
<LineId Id="139" Count="0" />
|
||||
<LineId Id="131" Count="0" />
|
||||
<LineId Id="155" Count="0" />
|
||||
<LineId Id="190" Count="0" />
|
||||
<LineId Id="140" Count="0" />
|
||||
<LineId Id="157" Count="0" />
|
||||
<LineId Id="210" Count="1" />
|
||||
<LineId Id="187" Count="0" />
|
||||
<LineId Id="150" Count="1" />
|
||||
<LineId Id="200" Count="0" />
|
||||
<LineId Id="145" Count="0" />
|
||||
<LineId Id="141" Count="0" />
|
||||
<LineId Id="166" Count="0" />
|
||||
<LineId Id="203" Count="0" />
|
||||
<LineId Id="201" Count="0" />
|
||||
<LineId Id="173" Count="0" />
|
||||
<LineId Id="56" Count="0" />
|
||||
<LineId Id="181" Count="0" />
|
||||
<LineId Id="57" Count="1" />
|
||||
<LineId Id="216" Count="0" />
|
||||
<LineId Id="219" Count="1" />
|
||||
<LineId Id="63" Count="2" />
|
||||
<LineId Id="174" Count="0" />
|
||||
<LineId Id="66" Count="0" />
|
||||
<LineId Id="182" Count="0" />
|
||||
<LineId Id="204" Count="1" />
|
||||
<LineId Id="67" Count="1" />
|
||||
<LineId Id="221" Count="0" />
|
||||
<LineId Id="71" Count="2" />
|
||||
<LineId Id="222" Count="0" />
|
||||
<LineId Id="79" Count="2" />
|
||||
<LineId Id="175" Count="0" />
|
||||
<LineId Id="82" Count="0" />
|
||||
<LineId Id="223" Count="0" />
|
||||
<LineId Id="83" Count="3" />
|
||||
<LineId Id="241" Count="0" />
|
||||
<LineId Id="87" Count="0" />
|
||||
<LineId Id="567" Count="105" />
|
||||
<LineId Id="1" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="MAIN.STORE_PERSISTENT">
|
||||
|
||||
@@ -1,118 +1,118 @@
|
||||
<?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
|
||||
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="mEnableAxis" Id="{12e91532-7139-4c17-998e-4c670b584b9d}">
|
||||
<Declaration><![CDATA[METHOD mEnableAxis : BOOL
|
||||
<Declaration><![CDATA[METHOD mEnableAxis: BOOL
|
||||
VAR_INPUT
|
||||
iAxisIndex: INT; // The idex of the axis to action the method on.
|
||||
iAxisIndex: UINT; //The idex of the axis to action the method on.
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[GVL.axes[iAxisIndex].control.bEnable := TRUE;]]></ST>
|
||||
<ST><![CDATA[GVL.astAxes[iAxisIndex].stControl.bEnable := TRUE;]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="mExecute" Id="{010bd927-5568-40db-a7c5-fcfe995a5cb1}">
|
||||
<Declaration><![CDATA[METHOD mExecute : BOOL
|
||||
<Declaration><![CDATA[METHOD mExecute: BOOL
|
||||
VAR_INPUT
|
||||
iAxisIndex: INT; // The idex of the axis to action the method on.
|
||||
iAxisIndex: UINT; //The idex of the axis to action the method on.
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[GVL.axes[iAxisIndex].control.bExecute := TRUE;]]></ST>
|
||||
<ST><![CDATA[GVL.astAxes[iAxisIndex].stControl.bExecute := TRUE;]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="mPrepareDefaultMove" Id="{c23244d5-896c-49ad-8d8a-19390856e4dc}">
|
||||
<Declaration><![CDATA[METHOD mPrepareDefaultMove
|
||||
|
||||
VAR_INPUT
|
||||
iAxisIndex: INT; // The idex of the axis to action the method on.
|
||||
iAxisIndex: 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.
|
||||
<ST><![CDATA[//Prepare an axis so it is ready to action a move using target defaults when executed.
|
||||
|
||||
GVL.axes[iAxisIndex].control.bEnable := TRUE;
|
||||
GVL.axes[iAxisIndex].control.eCommand := MotionFunctions.MoveAbsolute;
|
||||
GVL.astAxes[iAxisIndex].stControl.bEnable := TRUE;
|
||||
GVL.astAxes[iAxisIndex].stControl.eCommand := E_MotionFunctions.eMoveAbsolute;
|
||||
|
||||
GVL.axes[iAxisIndex].inputs.bLimitBwd := TRUE;
|
||||
GVL.axes[iAxisIndex].inputs.bLimitFwd := TRUE;
|
||||
GVL.astAxes[iAxisIndex].stInputs.bLimitBwd := TRUE;
|
||||
GVL.astAxes[iAxisIndex].stInputs.bLimitFwd := TRUE;
|
||||
|
||||
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>
|
||||
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}">
|
||||
<Declaration><![CDATA[METHOD mPrepareMove
|
||||
|
||||
VAR_INPUT
|
||||
iAxisIndex: INT; // The idex of the axis to action the method on.
|
||||
iAxisIndex: UINT; //The idex of the axis to action the method on.
|
||||
fTargetVelocity: LREAL;
|
||||
fTargetAcceleration: LREAL;
|
||||
fTargetDeceleration: LREAL;
|
||||
fTargetPosition: LREAL;
|
||||
eMotionStrategy: MotionFunctions; // The desired MotionFunctions motion strategy.
|
||||
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.
|
||||
<ST><![CDATA[//Prepare the axis so it is ready to action a move when executed for a given motion strategy.
|
||||
|
||||
GVL.axes[iAxisIndex].control.bEnable := FALSE;
|
||||
GVL.axes[iAxisIndex].control.eCommand := eMotionStrategy;
|
||||
GVL.astAxes[iAxisIndex].stControl.bEnable := FALSE;
|
||||
GVL.astAxes[iAxisIndex].stControl.eCommand := eMotionStrategy;
|
||||
|
||||
GVL.axes[iAxisIndex].inputs.bLimitBwd := TRUE;
|
||||
GVL.axes[iAxisIndex].inputs.bLimitFwd := TRUE;
|
||||
GVL.astAxes[iAxisIndex].stInputs.bLimitBwd := TRUE;
|
||||
GVL.astAxes[iAxisIndex].stInputs.bLimitFwd := TRUE;
|
||||
|
||||
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>
|
||||
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}">
|
||||
<Declaration><![CDATA[METHOD mSetAxisDefaults
|
||||
|
||||
VAR_INPUT
|
||||
iAxisIndex: INT; // The idex of the axis to action the method on.
|
||||
iAxisIndex: 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.axes[iAxisIndex].status.bBusy THEN
|
||||
GVL.axes[iAxisIndex].control.bStop := TRUE;
|
||||
IF GVL.astAxes[iAxisIndex].stStatus.bBusy THEN
|
||||
GVL.astAxes[iAxisIndex].stControl.bStop := TRUE;
|
||||
END_IF
|
||||
IF GVL.axes[iAxisIndex].status.bError THEN
|
||||
GVL.axes[iAxisIndex].control.bReset := TRUE;
|
||||
IF GVL.astAxes[iAxisIndex].stStatus.bError THEN
|
||||
GVL.astAxes[iAxisIndex].stControl.bReset := TRUE;
|
||||
END_IF
|
||||
IF NOT GVL.axes[iAxisIndex].control.bEnable AND GVL.axes[iAxisIndex].control.bStop THEN
|
||||
GVL.axes[iAxisIndex].control.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.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;
|
||||
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.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;
|
||||
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.axes[iAxisIndex].inputs.bLimitBwd := FALSE;
|
||||
GVL.axes[iAxisIndex].inputs.bLimitFwd := FALSE;
|
||||
GVL.axes[iAxisIndex].inputs.bEncLAtch := FALSE;
|
||||
GVL.axes[iAxisIndex].inputs.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">
|
||||
@@ -125,25 +125,15 @@ GVL.axes[iAxisIndex].inputs.bHomeSensor := FALSE;]]></ST>
|
||||
<LineId Id="5" 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="44" Count="11" />
|
||||
<LineId Id="19" Count="0" />
|
||||
</LineIds>
|
||||
<LineIds Name="FB_tcUNIT_common.mPrepareMove">
|
||||
<LineId Id="17" Count="11" />
|
||||
</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="50" Count="28" />
|
||||
<LineId Id="26" Count="0" />
|
||||
</LineIds>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
@@ -1,15 +1,14 @@
|
||||
<?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
|
||||
// Constants for axis defaults.
|
||||
//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;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<?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
|
||||
<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: INT := 1; // The <index> of the axis within GVL.axes[<index>] to test against.
|
||||
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
|
||||
<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();
|
||||
@@ -34,7 +34,7 @@ ExpectedResult := TRUE;
|
||||
fbCommon.mPrepareDefaultMove(iTargetAxis);
|
||||
fbCommon.mExecute(iTargetAxis);
|
||||
|
||||
Result := GVL.axes[iTargetAxis].status.bBusy;
|
||||
Result := GVL.astAxes[iTargetAxis].stStatus.bBusy;
|
||||
|
||||
IF nCycle > nMaxCycles OR ExpectedResult = Result THEN
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
@@ -52,24 +52,25 @@ 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.
|
||||
//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;
|
||||
InitialValue := GVL.astAxes[iTargetAxis].stConfig.fPosition;
|
||||
ExpectedResult := InitialValue + 10;
|
||||
GVL.axes[iTargetAxis].config.fPosition := ExpectedResult;
|
||||
GVL.astAxes[iTargetAxis].stConfig.fPosition := ExpectedResult;
|
||||
|
||||
GVL.axes[iTargetAxis].control.eCommand := MotionFunctions.MoveAbsolute;
|
||||
GVL.axes[iTargetAxis].control.bExecute := TRUE;
|
||||
GVL.astAxes[iTargetAxis].stControl.eCommand := E_MotionFunctions.eMoveAbsolute;
|
||||
GVL.astAxes[iTargetAxis].stControl.bExecute := TRUE;
|
||||
|
||||
Result := GVL.axes[iTargetAxis].status.fActPosition;
|
||||
Result := GVL.astAxes[iTargetAxis].stStatus.fActPosition;
|
||||
|
||||
IF nCycle > nCycleMax OR ExpectedResult = Result THEN
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
@@ -91,12 +92,12 @@ 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.
|
||||
//example of direct GVL axis reference for assert.
|
||||
|
||||
ExpectedResult := tcUNIT_gvl.fDEFAULT_TARGET_ACCELERATION;
|
||||
fbCommon.mPrepareDefaultMove(iTargetAxis);
|
||||
|
||||
Result := GVL.axes[1].config.fAcceleration;
|
||||
Result := GVL.astAxes[iTargetAxis].stConfig.fAcceleration;
|
||||
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
Actual := Result,
|
||||
@@ -110,18 +111,19 @@ TEST_FINISHED();]]></ST>
|
||||
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.
|
||||
//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;
|
||||
GVL.astAxes[iTargetAxis].stControl.bEnable := ExpectedResult;
|
||||
|
||||
Result := GVL.axes[iTargetAxis].status.bEnabled;
|
||||
Result := GVL.astAxes[iTargetAxis].stStatus.bEnabled;
|
||||
|
||||
IF nCycle > nMaxCycles OR ExpectedResult = Result THEN
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
@@ -146,13 +148,13 @@ 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).
|
||||
//Example of using a tcUNIT assert for a specific type (in this case LREAL).
|
||||
|
||||
InitialValue := GVL.axes[iTargetAxis].config.fVelocity;
|
||||
InitialValue := GVL.astAxes[iTargetAxis].stConfig.fVelocity;
|
||||
ExpectedResult := InitialValue + 0.5;
|
||||
GVL.Axes[iTargetAxis].config.fVelocity := ExpectedResult;
|
||||
GVL.astAxes[iTargetAxis].stConfig.fVelocity := ExpectedResult;
|
||||
|
||||
Result := GVL.axes[iTargetAxis].config.fVelocity;
|
||||
Result := GVL.astAxes[iTargetAxis].stConfig.fVelocity;
|
||||
|
||||
AssertEquals_LREAL(Expected := ExpectedResult,
|
||||
Actual := Result,
|
||||
@@ -176,9 +178,9 @@ END_VAR]]></Declaration>
|
||||
|
||||
ExpectedResult := TRUE;
|
||||
|
||||
GVL.axes[iTargetAxis].inputs.bLimitFwd := TRUE;
|
||||
GVL.astAxes[iTargetAxis].stInputs.bLimitFwd := TRUE;
|
||||
|
||||
Result := GVL.axes[iTargetAxis].status.bFwEnabled;
|
||||
Result := GVL.astAxes[iTargetAxis].stStatus.bFwEnabled;
|
||||
|
||||
IF nCycle > nMaxCycles OR ExpectedResult = Result THEN
|
||||
AssertEquals(Expected := ExpectedResult,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?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
|
||||
<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;
|
||||
//Declare standard library POU tests to be run
|
||||
fbAxisTest: FB_Axis_TEST;
|
||||
END_VAR]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[TcUnit.RUN();]]></ST>
|
||||
|
||||
Submodule solution/tc_project_app/tc_mca_std_lib updated: 5ee22a6d09...08a5fd1399
@@ -30,7 +30,19 @@
|
||||
<Compile Include="POUs\MAIN.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\DUTs\RestorePosition.TcDUT">
|
||||
<Compile Include="tc_mca_std_lib\DUTs\E_HomingRoutines.TcTLEO">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\DUTs\E_MotorTypeClass.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\DUTs\E_EncoderTypeClass.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\DUTs\E_HomeSwitchTypeClass.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\DUTs\E_RestorePosition.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\DUTs\ST_AxisConfig.TcDUT">
|
||||
@@ -39,7 +51,10 @@
|
||||
<Compile Include="tc_mca_std_lib\DUTs\ST_AxisControl.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\DUTs\MotionFunctions.TcDUT">
|
||||
<Compile Include="tc_mca_std_lib\DUTs\E_MotionFunctions.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\DUTs\ST_AxisDescription.TcDUT">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\DUTs\ST_AxisInputs.TcDUT">
|
||||
@@ -75,48 +90,20 @@
|
||||
<Compile Include="tc_mca_std_lib\POUs\Motion\FB_Axis.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\POUs\Motion\Homing\FB_HomeDirect.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\POUs\Motion\Homing\FB_HomeFinish.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\POUs\Motion\Homing\FB_HomePrepare.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\POUs\Motion\Homing\FB_HomeReadNcVelocities.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\POUs\Motion\Homing\FB_HomeReadSoftLimEnable.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\POUs\Motion\Homing\FB_HomeToSwitch.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\POUs\Motion\Homing\FB_HomeVirtual.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\POUs\Motion\Homing\FB_HomeWriteNcVelocities.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\POUs\Motion\Homing\FB_HomeWriteSoftLimEnable.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\POUs\Motion\Homing\FB_Homing.TcPOU">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\POUs\VISUs\Error_Log_Visu.TcVIS">
|
||||
<Compile Include="tc_mca_std_lib\VISUs\languageSupport.TcTLO">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\VISUs\MainVisu.TcVIS">
|
||||
<SubType>Code</SubType>
|
||||
<DependentUpon>Visualization Manager.TcVMO</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\POUs\VISUs\languageSupport.TcTLO">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\POUs\VISUs\MainVisu.TcVIS">
|
||||
<SubType>Code</SubType>
|
||||
<DependentUpon>Visualization Manager.TcVMO</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="tc_mca_std_lib\POUs\VISUs\visuTextLinks.TcTLO">
|
||||
<Compile Include="tc_mca_std_lib\VISUs\visuTextLinks.TcTLO">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Test\app_tests\tcUNIT_APP_RUN.TcPOU">
|
||||
@@ -141,6 +128,7 @@
|
||||
<ItemGroup>
|
||||
<Folder Include="DUTs" />
|
||||
<Folder Include="GVLs" />
|
||||
<Folder Include="tc_mca_std_lib\VISUs" />
|
||||
<Folder Include="Test" />
|
||||
<Folder Include="tc_mca_std_lib" />
|
||||
<Folder Include="tc_mca_std_lib\DUTs" />
|
||||
@@ -149,11 +137,9 @@
|
||||
<Folder Include="tc_mca_std_lib\POUs\ChangeConfig" />
|
||||
<Folder Include="tc_mca_std_lib\POUs\Motion" />
|
||||
<Folder Include="tc_mca_std_lib\POUs\Motion\Homing" />
|
||||
<Folder Include="tc_mca_std_lib\POUs\VISUs" />
|
||||
<Folder Include="Test\app_tests" />
|
||||
<Folder Include="Test\common" />
|
||||
<Folder Include="Test\standard_library_tests" />
|
||||
<Folder Include="VISUs" />
|
||||
<Folder Include="POUs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user