CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Attributes

xmas2dqm::wse::XmasToDQM Class Reference

#include <XmasToDQM.h>

List of all members.

Public Member Functions

void actionPerformed (xdata::Event &e)
void Default (xgi::Input *in, xgi::Output *out) throw (xgi::exception::Exception)
xoap::MessageReference report (xoap::MessageReference msg) throw (xoap::exception::Exception)
 Receive metrics from a sensor.
 XDAQ_INSTANTIATOR ()
 XmasToDQM (xdaq::ApplicationStub *s) throw (xdaq::exception::Exception)
 ~XmasToDQM ()

Protected Member Functions

void ConfigureAction (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception)
void EnableAction (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception)
void failedTransition (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception)
xoap::MessageReference fireEvent (xoap::MessageReference msg) throw (xoap::exception::Exception)
int getEXDR_LAS (xdata::Table *rtable)
void HaltAction (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception)
bool LASReadoutWorkLoop (toolbox::task::WorkLoop *wl)
xoap::MessageReference reset (xoap::MessageReference msg) throw (xoap::exception::Exception)
void ResumeAction (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception)
void stateChanged (toolbox::fsm::FiniteStateMachine &fsm) throw (toolbox::fsm::exception::Exception)
void SuspendAction (toolbox::Event::Reference e) throw (toolbox::fsm::exception::Exception)
void timeExpired (toolbox::task::TimerEvent &e)

Static Protected Member Functions

static void * myrealloc (void *ptr, size_t size)
static size_t WriteMemoryCallback (void *ptr, size_t size, size_t nmemb, void *data)

Protected Attributes

xdata::String LASQueueSize_
xdata::String LASurl_
xdata::String Period_
xdata::String state_

Private Attributes

xmas2dqm::wse::ToDqmdqmHook_
toolbox::fsm::FiniteStateMachine fsm_
toolbox::task::ActionSignature * LASReadout_
toolbox::task::Timer * LASReadoutTimer_
toolbox::task::WorkLoop * LASReadoutWorkLoop_
toolbox::TimeVal startLASReadout_

Detailed Description

Definition at line 80 of file XmasToDQM.h.


Constructor & Destructor Documentation

xmas2dqm::wse::XmasToDQM::XmasToDQM ( xdaq::ApplicationStub *  s) throw (xdaq::exception::Exception)

Definition at line 71 of file XmasToDQM.cc.

