Restored compilation on Windows/Cygwin
[u/mrichter/AliRoot.git] / RAW / AliRawReaderDateOnline.cxx
CommitLineData
3b98a4d4 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16///////////////////////////////////////////////////////////////////////////////
17///
18/// This is a class for reading raw data from a date monitoring libraries.
19/// It supports two modes - event taken from shared memory via DATE monitoring
20/// libs, or an emulation mode when the events are taken from a DATE file using
21/// the same monitoring libs.
22/// The constructor requires an argument:
23///
24/// : - events are taken from shared memory
25/// or
26/// <DATE_filename> - events are taken from date file
27///
28/// Cvetan Cheshkov 1/04/2008
29///////////////////////////////////////////////////////////////////////////////
30
31#include "AliRawReaderDateOnline.h"
32
33ClassImp(AliRawReaderDateOnline)
34
35AliRawReaderDate::AliRawReaderDate(
36#ifdef ALI_DATE
37 const char* filename
38#else
39 const char* /* filename */
40#endif
41 ) :
42 AliRawReaderDate()
43{
44
45// Constructor
46// Initialize the DATE monitoring libs
47
48#ifdef ALI_DATE
49
50 int status;
51
52 /* define data source : this is argument 1 */
53 status=monitorSetDataSource( filename );
54 if (status!=0) {
55 AliFatal(Form("monitorSetDataSource() failed : %s",monitorDecodeError(status)));
56 }
57
58 /* declare monitoring program */
59 status=monitorDeclareMp( __FILE__ );
60 if (status!=0) {
61 AliFatal(Form("monitorDeclareMp() failed : %s",monitorDecodeError(status)));
62 }
63
64 /* define wait event timeout - 1s max */
65 monitorSetNowait();
66 monitorSetNoWaitNetworkTimeout(1000);
67
68#else
69 Fatal("AliRawReaderDateOnline", "this class was compiled without DATE");
70#endif
71}
72
73Bool_t AliRawReaderDate::NextEvent()
74{
75// wait and get the next event
76// from shared memory
77
78#ifdef ALI_DATE
79
80 if (fEvent) free(fEvent);
81
82 while (1) {
83 /* get next event (blocking call until timeout) */
84 int status=monitorGetEventDynamic(&fEvent);
85 struct eventHeaderStruct *event=(eventHeaderStruct*)eventPtr;
86
87 if (status==MON_ERR_EOF) {
88 AliInfo("End of File detected");
89 return kFALSE; /* end of monitoring file has been reached */
90 }
91
92 if (status!=0) {
93 AliError(Form("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)));
94 return kFALSE;
95 }
96
97 /* retry if got no event */
98 if (event==NULL) {
99 continue;
100 }
101
102 eventTypeType eventT=event->eventType;
103 /* exit when last event received, no need to wait for TERM signal */
104 if (eventT==END_OF_RUN) {
105 AliInfo("EOR event detected");
106 return kFALSE;
107 }
108 if (eventT!=PHYSICS_EVENT) {
109 continue;
110 }
111
112 AliInfo(Form("Run #%lu, event size: %lu, BC:%u, Orbit:%u, Period:%u",
113 (unsigned long)event->eventRunNb,
114 (unsigned long)event->eventSize,
115 EVENT_ID_GET_BUNCH_CROSSING(event->eventId),
116 EVENT_ID_GET_ORBIT(event->eventId),
117 EVENT_ID_GET_PERIOD(event->eventId)
118 ));
119 }
120
121 return AliRawRederDate::NextEvent();
122}
123
124#endif
125
126 return kFALSE;
127}
128
129