Simotion ST 程序接口声明内容和顺序 interface

The interface section contains statements for declaring data public and using data (data types, variables, function blocks, functions, programs). Technology packages and libraries can also be downloaded.

The interface section has the following syntax:

Syntax

INTERFACE

// Interface statements (optional)

END_INTERFACE

An individual identifier of the section cannot be specified.

Optionally, interface statements exist in the following order between reserved words INTERFACE and END_INTERFACE.

  • 声明使用的工艺包Specification of utilized technology package. Syntax:

    USEPACKAGE tp-name [AS namespace];

    For more details, refer to the SIMOTION Basic Functions Function Manual.

  1. 声明库Specification of utilized libraries.

    Syntax:

    USELIB library-name-list [AS namespace];

    For more information, see "Using data types, functions and function blocks from libraries".

  2. 引用的其他部分Reference to other units in order to use their public components.

    The syntax is:

    USES unit_name-list;

    For more information, see "USES statement in a using unit".

  3. Declarations and information regarding declaration as public to other program sources:

    • Data type definitions:

      User-defined data types (UDT) that are public and valid within the entire ST source file

    • Variable declarations:

      Unit variables and unit constants that are public and valid within the entire ST source file.

      Permissible keywords: See Section "Variable declaration".

    • Object-oriented interfaces:

      Object-oriented interfaces that are public and valid within the entire ST source file.

      As of version V4.5 of the SIMOTION Kernel and with compiler option “Permit object-oriented programming” enabled.

       
      Note

      Object-oriented interfaces utilize the same keywords as the interface section (INTERFACE / END_INTERFACE).

    • Specification of the program organization units (POUs) to be declared public.

      Syntax:

      FUNCTION fc_name;

      FUNCTION_BLOCK fb_name;

      PROGRAM program_name;

      CLASS class_name; (as of version V4.5 of the SIMOTION Kernel and with compiler option "Permit object-oriented programming” enabled)

      If the "Permit forward declarations" compiler option is activated, they are also interpreted as POU prototypes for the forward declaration.

    • POU prototypes for the forward declaration.

      Specification of the prototypes for program organization units with forward declaration (only effective if the "Permit forward declarations" compiler option is activated).

      They are also interpreted as POUs to be exported.

All technology packages, libraries, units used, data type declarations, variable declarations, object-oriented interfaces and program organization units listed in the interface section are declared public. For further information about declaring public, see "Interface section of a unit with Declare Public function".

Sequence

The interface section is the first section of an ST source file.

 
Note

Optionally, the unit statement can precede the interface section, see "Identifier of the unit".

The order of the interface statements 1 to 4 is fixed.

Within number 4, any order is permitted. The individual declaration blocks for data type definitions (including POU prototypes) and variables declarations can appear more than once.

Please note: Identifiers must be declared before they are used.

Only if the "Permit forward declarations" compiler option is activated: When declaring an instance of a function block or a class, it is sufficient for the prototype of the function block to have been declared beforehand. It is not possible to initialize the function block or the class.

Frequency

Once per ST source file

Mandatory section

Yes

posted @ 2020-04-01 11:43  QUST  阅读(331)  评论(0编辑  收藏  举报