References EnableAction(), failedTransition(), fireEvent(), HaltAction(), xmas2dqm::wse::ToDqm::instance(), LASReadoutWorkLoop(), reset(), sistrip::runNumber_, and stateChanged().

        : xdaq::Application(s)
{       
        getApplicationDescriptor()->setAttribute("icon", "/xmas2dqm/wse/images/Las.png");
        
        LOG4CPLUS_DEBUG(this->getApplicationLogger(),"inside constructor of xmas2dqm::wse::Application");

        
        // Activates work loop for las asynchronous operations (SOAP messages)
        //dispatcher_.addActionListener(this);
        //(void) toolbox::task::getWorkLoopFactory()->getWorkLoop("urn:xdaq-workloop:las", "waiting")->activate();
        
        
        // bind SOAP interface
        xoap::bind(this, &xmas2dqm::wse::XmasToDQM::fireEvent, "Enable", XDAQ_NS_URI );
        xoap::bind(this, &xmas2dqm::wse::XmasToDQM::fireEvent, "Halt", XDAQ_NS_URI );
        xoap::bind(this, &xmas2dqm::wse::XmasToDQM::reset, "Reset", XDAQ_NS_URI );
        
        
        // Define FSM
        //              
        fsm_.addState('H', "Halted", this, &xmas2dqm::wse::XmasToDQM::stateChanged);
        fsm_.addState('E', "Enabled", this, &xmas2dqm::wse::XmasToDQM::stateChanged);

        fsm_.addStateTransition('H', 'E', "Enable", this,&xmas2dqm::wse::XmasToDQM::EnableAction);
        fsm_.addStateTransition('H', 'H', "Halt", this, &xmas2dqm::wse::XmasToDQM::HaltAction);
        fsm_.addStateTransition('E', 'H', "Halt", this, &xmas2dqm::wse::XmasToDQM::HaltAction);

        // Failure state setting
        fsm_.setFailedStateTransitionAction( this, &xmas2dqm::wse::XmasToDQM::failedTransition );
        fsm_.setFailedStateTransitionChanged(this, &xmas2dqm::wse::XmasToDQM::stateChanged );

        fsm_.setInitialState('H');
        fsm_.setStateName('F', "Failed"); // give a name to the 'F' state

        fsm_.reset();

        // Export a "State" variable that reflects the state of the state machine
        state_ = fsm_.getStateName (fsm_.getCurrentState());
        getApplicationInfoSpace()->fireItemAvailable("stateName",&state_);
        getApplicationInfoSpace()->fireItemAvailable("LASurl",&LASurl_);
        getApplicationInfoSpace()->fireItemAvailable("Period",&Period_);
        getApplicationInfoSpace()->fireItemAvailable("LASQueueSize",&LASQueueSize_);
        getApplicationInfoSpace()->fireItemAvailable("flashlistMonitor",&xmas2dqm::wse::ToDqm::instance()->flashlistMonitor_);
        getApplicationInfoSpace()->fireItemAvailable("runNumber",&xmas2dqm::wse::ToDqm::instance()->runNumber_);
        
        // Add infospace listeners for exporting data values
        getApplicationInfoSpace()->addItemChangedListener ("stateName", this);
        getApplicationInfoSpace()->addItemChangedListener ("LASurl", this);
        getApplicationInfoSpace()->addItemChangedListener ("Period", this);
        getApplicationInfoSpace()->addItemChangedListener ("LASQueueSize", this);
        getApplicationInfoSpace()->addItemChangedListener ("flashlistMonitor", this);
        getApplicationInfoSpace()->addItemChangedListener ("runNumber", this);
        
        LASurl_ = "https://srv-c2d04-18.cms:9943/urn:xdaq-application:lid=100/retrieveCollection";
        Period_ = "10";
        LASQueueSize_ = "100000";
        
        //https://srv-c2d04-18.cms:9943/urn:xdaq-application:lid=100/retrieveCollection
        //https://fu16.cmsdaqpreseries:9943/urn:xdaq-application:lid=100/retrieveCollection
        
        
        //curl_global_init(CURL_GLOBAL_DEFAULT);
        curl_global_init(CURL_GLOBAL_ALL);
        
        LASReadout_ = toolbox::task::bind (this, &xmas2dqm::wse::XmasToDQM::LASReadoutWorkLoop, "LASReadoutWorkLoop");
        
        LASReadoutWorkLoop_ = toolbox::task::getWorkLoopFactory()->getWorkLoop("LASReadoutWaitingWorkLoop", "waiting");
        
        
        if (LASReadoutWorkLoop_->isActive() == false) 
        {
                LASReadoutWorkLoop_->activate();
                
        }
        
        //LOG4CPLUS_INFO(this->getApplicationLogger(),"insdie constructor of xmas2dqm::wse::XmasToDQM Period = " << Period_.toString());
        
        LASReadoutTimer_ = toolbox::task::getTimerFactory()->createTimer("PeriodicLASReadout");

        // toolbox::TimeInterval interval(/*10*/atoi(Period_.toString().c_str()),0); // period of 8 secs 
//         
//      startLASReadout_ = toolbox::TimeVal::gettimeofday();
//         
//      LASReadoutTimer_->scheduleAtFixedRate( startLASReadout_, this, interval,  0, std::string("LASReadout") );       

        LOG4CPLUS_DEBUG(this->getApplicationLogger(),"finish of Constructor of xmas2dqm::wse::XmasToDQM");
        
}
xmas2dqm::wse::XmasToDQM::~XmasToDQM ( )

Definition at line 484 of file XmasToDQM.cc.

{

}

Member Function Documentation

void xmas2dqm::wse::XmasToDQM::actionPerformed ( xdata::Event &  e)

Definition at line 399 of file XmasToDQM.cc.

