Code Snippets


Attention: This documentation refers to the current state of the respective libraries or control extension.

Instantiate SLTLicense

CONTROL-WinCC OA

#uses "SLTLicenseCtrlExt"

The SLTLicense does not need to be instantiated. However, # uses "SLTLicenseCtrlExt" must be used to include the CtrlExt provided by SloopTools in the installation layer.

C++

Link for determining the item number or the product code

std::string projectName = Resources::getProjectName(); //WinCC OA API functionality
std::string serverAddress = Resources::getEventHostName();
std::string productCode = "YOUR_ITEM_NUMBER_OR_PRODUCT_CODE";

SLTLicenseCheck licenseCheck(_projectName, configValueStr);
licenseCheck.setItemNumber(productCodeStr);

If more than one product is to be checked, the product code to be checked must be set with setItemNumber before the next check.

C#

Link for determining the item number or the product code

string productCode = "YOUR_ITEM_NUMBER_OR_PRODUCT_CODE";
string projectName = ETM.WCCOA.Internal.Resources.GetProjectName();
string serverAddress = ETM.WCCOA.Internal.Resources.GetEventHostName();

SLTLicense sltLicense = new SLTLicense(productCode, projectName, serverAddress);

License check

CONTROL-WinCC OA

if ( sltCheckLicense("YOUR_ITEM_NUMBER_OR_PRODUCT_CODE") )
{
    //do something
}

C++

Link to identify the Add-on Internal Version

std::string internalVersionStr = "YOUR_ADDON_INTERNAL_VERSION";
RETURN_VALUES value = licenseCheck.sltCheckLicense(internalVersionStr);
if ( value == RETURN_VALUES::OK )
{
    //do something
}
else
{
    if ( value == RETURN_VALUES::NOK )
    {
        //e.g.: Error message
    }
    else //Return_VALUES::WRONG_VERSION
    {
        //e.g.: Wrong version message
    }
}

C#

Link to identify the Add-on Internal Version

string internalVersion = "YOUR_ADDON_INTERNAL_VERSION";
RETURN_VALUES_W value = licenseCheck.sltCheckLicense(internalVersion);
if (value == RETURN_VALUES_W.OK)
{
    //do something
}
else
{
    if (value == RETURN_VALUES_W.NOK)
    {
        //e.g.: Error message
    }
    else //Return_VALUES_W.WRONG_VERSION
    {
        //e.g.: Wrong version message
    }
}

Occupy & release license

CONTROL-WinCC OA

if ( sltOccupyLicense("YOUR_ITEM_NUMBER_OR_PRODUCT_CODE") )
{
    //do something

    //when finished
    sltReleaseLicense("YOUR_ITEM_NUMBER_OR_PRODUCT_CODE");
}

C++

Attention: To use this method you need the latest version of the SLTLicense library.

Link to identify the Add-on Internal Version

std::string internalVersionStr = "YOUR_ADDON_INTERNAL_VERSION";
RETURN_VALUES value = licenseCheck.sltOccupyLicense(internalVersionStr);
if ( value == RETURN_VALUES::OK )
{
    //do something

    //when finished
    licenseCheck.sltReleaseLicense();
}
else
{
    if ( value == RETURN_VALUES::NOK )
    {
        //e.g.: Error message
    }
    else if ( value == RETURN_VALUES::WRONG_VERSION )
    {
        //e.g.: "Wrong version" message
    }
    else if ( value == RETURN_VALUES::ALREADY_OCCUPIED )
    {
        //e.g.: "License already in use" message
    }
}

C#

Currently not available


Decrease the unit counter

If the license reaches UnitCounter = 0 the license becomes invalid. The normal license check "sltCheckLicense" then returns a negative value.

CONTROL-WinCC OA

int unitCounter = sltDecreaseUnitCounter("YOUR_ITEM_NUMBER_OR_PRODUCT_CODE", amount);

C++

int unitCounter = licenseCheck.sltDecreaseUnitCounter(amount);

C#

int unitCounter = licenseCheck.sltDecreaseUnitCounter(amount);

Decrease the unit counter (Limited)

When this method function is used, the unit counter can not be reduced to less than 1. This will not invalidate the license. However, it must be checked manually if the minimum has already been reached to disable the functionality bound to it. Example: no further UIs may be registered.

CONTROL-WinCC OA

int unitCounter = sltDecreaseUnitCounterChecked("YOUR_ITEM_NUMBER_OR_PRODUCT_CODE", amount);
if ( unitCounter == 1 )
{
    //e.g.: warning no more units & disable functionality
}

C++

int unitCounter = licenseCheck.sltDecreaseUnitCounterChecked(amount);
if ( unitCounter == 1 )
{
    //e.g.: warning no more units & disable functionality
}

C#

