14 #include <QtCore/QStringList>
15 #include <QtCore/QCoreApplication>
18 #include "cass_version.h"
77 InputBase::reference().end();
86 struct sigaction quit;
88 sigemptyset(&quit.sa_mask);
89 quit.sa_flags = SA_RESTART;
91 if (sigaction(SIGQUIT, &quit, 0))
92 throw runtime_error(
"setSignalHandler(): could not set up the quit signal");
117 int main(
int argc,
char **argv)
125 qRegisterMetaType< std::string >(
"std::string");
126 qRegisterMetaType<cass::ProcessorManager::key_t>(
"cass::ProcessorManager::key_t");
127 qRegisterMetaType<size_t>(
"size_t");
130 QCoreApplication::setOrganizationName(
"CFEL-ASG");
131 QCoreApplication::setOrganizationDomain(
"endstation.asg.cfel.de");
132 QCoreApplication::setApplicationName(
"CASS");
148 string filelistname(
"filesToProcess.txt");
149 parser.
add(
"-i",
"filename of file containing filesnames of files to process",filelistname);
150 bool multifile(
false);
151 parser.
add(
"-m",
"enable the multifile input",multifile);
152 bool quitwhendone(
false);
153 parser.
add(
"-q",
"quit after finished with all files",quitwhendone);
155 bool hdf5file(
false);
156 parser.
add(
"--hdf5",
"use the special hdf5 file parser",hdf5file);
157 bool xfelhdf5file(
false);
158 parser.
add(
"--xfelhdf5",
"use the xfel hdf5 file parser",xfelhdf5file);
162 parser.
add(
"-t",
"enable the tcp input",tcp);
164 string partitionTag(
"0_1_cass_AMO");
165 parser.
add(
"-p",
"partition tag for accessing the shared memory",partitionTag);
167 parser.
add(
"-c",
"client id for shared memory access",index);
171 parser.
add(
"--noSoap",
"Disable the Soap Server",noSoap);
172 int soap_port(12321);
173 parser.
add(
"-s",
"TCP port of the soap server ",soap_port);
176 string outputfilename(
"output.ext");
177 parser.
add(
"-o",
"output filename passed to the Processor",outputfilename);
178 string settingsfilename(settings.
fileName().toStdString());
179 parser.
add(
"-f",
"complete path to the cass.ini to use",settingsfilename);
181 bool sacladata(
false);
182 parser.
add(
"--sacla",
"Enable SACLA Input",sacladata);
186 parser.
add(
"--zmq",
"Enable the ZeroMQ Input",zmq);
189 bool xfelonlineinput(
false);
190 parser.
add(
"--xfelonline",
"Enable the XFEL-Online Input",xfelonlineinput);
192 bool showUsage(
false);
193 parser.
add(
"-h",
"show this help",showUsage);
194 bool showVersion(
false);
195 parser.
add(
"--version",
"display the version of cass",showVersion);
210 cout <<VERSION <<endl;
215 CASSSettings::setFilename(settingsfilename);
220 Log::add(Log::INFO,
"Start CASS");
229 RatePlotter plotter(inputrate,inputload,workerrate);
238 ProcessorManager::instance(outputfilename);
239 Workers::instance(ringbuffer, workerrate);
242 MultiFileInput::instance(filelistname, ringbuffer, inputrate, inputload, quitwhendone);
247 SACLAOfflineInput::instance(filelistname,ringbuffer,inputrate,inputload,quitwhendone);
251 HDF5FileInput::instance(filelistname,ringbuffer,inputrate, inputload,quitwhendone);
252 else if (xfelhdf5file)
253 XFELHDF5FileInput::instance(filelistname,ringbuffer,inputrate, inputload,quitwhendone);
257 ZMQInput::instance(ringbuffer, inputrate, inputload, quitwhendone);
260 FileInput::instance(filelistname, ringbuffer, inputrate, inputload, quitwhendone);
263 TCPInput::instance(ringbuffer,inputrate, inputload);
268 SACLAOnlineInput::instance(ringbuffer,inputrate,inputload);
272 ZMQInput::instance(ringbuffer, inputrate, inputload);
275 else if (xfelonlineinput)
276 XFELOnlineInput::instance(ringbuffer, inputrate, inputload);
280 SharedMemoryInput::instance(partitionTag, index, ringbuffer, inputrate, inputload);
292 server = SoapServer::instance(soap_port);
302 Workers::reference().start();
309 InputBase::reference().start();
317 while (!InputBase::reference().wait(500))
319 if (!Workers::reference().running())
321 Log::add(Log::DEBUG4,
"main(): One of the workers seem to not be working, quit all workers and then quit the input");
322 InputBase::reference().end();
323 InputBase::reference().wait();
324 Workers::reference().end();
325 Workers::reference().rethrowException();
332 if (InputBase::reference().exceptionThrown() == InputBase::NO_EXCEPTION)
333 InputBase::reference().ringbuffer().waitUntilEmpty();
336 Workers::reference().end();
339 InputBase::reference().rethrowException();
343 catch (
const invalid_argument &error)
345 Log::add(Log::ERROR,
string(
"User input is wrong: ") + error.what());
346 cout <<endl<<endl<<
"User input is wrong: Please review the log file '"
347 <<Log::filename()<<
"'"<<endl;
349 catch (exception &error)
351 Log::add(Log::ERROR,
string(
"Exception happened: ") + error.what());
352 cout <<endl<<endl<<
"An exception happened: Please review the log file '"
353 <<Log::filename()<<
"'"<<endl;
357 Log::add(Log::ERROR,
"main(): something bad happend, quitting the program.");
358 cout <<endl<<endl<<
"Bad error: Please review the log file '"
359 <<Log::filename()<<
"'"<<endl;
361 Log::add(Log::INFO,
"Quitting CASS");
void endInputThread(int)
end the input thread
void usage()
output which commandline parameters are available
file contains declaration of class Worker and Workers
class calculating a rate in Hz.
file contains declaration of class calculating a rate
a httpserver for serving histograms of cass
start(Priority priority=InheritPriority)
int main(int argc, char **argv)
The main program.
contains a parser for command line parameters
A Ringbuffer, handles communication between Input and Worker Threads.
file contains declaration of class to plot the rate calculated by ratemeters
void add(const std::string &sw, const std::string &desc, bool &val)
add a switch to the switches container
file contains the ringbuffer class
file contains global definitions for project cass
contains the manager for the processors
std::tr1::shared_ptr< SoapServer > shared_pointer
a shared pointer of this class
command line argument parser
Plotting information about the ongoing processing.
void setSignalHandler()
set up the own handler to react on the sigquit (crtl+ \) signal
file contains specialized class that do the settings for cass
the soap server implementation
contains a logger for cass
const size_t RingBufferSize
global variable to set the ring buffer size