References alignCSCRings::e, xmas2dqm::wse::ToDqm::instance(), MergeJob_cfg::interval, and sistrip::runNumber_.

{ 
        LOG4CPLUS_DEBUG(getApplicationLogger(), "start of actionperformed");
        LOG4CPLUS_DEBUG(getApplicationLogger(), e.type());
        
        // update exported parameters           
        if (e.type() == "ItemChangedEvent")
        {
                std::string item = dynamic_cast<xdata::ItemChangedEvent&>(e).itemName();        
                
                if ( item == "Period")
                {

                        LOG4CPLUS_DEBUG(getApplicationLogger(), "item = " + item);              
                        
                        if(fsm_.getStateName (fsm_.getCurrentState()) != "Enabled")
                        {
                                return;
                        }
                
                        try
                        {
                                LASReadoutTimer_->remove(std::string("LASReadout"));
                        }
                        catch(toolbox::task::exception::NotActive &e)
                        {
                                LOG4CPLUS_WARN(getApplicationLogger(), "toolbox::task::exception::NotActive exception occured...");
                        }
                        catch(toolbox::task::exception::NoJobs)
                        {
                                LOG4CPLUS_WARN(getApplicationLogger(), "toolbox::task::exception::NoJobs exception occured...");
                        }
                        catch(toolbox::task::exception::JobNotFound &e)
                        {
                                LOG4CPLUS_WARN(getApplicationLogger(), "toolbox::task::exception::JobNotFound exception occured...");
                                toolbox::TimeInterval interval(/*10*/atoi(Period_.toString().c_str()),0); // period of 8 secs 
        
                        }
                
                        //LASReadoutTimer_->stop();
                        
                        toolbox::TimeInterval interval(/*10*/atoi(Period_.toString().c_str()),0); // period of 8 secs 
        
                        startLASReadout_ = toolbox::TimeVal::gettimeofday();
        
                        LASReadoutTimer_->scheduleAtFixedRate( startLASReadout_, this, interval,  0, std::string("LASReadout") );       
                } 
        
        
                if ( item == "flashlistMonitor")
                {

                        LOG4CPLUS_INFO(getApplicationLogger(), "flashlist = " << xmas2dqm::wse::ToDqm::instance()->flashlistMonitor_.bag.flashlist.toString());
                        LOG4CPLUS_INFO(getApplicationLogger(), "element = " << xmas2dqm::wse::ToDqm::instance()->flashlistMonitor_.bag.element.toString());
                        LOG4CPLUS_INFO(getApplicationLogger(), "xtitle = " << xmas2dqm::wse::ToDqm::instance()->flashlistMonitor_.bag.xtitle.toString());
                        LOG4CPLUS_INFO(getApplicationLogger(), "ytitle = " << xmas2dqm::wse::ToDqm::instance()->flashlistMonitor_.bag.ytitle.toString());
                        
                        //flashlistMonitor_.bag.flashlist = "abc";
                        //std::cout << "flashlist = " << flashlistMonitor_.bag.flashlist.toString() << std::endl;
                }
                
                if ( item == "runNumber")
                {

                        LOG4CPLUS_INFO(getApplicationLogger(), "set runNumber to... = " << xmas2dqm::wse::ToDqm::instance()->runNumber_.toString());
                } 
        
        }
        
        LOG4CPLUS_DEBUG(getApplicationLogger(), "end of actionperformed");
}
void xmas2dqm::wse::XmasToDQM::ConfigureAction ( toolbox::Event::Reference  e) throw (toolbox::fsm::exception::Exception) [protected]
void xmas2dqm::wse::XmasToDQM::Default ( xgi::Input *  in,
xgi::Output *  out 
) throw (xgi::exception::Exception)
void xmas2dqm::wse::XmasToDQM::EnableAction ( toolbox::Event::Reference  e) throw (toolbox::fsm::exception::Exception) [protected]

Definition at line 550 of file XmasToDQM.cc.

References alignCSCRings::e, and MergeJob_cfg::interval.

Referenced by XmasToDQM().

