23.11.2012 Views

The FEE Server Control Engine of the ALICE-TRD - Westfälische ...

The FEE Server Control Engine of the ALICE-TRD - Westfälische ...

The FEE Server Control Engine of the ALICE-TRD - Westfälische ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

A Using <strong>the</strong> lib<strong>TRD</strong><br />

<strong>The</strong> C++ library lib<strong>TRD</strong> provides comfortable interface classes to control <strong>the</strong> readout<br />

chamber. Fur<strong>the</strong>rmore it provides some general purpose classes like <strong>the</strong> logging system.<br />

In this appendix an example program is described which illustrates how <strong>the</strong> lib<strong>TRD</strong> can<br />

be used by stand alone programs. <strong>The</strong> source code is shown in listing A.1.<br />

In <strong>the</strong> lines 1 to 14 <strong>the</strong> necessary header files are included. Apart from iostream and<br />

vector all o<strong>the</strong>r header files belongs to lib<strong>TRD</strong>. First <strong>the</strong> logging system is initialized (lines<br />

20 to 27). In this example two logging output channels are created. One channel writes<br />

all log messages with a log level equal or greater than einfo to standard out (line 21) and<br />

<strong>the</strong> o<strong>the</strong>r channel writes all messages, including debug messages, to a file (line 22). After<br />

<strong>the</strong> logging system is initialized, a corresponding debug message is printed (lines 29-30).<br />

<strong>The</strong> message will only show up in <strong>the</strong> log file but not on <strong>the</strong> screen because its log level<br />

is smaller than einfo.<br />

<strong>The</strong>n two SCSN commands are created. In line 32 <strong>the</strong> array which will hold <strong>the</strong> commands<br />

is created and filled afterwards (lines 35 to 43). <strong>The</strong> vector which will hold <strong>the</strong><br />

results <strong>of</strong> <strong>the</strong> SCSN commands is created in line 46. Next, <strong>the</strong> SCSN bus is opened, <strong>the</strong><br />

two frames are send, <strong>the</strong> results are stored in <strong>the</strong> created vector and <strong>the</strong> bus is closed. In<br />

case <strong>of</strong> an error, an exception is thrown by <strong>the</strong> class SCSNBus. To prevent <strong>the</strong> program<br />

from just quitting in such a case, <strong>the</strong> exception is caught and printed to tlog (lines 55 to<br />

59). For that output <strong>the</strong> second highest log-level (eerror) is chosen, because exceptions<br />

thrown by class SCSNBus usually indicate serious problems. <strong>The</strong> far most common cause<br />

for such an exception are not powered MCMs. If no error occurred, <strong>the</strong> if-clause in lines<br />

61 to 72 checks if <strong>the</strong> value was written correctly and prints out a suitable message. Afterwards<br />

<strong>the</strong> program is finished.<br />

95

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!