Device independent functions work on all module types, while Device dependent functions only work on specific module types (e.g. on 775 TDC's). If you call a device dependent member function on an incompatible module, it will throw a string exception. The code below shows how to turn this exception into an informative message before attempting to fix up the problem at a higher level in the code (or exit).
#include <iostream> #include <string> #include <CAENcard.h> ... CAENcard* pCard; ... try { pCard->commonStart(); } catch (string msg) { cerr << "Failed to set module in common start mode"; cerr << " module type: V" << pCard->cardType() << endl; cerr << "Message: " << msg << endl; cerr.flush(); throw; } ...
The code, assuming the module is a TDC attempts to initialize it to run in common start mode. If this module is not a TDC, a string exception will be thrown by CAENcard::commonStart and the catch block shown will be called. The catch block uses the member CAENcard::cardType() to get the actual module type, and the exception message caught to construct an informative message that is emitted to stderr. The exception is then rethrown. If there is no exception handler at a higher level in the call stack the program will exit.
It is also possible to attempt corrective action within the catch block above, depending on the needs of your application.
To find out more about each of these functions, click on the name of the function.
To find out more about each of these functions, click on the name of the function. Note that calling one of the functions below with a module that is not of the correct module type will in general cause a string exception to be thrown. The module type can be determined using the CAENcard::cardType function. See Module initialization. for an example of how to catch string exceptions.