00001 // $Id: XmasToDQM.h,v 1.2 2008/10/23 14:36:07 vpatras 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/types.h> 00063 #include <curl/easy.h> 00064 #include <fstream> // for ifstream, ofstream, ios_base 00065 #include <iostream> 00066 00067 //#include "DQMServices/XdaqCollector/interface/FlashlistElements.h" 00068 00069 namespace xmas2dqm 00070 { 00071 namespace wse 00072 { 00073 struct MemoryStruct 00074 { 00075 char *memory; 00076 size_t size; 00077 }; 00078 00079 class XmasToDQM :public xdaq::Application, public toolbox::task::TimerListener, public xdata::ActionListener 00080 /*,public toolbox::ActionListener,*/ 00081 { 00082 public: 00083 00084 XDAQ_INSTANTIATOR(); 00085 00086 XmasToDQM(xdaq::ApplicationStub* s) throw (xdaq::exception::Exception); 00087 ~XmasToDQM(); 00088 00089 // Callback for listening to exported parameter values 00090 void actionPerformed (xdata::Event& e); 00091 00092 //void actionPerformed( toolbox::Event& event ); 00093 00094 // 00095 // XGI Interface 00096 // 00097 void Default(xgi::Input * in, xgi::Output * out ) throw (xgi::exception::Exception); 00098 00099 00100 // 00101 // SOAP interface 00102 // 00103 00105 xoap::MessageReference report (xoap::MessageReference msg) throw (xoap::exception::Exception); 00106 00107 protected: 00108 00109 00110 00111 // SOAP Callback trigger state change 00112 // 00113 xoap::MessageReference fireEvent (xoap::MessageReference msg) 00114 throw (xoap::exception::Exception); 00115 00116 // SOAP Callback to reset the state machine 00117 // 00118 xoap::MessageReference reset (xoap::MessageReference msg) 00119 throw (xoap::exception::Exception); 00120 00121 // Finite State Machine action callbacks 00122 // 00123 void ConfigureAction (toolbox::Event::Reference e) 00124 throw (toolbox::fsm::exception::Exception); 00125 00126 void EnableAction (toolbox::Event::Reference e) 00127 throw (toolbox::fsm::exception::Exception); 00128 00129 void SuspendAction (toolbox::Event::Reference e) 00130 throw (toolbox::fsm::exception::Exception); 00131 00132 void ResumeAction (toolbox::Event::Reference e) 00133 throw (toolbox::fsm::exception::Exception); 00134 00135 void HaltAction (toolbox::Event::Reference e) 00136 throw (toolbox::fsm::exception::Exception); 00137 00138 void failedTransition (toolbox::Event::Reference e) 00139 throw (toolbox::fsm::exception::Exception); 00140 00141 // Finite State Machine callback for entring state 00142 // 00143 void stateChanged (toolbox::fsm::FiniteStateMachine & fsm) 00144 throw (toolbox::fsm::exception::Exception); 00145 00146 bool LASReadoutWorkLoop (toolbox::task::WorkLoop* wl); 00147 00148 void timeExpired (toolbox::task::TimerEvent& e); 00149 00150 static void *myrealloc(void *ptr, size_t size); 00151 00152 static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data); 00153 00154 int getEXDR_LAS(/*xdata::Table::Reference &*/xdata::Table *rtable); 00155 00156 xdata::String state_; // used to reflect the current state to the outside world 00157 xdata::String LASurl_; //holds the value of the LAS URL 00158 xdata::String Period_; //LAS parsing period time in seconds 00159 xdata::String LASQueueSize_; //LAS parsing period time in seconds 00160 00161 //xdata::Bag<xmas2dqm::wse::FlashlistElements> flashlistMonitor_; 00162 00163 00164 private: 00165 00166 00167 // dqm hook 00168 xmas2dqm::wse::ToDqm *dqmHook_; 00169 00170 //toolbox::task::AsynchronousEventDispatcher dispatcher_; 00171 //xdata::UnsignedInteger64T reportLostCounter_; 00172 00173 00174 toolbox::fsm::FiniteStateMachine fsm_; 00175 00176 //Working loop in the system 00177 toolbox::task::WorkLoop* LASReadoutWorkLoop_ ; 00178 00179 //method to be activated by the work loop 00180 toolbox::task::ActionSignature* LASReadout_ ; 00181 00182 toolbox::task::Timer * LASReadoutTimer_; 00183 toolbox::TimeVal startLASReadout_; 00184 00185 00186 }; 00187 } 00188 } 00189 #endif