Node initialization and deinitialization¶
The initialization and deinitialization of nodes is a multi-step process. Not all functions are available in every step.
init: Right after the node is loaded init is called. A Struct with information about the node (id, name, configuration parameters, ...) is passed to init. All initilialization that can be done at this point, should be done here. When initialization fails,
falsemust be returned, which aborts the initialization of that node. Homegear waits for
initto complete for all nodes before continuing with the next step.
start: In start there are no restrictions on what is allowed to do. Just note, that
startmustn't hang (don't sleep or wait). As with
falsecan be returned to abort the initialization of that node.
startis finished for all nodes, Homegear calls
configNodesStarted. This method must not hang as well.
- After calling
configNodesStartedon all nodes, Homegear executes
startUpComplete. As with the other start methods,
startUpCompleteis not allowed to hang.
stop: The deinitialization is started by Homegear calling
stopall RPC methods and all other nodes are still available. Stop must not hang. For threads that means, you should trigger the stopping of threads in
stop, but don't join them here. Homegear waits for all calls to
stopto finish before continuing.
waitForStop: This method is made for one purpose: Joining threads. The stopping of threads should be triggered within stop. Every single thread should be stopped after 1 second and with this construct, all threads are finished after about one second.
See the following table for an overview on what is allowed or available in the initialization/deinitialization methods:
|Node information available||yes||yes||yes||yes||yes||yes|
|RPC methods available||no||yes||yes||yes||yes||no|
|Get parameters from configuration nodes||no||(yes)||yes||yes||yes||no|
|Must return immediately||yes||yes||yes||yes||yes||no|
|Can abort loading of node||yes||yes||yes||no||no||no|
See the following table on the availability of the initialization/deinitialization methods for different programming languages:
initis called on nodes of other languages. ↩
The Python script is started in
Signal 15 is sent to the Python script in
Node-BLUE waits until the process exits. ↩