FC_GetModuleInterfaces - General Information

Overview

Type:

Function

Available as of:

V1.0.4.0

Task

Access to the default and additional interfaces of a module.

Description

The modules of the template from a tree-like structure due to the submodule relationship with the MainMachine on top. The function accesses the tree. It searches the module specified by i_udiModuleId and returns a pointer to its default interface and to its additional interface (if present).

NOTE: Access to the zero-pointer possible. The function returns two pointers. It is possible that both or only one of it are zero. If you access zero pointer a page fault can occur. This stops the execution of the program. In succession (brake at its limit of the current) a mechanical damage can appear.

Perform the following steps to avoid the danger.

  • Verify the return value of the function and use the returned pointer only if the function does not detect an error. At that point it is already possible to use the default interface. It is safe. In the following examples it is named pstStandard.

  • Before you use the pointer to the additional interface the following tests must be performed:

  • Verify if the pointer is <> 0.

  • Comparison of the module type in pstStandard^.stQ.dwModuleTypeId with the expected value. This is necessary because the additional interface differs module type to module type.

  • Comparison of the module version in pstStandard^.stQ.diModuleVersion with the expected value. This is necessary because the additional interface can also differ between two versions of a module. Please note to explicitly exclude newer version when performing this checks. At any time it can occur, that they own another additional interface.

  • If one of the checks fails, an error is generated and the interface is not accessed.

  • After you performed the checks, assign the pointer which was stored in a DWORD until now to a variable type POINTER TO of the additional interface of interesting module type. Respectively POINTER TO TPD_ST_AXIS_MODULE_INTERFACE for an AxisModule (dwModuleTypeId = TPD_GE_MTI_AXIS_MODULE) with version 1 (diModuleVersion = 1).

  • It is only allowed to use the pointers in the same cycle of the task in which you have read it out. The use in subsequent cycles is not allowed due to a possible OnlineChange. If you need the pointer again, you need to read it again by calling up the FC_GetModuleInterfaces function.

Interface

Input

Data type

Description

i_pstMachineStandardItf

POINTER TO ST_StandardModuleInterface

Pointer to the default interface of the MainMachine. Connect this input always to "ADR(SR_MainMachine.stMachineInterface)".

i_udiModuleId

UDINT

Id of the searched module.

Output

Data type

Description

q_etDiag

GD.ET_Diag

General, library-independent statement on the diagnostic.

A value not equal to ET_Diag.Ok corresponds to an error message.

q_etDiagExt

ET_DiagExt

POU-specific output on the diagnostic.

q_etDiag = ET_Diag.Ok -> Status message

q_etDiag <> ET_Diag.Ok -> Error message

Input/Output

Data type

Description

iq_pstStandardItf

POINTER TO ST_StandardModuleInterface

Variable the pointer to the default interface of the searched module is written into.

iq_dwAdditionalItf

DWORD

Variable the pointer to the additional interface of the searched module is written into. The pointer has no type (executed as DWORD) because the type of the additional interface differs module to module.

Return Value

Data type

Description

BOOL

Diagnostic Messages

q_etDiag

q_etDiagExt

Enumeration value

Description

OK

Ok

0

Ok

ExecutionAborted

MissingExtInit

56

Initialization of the Ext structure failed.

InputParameterInvalid

ModuleIdInvalid

67

The module ID is invalid.

InputParameterInvalid

PointerMachineStandardItfInvalid

58

The pointer MachineStandardItf is invalid

UnexpectedProgramBehavior

UnexpectedFeedback

10

An unintended error has been detected during execution.

MissingExtInit

Enumeration name:

MissingExtInit

Enumeration value:

56

Description:

Initialization of the Ext structure failed.

Issue

Cause

Solution

-

Initialization of Ext failed

The parameter SubModulesAddItf must be > 0

ModuleIdInvalid

Enumeration name:

ModuleIdInvalid

Enumeration value:

67

Description:

The module ID is invalid.

Issue

Cause

Solution

-

TheModulId is invalid

The ModulId must be >99

Ok

Enumeration name:

Ok

Enumeration value:

0

Description:

Ok

The function GetModuleInterfaces was executed without errors

PointerMachineStandardItfInvalid

Enumeration name:

PointerMachineStandardItfInvalid

Enumeration value:

58

Description:

The pointer MachineStandardItf is invalid

Issue

Cause

Solution

-

The pointer MachineStandardItf is invalid

The values SubModulesItf, SubModuleNum and MachineStandardItf must not be 0

UnexpectedFeedback

Enumeration name:

UnexpectedFeedback

Enumeration value:

10

Description:

An unintended error has been detected during execution.

Issue

Cause

Solution

-

Unintended feedback during execution

The parameter SubModuleNum must be >0