-
Notifications
You must be signed in to change notification settings - Fork 5
Step by step instructions for creating your own DAQModule package under v2.0.0
[Under development]
This page is intended to provide a step-by-step guide to setting up a work area in which you create software modules that run within the DUNE DAQ software application framework (appfwk). These modules are often called DAQModules since that is the C++ base class that they inherit from. If you are impatient to get started, you can jump to the Step-by-step Instructions now.
New users should probably continue reading this introduction, though, to learn a little bit of background information.
This page draws from, and references, several other Wiki pages in the appfwk repository. Links to these pages are listed in the text in the relevant places, and they are a good source of additional information for interested readers. Here are some of these references collected for you in one place on this page:
and last, but certainly not least
A brief recap of the main idea behind appfwk the can be found in a presentation about v1 This snipped provides a quick summary.
Since DAQ Suite v2, the system has been enriched with automated generated code tools. References to this can be found at these links
Instructions on setting up a work area in which you can create your new package can be found here. After you've created your own working area, for our purposes the first things to do is to add the packages your new package will depend on and compile them. Most likely your dependencies will include appfwk
and cmdlib
as per the installation instructions.
For future reference we'll call your working area WORK_DIR
, which is the directory that at this point should contain the following automatic generated sub-directories: build
, dbt-pyvenv
, install
, log
and sourcecode
.
From the C++ point of view, DAQ modules are implementation of a DAQ Module interface.
That means that apart from the constructor (that receives a name) only one method has to be implemented: init()
.
The function has to handle all those configuration items that are not supposed to be reconfigurable during the run.
Optionally it can configure all those variables that can be overridden during run time.
The most important thing that init
has to do is to call register_command
in order to associate functions to each command that the module is expected to support.
Each function has to be a set of operations that changes the internal status of the module according to the command that it is implementing.
The prototype of each function is in the form
void do_something( const nlohmann::json & ) ;
The function can be virtual and the system is able to pick the most downstream specification.
Assuming that the name of the module you are developing is MyNewDAQModule
a call to associate the command "start"
to a function called do_start
will be
register_command("start", & MyNewDAQModule::do_start);
It is expected that the operations of the DAQ Module are carried on in other threads under the control of the DAQModule itself.
DAQModules need to be created with a factory pattern simply via their name.
In the application framework this is done using CETlib.
In order to do that, each implementation (cpp
file) needs to have a call to the macro DEFINE_DUNE_DAQ_MODULE(<name_including_namespace>)
for example
DEFINE_DUNE_DAQ_MODULE(dunedaq::appfwk::DummyModule)
In order to generate a shared object library that is linkable in runtime from the application framework, the name of the library has to be the in the form <package>_<module_name_no_namespace>_duneDAQModule
.
This can be achieved simply adding a line in the CMakeLists.txt
file of your project in the form daq_add_plugin(<module_name_no_namespace> duneDAQModule LINK_LIBRARIES ers::ers appfwk <...>)
.
After the command LINK_LIBRARIES
you list all the dependencies necessary for your plugin.
For example:
daq_add_plugin( DummyModule duneDAQModule LINK_LIBRARIES ers::ers appfwk )