00001 // $Id: XmasToDQM.h,v 1.3 2012/10/25 06:07:57 davidlt Exp $ 00002 00003 /************************************************************************* 00004 * XDAQ Components for Distributed Data Acquisition * 00005 * Copyright (C) 2000-2004, CERN. * 00006 * All rights reserved. * 00007 * Authors: J. Gutleber and L. Orsini * 00008 * * 00009 * For the licensing terms see LICENSE. * 00010 * For the list of contributors see CREDITS. * 00011 *************************************************************************/ 00012 00013 #ifndef _parse_xmas2dqm_wse_Application_h_ 00014 #define _parse_xmas2dqm_wse_Application_h_ 00015 00016 #include <string> 00017 #include <map> 00018 00019 #include "toolbox/ActionListener.h" 00020 #include "toolbox/task/AsynchronousEventDispatcher.h" 00021 00022 #include "xdaq/ApplicationDescriptorImpl.h" 00023 #include "xdaq/Application.h" 00024 #include "xdaq/ApplicationContext.h" 00025 00026 #include "xdata/String.h" 00027 #include "xdata/Vector.h" 00028 #include "xdata/Boolean.h" 00029 #include "xdata/ActionListener.h" 00030 00031 #include "xoap/MessageReference.h" 00032 #include "xoap/MessageFactory.h" 00033 #include "xoap/SOAPEnvelope.h" 00034 #include "xoap/SOAPBody.h" 00035 #include "xoap/domutils.h" 00036 #include "xoap/Method.h" 00037 #include "xdata/UnsignedInteger64.h" 00038 00039 #include "ws/addressing/EndpointReference.h" 00040 00041 #include "xgi/Method.h" 00042 #include "xgi/Utils.h" 00043 #include "xgi/exception/Exception.h" 00044 #include "Exception.h" 00045 #include "ToDqm.h" 00046 00047 #include "xdaq/ContextTable.h" 00048 00049 #include "xdaq/NamespaceURI.h" 00050 00051 #include "toolbox/fsm/FiniteStateMachine.h" 00052 #include "toolbox/fsm/FailedEvent.h" 00053 00054 00055 // for the work loop and timer 00056 #include "toolbox/task/WorkLoopFactory.h" 00057 #include "toolbox/task/WaitingWorkLoop.h" 00058 #include "toolbox/task/Timer.h" 00059 #include "toolbox/task/TimerFactory.h" 00060 00061 #include <curl/curl.h> 00062 #include <curl/easy.h> 00063 #include <fstream> // for ifstream, ofstream, ios_base 00064 #include <iostream> 00065 00066 //#include "DQMServices/XdaqCollector/interface/FlashlistElements.h" 00067 00068 namespace xmas2dqm 00069 { 00070 namespace wse 00071 { 00072 struct MemoryStruct 00073 { 00074 char *memory; 00075 size_t size; 00076 }; 00077 00078 class XmasToDQM :public xdaq::Application, public toolbox::task::TimerListener, public xdata::ActionListener 00079 /*,public toolbox::ActionListener,*/ 00080 { 00081 public: 00082 00083 XDAQ_INSTANTIATOR(); 00084 00085 XmasToDQM(xdaq::ApplicationStub* s) throw (xdaq::exception::Exception); 00086 ~XmasToDQM(); 00087 00088 // Callback for listening to exported parameter values 00089 void actionPerformed (xdata::Event& e); 00090 00091 //void actionPerformed( toolbox::Event& event ); 00092 00093 // 00094 // XGI Interface 00095 // 00096 void Default(xgi::Input * in, xgi::Output * out ) throw (xgi::exception::Exception); 00097 00098 00099 // 00100 // SOAP interface 00101 // 00102 00104 xoap::MessageReference report (xoap::MessageReference msg) throw (xoap::exception::Exception); 00105 00106 protected: 00107 00108 00109 00110 // SOAP Callback trigger state change 00111 // 00112 xoap::MessageReference fireEvent (xoap::MessageReference msg) 00113 throw (xoap::exception::Exception); 00114 00115 // SOAP Callback to reset the state machine 00116 // 00117 xoap::MessageReference reset (xoap::MessageReference msg) 00118 throw (xoap::exception::Exception); 00119 00120 // Finite State Machine action callbacks 00121 // 00122 void ConfigureAction (toolbox::Event::Reference e) 00123 throw (toolbox::fsm::exception::Exception); 00124 00125 void EnableAction (toolbox::Event::Reference e) 00126 throw (toolbox::fsm::exception::Exception); 00127 00128 void SuspendAction (toolbox::Event::Reference e) 00129 throw (toolbox::fsm::exception::Exception); 00130 00131 void ResumeAction (toolbox::Event::Reference e) 00132 throw (toolbox::fsm::exception::Exception); 00133 00134 void HaltAction (toolbox::Event::Reference e) 00135 throw (toolbox::fsm::exception::Exception); 00136 00137 void failedTransition (toolbox::Event::Reference e) 00138 throw (toolbox::fsm::exception::Exception); 00139 00140 // Finite State Machine callback for entring state 00141 // 00142 void stateChanged (toolbox::fsm::FiniteStateMachine & fsm) 00143 throw (toolbox::fsm::exception::Exception); 00144 00145 bool LASReadoutWorkLoop (toolbox::task::WorkLoop* wl); 00146 00147 void timeExpired (toolbox::task::TimerEvent& e); 00148 00149 static void *myrealloc(void *ptr, size_t size); 00150 00151 static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data); 00152 00153 int getEXDR_LAS(/*xdata::Table::Reference &*/xdata::Table *rtable); 00154 00155 xdata::String state_; // used to reflect the current state to the outside world 00156 xdata::String LASurl_; //holds the value of the LAS URL 00157 xdata::String Period_; //LAS parsing period time in seconds 00158 xdata::String LASQueueSize_; //LAS parsing period time in seconds 00159 00160 //xdata::Bag<xmas2dqm::wse::FlashlistElements> flashlistMonitor_; 00161 00162 00163 private: 00164 00165 00166 // dqm hook 00167 xmas2dqm::wse::ToDqm *dqmHook_; 00168 00169 //toolbox::task::AsynchronousEventDispatcher dispatcher_; 00170 //xdata::UnsignedInteger64T reportLostCounter_; 00171 00172 00173 toolbox::fsm::FiniteStateMachine fsm_; 00174 00175 //Working loop in the system 00176 toolbox::task::WorkLoop* LASReadoutWorkLoop_ ; 00177 00178 //method to be activated by the work loop 00179 toolbox::task::ActionSignature* LASReadout_ ; 00180 00181 toolbox::task::Timer * LASReadoutTimer_; 00182 toolbox::TimeVal startLASReadout_; 00183 00184 00185 }; 00186 } 00187 } 00188 #endif