New Node-types
This page describes the necessary steps for adding a new node-type to VILLASnode. VILLASnode already comes with a lot of existing implementations of node-types which should provide a good starting point.
-
Choose a short and descriptive name for you node-type. E.g
mqtt,websocket,iec61850-9-2.- The name must only contain lower-case letters and dashes.
- In this guide we use
my-protoas an example.
-
Identify required external dependencies & libraries
-
Check for availability of external libraries in main
CMakeLists.txt.- Do not forget to introduce a new calls to
cmake_dependent_option()as well as aadd_feature_info()for your new node-type further down in the CMake file.
- Do not forget to introduce a new calls to
-
Copy the example C++ code:
- Name the files according to the name of your node-type.
- Replace dashes with underscores.
cp lib/nodes/example.cpp lib/nodes/my_proto.cpp
cp include/villas/example.hpp include/villas/my_proto.hpp -
Add the new C++ file to the
lib/nodes/CMakeLists.txtfile- Make sure it is guarded by the new CMake option introduce in step 2)
-
Implement the new node-type by editing
my_proto.cppandmy_proto.cpp- Make sure to register the new node-type in the last lines of
my_proto.cpp. - Adjust the node-type name as well as add a short description.
- Remove the
NodeFactory::Flags::HIDDENflag from the node-type registration.
- Make sure to register the new node-type in the last lines of
-
Implement an integration test for your node-type which test its functionality in an end-to-end test:
cp tests/integration/node-example.sh tests/integration/node-my-proto.sh -
Copy the example configuration and adapt it to your node-type
cp etc/example/nodes/example.conf etc/example/nodes/my_proto.conf -
Copy the configuration schema (OpenAPI spec) and adapt it to your node-type:
cp doc/openapi/components/schemas/config/nodes/example.yaml doc/openapi/components/schemas/config/nodes/my_proto.yaml
cp doc/openapi/components/schemas/config/nodes/_example.yaml doc/openapi/components/schemas/config/nodes/_my_proto.yaml -
Add the configuration schema of your node-type to the list of available nodes in:
doc/openapi/components/schemas/config/node_obj.yaml -
Submit a new pull-request with your changes.
- Check if build finishes successfully