19 #define RCDAQEVENTITERATOR 1
20 #define FILEEVENTITERATOR 2
21 #define TESTEVENTITERATOR 3
22 #define ONCSEVENTITERATOR 4
24 #if defined(SunOS) || defined(Linux) || defined(OSF1)
37 COUT <<
"** usage: dlist -ecntfTOiIh datastream" << std::endl;
38 COUT <<
" type dlist -h for more help" << std::endl;
44 COUT <<
"** cannot specify both -e and -c!" << std::endl;
45 COUT <<
" type dlist -h for more help" << std::endl;
55 COUT <<
"test output " << 5 << ii << std::endl;
57 COUT <<
" dlist lists the packets contained in a given event. The event can come" << std::endl;
58 COUT <<
" from any of the standard sources, rcdaq, file, or test stream. " << std::endl;
59 COUT <<
" The default is to get the next available event from a file." << std::endl;
60 COUT <<
" dlist can optionally identify the event with the -i option." << std::endl;
61 COUT <<
" You can request a certain event number with the -e option. " << std::endl;
62 COUT <<
" You can ask for a certain event type (data, beg-run, etc) with -t." << std::endl;
63 COUT <<
" -t takes a number (e.g. 9 for begin-run) for an exact match," << std::endl;
64 COUT <<
" or DATA or SPECIAL to selct data or special events (DATA is default)" << std::endl;
65 COUT <<
" you can abbreviate DATA to D or d and SPECIAL to S or s." << std::endl;
66 COUT <<
" Example:" << std::endl;
68 COUT <<
" -T says the input is a test stream (which always has 3 packets):" << std::endl;
70 COUT <<
" dlist -T" << std::endl;
71 COUT <<
" Packet 1001 26 0 (Unformatted) 30006 (ID4EVT)" << std::endl;
72 COUT <<
" Packet 1002 16 0 (Unformatted) 30005 (ID2EVT)" << std::endl;
73 COUT <<
" Packet 1003 10 0 (Unformatted) 30006 (ID4EVT)" << std::endl;
75 COUT <<
" The -i option causes the event to be identified. " << std::endl;
77 COUT <<
" dlist -T -i" << std::endl;
78 COUT <<
" -- Event 1 Run: 1331 length: 68 frames: 1 type: 1 (Data Event)" << std::endl;
79 COUT <<
" Packet 1001 26 0 (Unformatted) 30006 (ID4EVT)" << std::endl;
80 COUT <<
" Packet 1002 16 0 (Unformatted) 30005 (ID2EVT)" << std::endl;
81 COUT <<
" Packet 1003 10 0 (Unformatted) 30006 (ID4EVT)" << std::endl;
83 COUT <<
" List of options: " << std::endl;
84 COUT <<
" usage: dlist -ecntfTOih datastream" << std::endl;
85 COUT <<
" -e <event number>" << std::endl;
86 COUT <<
" -c <number> get nth event (-e gives event with number n)" << std::endl;
87 COUT <<
" -n <number> repeat for n events (0: until end of stream)" << std::endl;
88 COUT <<
" -t <event type>" << std::endl;
89 COUT <<
" -i <print event identity>" << std::endl;
90 COUT <<
" -I <print in-depth packet identity>" << std::endl;
91 COUT <<
" -f (stream is a file)" << std::endl;
92 COUT <<
" -T (stream is a test stream)" << std::endl;
93 COUT <<
" -r (stream is a rcdaq monitoring stream)" << std::endl;
94 COUT <<
" -O (stream is a legacy ONCS format file)" << std::endl;
95 COUT <<
" -v verbose" << std::endl;
96 COUT <<
" -h this message" << std::endl << std::endl;
100 #if defined(SunOS) || defined(Linux) || defined(OSF1)
106 COUT <<
"sig_handler: signal seen " << std::endl;
121 int eventtypemin = 1;
122 int eventtypemax = 7;
124 int type_is_a_range = 1;
130 int fullidentify = 0;
138 while ((c = getopt(argc, argv,
"n:c:e:t:iIrfhTOv")) != EOF)
142 if ( !sscanf(optarg,
"%d", &eventnumber) )
exitmsg();
146 if ( !sscanf(optarg,
"%d", &countnumber) )
exitmsg();
150 if ( !sscanf(optarg,
"%d", &repeatcount) )
exitmsg();
154 if (*optarg ==
'S' || *optarg ==
's' )
160 else if (*optarg ==
'D' || *optarg ==
'd')
166 else if (*optarg ==
'A' || *optarg ==
'a')
174 if ( !sscanf(optarg,
"%d", &eventtype) )
exitmsg();
235 if ( getenv(
"RCDAQHOST") )
237 host = getenv(
"RCDAQHOST");
272 COUT <<
"Could not open input stream" << std::endl;
300 int accepted_count = 0;
315 if ( countnumber && count < countnumber)
319 if ( type_is_a_range)
327 if (evt->
getEvtType() != eventtype) take_this = 0;
342 if ( repeatcount==0 || ++accepted_count < repeatcount) evt = it->
getNextEvent();