int unitCounter = licenseCheck.sltDecreaseUnitCounterChecked(amount);
if ( unitCounter == 1 )
{
    //e.g.: warning no more units & disable functionality
}

Read the unit counter

Queries the UnitCounter of the license. (Only if there is a UnitCounter)

CONTROL-WinCC OA

Link for determining the item number or the product code

int unitCounter = sltGetUnitCounter("YOUR_ITEM_NUMBER_OR_PRODUCT_CODE");

C++

int unitCounter = licenseCheck.sltGetUnitCounter();

C#

int unitCounter = licenseCheck.sltGetUnitCounter();

Check Featuremap

Returns the Int value of the 32Bit FeatureMap. With this value, it must then be checked whether which bits are set in order then to enable the respective functions.

CONTROL-WinCC OA

Link for determining the item number or the product code

int featureMap = sltGetFeatureMap("YOUR_ITEM_NUMBER_OR_PRODUCT_CODE");

bool is_set = (featureMap & (1 << pos)) != 0;

if ( is_set )
{
    //e.g.: unlock functionality
}

C++

int featureMap = licenseCheck.sltGetFeatureMap(); //Featuremap as int

typedef std::bitset<sizeof(int)> IntBits;
bool is_set = IntBits(featureMap).test(position); //check bit(position) from featureMap

if ( is_set )
{
    //e.g.: unlock functionality
}

C#

int featureMap = licenseCheck.sltGetFeatureMap(); //Featuremap as int

bool is_set = (featureMap & (1 << pos)) != 0;

if ( is_set )
{
    //e.g.: unlock functionality
}

Read product text

Returns the product text from the license. From this one you can also determine whether the license is a demo license. You can then unlock special features for the demo period for the customer.

CONTROL-WinCC OA

Link for determining the item number or the product code

string productText = sltGetProductText("YOUR_ITEM_NUMBER_OR_PRODUCT_CODE");

if(strpos(productText,"- DEMO |") >= 0)
{
    //e.g.: unlock demo special demo functionality
}

C++

std::string productText = licenseCheck.sltGetProductText();

if ( productText.find("- DEMO |") != std::string::npos )
{
    //e.g.: unlock demo special demo functionality
}

C#

Currently not available


Read extended license data

If certain data of the license is needed this can be queried with this method / function. The index of the information to be requested is required.

Name Index Display name
Order data 0 OrderData
Ticket 10 Ticket
Software 11 Software
Projektinfo 12 ProjectInfo
User who activated the license 13 ActivationUser
Activation data 14 ActivationData
Add-on Version at activation 15 ActivationVersion
Provider order data 20 ProviderOrderData
Provider Activation data 30 ProviderActivationData
Provider Secret Key 99 ProviderSecretKey

CONTROL-WinCC OA

Link for determining the item number or the product code

string data = sltGetExtendedData("YOUR_ITEM_NUMBER_OR_PRODUCT_CODE", index)
string providerOrderData = sltGetProviderOrderData("YOUR_ITEM_NUMBER_OR_PRODUCT_CODE")
string providerActivationData = sltGetProviderActivationData("YOUR_ITEM_NUMBER_OR_PRODUCT_CODE")

C++

std::string data = licenseCheck.sltGetExtendedData(index);

C#

string data = licenseCheck.sltGetExtendedData(index);

Determine expiry time

This can be used to determine the seconds up to the time when the license is invalid. Only possible with subscription license.

CONTROL-WinCC OA

Link for determining the item number or the product code

time elapsedSeconds = sltGetExpirationTime("YOUR_ITEM_NUMBER_OR_PRODUCT_CODE");

C++

time_t elapsedSeconds = licenseCheck.sltGetExpirationTime();
TimeVar timeVar.setValue(BC_CTime(elapsedSeconds), 0);

C#

time_t elapsedSeconds = licenseCheck.sltGetExpirationTime();

Check Add-on version

If the installed version of the Add-on is larger than the version for which the license was activated, FALSE will be rebuilt.

CONTROL-WinCC OA

Link for determining the item number or the product code

bool suitableVersion = sltCheckAddonVersion("YOUR_ITEM_NUMBER_OR_PRODUCT_CODE");

C++

Link to identify the Add-on Internal Version

bool suitableVersion = licenseCheck.sltCheckAddonVersion("YOUR_ADDON_INTERNAL_VERSION");

C#

Link to identify the Add-on Internal Version

bool suitableVersion = licenseCheck.sltCheckAddonVersion("YOUR_ADDON_INTERNAL_VERSION");

Get last error

Returns the last error that occurred.

CONTROL-WinCC OA

mapping lastError = sltGetLastError();

C++

Attention: To use this method you need the latest version of the SLTLicense library.

Returns the last error code set by the CmEmbedded library.

int errorCode = licenseCheck.sltGetLastErrorCode();

C#

Currently not available


results matching ""

    No results matching ""