TC9.18: Advanced Features of Sensors Actuators of Dashboards vs IOT App

The Interactive Widgets in Snap4City Dashboards can be compounded to create adaptive effect. Most of them are reported in the following demonstrative dashboard and are connected each other via and IOT Application. This example is called SATEST (Test SA and WS), since it is presenting advancing features of SensorsActuators exploiting WebSocket from IOT Application and Dashboards.

https://www.snap4city.org/dashboardSmartCity/view/index.php?iddasboard=Mjc2NA==

Please note the set of widgets above have been named IB1 (impulse button 1), B1 (button 1), D1 (Dimmer 1), NK1 (numeric keypad 1), SC1 (Single Content 1), G1 (gauge 1), SM1 (speedometer 1), and TT1 (Time Trend 1. The name assigned correspond to the terminology that you can find on the Dashboard Builder and on the IOT Application library of Dashboard elements.

The second layer includes: IB2, B2, D2, NK2, SC2, G2, SM2, TT2 with similar meaning.

Please note that:

  • IB1 is an input for the system. When IB1 is pressed a random number is generated and assigned to D1, SC1, G1, SM1 and TT1. This means that the D1 and is not only a device to send a value from dashboard to the IOT App, but it is also capable to change its value on the basis of an input.
  • B1 is a switch the change the status and connect the value of the second layer to the first layer. Please note that when the Status of B2 is changed, the status of B1 is following it.
  • B2 generates a random number which is propagated on D2, SC2, G2, SM2 and TT2, and also on B1 which in turn propagates the value on D1, SC1, G1, SM1 and TT1.
  • IB2 is a input for the system which generate a Random number only the set of widget on the second line. But if the second line has a certain value, by pressing B1 to ON you can copy on first line too.
  • NK1 can be used to compose a number and send it to the first line D1, SC1, G1, SM1 and TT1.
  • NK1 can be used to compose a number and send it to the second line D2, SC2, G2, SM2 and TT2.
  • Despite the play you have done, every 10 minutes a new On-Off signal is automatically send to B2 that start creating a random number to set all at the same value: D1, SC1, G1, SM1 and TT1, D2, SC2, G2, SM2 and TT2.
  • B1, B2, IB1, IB2, D1, D2, NK1, NK2 are Virtual Sensors since create a message into the IOT App. On the other hand, they are also actuators from the point of view of the users. Thus are also called Sensors-Actuators.
  • SC1, SC2, G1, G2, SC1, SC2, TT1, TT2 are Actuators for the point of view of the IOT App, while are rendering tool for the users observing the Dashboards.

How this has been possible to implement?

The logic behind the dashboard has been implemented by using an IOT Applications as follows.

Please note that:

  • The first three blocks on top are for creating ON-OFF signal with 5s of duration, which is passed at the B2 to change it status and simulating the user behaviour. Thus the Button is not only a tool to allow the user to set a value, but also an actuator to show the value at the user.
  • Function blocks “copy”, have been added to give the evidence of what you can put in the middle. They could be even avoided since the JavaScript included contains only:
    • return msg;
  • Function block “set rand” includes the following code to avoid passing/saving NaN and save the random value in a variable called “valore”:
    • var val = msg.payload;
    • if (! isNaN(val))    flow.set ("valore", val);
    • else    flow.set ("valore", 99 );
    • return msg;
  • Function block “get rand” is used to recover the value:
    • msg.payload = parseInt(flow.get("valore"));
    • return msg;
  • Random blocks create a random number from 1 to 100. They can be configured in other manner as well.
  • Delay blocks have been set to impose some time to see the changes propagating in the dashboard and logic.
  • B1, B2 switch blocks accept in input messages to change the status, which is also shown on the dashboard
  • D1, D2 dimmer blocks accept in input messages to change the status, which is also shown on the dashboard with a corresponding animation
  • Be careful on creating chains of buttons and dimmers, since you could create also loops  that could lead to lose the control of the IOT App that could be engaged in creating an infinite number of messages.