How To Dev - Development: Server-Side Business Logic, as Processing Logic

This approach is a prerogative of Snap4City development environment. In Snap4Ciy, it is possible to have one Proc.Logic (IoT App) referring to multiple Dashboards, and one Dashboard referring multiple Processing Logic (IoT Apps). For this purpose, the Snap4City libraries on Node-RED includes a number of dashboard nodes as reported in the figure below. They are used in the Proc.Logic / Node-RED and at the deploy they are also created into the Dashboard. How to work with widget/nodes is reported in the online help into the Node-RED visual programming environment.

According to the training https://www.snap4city.org/download/video/course/das/

Let see a 1:1 relationship from Proc.Logic and Dashboard:

  • Any Action performed on Dashboard is provided to the Proc.Logic, which may produce reactions on Dashboard.
  • The context of Proc.LogicßàDashboard is a singleton, thus any user connected to the Dashboard will observe the evolutions performed. So that all the users will see the same story and view, even if they are authenticated and authorized by using different credentials, and they are on multiple dislocated terminals.
  • This is good for control rooms, and single/few users prototypes.

This activity is performed by using a number of Dashboard Widgets which have the counterpart on the Proc.Logic (IoT App) Node-RED as above summarized.


Figure: Dashboards with Widgets and their counterpart on Proc.Logic for implementing Server-Side Business Logic widgets/nodes: in (left), out (right) and in/out (left and right).

 

According to the training https://www.snap4city.org/download/video/course/das/  some of widgets are capable to:

  • Send information and commands to the Dashboard Widget, for example for an action produced by the users. (IN widget/node)
  • Receive information and commands from the Dashboard Widget, for example presenting a dashboard change to the users. (OUT widget/node).
  • Send/receive information and commands to/from the Dashboard Widget, for example for collecting users’ actions and presenting a change to the users on the same widget (in/out widget/node).

The typical pattern can be IN widget receiving data from dashboard, function, then an OUT Widget sending data on dashboard:


On Server-Side (into Proc.Logic) the developer can even create dynamically HTML pages of any kind and embed them into a Dashboard Widget as external content. A mix of in, out, and in/out widgets can also be included in the same dashboard. This approach, shown in the figure below here, is very powerful and presents the behavior of Server-Side Business Logic for control room described above.


Figure: Dashboards with External Content Widgets hosting HTML page produced by Server-Side Business Logic, and recollecting/presenting data to the user.

 

Note that, dynamic HTML pages can include in/out callbacks from/to Proc.Logic (IoT App) using web sockets. In this way the HTML page can exchange information with an IoT App to interactively update some visualizations: being such data get or sent to server-side business logic (implemented in Proc.Logic (IoT App) Node-RED) changes in the visualization will be reflected to all the users viewing the same dashboard. Differently, if the HTML page includes some JavaScript client-side logic (such as a table with sortable columns) the actions performed by one user will not be reflected to other user accessing the same dashboard (see more about this in the next section).