码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2020-04-01 12:41:23      阅读:96      评论:0      收藏:0      [点我收藏+]

标签:ons   format   declared   ble   inf   ext   wss   fixed   can   

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

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

标签:ons   format   declared   ble   inf   ext   wss   fixed   can   

原文地址:https://www.cnblogs.com/Lion-Ming/p/12611464.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!