RHD:Plug-in architecture
Load a plug-in
Plugins are loaded when they are mentioned in the rhdconfig file, e.g. like
<?xml version="1.0" ?> <rhd> <sheduler> <period value="3000000"/> <type value="itimer"/> </sheduler> <server> <port value="24902"/> <clients number="10" allwriters="1"/> </server> <plugins basepath="/usr/local/smr/lib/rhdplugin/"> <joycontrol enable="true" lib="libjoycontrol.so.1" critical="false" safety="1"> <joystick port="/dev/input/js0"/> </joycontrol> <sf9dof enable="true" lib="libsf9dof.so.1" critical="false" dev="/dev/ttyS1" baudrate="38400" debug="0"> </sf9dof> </plugins> </rhd>
Here the plugins section has an attribute basepath that states where the plug-in files are to be found.
Two plugins are loaded in this example, a joycontrol plug-in from the file libjoycontrol.so.1, in the joycontrol XML group is an embedded XML tag, called joystick with the needed configuration data.
Further is a sf9dof plugin, where the plugin configuration data is placed as attributes directly in the sf9dof tag.
Plug-in function
A plugin should read the configuration file, and all relevant configuration values should be controllable from the configuration file.
The plug-in is expected to have a function called initXML(char * filename) that reads the configuration file and initializes the plug-in as needed. If all went well, then the function should return 0.
At every sample time, just after data may have been received from weriter clients, a function called periodic(int tick) is called. This can be used to react on new variable values, or other regular tasks.