13 #include <QtCore/QReadLocker>
14 #include <QtCore/QBuffer>
15 #include <QtCore/QByteArray>
16 #include <QtCore/QQueue>
17 #include <QtGui/QColor>
18 #include <QtGui/QImage>
19 #include <QThreadPool>
23 #include "CASSsoap.nsmap"
63 _soap(new CASSsoapService),
81 _soap->send_timeout = 60;
82 _soap->recv_timeout = 60;
83 _soap->accept_timeout = 0;
84 _soap->max_keep_alive = 1000;
86 _soap->bind_flags = SO_REUSEADDR;
91 toString(
_port) +
"' for SOAP connection, Quitting the soap server");
96 if(SOAP_INVALID_SOCKET ==
_soap->accept())
100 _soap->soap_stream_fault(cerr);
107 CASSsoapService *tsoap(
_soap->copy());
116 int CASSsoapService::quit(
bool *success)
129 int CASSsoapService::readini(
size_t what,
bool *success)
151 int CASSsoapService::getPostprocessorIds(
bool *success)
156 std::tr1::shared_ptr<Serializer> ser(
new Serializer);
157 keys->serialize(*ser);
159 std::tr1::shared_ptr<string> datstr(
new string(ser->buffer()));
160 int result = soap_set_dime_attachment(
this, (
char*) datstr->data(),datstr->size(),
"application/processorList",
"0", 0, NULL);
161 string output(
"CASSsoapService::getPostprocessorIds: Sending the following names:");
162 for (Processor::names_t::const_iterator it(keys->getList().begin());
163 it != keys->getList().end(); ++it)
164 output += *it +
", ";
165 output +=
" size of serializer: " +
toString(datstr->size());
168 if(100 < queue.size())
180 int CASSsoapService::writeini(
size_t ,
bool *)
191 return SOAP_FATAL_ERROR;
192 throw logic_error(
"CASSsoapService::writeini: should not be used anymore");
214 return SOAP_FATAL_ERROR;
222 int CASSsoapService::controlDarkcal(
const string &controlCommand,
bool *success)
229 ProcessorManager::processors_t::iterator iter(
processors.begin());
230 ProcessorManager::processors_t::iterator end(
processors.end());
232 (*iter++)->processCommand(controlCommand);
236 catch(
const invalid_argument &)
239 return SOAP_FATAL_ERROR;
251 command +
"' is for processor " + type );
262 return SOAP_FATAL_ERROR;
266 int CASSsoapService::getEvent(
size_t ,
unsigned ,
unsigned ,
bool *)
281 throw runtime_error(
"CASSsoapService::getEvent: has not yet been properly implemented");
304 const size_t dim(result->dim());
305 serializer << *result;
306 std::tr1::shared_ptr<pair<size_t, string> >
data(
307 new pair<size_t, string>(make_pair(dim,serializer.buffer())));
313 mimetype = string(
"application/cass0Dhistogram");
316 mimetype = string(
"application/cass1Dhistogram");
319 mimetype = string(
"application/cass2Dhistogram");
322 mimetype = string(
"application/casshistogram");
327 if(200 < queue.size())
333 " from event " +
toString(eventId) +
", the serialized size is "
335 return soap_set_dime_attachment(
this, (
char *)
data->second.data(),
336 data->second.size(), mimetype.c_str(),
337 type.c_str(), 0, NULL);
343 return SOAP_FATAL_ERROR;
349 return SOAP_FATAL_ERROR;
353 int CASSsoapService::getResults(
bool sameEventID,
bool *success)
355 static deque<string> cache;
359 soap_multipart::iterator attachment(this->dime.begin());
360 cout <<
"TCPServer: DIME attachment:" << endl
361 <<
" TCPServer: Memory=" << (
void*)(*attachment).ptr << endl
362 <<
" TCPServer: Size=" << (*attachment).size << endl
363 <<
" TCPServer: Type=" << ((*attachment).type?(*attachment).type:
"null") << endl
364 <<
" TCPServer: ID=" << ((*attachment).id?(*attachment).id:
"null") << endl;
365 Serializer deserializer(
string((
char*)(*attachment).ptr, (*attachment).size));
366 IdList list(deserializer);
371 Processor::names_t::const_iterator it(list.getList().begin());
373 while (it != list.getList().end())
379 if (sameEventID && it == list.getList().begin())
381 serializer << *result;
390 cache.push_back(
data);
391 if (cache.size() > 100)
397 return soap_set_dime_attachment(
this, (
char *)cache.back().data(),
398 cache.back().size(),
"cass/Result",
405 return SOAP_FATAL_ERROR;
411 return SOAP_FATAL_ERROR;
file contains declaration of class Worker and Workers
Processor::name_t key_t
type of proccessor accessor key
static void loadSettings()
load the logging settings from the .ini file
std::tr1::shared_ptr< self_type > shared_pointer
a shared pointer of this class
std::list< Processor::shared_pointer > processors_t
Container of all currently active processors.
static void controlCalibration(const std::string &command)
issue a command to the map creators of all instances
CASSsoapService * _soap
the service
file contains custom exceptions used in cass
virtual void run()
perform thread-work
static QMutex _mutex
Singleton operation locker.
static void add(Level level, const std::string &line)
add a string to the log
static shared_pointer instance()
return the already created instance of this
const std::string buffer() const
retrieve a const reference to the compressed string.
static shared_pointer::element_type & reference()
return a reference to the instance itselve if it exists
static shared_pointer instance()
return existing instance for our friends
contains the manager for the processors
std::tr1::shared_ptr< SoapServer > shared_pointer
a shared pointer of this class
Exception thrown when accessing invalid processor.
static const size_t _backlog
maximum backlog of open requests
std::string toString(const Type &t)
convert any type to a string
auxiliary data[Processor]
file contains processors baseclass declaration
Handle a single SOAP request.
static shared_pointer _instance
pointer to the singleton instance
wait(unsigned long time=ULONG_MAX)
SoapServer()
Disabled default constructor.
contains the common data for one advanced pixeldetector
virtual void run()
handle request and terminate
static shared_pointer::element_type & reference()
return a reference to this instance
Exception thrown when accessing invalid histogram.
the soap server implementation
contains a logger for cass
const size_t _port
server port