{
        LOG4CPLUS_DEBUG (getApplicationLogger(), e->type());
        
        
        try
        {
                LASReadoutTimer_->remove(std::string("LASReadout"));
        }
        catch(toolbox::task::exception::NotActive &e)
        {
                LOG4CPLUS_WARN(getApplicationLogger(), "toolbox::task::exception::NotActive exception occured...");
        }
        catch(toolbox::task::exception::NoJobs)
        {
                LOG4CPLUS_INFO(getApplicationLogger(), "toolbox::task::exception::NoJobs exception occured...");
        }
        catch(toolbox::task::exception::JobNotFound &e)
        {
                LOG4CPLUS_INFO(getApplicationLogger(), "toolbox::task::exception::JobNotFound exception occured...");
                toolbox::TimeInterval interval(/*10*/atoi(Period_.toString().c_str()),0); // period of 8 secs 
        
        }
        
        
        toolbox::TimeInterval interval(/*10*/atoi(Period_.toString().c_str()),0); // period of 8 secs 
        
        startLASReadout_ = toolbox::TimeVal::gettimeofday();
        
        LASReadoutTimer_->scheduleAtFixedRate( startLASReadout_, this, interval,  0, std::string("LASReadout") );
        
}
void xmas2dqm::wse::XmasToDQM::failedTransition ( toolbox::Event::Reference  e) throw (toolbox::fsm::exception::Exception) [protected]

Definition at line 618 of file XmasToDQM.cc.

Referenced by XmasToDQM().

{
        toolbox::fsm::FailedEvent & fe = dynamic_cast<toolbox::fsm::FailedEvent&>(*e);
        LOG4CPLUS_ERROR (getApplicationLogger(), "Failure occurred when performing transition from: "  <<
                        fe.getFromState() <<  " to: " << fe.getToState() << " exception: " << fe.getException().what() );
}
xoap::MessageReference xmas2dqm::wse::XmasToDQM::fireEvent ( xoap::MessageReference  msg) throw (xoap::exception::Exception) [protected]

Definition at line 490 of file XmasToDQM.cc.

References edmPickEvents::command, alignCSCRings::e, Exception, i, lumiQueryAPI::msg, and python::Node::node.

Referenced by XmasToDQM().

{
        xoap::SOAPPart part = msg->getSOAPPart();
        xoap::SOAPEnvelope env = part.getEnvelope();
        xoap::SOAPBody body = env.getBody();
        DOMNode* node = body.getDOMNode();
        DOMNodeList* bodyList = node->getChildNodes();
        for (unsigned int i = 0; i < bodyList->getLength(); i++) 
        {
                DOMNode* command = bodyList->item(i);

                if (command->getNodeType() == DOMNode::ELEMENT_NODE)
                {

                        std::string commandName = xoap::XMLCh2String (command->getLocalName());


                        try 
                        {
                                toolbox::Event::Reference e(new toolbox::Event(commandName,this));
                                fsm_.fireEvent(e);
                        }
                        catch (toolbox::fsm::exception::Exception & e)
                        {
                                XCEPT_RETHROW(xoap::exception::Exception, "invalid command", e);
                        }

                        xoap::MessageReference reply = xoap::createMessage();
                        xoap::SOAPEnvelope envelope = reply->getSOAPPart().getEnvelope();
                        xoap::SOAPName responseName = envelope.createName( commandName +"Response", "xdaq", XDAQ_NS_URI);
                        // xoap::SOAPBodyElement e = envelope.getBody().addBodyElement ( responseName );
                        (void) envelope.getBody().addBodyElement ( responseName );
                        return reply;
                }
        }

        XCEPT_RAISE(xcept::Exception,"command not found");              
}
int xmas2dqm::wse::XmasToDQM::getEXDR_LAS ( xdata::Table *  rtable) [protected]

Definition at line 255 of file XmasToDQM.cc.

References AlCaHLTBitMon_QueryRunRegistry::data, alignCSCRings::e, Exception, xmas2dqm::wse::ToDqm::instance(), xmas2dqm::wse::MemoryStruct::memory, NULL, and xmas2dqm::wse::MemoryStruct::size.

Referenced by LASReadoutWorkLoop().

