Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
SYPT PRO User Guide / SYPT PRO User Guide.doc
Скачиваний:
244
Добавлен:
03.03.2016
Размер:
17.32 Mб
Скачать

Program Structure

A DPL program can be broadly divided into a number of subsections. The following is an example of a simple DPL program.

The example shows the main subsections of a DPL program. The subsections are:

The example shows the main subsections of a DPL program. The subsections are:

  • Properties Section

  • Notes/ Description Section

  • Directives Section

  • Aliases Section

  • Constant Section

  • Code Section

In general, the subsections should always be placed in this order in a file. If this order is not obeyed, the program may fail to compile. For example, if directives are placed after code the program will not compile.

Properties Section

The Properties section shows the target for which the program is being compiled together with identity information for the program and author. This information has no effect on the operation of the compiled program. The information is downloaded to the target and can be inspected when online in SYPT.

Notes/ Description Section

The Notes section is a convenient place to add a description of the purpose and operation of the program. The information has no effect on the operation of the compiled program. If the option is taken to embed the DPL source file when building, the Notes section will be downloaded to the target with the built user program.

Directives Section

This section is an appropriate place to put any directives to the DPL compiler. For more information, see:

  • Directives

Aliases Section

$defines do not affect any code which occurs before them in the DPL program. To reduce the likelihood of errors and to increase the readability of programs it is recommended that any $defines are placed in an Alias section prior to any code sections in the DPL program. For more information, see:

  • Aliases

Constants cannot be used in code until they have been declared. Constants should be placed at the top of the DPL program after any directives. For more information, see:

  • Constants

Code Section

The final section in a DPL program is the Code section. Any tasks, subroutines and user-defined function blocks should be placed in this section at the end of the file. These items contain the executable code in the user program. Tasks, subroutines and UDFBs can contain DPL code, QLD diagrams and LD/ FB diagrams. It is possible to mix DPL code and diagrams inside a single entity. Follow the links below to find more information:

  • Tasks

  • Subroutines

  • User-Defined Function Blocks (UDFBs)

See Also

  • Reference

  • Developing Applications

________________________________________________________________________________

Tasks

Tasks are code sections executed directly by the target system. Code should be written in tasks to call the subroutines and UDFBs within the user program. There are five kinds of task as shown in the following table.

For more information on the tasks supported by specific targets see the target manuals which are accessible from the Help menu. Each target supports a slightly different set of tasks. The names of the tasks are predefined for each target, i.e. a DPL program can only the tasks supported on a target - the user cannot define new tasks.

The code within the task body can be written in DPL, QLD or LD/ FB. The code can read or write variables, parameters and PLC registers. A single task can contain any mixture of DPL and diagrams. For example

All variables declared in tasks are global to the program. This means that variables used in tasks can be read and written to in any other task or subroutine within the DPL program.

Note:

User-defined function blocks and tasks cannot access each others variables - values can only be exchanged via the function block inputs and outputs when the task calls the function block.

To aid debugging, it is possible to set execution breakpoints in tasks and monitor the values of parameters and variables in tasks when online and communicating with a target.

Tasks cannot be called from other tasks, subroutines or user-defined function blocks - they are always executed directly by the target system.

See Also

  • Subroutines

  • User-Defined Function Blocks (UDFBs)

  • Debugging Applications

  • Developing Applications

  • Variables

  • Parameters

  • PLC Registers

________________________________________________________________________________