Panel | ||||||
---|---|---|---|---|---|---|
| ||||||
After the Getting Started tutorial, you should know how to create a spinal-system with one model and one organ. We will now see how to create an intelligent system with more synchronized information. System architecture:In this tutorial you will learn how to make a list of items and how to launch your organs with more efficiency. |
Panel | ||
---|---|---|
| ||
For this tutorial, you just need the basic requirements |
Panel | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||
In this part we will create 2 new models:
But first you need to create a spinal-system called 'equipement-system' like in the section Creating a new Spinal System in the Getting Started tutorial, then create a folder spinal-model to store the differents models. Within this folder create a file model.js spinal-model/model.js
|
Panel | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
With our new models we will now create a list of 2 equipments. We will create an organ for each equipment. Each one will have an automate which changes its hydrometry and temperature. Equipment 1Make a folder named equipment1 and the file index.js in it.
This organ will create the first equipment and will revover data from a simulated sensor. equipment1/index.js
You can launch your new organ with node.
Go to the admin UI and put 'List' into the inspector and you should see the hydrometry and temperature of equipment0 change every second. Equipment2Equipment2 will be almost identical to equipment1 so I suggest you start by copying equipment1.
There are very few changes to make to index.js. equipment2/index.js
Now launch equipment2 with node.
If you go back to the inspector you will notice that a new equipment has appeared in the List. |
Panel | |||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||
After the last part you might have noticed that the way we have been launching our organs isn't very effective, you have to launch and stop organs one by one. This is because this is not the right way to do it. In this part you will learn how to launch your organs effectively. To do that we need to look at .apps.json. When you open it for the first time it should look like this:
.apps.json contains the organs that should be launched. They are identified by:
With all that in mind let's add equipment 1 and 2 to the list.
Now all we have to do is let pm2 do the work.
pm2 will now show you equipment 1 and 2 along with spinal-core-hub. |
Conclusion
In this tutorial you learned:
- how to create more complex models
- how to organize your data coming from multiple organs
- how to launch you your organs effectively
This tutorial will be continued in Basic Automate Tutorial.