Service_SystemLink()

Example
// assuming you declared <service-systemlink> with the id, "service_systemlink"
var mySL = document.getElemenyById("service_systemlink").getService();
mySL.setAttribute("apikey", "YOUR API KEY");
mySL.init();

Methods

async, inner init(APIKeyInput, pollIntervalInput) → {boolean}

initialize SystemLink_Service

Starts polling the System Link cloud

this function needs to be executed after executeAfterInit but before all other public functions

Parameters:
Name Type Description
APIKeyInput string

SYstemlink APIkey

pollIntervalInput integer

interval at which to get tags from the cloud in MILISECONDS. Default value is 1000 ms.

Returns:
boolean -

True if service was successsfully initialized, false otherwise

Example
var SystemLinkElement = document.getElemenyById("service_systemlink");
var mySL = SystemLinkElement.getService();
mySL.init("APIKEY", 1000); // initialize SystemLink Service with a poll interval of 10 ms

inner executeAfterInit(callback)

Get the callback function to execute after service is initialized

This function needs to be executed before calling init()

Parameters:
Name Type Description
callback function

function to execute after initialization

Example
mySL.executeAfterInit( function () {
    var tagsInfo = mySL.getTagsInfo();
})

inner getTagsInfo()

Return the tagsInfo global variable

Returns:
-

basic information about currently existing tags in the cloud

Example
var tagsInfo = mySL.getTagsInfo();
var astringValue = tagsInfo["astring"]["value"];
var astringType = tagsInfo["astring"]["type"];

inner setTagValueNotStrict(tagName, newValue, callback)

Change the current value of a tag on SystemLink cloud with strict data types. Values will be implicitly converted
NotStrict property indicates that the data type of the Value supplied will be implicitly converted. For example, allowing for setting an INT tag's value with a string, "123" or a STRING tag's value with a number. This method exists for convenience but please avoid using it extensively as it can lead to unpredictable outcomes.

Parameters:
Name Type Description
tagName any
newValue any
callback any
Example
// set a string type Value of a Tag and display
mySL.setTagValueNotStrict("message", 123, function () {
   let messageValue = mySL.getTagValue("message");
   console.log("message: ", messageValue); // display the updated value, which will be 123.
})
// set value of a boolean Tag
mySL.setTagValueNotStrict("aBoolean", true);

// set value of an integer Tag
mySL.setTagValueNotStrict("anInteger", 10);
mySL.setTagValueNotStrict("anInteger", "10");

// set value of a double Tag
mySL.setTagValueNotStrict("aDouble", 5.2);
mySL.setTagValueNotStrict("aDouble", "5.2");

inner setTagValueStrict(name, value, callback)

Change the current value of a tag on SystemLink cloud with strict data types. There will be no implicit data type conversions. E.g. Updating tags of INT type will only work with javascript number.

Parameters:
Name Type Description
name any

name of tag to update

value any

value to update tag to

callback any

function to execute after tag is updated

Example
// set a string type Value of a Tag and display
mySL.setTagValueStrict("message", "hello there", function () {
   let messageValue = mySL.getTagValue("message");
   console.log("message: ", messageValue); // display the updated value
})
// set value of a boolean Tag
mySL.setTagValueStrict("aBoolean", true);

// set value of an integer Tag
mySL.setTagValueStrict("anInteger", 10);

// set value of a double Tag
mySL.setTagValueStrict("aDouble", 5.2);

inner getTagValue(tagName) → {any}

Get the current value of a tag on SystemLink cloud

Parameters:
Name Type Description
tagName string
Returns:
any -

current value of tag

Example
messageValue = mySL.getTagValue("message");
console.log("message: ", messageValue);

inner isActive() → {boolean}

Get whether the Service was initialized or not

Returns:
boolean -

whether Service was initialized or not

Example
if (mySL.isActive() === true)
    // do something if SystemLink Service is active

inner createTag(tagName, tagValue, callback)

Create a new tag. The type of new tag is determined by the javascript data type of tagValue.

Parameters:
Name Type Description
tagName string

name of tag to create

tagValue any

value to assign the tag after creation

callback function

optional callback

Example
mySL.createTag("message", "hi", function () {
     mySL.setTagValueStrict("message", "bye"); // change the value of 'message' from "hi" to "bye"
})

inner deleteTag(tagName, callback)

Delete tag

Parameters:
Name Type Description
tagName string

name of tag to delete

callback function

optional callback

Example
mySL.deleteTag("message", function () {
     let tagsInfo = mySL.getTagsInfo();
     console.log("tagsInfo: ", tagsInfo); // tags information will now not contain the 'message' tag
})