Library development

Topics:

  1. Library names [++]
  2. Revision control [++]
  3. Encapsulation of internal type definitions [+]
  4. Identifiers in libraries [+]

Library names

Beckhoff PLC libraries start with the prefix Tc (e.g.: Tc3_EventLogger), have the file name extension *.compiled-library and are included in the library repository.

Choose library names that are short, yet unambiguous.

The namespace of a Beckhoff PLC library matches the name of the library.

The default placeholder of a Beckhoff PLC library matches the name of the library.

Revision control

Each PLC library has a four-digit version number (Major.Minor.Build.Revision).

Major

The first digit is incremented if the new version is incompatible with the previous version.
Thereby the digits for minor and build are reset to one.

Minor

The second digit is incremented if the new version includes function expansion.
In this case, the digit for Build is reset to one.

Build (Patch)

The third digit is incremented if the new version contains only bug fixes.

Revision

The fourth digit is always zero, if it is a release version.

If a PLC library is still in beta status, it is major version zero or a version number 0.x.y.z. A release version has at least the version number 1.1.1.0.

If other program parts provide a three-digit version (Major.Minor.Patch), the first three digits can be used accordingly (Build = Patch).

Encapsulation of internal type definitions

To prevent the use of internal type definitions from outside the library and to highlight to the user the POUs and DUTs that are relevant to him, encapsulation is used in PLC libraries. The access specifier INTERNAL is recommended for this purpose.

The PRIVATE access specifier can also be used for individual methods of function blocks. To hide local variables of function blocks, the Attribute 'conditionalshow_all_locals' can be used.

Identifiers in libraries

To prevent compiler errors to duplicate identifiers and to allow the library to be used without a mandatory namespace, the use of an additional abbreviation in the identifiers is recommended. This abbreviation of the library name is placed between the prefix and the actual name of the respective type.

Likewise, global variable lists of a library should be supplemented with the abbreviation to avoid multiple existence of lists named 'GVL'.

Samples (from the PLC library Tc3_Filter):

STRUCT ST_FTR_PT1
ENUM E_FTR_Type
FUNCTION_BLOCK FB_FTR_PT1
VAR_GLOBAL GVL_FTR

 

See also: