CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
XmasToDQM.cc
Go to the documentation of this file.
1 // $Id: XmasToDQM.cc,v 1.5 2009/09/17 17:21:27 dellaric Exp $
2 
3 /*************************************************************************
4  * XDAQ Components for Distributed Data Acquisition *
5  * Copyright (C) 2000-2004, CERN. *
6  * All rights reserved. *
7  * Authors: J. Gutleber and L. Orsini *
8  * *
9  * For the licensing terms see LICENSE. *
10  * For the list of contributors see CREDITS. *
11  *************************************************************************/
12 #include "cgicc/CgiDefs.h"
13 #include "cgicc/Cgicc.h"
14 #include "cgicc/HTTPHTMLHeader.h"
15 #include "cgicc/HTMLClasses.h"
16 #include "cgicc/HTTPResponseHeader.h"
17 
18 
19 #include "xdaq/ApplicationGroup.h"
20 #include "xdaq/ApplicationRegistry.h"
21 
22 #include "xoap/MessageReference.h"
23 #include "xoap/MessageFactory.h"
24 #include "xoap/SOAPEnvelope.h"
25 #include "xoap/SOAPPart.h"
26 #include "xoap/SOAPBody.h"
27 #include "xoap/SOAPBodyElement.h"
28 #include "xoap/Method.h"
29 #include "xoap/domutils.h"
30 #include "xoap/DOMParser.h"
31 #include "xoap/SOAPHeader.h"
32 
33 #include "xgi/Table.h"
34 #include "xcept/tools.h"
35 
37 //#include "xplore/DiscoveryEvent.h"
38 #include "toolbox/task/WorkLoopFactory.h"
39 #include "xdata/InfoSpaceFactory.h"
40 //#include "xplore/Interface.h"
41 //#include "xplore/exception/Exception.h"
42 //#include "ws/addressing/WSAddressing.h"
43 //#include "xdata/exdr/Serializer.h"
44 #include "toolbox/Runtime.h"
45 
46 
47 #include "xdata/exdr/FixedSizeInputStreamBuffer.h"
48 #include "xdata/Table.h"
49 #include "xdata/exdr/Serializer.h"
50 #include "xdata/exdr/AutoSizeOutputStreamBuffer.h"
51 #include "xdaq/ApplicationDescriptorImpl.h"
52 
53 #include "toolbox/TimeVal.h"
54 #include "toolbox/stl.h"
55 #include "toolbox/regex.h"
56 
57 //#include "ws/eventing/Identifier.h"
58 //#include "ws/eventing/WSEventing.h"
59 //#include "ws/eventing/SubscribeRequest.h"
60 //#include "DQMServices/XmasToDQM/interface/SubscribeRequest.h"
61 //#include "ws/eventing/RenewRequest.h"
62 //#include "xmas/xmas.h"
63 #include "xoap/Event.h"
64 
65 #include<boost/tokenizer.hpp>
66 
67 
68 
69 XDAQ_INSTANTIATOR_IMPL(xmas2dqm::wse::XmasToDQM)
70 
71 xmas2dqm::wse::XmasToDQM::XmasToDQM(xdaq::ApplicationStub* s) throw (xdaq::exception::Exception)
72  : xdaq::Application(s)
73 {
74  getApplicationDescriptor()->setAttribute("icon", "/xmas2dqm/wse/images/Las.png");
75 
76  LOG4CPLUS_DEBUG(this->getApplicationLogger(),"inside constructor of xmas2dqm::wse::Application");
77 
78 
79  // Activates work loop for las asynchronous operations (SOAP messages)
80  //dispatcher_.addActionListener(this);
81  //(void) toolbox::task::getWorkLoopFactory()->getWorkLoop("urn:xdaq-workloop:las", "waiting")->activate();
82 
83 
84  // bind SOAP interface
85  xoap::bind(this, &xmas2dqm::wse::XmasToDQM::fireEvent, "Enable", XDAQ_NS_URI );
86  xoap::bind(this, &xmas2dqm::wse::XmasToDQM::fireEvent, "Halt", XDAQ_NS_URI );
87  xoap::bind(this, &xmas2dqm::wse::XmasToDQM::reset, "Reset", XDAQ_NS_URI );
88 
89 
90  // Define FSM
91  //
92  fsm_.addState('H', "Halted", this, &xmas2dqm::wse::XmasToDQM::stateChanged);
93  fsm_.addState('E', "Enabled", this, &xmas2dqm::wse::XmasToDQM::stateChanged);
94 
95  fsm_.addStateTransition('H', 'E', "Enable", this,&xmas2dqm::wse::XmasToDQM::EnableAction);
96  fsm_.addStateTransition('H', 'H', "Halt", this, &xmas2dqm::wse::XmasToDQM::HaltAction);
97  fsm_.addStateTransition('E', 'H', "Halt", this, &xmas2dqm::wse::XmasToDQM::HaltAction);
98 
99  // Failure state setting
100  fsm_.setFailedStateTransitionAction( this, &xmas2dqm::wse::XmasToDQM::failedTransition );
101  fsm_.setFailedStateTransitionChanged(this, &xmas2dqm::wse::XmasToDQM::stateChanged );
102 
103  fsm_.setInitialState('H');
104  fsm_.setStateName('F', "Failed"); // give a name to the 'F' state
105 
106  fsm_.reset();
107 
108  // Export a "State" variable that reflects the state of the state machine
109  state_ = fsm_.getStateName (fsm_.getCurrentState());
110  getApplicationInfoSpace()->fireItemAvailable("stateName",&state_);
111  getApplicationInfoSpace()->fireItemAvailable("LASurl",&LASurl_);
112  getApplicationInfoSpace()->fireItemAvailable("Period",&Period_);
113  getApplicationInfoSpace()->fireItemAvailable("LASQueueSize",&LASQueueSize_);
114  getApplicationInfoSpace()->fireItemAvailable("flashlistMonitor",&xmas2dqm::wse::ToDqm::instance()->flashlistMonitor_);
115  getApplicationInfoSpace()->fireItemAvailable("runNumber",&xmas2dqm::wse::ToDqm::instance()->runNumber_);
116 
117  // Add infospace listeners for exporting data values
118  getApplicationInfoSpace()->addItemChangedListener ("stateName", this);
119  getApplicationInfoSpace()->addItemChangedListener ("LASurl", this);
120  getApplicationInfoSpace()->addItemChangedListener ("Period", this);
121  getApplicationInfoSpace()->addItemChangedListener ("LASQueueSize", this);
122  getApplicationInfoSpace()->addItemChangedListener ("flashlistMonitor", this);
123  getApplicationInfoSpace()->addItemChangedListener ("runNumber", this);
124 
125  LASurl_ = "http://srv-c2d04-18.cms:9943/urn:xdaq-application:lid=100/retrieveCollection";
126  Period_ = "10";
127  LASQueueSize_ = "100000";
128 
129  //http://srv-c2d04-18.cms:9943/urn:xdaq-application:lid=100/retrieveCollection
130  //http://fu16.cmsdaqpreseries:9943/urn:xdaq-application:lid=100/retrieveCollection
131 
132 
133  //curl_global_init(CURL_GLOBAL_DEFAULT);
134  curl_global_init(CURL_GLOBAL_ALL);
135 
136  LASReadout_ = toolbox::task::bind (this, &xmas2dqm::wse::XmasToDQM::LASReadoutWorkLoop, "LASReadoutWorkLoop");
137 
138  LASReadoutWorkLoop_ = toolbox::task::getWorkLoopFactory()->getWorkLoop("LASReadoutWaitingWorkLoop", "waiting");
139 
140 
141  if (LASReadoutWorkLoop_->isActive() == false)
142  {
143  LASReadoutWorkLoop_->activate();
144 
145  }
146 
147  //LOG4CPLUS_INFO(this->getApplicationLogger(),"insdie constructor of xmas2dqm::wse::XmasToDQM Period = " << Period_.toString());
148 
149  LASReadoutTimer_ = toolbox::task::getTimerFactory()->createTimer("PeriodicLASReadout");
150 
151  // toolbox::TimeInterval interval(/*10*/atoi(Period_.toString().c_str()),0); // period of 8 secs
152 //
153 // startLASReadout_ = toolbox::TimeVal::gettimeofday();
154 //
155 // LASReadoutTimer_->scheduleAtFixedRate( startLASReadout_, this, interval, 0, std::string("LASReadout") );
156 
157  LOG4CPLUS_DEBUG(this->getApplicationLogger(),"finish of Constructor of xmas2dqm::wse::XmasToDQM");
158 
159 }
160 
161 
162 bool xmas2dqm::wse::XmasToDQM::LASReadoutWorkLoop (toolbox::task::WorkLoop* wl)
163 {
164  //keep log how many times the workloop was called...
165  static int times = 0;
166  times++;
167 
168  LOG4CPLUS_DEBUG (getApplicationLogger(), "inside WorkLoop...ready to ask LAS for EXDR data : time " << times <<"th");
169  LOG4CPLUS_DEBUG (getApplicationLogger(), "Period = " + Period_.toString() + " LASurl = " + LASurl_.toString());
170 
171 
172  xdata::Table * ptr_table = new xdata::Table();
173 
174  int ret = getEXDR_LAS(ptr_table);
175 
176  LOG4CPLUS_DEBUG (getApplicationLogger(), "return value from getEXDR_LAS = " << ret );
177 
178  if (ret == -1 || ret == -2) //exception during xdata::exdr deserialization occured or during CURL (could log different messages)
179  {
180  //LOG4CPLUS_INFO (getApplicationLogger(), "LASWorkLoop ready to call xdata::Table::Reference destructor..." );
181 
182  //ref_table->~Table();
183 
184 
185  LOG4CPLUS_DEBUG (getApplicationLogger(), "LASWorkLoop freeing xdata::Table * space" );
186 
187  delete ptr_table;
188 
189  LOG4CPLUS_WARN (getApplicationLogger(), "getEXDRLAS didn't complete properly, returning from LASREeadoutWorkLoop" );
190  return false;
191  }
192 
193 
194 
195  LOG4CPLUS_DEBUG (getApplicationLogger(), "inside WorkLoop...lock the mutex ");
196 
197 
198  //BSem_.take();
199  //acquire the mutex - protect access to the queue
200  pthread_mutex_lock(&xmas2dqm::wse::ToDqm::instance()->LASmutex_);
201 
202  LOG4CPLUS_INFO (getApplicationLogger(), "inside WorkLoop...check (...and possible wait) if data queue is full");
203 
204  //check if the queue is full and wait (a signal that informs that an element has been poped)
205  // until there is 'space' in the queue
206  while (xmas2dqm::wse::ToDqm::instance()->MemoryTable_.size() >= (unsigned int) atoi(LASQueueSize_.toString().c_str())/*Qsize_max*/)
207  {
208  pthread_cond_wait(&xmas2dqm::wse::ToDqm::instance()->less_, &xmas2dqm::wse::ToDqm::instance()->LASmutex_);
209  }
210 
211  LOG4CPLUS_DEBUG (getApplicationLogger(), "data queue has available store...proceeding...");
212 
213 
214 
215  std::map<std::string, std::string, std::less<std::string> >::iterator i;
216 
217  //size_t row = ref_table->getRowCount();
218  // size_t row = ptr_table->getRowCount();
219 //
220 // for ( size_t r = 0; r < ptr_table->numberOfRows_ /*ref_table->numberOfRows_*/; r++ )
221 // {
222 // LOG4CPLUS_INFO(this->getApplicationLogger(),"********* Printing table inside XmasToDQM ***************");
223 // LOG4CPLUS_INFO(this->getApplicationLogger(),/*ref_table*/ ptr_table->columnData_["bxHistogram"]->elementAt(r)->toString());
224 //
225 // boost::tokenizer<> tokens(/*ref_table*/ ptr_table->columnData_["bxHistogram"]->elementAt(r)->toString());
226 // for(boost::tokenizer<>::iterator itok=tokens.begin(); itok!=tokens.end();++itok)
227 // {
228 // //LOG4CPLUS_INFO(this->getApplicationLogger, (std::string)(*itok) );
229 // }
230 //
231 // row++;
232 // }
233 
234 
235  LOG4CPLUS_DEBUG (getApplicationLogger(), "inside WorkLoop...ready to call XmastoDQM::ToDQM::digest " );
236 
237  //insert LAS data table to ToDQM objec - queue
238  xmas2dqm::wse::ToDqm::instance()->digest("flashListName", "originator", "tagName", ptr_table /*ref_table*/);
239 
240  LOG4CPLUS_DEBUG (getApplicationLogger(), "inside WorkLoop...signaling new element added to the data queue ");
241 
242  //signal that a new element has been inserted
243  pthread_cond_signal(&xmas2dqm::wse::ToDqm::instance()->more_);
244 
245  LOG4CPLUS_DEBUG (getApplicationLogger(), "inside WorkLoop...release mutex, allow access to the data queue");
246 
247  //allow access to the queue
248  pthread_mutex_unlock(&xmas2dqm::wse::ToDqm::instance()->LASmutex_);
249 
250  return false;
251 }
252 
253 
254 
255 int xmas2dqm::wse::XmasToDQM::getEXDR_LAS(/*xdata::Table::Reference & rtable*/ xdata::Table * rtable)
256 {
257  LOG4CPLUS_DEBUG(this->getApplicationLogger(),"inside getEXDR_LAS.........");
258 
259  CURL *curl_handle;
260  CURLcode code;
261 
262  char data[200] = "fmt=exdr&flash=";
263 
264  strcat(data, xmas2dqm::wse::ToDqm::instance()->flashlistMonitor_.bag.flashlist.toString().c_str());
265 
266 
267  struct MemoryStruct chunk;
268 
269  chunk.memory=NULL; /* we expect realloc(NULL, size) to work */
270  chunk.size = 0; /* no data at this point */
271 
272  /* init the curl session */
273  curl_handle = curl_easy_init();
274 
275  if (curl_handle == NULL)
276  {
277  LOG4CPLUS_WARN(getApplicationLogger(), "Failed to create CURL connection");
278 
279  return -2;
280  }
281 
282  code = curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, data);
283  if (code != CURLE_OK)
284  {
285  LOG4CPLUS_WARN (getApplicationLogger(),"Failed to set post fields");
286 
287  return -2;
288  }
289 
290  /* specify URL to get */
291  curl_easy_setopt(curl_handle, CURLOPT_URL, LASurl_.toString().c_str()/*"http://fu16.cmsdaqpreseries:9943/urn:xdaq-application:lid=100/retrieveCollection"*/);
292 
293  /* send all data to this function */
294  curl_easy_setopt(curl_handle, /*CURLOPT_HEADERFUNCTION*/ CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
295 
296  //curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, HeaderMemoryCallback);
297 
298  /* we pass our 'chunk' struct to the callback function */
299  curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
300 
301  /* some servers don't like requests that are made without a user-agent
302  field, so we provide one */
303  curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
304 
305  /* get it! */
306  curl_easy_perform(curl_handle);
307 
308  /* cleanup curl stuff */
309  curl_easy_cleanup(curl_handle);
310 
311  /*
312  * Now, our chunk.memory points to a memory block that is chunk.size
313  * bytes big and contains the remote file.
314  *
315  * Be aware of the fact that at this point we might have an
316  * allocated data block, and nothing has yet deallocated that data. So when
317  * you're done with it, you should free() it as a nice application.
318  */
319 
320  LOG4CPLUS_DEBUG (getApplicationLogger(),"chunk.memory length = " << chunk.size);
321 
322  xdata::exdr::FixedSizeInputStreamBuffer inBuffer(chunk.memory,chunk.size);
323 
324  /*if(chunk.size > 0)
325  free(chunk.memory);*/
326 
327  xdata::exdr::Serializer serializer;
328 
329  try
330  {
331  serializer.import(/*&(*rtable)*/ rtable, &inBuffer );
332  //serializer.import( rtable, &inBuffer );
333  }
335  {
336  LOG4CPLUS_ERROR(this->getApplicationLogger(),"xdata::exdr::Serializer exception occured...");
337  LOG4CPLUS_ERROR(this->getApplicationLogger(),xcept::stdformat_exception_history(e));
338 
339  if(chunk.size > 0)
340  free(chunk.memory);
341 
342  return -1 ;
343  }
344 
345  if(chunk.size > 0)
346  free(chunk.memory);
347 
348  return 0;
349 }
350 
351 
352 
353 
356 void xmas2dqm::wse::XmasToDQM::timeExpired (toolbox::task::TimerEvent& e)
357 {
358  //keep log how many times the period for parsing LAS expired...
359  static int times = 0;
360 
361  times++;
362 
363  LOG4CPLUS_DEBUG (getApplicationLogger(), "timeExpired was called... : time " << times <<"th");
364  LASReadoutWorkLoop_->submit(LASReadout_);
365 
366 }
367 
368 
370 {
371  /* There might be a realloc() out there that doesn't like reallocing
372  NULL pointers, so we take care of it here */
373  if(ptr)
374  return realloc(ptr, size);
375  else
376  return malloc(size);
377 }
378 
379 
380 //This function gets called by libcurl as soon as there is data received that needs to be saved
381 size_t xmas2dqm::wse::XmasToDQM::WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
382 {
383  size_t realsize = size * nmemb;
384  struct MemoryStruct *mem = (struct MemoryStruct *)data;
385 
386  mem->memory = (char *)myrealloc(mem->memory, mem->size + realsize + 1);
387  if (mem->memory)
388  {
389  memcpy(&(mem->memory[mem->size]), ptr, realsize);
390  mem->size += realsize;
391  mem->memory[mem->size] = 0;
392  }
393  return realsize;
394 }
395 
396 
397 
398 //listening to exported paramater values
400 {
401  LOG4CPLUS_DEBUG(getApplicationLogger(), "start of actionperformed");
402  LOG4CPLUS_DEBUG(getApplicationLogger(), e.type());
403 
404  // update exported parameters
405  if (e.type() == "ItemChangedEvent")
406  {
407  std::string item = dynamic_cast<xdata::ItemChangedEvent&>(e).itemName();
408 
409  if ( item == "Period")
410  {
411 
412  LOG4CPLUS_DEBUG(getApplicationLogger(), "item = " + item);
413 
414  if(fsm_.getStateName (fsm_.getCurrentState()) != "Enabled")
415  {
416  return;
417  }
418 
419  try
420  {
421  LASReadoutTimer_->remove(std::string("LASReadout"));
422  }
423  catch(toolbox::task::exception::NotActive &e)
424  {
425  LOG4CPLUS_WARN(getApplicationLogger(), "toolbox::task::exception::NotActive exception occured...");
426  }
427  catch(toolbox::task::exception::NoJobs)
428  {
429  LOG4CPLUS_WARN(getApplicationLogger(), "toolbox::task::exception::NoJobs exception occured...");
430  }
431  catch(toolbox::task::exception::JobNotFound &e)
432  {
433  LOG4CPLUS_WARN(getApplicationLogger(), "toolbox::task::exception::JobNotFound exception occured...");
434  toolbox::TimeInterval interval(/*10*/atoi(Period_.toString().c_str()),0); // period of 8 secs
435 
436  }
437 
438  //LASReadoutTimer_->stop();
439 
440  toolbox::TimeInterval interval(/*10*/atoi(Period_.toString().c_str()),0); // period of 8 secs
441 
442  startLASReadout_ = toolbox::TimeVal::gettimeofday();
443 
444  LASReadoutTimer_->scheduleAtFixedRate( startLASReadout_, this, interval, 0, std::string("LASReadout") );
445  }
446 
447 
448  if ( item == "flashlistMonitor")
449  {
450 
451  LOG4CPLUS_INFO(getApplicationLogger(), "flashlist = " << xmas2dqm::wse::ToDqm::instance()->flashlistMonitor_.bag.flashlist.toString());
452  LOG4CPLUS_INFO(getApplicationLogger(), "element = " << xmas2dqm::wse::ToDqm::instance()->flashlistMonitor_.bag.element.toString());
453  LOG4CPLUS_INFO(getApplicationLogger(), "xtitle = " << xmas2dqm::wse::ToDqm::instance()->flashlistMonitor_.bag.xtitle.toString());
454  LOG4CPLUS_INFO(getApplicationLogger(), "ytitle = " << xmas2dqm::wse::ToDqm::instance()->flashlistMonitor_.bag.ytitle.toString());
455 
456  //flashlistMonitor_.bag.flashlist = "abc";
457  //std::cout << "flashlist = " << flashlistMonitor_.bag.flashlist.toString() << std::endl;
458  }
459 
460  if ( item == "runNumber")
461  {
462 
463  LOG4CPLUS_INFO(getApplicationLogger(), "set runNumber to... = " << xmas2dqm::wse::ToDqm::instance()->runNumber_.toString());
464  }
465 
466  }
467 
468  LOG4CPLUS_DEBUG(getApplicationLogger(), "end of actionperformed");
469 }
470 
471 
472 // LASReadoutTimer_->scheduleAtFixedRate( startLASReadout_, this, interval, 0, std::string("") );
473 // //! Schedules the specified task for execution after the specified delay
474 // void scheduleAtFixedRate (
475 // toolbox::TimeVal& start,
476 // toolbox::task::TimerListener* listener,
477 // toolbox::TimeInterval& period,
478 // void* context,
479 // const std::string& name)
480 // throw (toolbox::task::exception::InvalidListener, toolbox::task::exception::InvalidSubmission, toolbox::task::exception::NotActive);
481 
482 
483 
485 {
486 
487 }
488 
489 
490 xoap::MessageReference xmas2dqm::wse::XmasToDQM::fireEvent (xoap::MessageReference msg)
492 {
493  xoap::SOAPPart part = msg->getSOAPPart();
494  xoap::SOAPEnvelope env = part.getEnvelope();
495  xoap::SOAPBody body = env.getBody();
496  DOMNode* node = body.getDOMNode();
497  DOMNodeList* bodyList = node->getChildNodes();
498  for (unsigned int i = 0; i < bodyList->getLength(); i++)
499  {
500  DOMNode* command = bodyList->item(i);
501 
502  if (command->getNodeType() == DOMNode::ELEMENT_NODE)
503  {
504 
505  std::string commandName = xoap::XMLCh2String (command->getLocalName());
506 
507 
508  try
509  {
510  toolbox::Event::Reference e(new toolbox::Event(commandName,this));
511  fsm_.fireEvent(e);
512  }
514  {
515  XCEPT_RETHROW(xoap::exception::Exception, "invalid command", e);
516  }
517 
518  xoap::MessageReference reply = xoap::createMessage();
519  xoap::SOAPEnvelope envelope = reply->getSOAPPart().getEnvelope();
520  xoap::SOAPName responseName = envelope.createName( commandName +"Response", "xdaq", XDAQ_NS_URI);
521  // xoap::SOAPBodyElement e = envelope.getBody().addBodyElement ( responseName );
522  (void) envelope.getBody().addBodyElement ( responseName );
523  return reply;
524  }
525  }
526 
527  XCEPT_RAISE(xcept::Exception,"command not found");
528 }
529 
530 
531 xoap::MessageReference xmas2dqm::wse::XmasToDQM::reset (xoap::MessageReference msg) throw (xoap::exception::Exception)
532 {
533  LOG4CPLUS_DEBUG (getApplicationLogger(), "New state before reset is: " << fsm_.getStateName (fsm_.getCurrentState()) );
534 
535  fsm_.reset();
536  state_ = fsm_.getStateName (fsm_.getCurrentState());
537 
538  xoap::MessageReference reply = xoap::createMessage();
539  xoap::SOAPEnvelope envelope = reply->getSOAPPart().getEnvelope();
540  xoap::SOAPName responseName = envelope.createName("ResetResponse", "xdaq", XDAQ_NS_URI);
541  // xoap::SOAPBodyElement e = envelope.getBody().addBodyElement ( responseName );
542  (void) envelope.getBody().addBodyElement ( responseName );
543 
544  LOG4CPLUS_DEBUG (getApplicationLogger(), "New state after reset is: " << fsm_.getStateName (fsm_.getCurrentState()) );
545 
546  return reply;
547 }
548 
549 
551 {
552  LOG4CPLUS_DEBUG (getApplicationLogger(), e->type());
553 
554 
555  try
556  {
557  LASReadoutTimer_->remove(std::string("LASReadout"));
558  }
559  catch(toolbox::task::exception::NotActive &e)
560  {
561  LOG4CPLUS_WARN(getApplicationLogger(), "toolbox::task::exception::NotActive exception occured...");
562  }
563  catch(toolbox::task::exception::NoJobs)
564  {
565  LOG4CPLUS_INFO(getApplicationLogger(), "toolbox::task::exception::NoJobs exception occured...");
566  }
567  catch(toolbox::task::exception::JobNotFound &e)
568  {
569  LOG4CPLUS_INFO(getApplicationLogger(), "toolbox::task::exception::JobNotFound exception occured...");
570  toolbox::TimeInterval interval(/*10*/atoi(Period_.toString().c_str()),0); // period of 8 secs
571 
572  }
573 
574 
575  toolbox::TimeInterval interval(/*10*/atoi(Period_.toString().c_str()),0); // period of 8 secs
576 
577  startLASReadout_ = toolbox::TimeVal::gettimeofday();
578 
579  LASReadoutTimer_->scheduleAtFixedRate( startLASReadout_, this, interval, 0, std::string("LASReadout") );
580 
581 }
582 
583 
585 {
586  LOG4CPLUS_DEBUG (getApplicationLogger(), e->type());
587 
588  try
589  {
590  LASReadoutTimer_->remove(std::string("LASReadout"));
591  }
592  catch(toolbox::task::exception::NotActive &e)
593  {
594  LOG4CPLUS_WARN(getApplicationLogger(), "toolbox::task::exception::NotActive exception occured...");
595  }
596  catch(toolbox::task::exception::NoJobs)
597  {
598  LOG4CPLUS_WARN(getApplicationLogger(), "toolbox::task::exception::NoJobs exception occured...");
599  }
600  catch(toolbox::task::exception::JobNotFound &e)
601  {
602  LOG4CPLUS_WARN(getApplicationLogger(), "toolbox::task::exception::JobNotFound exception occured...");
603  toolbox::TimeInterval interval(/*10*/atoi(Period_.toString().c_str()),0); // period of 8 secs
604 
605  }
606 
607 }
608 
609 
610 
611 void xmas2dqm::wse::XmasToDQM::stateChanged (toolbox::fsm::FiniteStateMachine & fsm) throw (toolbox::fsm::exception::Exception)
612 {
613  // Reflect the new state
614  state_ = fsm.getStateName (fsm.getCurrentState());
615  LOG4CPLUS_DEBUG (getApplicationLogger(), "New state is:" << fsm.getStateName (fsm.getCurrentState()) );
616 }
617 
619 {
620  toolbox::fsm::FailedEvent & fe = dynamic_cast<toolbox::fsm::FailedEvent&>(*e);
621  LOG4CPLUS_ERROR (getApplicationLogger(), "Failure occurred when performing transition from: " <<
622  fe.getFromState() << " to: " << fe.getToState() << " exception: " << fe.getException().what() );
623 }
624 
625 
static const char runNumber_[]
int i
Definition: DBlmapReader.cc:9
xoap::MessageReference fireEvent(xoap::MessageReference msg)
Definition: XmasToDQM.cc:490
tuple interval
Definition: MergeJob_cfg.py:20
void stateChanged(toolbox::fsm::FiniteStateMachine &fsm)
Definition: XmasToDQM.cc:611
xdata::String Period_
Definition: XmasToDQM.h:157
xdata::String LASurl_
Definition: XmasToDQM.h:156
void failedTransition(toolbox::Event::Reference e)
Definition: XmasToDQM.cc:618
void digest(const std::string &flashListName, const std::string &originator, const std::string &tag, xdata::Table *table)
Definition: ToDqm.cc:33
void actionPerformed(xdata::Event &e)
Definition: XmasToDQM.cc:399
static void * myrealloc(void *ptr, size_t size)
Definition: XmasToDQM.cc:369
#define NULL
Definition: scimark2.h:8
tuple node
Definition: Node.py:50
void HaltAction(toolbox::Event::Reference e)
Definition: XmasToDQM.cc:584
void EnableAction(toolbox::Event::Reference e)
Definition: XmasToDQM.cc:550
static ToDqm * instance()
Definition: ToDqm.cc:6
void timeExpired(toolbox::task::TimerEvent &e)
Definition: XmasToDQM.cc:356
uint16_t mem[nChs][nEvts]
double & fe
Definition: VDTMath.h:196
part
Definition: HCALResponse.h:21
int getEXDR_LAS(xdata::Table *rtable)
Definition: XmasToDQM.cc:255
bool LASReadoutWorkLoop(toolbox::task::WorkLoop *wl)
Definition: XmasToDQM.cc:162
xoap::MessageReference reset(xoap::MessageReference msg)
Definition: XmasToDQM.cc:531
xdata::String LASQueueSize_
Definition: XmasToDQM.h:158
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
Definition: XmasToDQM.cc:381
tuple size
Write out results.