{
        LOG4CPLUS_DEBUG(this->getApplicationLogger(),"inside getEXDR_LAS.........");    
        
        CURL *curl_handle;
        CURLcode code;
         
        char data[200] = "fmt=exdr&flash=";
        
        strcat(data, xmas2dqm::wse::ToDqm::instance()->flashlistMonitor_.bag.flashlist.toString().c_str());
        
        
        struct MemoryStruct chunk;
  
        chunk.memory=NULL; /* we expect realloc(NULL, size) to work */
        chunk.size = 0;    /* no data at this point */
          
        /* init the curl session */
        curl_handle = curl_easy_init();
  
        if (curl_handle == NULL)
        {
                LOG4CPLUS_WARN(getApplicationLogger(), "Failed to create CURL connection");
  
                return -2;
        }       
      
        code = curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, data);
        if (code != CURLE_OK)
        {
                LOG4CPLUS_WARN (getApplicationLogger(),"Failed to set post fields");
  
                return -2;
        }
        
        /* specify URL to get */
        curl_easy_setopt(curl_handle, CURLOPT_URL, LASurl_.toString().c_str()/*"https://fu16.cmsdaqpreseries:9943/urn:xdaq-application:lid=100/retrieveCollection"*/);
  
        /* send all data to this function  */
        curl_easy_setopt(curl_handle, /*CURLOPT_HEADERFUNCTION*/ CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
        
        //curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, HeaderMemoryCallback);
  
        /* we pass our 'chunk' struct to the callback function */
        curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
 
        /* some servers don't like requests that are made without a user-agent
        field, so we provide one */
        curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
 
        /* get it! */
        curl_easy_perform(curl_handle);
 
        /* cleanup curl stuff */
        curl_easy_cleanup(curl_handle);
 
         /*
        * Now, our chunk.memory points to a memory block that is chunk.size
        * bytes big and contains the remote file.
        *
        * Be aware of the fact that at this point we might have an
        * allocated data block, and nothing has yet deallocated that data. So when
        * you're done with it, you should free() it as a nice application.
        */
 
        LOG4CPLUS_DEBUG (getApplicationLogger(),"chunk.memory length = " << chunk.size);
        
        xdata::exdr::FixedSizeInputStreamBuffer inBuffer(chunk.memory,chunk.size);
        
        /*if(chunk.size > 0)
                free(chunk.memory);*/
        
        xdata::exdr::Serializer serializer;

        try 
        {
                serializer.import(/*&(*rtable)*/ rtable, &inBuffer );
                //serializer.import( rtable, &inBuffer );
        }
        catch(xdata::exception::Exception & e )
        {
                LOG4CPLUS_ERROR(this->getApplicationLogger(),"xdata::exdr::Serializer exception occured...");
                LOG4CPLUS_ERROR(this->getApplicationLogger(),xcept::stdformat_exception_history(e));
                        
                if(chunk.size > 0)
                        free(chunk.memory);
                        
                return -1 ;
        }
        
        if(chunk.size > 0)
                free(chunk.memory);
        
        return 0;
}
void xmas2dqm::wse::XmasToDQM::HaltAction ( toolbox::Event::Reference  e) throw (toolbox::fsm::exception::Exception) [protected]

Definition at line 584 of file XmasToDQM.cc.

References alignCSCRings::e, and MergeJob_cfg::interval.

Referenced by XmasToDQM().

{
        LOG4CPLUS_DEBUG (getApplicationLogger(), e->type());
        
        try
        {
                LASReadoutTimer_->remove(std::string("LASReadout"));
        }
        catch(toolbox::task::exception::NotActive &e)
        {
                LOG4CPLUS_WARN(getApplicationLogger(), "toolbox::task::exception::NotActive exception occured...");
        }
        catch(toolbox::task::exception::NoJobs)
        {
                LOG4CPLUS_WARN(getApplicationLogger(), "toolbox::task::exception::NoJobs exception occured...");
        }
        catch(toolbox::task::exception::JobNotFound &e)
        {
                LOG4CPLUS_WARN(getApplicationLogger(), "toolbox::task::exception::JobNotFound exception occured...");
                toolbox::TimeInterval interval(/*10*/atoi(Period_.toString().c_str()),0); // period of 8 secs 
        
        }

}
bool xmas2dqm::wse::XmasToDQM::LASReadoutWorkLoop ( toolbox::task::WorkLoop *  wl) [protected]

