/*----------------------------------------------------------------------------* * Copyright (c) 2005 Southeastern Universities Research Association, * * Thomas Jefferson National Accelerator Facility * * * * This software was developed under a United States Government license * * described in the NOTICE file included as part of this distribution. * * * * E.Wolin, 25-Feb-2005, Jefferson Lab * * * * Authors: Elliott Wolin * * wolin@jlab.org Jefferson Lab, MS-6B * * Phone: (757) 269-7365 12000 Jefferson Ave. * * Fax: (757) 269-5519 Newport News, VA 23606 * * *----------------------------------------------------------------------------*/ #ifndef _RunObject_hxx #define _RunObject_hxx #include #include #include namespace codaObject { using namespace std; using namespace cmsg; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- /** * Extends SessionObject to accept transition commands from run control, but has no interrupt capability. * If interrupt capability is needed use InterruptibleObject. * * User customizes a RunObject via override of some of download,prestart,go,pause,resume,end methods. * Alternatively, can specify dll containing download,etc. functions. * * If dealing with events, user must set eventCount and dataCount as events are sent to the DAQ system. * * @warning User routines should be pthread-cancelable in case abort/reset command is received. */ class RunObject : public SessionObject { public: RunObject(const string& UDL, const string& name, const string& descr, const string &codaClass = "USER", const cMsgSubscriptionConfig *scfg = NULL) throw(CodaException); virtual ~RunObject(void) throw(); protected: virtual void setDllUserArg(void *arg) throw(); virtual void handleDownload(const cMsgMessage *msg) throw(CodaException); virtual void handlePrestart(const cMsgMessage *msg) throw(CodaException); virtual void handleGo(const cMsgMessage *msg) throw(CodaException); virtual void handlePause(const cMsgMessage *msg) throw(CodaException); virtual void handleResume(const cMsgMessage *msg) throw(CodaException); virtual void handleEnd(const cMsgMessage *msg) throw(CodaException); protected: virtual bool setSession(const string& newSession) throw(CodaException); virtual bool releaseSession(void) throw(CodaException); virtual bool download(const string& s) throw(CodaException); virtual bool prestart(const string& s) throw(CodaException); virtual bool go(const string& s) throw(CodaException); virtual bool pause(const string& s) throw(CodaException); virtual bool resume(const string& s) throw(CodaException); virtual bool end(const string& s) throw(CodaException); virtual bool abort(const string& s) throw(CodaException); virtual bool reset(const string& s) throw(CodaException); protected: virtual bool userDownload(const string& s) throw(CodaException); virtual bool userPrestart(const string& s) throw(CodaException); virtual bool userGo(const string& s) throw(CodaException); virtual bool userPause(const string& s) throw(CodaException); virtual bool userResume(const string& s) throw(CodaException); virtual bool userEnd(const string& s) throw(CodaException); virtual bool userAbort(const string& s) throw(CodaException); virtual bool userReset(const string& s) throw(CodaException); public: int getRunNumber(void) const throw(); string getRunType(void) const throw(); virtual string getStatus(void) const throw(); virtual void startProcessing(void) throw(CodaException); private: void runControlCallback(cMsgMessage *msg, void* userArg) throw(CodaException); void runTransitionCallback(cMsgMessage *msg, void* userArg) throw(CodaException); void dispatchTransition(bool (RunObject::*mfp)(const string &s), const string &s); void *runStatisticsThread(void*); protected: virtual void daLogMsgFill(cMsgMessage &msg, const string& text, int sevid) const throw(CodaException); protected: int runNumber; /** *statisticsThreadDispatcher; /**