Loading Control libraries

Apart from the functions listed in the following sections, you can also use in a Control script all functions held in a file in the libs directory under the Scripts directory. Library functions which contain functions which can only be called from a Control Manager or - like setValue() - only from the UIM, can only be used in these managers.

The Control library can be modified by the user (even at runtime) in any text editor. Using the menu option "Control Libraries", a library file can also be loaded directly into the script editor of the GEDI module, which also provides a syntax checker when editing the file.

Every time a panel is opened in the PARA module or via a data selection dialog in the VISION module, the user interface manager checks whether a library file has changed. If the library has changed and no scripts are currently running, the new library file is opened. If scripts are running, however, the warning Library in use is issued. If a library file contains syntax errors it is not loaded. The file name and line number of the error is output however.

Several CTRL scripts

It is possible to run several scripts with one CTRL Manager (WCCOActrl). To do this you specify the option -f followed by the file name of a CTRL script list.

Example

WCCOActrl -f pvss_scripts.lst

It is not necessary to define the file extension for scripts. Per default script extensions are browsed in the following order:

1. given name

2. <Name>.ctl

3. <Name>.ctc

The CTRL script list pvss_scripts.lst is an ASCII file in which you can enter the file names of several CTRL scripts, one on each line. All scripts specified are run by the CTRL Manager, with the first script in the list being executed first. The script list can also contain comment lines and blank lines (comment lines begin with "#"). A search is made for the script list itself in all script directories for the project, in exactly the same way as for each CTRL script.

Configuration of the libraries

Via the keyword #uses you can specify which CTRL, DLL or shlib libraries are needed in a script or in a panel. Therefore, the libraries must not be entered into the config file anymore. This facilitates the use of the libraries and the libraries are loaded first when they are needed. Which CTRL libraries a manager should load can also be defined via entries in the config.levelfile. We, however, recommend to use the keyword #uses. How to use the keyword #uses or how you can define which CTRL libraries should be loaded via the entries in the config.levelfile are described in the following.

If your panels need functions from CTRL libraries and the functions are not loaded by default load them as described below.

Keyword #uses

Via the keyword #uses you can define which CTRL,DLL or shlib library a panel or a script needs.

#uses "myLib.ctl"

It is not necessary to define the file extension for script libraries. Per default libraries and control extensions are browsed in the following order:

1. given name

2. <Name>.ctl

3. <Name>.ctc

4. <Name>.dll or <Name>.so

or a DLL

#uses "CtrlADO"

If #uses is used for a DLL/shlib, do not specify a file extension since the CTRL searches the right file depending on the platform. For #uses "CtrlADO" the CtrlADO.dll is loaded under Windows and the CtrlADO.so under Linux. The extension must, however, be used for own script libraries like #uses "myLib.ctl".

The CTRL, DLL or shlib libraries specified in a script or in a panel are not valid only in the script but manager wide and remain in the memory until the manager is stopped. The libraries are loaded into the memory by the CTRL kernel. The keyword can be used in each script before the functions and in panel global functions. An arbitrary number of #uses definitions can be used in panels and scripts. If you want to include a library that requires another library (for example, myLib.ctl requires yourLib.ctl and yourLib.ctl requires xLib.ctl) you only have to include yourLib.ctl. Note that the opening of panels may take a little bit longer when one or more big libraries are loaded for the first time.

Note that "uses" is a keyword and may not be used as a variable name.

Entries in the config.level file

There is a standard file <wincc_oa_path>/config/config.level which specifies which CTRL library each manager should load. It contains the default settings for managers.

These defaults are read automatically from the config.level file of the program directory. This file should not be changed! Changes to the defaults must be made in a config.level file of the project directory! If a config file is located in the project directory this is read first. Thereafter the file located in the version is read. If there is a remote project that uses the local project as server project this file is read as last one. The sequence is:

1. Project file

2. Version file

3. Remote project that uses the local project as server project

The entries are made in sections of the config.level file belonging to each of the managers , for example, [ui], [ctrl] etc. The section [ui_extend] has been inserted for PARA and GEDI: a manager that is run with -extend or -m para or -m gedi (PARA, GEDI) then also reads this section [ui_extend]. For all managers, 3 keywords have been introduced for the config.level file:

LoadAllCtrlLibs

Spelling with a lower case l is allowed for the LoadAllCtrlLibs, LoadCtrlLibs and UnloadCtrlLibs entries, e.g. loadAllCtrlLibs. The entries are not case-sensitive.

Type: unsigned

Default: 0 (Range:0/1)

With the value 1, the manager behaves as it used to behave, and loads all files from the directory scripts/libs. This keyword means that the entries LoadCtrlLibs and UnloadCtrlLibs have no effect. The default is to load only those CTRL Libraries that are explicitly listed.

LoadCtrlLibs

Located in a manager-specific section and loads all specified libraries of the manager. The library names are separated by commas. The keyword can be used as many times as required. A library loaded by this entry can be removed again by a subsequent UnloadCtrlLibs entry.

Scripts that are empty or begin with "." are not loaded!

UnloadCtrlLibs

Located in a manager-specific section and removes the specified library from the list of all libraries that this manager is meant to load. The library names are separated by commas. The keyword can be used as many times as required. A library removed by this entry can be loaded again by a subsequent LoadCtrlLibs entry.

Example

[ctrl_1]

LoadCtrlLibs = "archiv.ctl"

The CTRL with the number 1 needs "archiv.ctl" for data archiving.

[ui]

LoadCtrlLibs = "archiv.ctl, libTOOLs"

The UI starts panels for data archiving.

Loading Ctrl libraries by command line

-loadCtrlLibs <list> e.g. WCCOActrl.exe -loadCtrlLibs
                    list.lst

Loads the defined Ctrl libraries. <list> (an .lst file) is a list of libraries like it can be defined in the config file without quotation marks.

In the same manner the command line option -LoadNoCtrlLib und -LoadAllCtrlLibs can be used.

-LoadNoCtrlLib empties the list of libraries loaded. However, this can be re-filled with new libraries using the option
-LoadCtrlLibs
                    <list>
in the same command line.

Example

WCCOActrl.exe -loadNoCtrlLib -loadCtrlLibs javaui.ctc

Only the Ctrl library "javaui.ctc" is loaded after the list of libraries to be loaded was emptied.