CSBL - Writing and Reading widgets


Warning message

  • You can't delete this newsletter because it has not been sent to all its subscribers.
  • You can't delete this newsletter because it has not been sent to all its subscribers.


2. Writing and Reading widgets

Some widgets are able to receive an external input from the user and triggers a script with parameters and data. These so calling writing or INPUT widgets. They can send also command to other widgets which are ready to receive those command. For this reason, they are called Reading/Output widget which respond to command. The received command can influence their content. Also requesting data to the platform by using smart city API. There are also widgets that can do both, can play both roles: IN/OUT, Writing and Reading, triggers and responders. The structure of this feature requires two widgets, one that acts as a trigger and one that acts as a responder.

Among the customizable metadata of the widgets there is an editor, accessible only to some authorized users, which allows you to insert a short script in JavaScript code in which to insert a function that can be used to send data parameters to another widget, as well as performing more complex logic, such as data analytics, retrieving data by API requests etc., and send the results of computation to be shown in another widget.


2.1 Writing Widgets (IN in green)

In the configuration of some widgets, it is possible to insert a script in JavaScript code which allows the sending of data or commands to another widget.
This code can be entered using the graphical interface of the Dashboard Editor through a special menu. The code is a JavaScript language function, which to be considered valid must comply with the conventions, which will be explained in detail in the following sections.
For example, the identification name of the target widget must be specified.

Through the activation of a specific event, for example a click or the selection of a specific value, it is possible to activate the execution of this function at the target widget, which however must have the possibility to read and interpret this code.

For example, a widget enabled to write a function are WidgetInpulseButton, WidgetKnob and WidgetOnOffButton.


2.2 Reading Widgets (OUT in green)


While some widgets have the ability to activate a function to another widget, there are some widgets that are configured to receive and interpret these functions.

When the event is activated in the writing widget and the function is executed, the reading widget reads its content and interprets it by modifying its own content.
Each type of widget expects to receive certain parameters or values.


2.3 Writing and Reading widgets (IN/OUT in green)

In addition to the already defined categories, there are widgets that can both receive a JavaScript function as read input and in turn be able to send it as output.