spectrodaq client application framework
0.2
- Author:
- Ron Fox
Eric Kasten (Spectrodaq)
Jason Venema
This documentation describes an application framework which simplifies the process of writing clients to spectrodaq, the NSCL data acquisition and distribution system. This set of web pages provides general documenation as well as reference information for this class library.
To write programs under the client application framework you will need to know:
- How to subclass the DAQROCNode class.
- How to Write a Makefile to build your program.
DAQROCNode (DAQ Readout Controller Node) is the base class from which all spectrodaq clients are derived. #include <iostream.h>
#include <spectrodaq.h>
#include <SpectroFramework.h>
class MyClass : public DAQROCNode
{
protected:
int operator()(int argc, char** pargv);
};
int
MyClass::operator()(int argc, char** pargv)
{
cout << "Hello World." << endl;
}
MyClass theApp;
is a minimal sample Spectrodaq client which uses the framework.
This example includes the following headers:
- <spectrodaq.h> - header which defines the spectrodaq client interface classes.
- <SpectroFramework.h> - header which defines the classes in the application framwork.
- <iostream.h> - Which defines classes in the C++ I/O subsystem.
The bulk of the program is the definition of a class: MyClass which extends DAQROCNode, definining and implementing the operator() member function. This member function is called when Spectrodaq has initialized and is ready to run application code. The implementation of that function simply puts the message "Hello World" to stdout.
The final line of the example declares an instance of MyClass. This instance is the application object which will actually be run by spectrodaq.
This example shows the general pattern which you must follow to write Spectrodaq clients:
- Include the necessary headers (<spectrodaq.h> <SpectroFramework.h> at a minimum.
- Write a subclass to DAQROCNode which defines the behavior of your application. The entry point to the program will be the operator() member function which has the same signature as the main function. be sure not to provide an implementation of main() as that's provided by the spectrodaq client libraries.
- Declare an instance of this class to provide spectrodaq with an application object to run.
Writing a Makefile to build your application requires:
- Obtaining the compilation and link flags needed by spectrodaq.
- Listing the dependencies between modules, and build rules needed to get from indenendent to dependent half of these dependencies.
For the example in the previous section, the resulting Makefile might look like
SPECTRO_FLAGS=$(shell /opt/spectrodaq/bin/spectrodaq-conf --cflags)
SPECTRO_LDFLAGS=$(shell /opt/spectrodaq/bin/spectrodaq-conf --libs)
CXXFLAGS=$(SPECTRO_FLAGS) -I/opt/daq/Include -I/usr/X11/include
LDFLAGS = $(SPECTRO_LDFLAGS) -L /opt/daq/Lib -L/usr/X11/lib \
-lEventFramework -ltk -ltcl -lm -lXm -lXt
minimal: minimal.o
g++ -o minimal $< $(LDFLAGS)
minimal.o: minimal.cpp
g++ -c $< $(CXXFLAGS) -ltcl
The first four macro definitions group together the compilation and load flags needed by spectrodaq and the framework into two macros CXXFLAGS (compile flags), and LDFLAGS (loader flags).
Two dependencies describe how to build the object from the source, and the executable from the object. Note that it may also be wise to include the -ggdb flag in LDFLAGS so that you can use the gdb debugger.
The following is a list of general concepts which are used by the event framework and should be understood.
Guest event loops including:
- Synchronization of guest event loops with other framework code.
- Tcl/Tk guest event loops
- X11/Xt guest event loops
The Configuration subsystem.
Generated on Thu Jan 6 16:58:34 2005 for Spectrodaq External Event Framework by
1.3.9.1