Class: Widget

Widget

The Widget handles the access to sensors.

abstractnew Widget()

Constructor: Generates the ID and initializes the Widget with attributes, callbacks and subscriber that are specified in the provided functions.

Members

protectedcallbacksCallbackList

List of Callbacks.

protectedconstantAttributesAttributeList

All available constant Attributes and their values.

idstring

ID of the Widget. Will be generated.

namestring

Name of the Widget.

protectedoldAttributesAttributeList

This temporary variable is used for storing the old attribute values. So these can be used to check conditions.

protectedsubscribersSubscriberList

List of Subscriber.

Methods

protected_addConstantOutAttribute(constantAttribute)

Adds a new constantAttributeValue. If the given value is not included in the list, the associated type will be also added. Otherwise, only the value will be updated.

Name Type Description
constantAttribute Attribute

AttributeValue

protected_init()

Function for initializing. Calls all initFunctions and will be called by the constructor.

abstract,protected_initCallbacks()

Initializes the provided Callbacks.

abstract,protected_initConstantOutAttributes()

Initializes the provided ConstantAttributes.

abstract,protected_initOutAttributes()

Initializes the provided Attributes.

abstract,protected_intervalRunning(interval)

Runs the context acquisition constantly in an interval. Can be called by init.

Name Type Description
interval Number

Interval in ms

protected_register()

Registers the component to the associated Discoverer.

protected_sendResponse(response, callback)

Name Type Description
response
callback

protected_sendToSubscriber(callback)

Sends all Attributes, specified in the given callback, to components which are subscribed to this Callback.

Name Type Description
callback string

Name of the searched Callback.

protected_setOutAttributes(attributesOrArray)

Sets the AttributeValueList and also the associated AttributeTypes.

Name Type Description
attributesOrArray AttributeList | Array

List or Array of AttributeValues

protectedaddCallback(callback)

Adds a new Callback.

Name Type Description
callback Callback

List or Array of AttributeValues.

addOutAttribute(attribute, multipleInstances)

Adds a new AttributeValue. If the given value is not included in the list, the associated type will be also added. Otherwise, only the value will be updated.

Name Type Description
attribute Attribute
multipleInstances Boolean

addSubscriber(subscriber)

Adds a new Subscriber.

Name Type Description
subscriber Subscriber nullable

Subscriber

abstractdidFinishInitialization(attributes)

Method will be invoked after the initialization of the widget finished. Can be overridden by inheriting classes to take action after initialization.

Name Type Description
attributes

doesSatisfyTypeOf(attribute){boolean}

Returns true if the widget can satisfy the requested attribute type.

Name Type Description
attribute AttributeType
Returns:
Type Description
boolean

Returns a list of callbacks that can be subscribed to.

Returns:
Type Description
CallbackList

getCallbacks(){Array}

Returns the specified callbacks that can be subscribed to.

Returns:
Type Description
Array

getConstantOutAttributes(attributes){AttributeList}

Returns the available ConstantAttributeTypes (attributes that do not change).

Name Type Description
attributes AttributeList nullable
Returns:
Type Description
AttributeList

getId(){string}

Returns the id of the widget.

Returns:
Type Description
string

getName(){string}

Returns the name of the widget.

Returns:
Type Description
string

getOutAttributes(attributes){AttributeList}

Returns the available AttributeTypes.

Name Type Description
attributes AttributeList optional nullable
Returns:
Type Description
AttributeList

Returns the Subscriber.

Returns:
Type Description
SubscriberList

abstractgetType(){string}

Returns the type of this class, in this case "Widget".

Returns:
Type Description
string

getValueForAttributeWithTypeOf(attributeType){*}

Returns the last acquired attribute value with the given attribute type.

Name Type Description
attributeType AttributeType

The attribute type to return the last value for.

Returns:
Type Description
*

protectedisOutAttribute(attribute){boolean}

Verifies whether the specified attributes is a provided Attribute.

Name Type Description
attribute Attribute
Returns:
Type Description
boolean

abstractnotify()

Notifies other components and sends the attributes.

putData(attributes)

Updates the Attributes by external components.

Name Type Description
attributes AttributeList | Array

Data that should be entered.

abstractqueryGenerator(callback)

Name Type Description
callback

Returns all available AttributeValues, Attributes and ConstantAttributes.

Returns:
Type Description
AttributeList

removeSubscriber(subscriberId)

Removes the specified Subscriber.

Name Type Description
subscriberId Subscriber

Subscriber

abstractsendToSubscriber(callback)

Queries the associated sensor and updates the attributes with new values. Must be overridden by the subclasses. Overriding subclasses can call this.__super(_function) to invoke the provided callback function.

Name Type Description
callback function nullable

For alternative actions, because an asynchronous function can be used.

protectedsetCallbacks(callbacks)

Sets Callbacks.

Name Type Description
callbacks CallbackList | Array

List or Array of Callbacks.

protectedsetConstantOutAttributes(constantAttributes)

Sets the ConstantAttributeValueList and also the associated AttributeTypes.

Name Type Description
constantAttributes AttributeList | Array

List or Array of AttributeValues

setDiscoverer(_discoverer)

Sets the associated Discoverer and registers to that.

Name Type Description
_discoverer Discoverer

Discoverer

protectedsetId(id)

Sets the id of the Widget.

Name Type Description
id string

Id of the Widget.

protectedsetName(name)

Sets the name of the Widget.

Name Type Description
name string

Name of the Widget.

protectedsetSubscriber(subscribers)

Sets SubscriberList.

Name Type Description
subscribers SubscriberList | Array

List or Array of Subscriber.

updateAndQueryWidget(callback){AttributeList}

Updates and returns all available AttributeValues, Attributes and ConstantAtrributes.

Name Type Description
callback function nullable

For alternative actions, because an asynchronous function can be used.

Returns:
Type Description
AttributeList

updateWidgetInformation(callback)

Updates the attributes by calling queryGenerator.

Name Type Description
callback function nullable

For alternative actions, because an asynchronous function can be used.