Test Case Title |
TC2.28 - Snap4City MicroServices for Snap4City platform management from IOT Applications, feature of reflection |
Goal |
I can:
|
Prerequisites |
Know the host where is hosted the process loader that run the desired process. Know the features and functionality offered by DISCES Download or ask for permits to enable you to develop your own process The following functionalities are available only for specific Snap4city users with specific privileges. |
Expected successful result |
Starting a new job, read current status of a job |
Steps |
|
- In the Snap4City project, microservices have been developed that allow process management to be carried out.
- The microservices are located under the S4CManagement menu and are divided according to the functions they provide. There are those who provide information about the system that contains the processes to be performed and respond with TRUE or FALSE
- There are those that provide information about jobs and triggers related to jobs and return more information than the previous ones, even with lists and objects
- The ones described so far are microservices that only take readings inside the host indicated in the configuration. The following microservices allow you to interact with the platform and start or stop processes in the system
- An example of how such nodes can be used is the following
- After deepening the study of the DISCES and have prepared the development environment as described here.
- Open a Flow in your cloud (TC2.1a) or local (TC2.1b) IotApplication
- Import for testing the flow " TC2.28 - Snap4City MicroServices for Snap4City platform management" with the steps described in TC2.13 (on cloud) or import it from a file (if you have not an IOT Application on cloud)
- Check the imported node and change values of configuration tab to use your own job
- Configured on a desired job:
- This node return a TRUE value if the job exist in that machine, so add a “switch” node from “functions” menu:
- And configure it as follows:
- Then, add the “get-currently-executing-jobs” node from the “S4CManagement” menu
- And configure it as follows
- Next step it is check if the desired job is running, searching its name in the list of running jobs. This can be made with a “switch” node:
- Configured like:
- If the job is running msut be notified to the dashboard with “The job is running” message. Otherwise, the job can be triggered with a “trigger job” node from “S4cManagement”:
- Configured as follows:
- If the job start correctly a message “job triggered” is show on the dashboard and a check is made to write “job completed” at the end of the running. To make this check it is possible to add a “trigger” node that check if the job is running and reset the trigger when the job complete its work:
- The trigger node must be configured:
- The get-currently-executing-jobs as follows:
- And the switch:
- The function node create the reset command for the trigger node:
- At the end a “text” node from “dashboard menu must be added to notify the user about job status:
- Configured like:
- And in addition a “template” node containing an iframe with the Datagate site to show the last job executed, is added:
- Configured like:
- The resulting flow is:
- And if you go on the node-red dashboard, it shows the results as following if you use datagate in your job: