Use the right way for referencing other Libraries (Required)
Common Libraries: Placeholder Reference
Interface Libraries: Newest Constraint
Container Libraries: Absolute Reference
In the world of CODESYS libraries there is a main basic principle: “There can be only one!”
This famous quotation from the Highlander Saga wants to be understood as follows: In the memory of a controller at a definite time there should be used a definite version of a definite library. In exceptional cases it might be well to be able to use more than one version of a library (in such a case however with different namespaces), but usually it won’t. It is a great strength of CODESYS, that new libraries can be created easily by reusing existing libraries. By consequently using this possibility in CODESYS, deeply nested library hierarchies may result. However for those the same base principle must apply: If possible, at a definite time there should be just one definite version of a library in the controller’s memory. Besides the saving of memory space this will ensure that all overlaid libraries are using the same code via the same interfaces with the same data types.
In the course of time, for the different library types certain methods have arised for maintaining the network of dependencies between the libraries with a minimum effort.
Asterisk References (“Newest-Constraint”) |
This method requires no definite version of the library to be referenced. Automatically the latest version available in the library repository will be used for compilation. This is a very effective way of referencing, however also has some drawbacks. Always when a new version of a certain library gets installed in the library repository, all projects and libraries referencing this library with the “newest” constraint, will get changed. Usually this is not the desired behaviour. |
Absolute References |
This method of referencing requires to exactly define within a library, which version of another library should be used. CODESYS itself gets no chance to modify the defined relationships. This very rigorous way of referencing however harbours a high maintenance effort. Always when an underlaid library gets changed, then the reference of the respective overlaid libraries must be adapted. Due to the fact that the modification of the reference forces a change of the library version, this process is necessary over all layers up to the root of the library hierarchy. |
Placeholder Reference |
The advantages of the absolute references are clear. They result in exactly defined relationships among the libraries. The disadvantage however is the high adaptation effort in case an underlaid library changes. By introducing so-called placeholders this disadvantage could be eliminated. Now there is a location outside of the respective library, where an exact reference of another library can be specified: The placeholder definition. There the relevant properties of a library reference (Name, Company and Version) can be assigned to a placeholder name. So in the particular library another library can be referenced merely by its placeholder. If this underlaid library changes, “only” the placeholder definition will have to be adapted accordingly, not however each library using this placeholder. The references of all libraries, which each reference the other library, will get changed automatically. For a more detailed explanation about placeholders have a look at Placeholder. However, if references again might change also unintentionally, what is the benefit compared to using the Asterisk References? There are various places for the definition of placeholders. Depending on the definition place and the CODESYS component, the resolution of the placeholders to definite library versions will be treated differently.
With this measurements you are able to control very exactly, in which context the relationships of certain library families should be treated. Only by re-setting certain CODESYS parameters automatically the appropriate placeholder groups will be switched.
Placeholder references, in contrast to the asterisk references, get not changed merely by the - often accidentally done - installation of a newer library version. Placeholder references get only changed by a deliberate switching to newer versions of certain CODESYS components (device description, compiler, package, project) |