Installation Layer
The Installation Layer (IL) is an add-on which has to be obtained from the Slooptools Store and installed via the installer. As with the other add-ons, the structure is based on a WinCC OA subproject. This add-on also includes the SLTLicenseCtrlExt. This is necessary to be able to check the licenses of the add-ons.
The installation layer is responsible for the installation of other add-ons. The central element here is the installation layer script, which is automatically added to the console when adding the IL to a project. This checks when starting the script and every 5 min if new add-ons have been installed. If an add-on was found, the IL performs the following actions on each add-on:
- Create a _Slooptools_Add_ons data point.
- Write the information from the AddonInformation.json file to the created data point.
- Add a menu entry to the Slooptools category in the system management. This menu entry opens a panel in which information about the add-on is displayed. If there is an AddonInfo.pnl under "panels / [extended_technical_name] /" when creating the menu entry this will be used in the future when opening the menu.
- If an updateAddon.ctl script exists under "scripts / [extended_technical_name] /", it will be executed by the installation layer. This script can be used to e.g. create required data points. For more details see Custom update script.
SLTLicense Control Extension
With the installation layer the SLTLicenseCtrlExt is delivered. The following functions are provided by the Control Extension:
bool sltCheckLicense (string itemNumber)
- Checks if the license is valid and if the add-on with the license can be used.
int sltDecreaseUnitCounter (string itemNumber, int amount)
- Decreases the UnitCounter of the respective license. (Only if there is a UnitCounter)
- Example: The license is valid for [X] hours / days. As soon as the counter was decremented the last time (Counter = 0), the license is invalid.
int sltDecreaseUnitCounterChecked (string itemNumber, int amount)
- Decreases the UnitCounter of the respective license, but not below 1. (Only if a UnitCounter exists.) If the UnitCounter is reduced to 0, the license will be invalidated, there may be cases where this is not desired)
- Example: The license is valid for [Y] widgets. Then the last decrementing should not set the counter to 0 because otherwise the complete license would be invalid, which does not correspond to the license type.
int sltGetUnitCounter (string itemNumber)
- Queries the UnitCounter of the license. (Only if there is a UnitCounter)
string sltGetExpirationTime (string itemNumber)
- Returns the expiration date of the license in the format "% Y-% m-% dT% I:% M:% S" (Only if there is an expiry date)
int sltGetFeatureMap (string itemNumber)
- Returns the Int value of the 32Bit FeatureMap
string sltGetProductText (string itemNumber)
- Returns the product name and the provider name with | separated. Example: SloopTools | SLT_Installation_Layer
bool sltOccupyLicense (string itemNumber)
- Checks if the license is valid, if the add-on can be used with the license and occupies it.
- Other function calls with the same itemNumber (for example: sltDecreaseUnitCounter, sltGetFeatureMap, ...) are performed with the occupied license.
- In order to use the assigned license for other projects, it must be released with sltReleaseLicense.
string sltReleaseLicense (string itemNumber)
- Free a occupied license.
- If there is no occupied license under the ItemNumber, nothing happens.
Each of these functions uses the ItemNumber. The ItemNumber of the add-on is the data point name of the respective add-on of the data point type "SloopTools_Add_ons" whereby in WinCC OA the hyphen "-" was replaced by an underscore "\" due to WinCC OA defaults. The CtrlExtension can handle both types.
These functions can be used in appropriate places in the code as described here. However, the following criteria should be taken into account:
- Checks should take place regularly but not in too short intervals.
- The license should be checked at a central point. It should be prevented that the license is checked in each function call. This would technically be possible, but would reduce the performance of the add-on.
- sltCheckLicense, sltGetUnitCounter and sltGetFeatureMap are replaced by corresponding functions during the Quality Gate (QG) to ensure additional security. This also means that these functions can not be used normally without a Quality Gate Check. If the add-on needs to be tested without QG, it is necessary to replace these functions for the test.
- Using #uses SLTLicenseCtrlExt
The licenses are tied to the project. This means that other projects using the same add-on on the same computer will also need a license.
Custom update script
If, in addition to normal installation, e.g. Data point types or data points must be created, it is possible to provide a custom update script. This must be stored under "scripts / [techAdd-OnName] /" as updateAddon.ctl. This script must have the following function:
main (int currentVersion, int updateVersion)
{
}
Functionalities can now be executed in this script, depending on the versions before and after the update.
This script will run at the following times:
- After the first installation of the add-on
- After every update of the add-on
- currentVersion = previously installed version
- updateVersion = with the update now new version