Definition at line 162 of file XmasToDQM.cc.

References getEXDR_LAS(), i, instance, xmas2dqm::wse::ToDqm::instance(), LASQueueSize_, LASurl_, Period_, and runTheMatrix::ret.

Referenced by XmasToDQM().

{
        //keep log how many times the workloop was called...
        static int times = 0;
        times++;
        
        LOG4CPLUS_DEBUG (getApplicationLogger(), "inside WorkLoop...ready to ask LAS for EXDR data : time " << times <<"th");
        LOG4CPLUS_DEBUG (getApplicationLogger(), "Period = " + Period_.toString() + " LASurl = " + LASurl_.toString());
        
        
        xdata::Table * ptr_table = new xdata::Table();
        
        int ret = getEXDR_LAS(ptr_table);
        
        LOG4CPLUS_DEBUG (getApplicationLogger(), "return value from getEXDR_LAS = " << ret );
        
        if (ret == -1 || ret == -2) //exception during xdata::exdr deserialization occured or during CURL (could log different messages)
        {       
                //LOG4CPLUS_INFO (getApplicationLogger(), "LASWorkLoop ready to call xdata::Table::Reference destructor..." );
                
                //ref_table->~Table();
                
                
                LOG4CPLUS_DEBUG (getApplicationLogger(), "LASWorkLoop freeing xdata::Table * space" );
                
                delete ptr_table;
                
                LOG4CPLUS_WARN (getApplicationLogger(), "getEXDRLAS didn't complete properly, returning from LASREeadoutWorkLoop" );
                return false;
        }

        
        
        LOG4CPLUS_DEBUG (getApplicationLogger(), "inside WorkLoop...lock the mutex ");
        
        
        //BSem_.take();
        //acquire the mutex - protect access to the queue
        pthread_mutex_lock(&xmas2dqm::wse::ToDqm::instance()->LASmutex_);
   
        LOG4CPLUS_INFO (getApplicationLogger(), "inside WorkLoop...check (...and possible wait) if data queue is full");
        
        //check if the queue is full and wait (a signal that informs that an element has been poped)
        // until there is 'space' in the queue    
        while (xmas2dqm::wse::ToDqm::instance()->MemoryTable_.size() >= (unsigned int) atoi(LASQueueSize_.toString().c_str())/*Qsize_max*/)
        {
                pthread_cond_wait(&xmas2dqm::wse::ToDqm::instance()->less_, &xmas2dqm::wse::ToDqm::instance()->LASmutex_);
        }
        
        LOG4CPLUS_DEBUG (getApplicationLogger(), "data queue has available store...proceeding...");
        
                
        
        std::map<std::string, std::string, std::less<std::string> >::iterator i;
        
        //size_t row = ref_table->getRowCount();
        // size_t row = ptr_table->getRowCount();
// 
//      for ( size_t r = 0; r <  ptr_table->numberOfRows_ /*ref_table->numberOfRows_*/; r++ )
//      {
//              LOG4CPLUS_INFO(this->getApplicationLogger(),"********* Printing table inside XmasToDQM ***************");
//              LOG4CPLUS_INFO(this->getApplicationLogger(),/*ref_table*/ ptr_table->columnData_["bxHistogram"]->elementAt(r)->toString());
//          
//              boost::tokenizer<> tokens(/*ref_table*/ ptr_table->columnData_["bxHistogram"]->elementAt(r)->toString());
//              for(boost::tokenizer<>::iterator itok=tokens.begin(); itok!=tokens.end();++itok)
//              {
//                              //LOG4CPLUS_INFO(this->getApplicationLogger, (std::string)(*itok) );
//              }
//          
//              row++;
//      }
        
        
        LOG4CPLUS_DEBUG (getApplicationLogger(), "inside WorkLoop...ready to call XmastoDQM::ToDQM::digest " );
        
        //insert LAS data table to ToDQM objec - queue
        xmas2dqm::wse::ToDqm::instance()->digest("flashListName", "originator", "tagName", ptr_table /*ref_table*/);
        
        LOG4CPLUS_DEBUG (getApplicationLogger(), "inside WorkLoop...signaling new element added to the data queue ");
        
        //signal that a new element has been inserted
        pthread_cond_signal(&xmas2dqm::wse::ToDqm::instance()->more_);

        LOG4CPLUS_DEBUG (getApplicationLogger(), "inside WorkLoop...release mutex, allow access to the data queue");

        //allow access to the queue
        pthread_mutex_unlock(&xmas2dqm::wse::ToDqm::instance()->LASmutex_);     
        
        return false;
}
void * xmas2dqm::wse::XmasToDQM::myrealloc ( void *  ptr,
size_t  size 
) [static, protected]

