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.

Requires

  • module:easejs
  • module:MathUuid
  • module:Callback
  • module:CallbackList
  • module:AttributeType
  • module:AttributeValue
  • module:AttributeTypeList
  • module:AttributeValueList
  • module:ConditionList
  • module:Subscriber
  • module:SubscriberList
  • module:WidgetDescription
  • module:Discoverer

Members

protectedattributesAttributeValueList

All available Attributes and their values.

protectedattributeTypesAttributeTypeList

Types of all available attributes.

protectedcallbacksCallbackList

List of Callbacks.

protectedconstantAttributesAttributeValueList

All available constant Attributes and their values.

protectedconstantAttributeTypesAttributeTypeList

Types of all available ConstantAttributes.

protecteddiscovererDiscoverer

Associated discoverer.

idstring

ID of the Widget. Will be generated.

namestring

Name of the Widget.

protectedoldAttributesAttributeValueList

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

protectedsubscribersSubscriberList

List of Subscriber.

Methods

addAttribute(_attribute)

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 AttributeValue AttributeValue

protectedaddCallback(_callback)

Adds a new Callback.
Name Type Description
_callback Callback List or Array of AttributeValues.

protectedaddConstantAttribute(_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 AttributeValue AttributeValue

addSubscriber(_subscriber)

Adds a new Subscriber.
Name Type Description
_subscriber Subscriber Subscriber

privatedataValid(_conditions){boolean}

Verifies if the attributes match to the specified conditions in case any exists.
Name Type Description
_conditions string List of Conditions that will be verified.

privategetCurrentTime(){Date}

Returns the current time.

getId(){string}

Returns the id of the widget.

getName(){string}

Returns the name of the widget.

privategetOldAttributes(){AttributeValueList}

Returns the old Attributes.
Returns the Subscriber.

abstractgetType(){string}

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

getWidgetAttributeTypes(){AttributeTypeList}

Returns the available AttributeTypes.

getWidgetConstantAttributeTypes(){AttributeTypeList}

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

abstractgetWidgetDescription(){WidgetDescription}

Returns the description of this component.

protectedinit()

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

abstract,protectedinitAttributes()

Initializes the provided Attributes.

abstractinitCallbacks()

Notifies other components and sends the attributes. Must be overridden by the subclasses

abstract,protectedinitCallbacks()

Initializes the provided Callbacks.

abstract,protectedinitConstantAttributes()

Initializes the provided ConstantAttributes.

abstract,protectedintervalRunning(_interval)

Runs the context acquisition constantly in an interval. Can be called by init.
Name Type Description
_interval integer Interval in ms

protectedisAttribute(_attribute){boolean}

Verifies whether the specified attributes is a provided Attribute.
Name Type Description
_attribute AttributeValue

abstractputData(_data)

Updates the Attributes by external components.
Name Type Description
_data AttributeValueList | Array Data that should be entered.
Returns the last acquired Attributes.
Returns the specified Callbacks that can be subscribed.

queryConstantAttributes(){AttributeValueList}

Returns the ConstantAttributes.

abstractqueryGenerator(_function)

Queries the associated sensor and updates the attributes with new values. Must be overridden by the subclasses.
Name Type Description
_function function nullable For alternative actions, because an asynchronous function can be used.
Returns all available AttributeValues, Attributes and ConstantAtrributes.
Registers the component to the associated Discoverer.

removeSubscriber(_subscriber)

Removes the specified Subscriber.
Name Type Description
_subscriber Subscriber Subscriber

protectedsendToSubscriber(_callbackName)

Sends all Attributes, specified in the given callback, to components which are subscribed to this Callback.
Name Type Description
_callbackName string Name of the searched Callback.

protectedsetAttributes(_attributes)

Sets the AttributeValueList and also the associated AttributeTypes.
Name Type Description
_attributes AttributeValueList | Array List or Array of AttributeValues

protectedsetCallbacks(_callbacks)

Sets Callbacks.
Name Type Description
_callbacks CallbackList | Array List or Array of Callbacks.

protectedsetConstantAttributes(_constantAttributes)

Sets the ConstantAttributeValueList and also the associated AttributeTypes.
Name Type Description
_constantAttributes AttributeValueList | 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(_subscriber)

Sets SubscriberList.
Name Type Description
_subscriber SubscriberList | Array List or Array of Subscriber.

updateAndQueryWidget(_function){AttributeValueList}

Updates and returns all available AttributeValues, Attributes and ConstantAtrributes.
Name Type Description
_function function nullable For alternative actions, because an asynchronous function can be used.

updateWidgetInformation(_function)

Updates the attributes by calling queryGenerator.
Name Type Description
_function function nullable For alternative actions, because an asynchronous function can be used.