Libraries of sub-programs and UDFBs
The Workbench Studio enables you to create pure "libraries" of sub-programs, UDFBs and data structures to be referenced in projects. The link with libraries is automatically performed each time the project is open or re-built. This ensures you that your project always use the latest version of library objects, but it imposes that the library forlder is found at build time.
|
Alternatively, you can use other methods for sharing programs and sub-programs. |
What is a library ?
A "library" is similar to a project, but has a special "mark" so that it can be used as a library. All sub-programs, UDFBs and data structures of a library can be used in projects referring to it. Additionnaly, the library can be open as a normal project, and may contain other material (main programs, global variables...) in order for the library designer to test and validate locally the shared objects of the library.
Creating a library
To create a library, use the File / New Project command, and select the Library choice in the upper side list of the project creation wizard. The Workbench Studio uses different color settings when editing a library. You can also use the File / Save Project As menu command to save an existing project as a library or the opposite.
Structured organisation of a library
When a library is linked to a project, all blocks are shown in the tree view of the project workspace and can be moved into subfolders.
POUs can also be hidden in the list of blocks. All POUs under a folder with the name Hidden will not be visible in the list of blocks.
Linking a project to libraries
In order to use library items in a project, you must link it to the library. For that run the Libraries popup menu command when a project is selected in the workspace. A box is open and shows the list of already linked libraries. Press the Add button to browse the disk for a library folder to be used in the project. Press the Remove button to unlink the project from the library selected in the list. Libraries are checked and scanned when you close the box.
A project can be linked to several libraries.
Library items (sub-programs and UDFBs) are not visible in the Workspace area, but can be selected from the bottom-right list area in the Workbench Studio.
Any sub-program or UDFB of a linked library can be used in a program as any other block. The definition of the library blocks (their inputs and outputs) is refreshed automatically:
- When the project is open.
- Before the project is build.
- When you close the library selection box (even with no change).
If the project refers to a library that actually does not exist, an error message is displayed. Compiling errors will happen in that case if you use in your programs items of the missing library.
|
|
|
|
|
|
A library can be linked to another library. But in that case, when used in a project, the project must be linked to both of them. |
|
|
Tree |
Description |
|
Project1 |
"Project1" must be linked to "LIB1" and "LIB2" |
|
uses LIB1 |
"LIB1" must be linked to "LIB2" |
|
uses LIB2 |
|
You can never open the contents (source code) of a library item from a project. When debugging, you cannot step into a UDFB or sub-program from a library. Library items are not scanned during a "Find in files" research.
Libraries of sub-programs and UDFBs |
IEC 61131-3 Automation platform > IEC 61131-3 Programming Environment > Libraries > Libraries of sub-programs and UDFBs |
Created with the Personal Edition of HelpNDoc: Effortlessly Convert Your Word Doc to an eBook: A Step-by-Step Guide