Definition at line 369 of file XmasToDQM.cc.

{
        /* There might be a realloc() out there that doesn't like reallocing
        NULL pointers, so we take care of it here */
        if(ptr)
                return realloc(ptr, size);
        else
                return malloc(size);
}
void DDErrorDetection::report ( xoap::MessageReference  msg) throw (xoap::exception::Exception)

Receive metrics from a sensor.

Definition at line 235 of file DDErrorDetection.cc.

References gather_cfg::cout, and instance.

{
  
  o << std::endl << std::endl << "---> DDD ERROR REPORT <---" << std::endl << std::endl;
  o << "MISSING DEFINITIONS:" << std::endl << std::endl;
  o << "LogicalParts:" << std::endl
    << lp_err::instance() << std::endl;
  o << "Materials:" << std::endl
    << ma_err::instance()  << std::endl;
  o << "Solids:" << std::endl
    << so_err::instance() << std::endl;
  o << "Rotations:" << std::endl
    << ro_err::instance() << std::endl;
  o << "Specifics:" << std::endl
    << sp_err::instance() << std::endl;
  o << std::endl << "IMPLICATIONS OF MISSING DEFINITIONS:" << std::endl << std::endl;
 
  o << "A) LogicalParts that have missing definitions but are used in the geometr. hierarchy (PosParts):" << std::endl
    << "   Format: namespace:name: [name of child]*" << std::endl;
  o << lp_cpv(cpv) << std::endl;
  
  o << "B) Detailed report on Materials:" << std::endl;
  const std::vector<pair<std::string,DDName> > & res = ma();
  std::vector<pair<std::string,DDName> >::const_iterator it(res.begin()), ed(res.end());
  for (; it != ed; ++it) {
    std::cout << it->second << ":  " << it->first << std::endl;
  }
  std::cout << std::endl;

  
  o << "C) Solids affected by Solids that have missing definitions:" << std::endl;
  o << so() << std::endl;
   
  o << "D) LogicalParts affected by Materials of B):" << std::endl;
  o << ma_lp() << std::endl;
  
  o << "E) LogicalParts affected by Solids of C):" << std::endl;
  o << so_lp() << std::endl;
  
  // Did this ever exist?
  //  o << "F) Parent-Child positionings affected by Rotations that have missing definitions:"  << std::endl;
  o << std::endl;
  //nix();
}
xoap::MessageReference xmas2dqm::wse::XmasToDQM::reset ( xoap::MessageReference  msg) throw (xoap::exception::Exception) [protected]

Definition at line 531 of file XmasToDQM.cc.

Referenced by XmasToDQM().

{
        LOG4CPLUS_DEBUG (getApplicationLogger(), "New state before reset is: " << fsm_.getStateName (fsm_.getCurrentState()) );

        fsm_.reset();
        state_ = fsm_.getStateName (fsm_.getCurrentState());

        xoap::MessageReference reply = xoap::createMessage();
        xoap::SOAPEnvelope envelope = reply->getSOAPPart().getEnvelope();
        xoap::SOAPName responseName = envelope.createName("ResetResponse", "xdaq", XDAQ_NS_URI);
        // xoap::SOAPBodyElement e = envelope.getBody().addBodyElement ( responseName );
        (void) envelope.getBody().addBodyElement ( responseName );

        LOG4CPLUS_DEBUG (getApplicationLogger(), "New state after reset is: " << fsm_.getStateName (fsm_.getCurrentState()) );

        return reply;
}
void xmas2dqm::wse::XmasToDQM::ResumeAction ( toolbox::Event::Reference  e) throw (toolbox::fsm::exception::Exception) [protected]
void xmas2dqm::wse::XmasToDQM::stateChanged ( toolbox::fsm::FiniteStateMachine &  fsm) throw (toolbox::fsm::exception::Exception) [protected]

