00001 /*----------------------------------------------------------------------------* 00002 * Copyright (c) 2005 Southeastern Universities Research Association, * 00003 * Thomas Jefferson National Accelerator Facility * 00004 * * 00005 * This software was developed under a United States Government license * 00006 * described in the NOTICE file included as part of this distribution. * 00007 * * 00008 * E.Wolin, 25-Feb-2005, Jefferson Lab * 00009 * * 00010 * Authors: Elliott Wolin * 00011 * wolin@jlab.org Jefferson Lab, MS-6B * 00012 * Phone: (757) 269-7365 12000 Jefferson Ave. * 00013 * Fax: (757) 269-5519 Newport News, VA 23606 * 00014 * 00015 *----------------------------------------------------------------------------*/ 00016 00017 00018 #ifndef _RunObject_hxx 00019 #define _RunObject_hxx 00020 00021 00022 #include <SessionObject.hxx> 00023 #include <RunObject.h> 00024 #include <pthread.h> 00025 00026 00027 namespace codaObject { 00028 00029 using namespace std; 00030 using namespace cmsg; 00031 00032 00033 //----------------------------------------------------------------------------- 00034 //----------------------------------------------------------------------------- 00035 00036 00048 class RunObject : public SessionObject { 00049 00050 00051 public: 00052 RunObject(const string& UDL, const string& name, const string& descr, const string &codaClass = "USER", 00053 const cMsgSubscriptionConfig *scfg = NULL) throw(CodaException); 00054 virtual ~RunObject(void) throw(); 00055 00056 00057 protected: 00058 virtual void setDllUserArg(void *arg) throw(); 00059 virtual void handleConfigure(const cMsgMessage *msg) throw(CodaException); 00060 virtual void handleDownload(const cMsgMessage *msg) throw(CodaException); 00061 virtual void handlePrestart(const cMsgMessage *msg) throw(CodaException); 00062 virtual void handleGo(const cMsgMessage *msg) throw(CodaException); 00063 virtual void handlePause(const cMsgMessage *msg) throw(CodaException); 00064 virtual void handleResume(const cMsgMessage *msg) throw(CodaException); 00065 virtual void handleEnd(const cMsgMessage *msg) throw(CodaException); 00066 virtual void handleReset(const cMsgMessage *msg) throw(CodaException); 00067 00068 00069 protected: 00070 virtual void handleSetSession(const string &newSession) throw(CodaException); 00071 virtual void handleSetSession(const cMsgMessage *msg) throw(CodaException); 00072 virtual bool download(const string& s) throw(CodaException); 00073 virtual bool prestart(const string& s) throw(CodaException); 00074 virtual bool go(const string& s) throw(CodaException); 00075 virtual bool pause(const string& s) throw(CodaException); 00076 virtual bool resume(const string& s) throw(CodaException); 00077 virtual bool end(const string& s) throw(CodaException); 00078 virtual bool reset(const string& s) throw(CodaException); 00079 virtual bool configure(const cMsgMessage *msg) throw(CodaException); 00080 00081 00082 protected: 00083 virtual bool userConfigure(const string& runConfig) throw(CodaException); 00084 virtual bool userDownload(const string& s) throw(CodaException); 00085 virtual bool userPrestart(const string& s) throw(CodaException); 00086 virtual bool userGo(const string& s) throw(CodaException); 00087 virtual bool userPause(const string& s) throw(CodaException); 00088 virtual bool userResume(const string& s) throw(CodaException); 00089 virtual bool userEnd(const string& s) throw(CodaException); 00090 virtual bool userReset(const string& s) throw(CodaException); 00091 00092 00093 public: 00094 int getRunNumber(void) const throw(); 00095 string getRunType(void) const throw(); 00096 virtual void startProcessing(void) throw(CodaException); 00097 00098 00099 private: 00100 void runControlCallback(cMsgMessage *msg, void* userArg) throw(CodaException); 00101 void runTransitionCallback(cMsgMessage *msg, void* userArg) throw(CodaException); 00102 void dispatchTransition(bool (RunObject::*mfp)(const string &s), const string &s); 00103 void *runStatisticsThread(void*); 00104 00105 00106 protected: 00107 virtual void fillReport(cMsgMessage *m) throw(); 00108 00109 00110 protected: 00111 int runNumber; 00112 string runType; 00113 int runStatisticsInterval; 00116 public: 00117 int eventNumber; 00118 double eventRate; 00119 int dataCount; 00120 double dataRate; 00121 float liveTime; 00124 protected: 00125 bool hasDLL; 00126 string dllFileName; 00127 void *dllHandle; 00128 dllSysStruct dllSysArg; 00129 void *dllUserArg; 00130 dllFuncPtr dllDownload; 00131 dllFuncPtr dllPrestart; 00132 dllFuncPtr dllGo; 00133 dllFuncPtr dllPause; 00134 dllFuncPtr dllResume; 00135 dllFuncPtr dllEnd; 00136 dllFuncPtr dllReset; 00139 protected: 00140 cMsgCallback *runControlCBD; 00141 cMsgCallback *runTransitionCBD; 00144 protected: 00145 pthread_mutex_t runResetMutex; 00146 pthread_mutex_t runTransitionMutex; 00147 pthread_t transitionThreadId; 00148 pthread_t runStatisticsThreadId; 00150 pthreadDispatcher<RunObject,void*,void*> *statisticsThreadDispatcher; 00152 virtual void daLogMsgFill(cMsgMessage &msg) const throw(CodaException); 00153 00154 00155 private: 00156 void *rcsSubId; 00157 void *rtsSubId; 00159 }; 00160 00161 00162 //----------------------------------------------------------------------------- 00163 //----------------------------------------------------------------------------- 00164 00165 00166 } // namespace codaObject 00167 00168 #endif /* _RunObject_hxx */