Definition at line 611 of file XmasToDQM.cc.

Referenced by XmasToDQM().

{
        // Reflect the new state
        state_ = fsm.getStateName (fsm.getCurrentState());
        LOG4CPLUS_DEBUG (getApplicationLogger(), "New state is:" << fsm.getStateName (fsm.getCurrentState()) );
}
void xmas2dqm::wse::XmasToDQM::SuspendAction ( toolbox::Event::Reference  e) throw (toolbox::fsm::exception::Exception) [protected]
void xmas2dqm::wse::XmasToDQM::timeExpired ( toolbox::task::TimerEvent &  e) [protected]

Timer method called, this method inject the method dcuReadWorkLoop in the queue to be executed

Definition at line 356 of file XmasToDQM.cc.

{
        //keep log how many times the period for parsing LAS expired...
        static int times = 0;
        
        times++;        
        
        LOG4CPLUS_DEBUG (getApplicationLogger(), "timeExpired was called... : time " << times <<"th");
        LASReadoutWorkLoop_->submit(LASReadout_);
 
}
size_t xmas2dqm::wse::XmasToDQM::WriteMemoryCallback ( void *  ptr,
size_t  size,
size_t  nmemb,
void *  data 
) [static, protected]

Definition at line 381 of file XmasToDQM.cc.

References mem, xmas2dqm::wse::MemoryStruct::memory, and xmas2dqm::wse::MemoryStruct::size.

{
        size_t realsize = size * nmemb;
        struct MemoryStruct *mem = (struct MemoryStruct *)data;
  
        mem->memory = (char *)myrealloc(mem->memory, mem->size + realsize + 1);
        if (mem->memory) 
        {
                memcpy(&(mem->memory[mem->size]), ptr, realsize);
                mem->size += realsize;
                mem->memory[mem->size] = 0;
        }
        return realsize;
}
xmas2dqm::wse::XmasToDQM::XDAQ_INSTANTIATOR ( )

Member Data Documentation

Definition at line 169 of file XmasToDQM.h.

toolbox::fsm::FiniteStateMachine xmas2dqm::wse::XmasToDQM::fsm_ [private]

Definition at line 175 of file XmasToDQM.h.

xdata::String xmas2dqm::wse::XmasToDQM::LASQueueSize_ [protected]

Definition at line 160 of file XmasToDQM.h.

Referenced by LASReadoutWorkLoop().

toolbox::task::ActionSignature* xmas2dqm::wse::XmasToDQM::LASReadout_ [private]

Definition at line 181 of file XmasToDQM.h.

toolbox::task::Timer* xmas2dqm::wse::XmasToDQM::LASReadoutTimer_ [private]

Definition at line 183 of file XmasToDQM.h.

toolbox::task::WorkLoop* xmas2dqm::wse::XmasToDQM::LASReadoutWorkLoop_ [private]

Definition at line 178 of file XmasToDQM.h.

xdata::String xmas2dqm::wse::XmasToDQM::LASurl_ [protected]

Definition at line 158 of file XmasToDQM.h.

Referenced by LASReadoutWorkLoop().

xdata::String xmas2dqm::wse::XmasToDQM::Period_ [protected]

Definition at line 159 of file XmasToDQM.h.

Referenced by LASReadoutWorkLoop().

toolbox::TimeVal xmas2dqm::wse::XmasToDQM::startLASReadout_ [private]

Definition at line 184 of file XmasToDQM.h.

xdata::String xmas2dqm::wse::XmasToDQM::state_ [protected]

Definition at line 157 of file XmasToDQM.h.