TMidasOnline.h
Go to the documentation of this file.00001 #ifndef TMidasOnline_hxx_seen
00002 #define TMidasOnline_hxx_seen
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <stdio.h>
00016 #include <string>
00017
00018 #include "VirtualOdb.h"
00019
00020
00021
00022 struct EventRequest
00023 {
00024 public:
00025 EventRequest* fNext;
00026 std::string fBufferName;
00027 int fBufferHandle;
00028 int fEventId;
00029 int fTriggerMask;
00030 int fSamplingType;
00031 int fRequestId;
00032 };
00033
00034
00035
00036 class TMidasOnline : public VirtualOdb
00037 {
00038 public:
00039
00040
00041 typedef void (*TransitionHandler)(int transition,int run_number,int trans_time);
00042
00043
00044 typedef void (*EventHandler)(const void*header,const void*data,int length);
00045
00046 public:
00047
00048 std::string fHostname;
00049 std::string fExptname;
00050
00051 int fDB;
00052
00053 TransitionHandler fStartHandler;
00054 TransitionHandler fStopHandler;
00055 TransitionHandler fPauseHandler;
00056 TransitionHandler fResumeHandler;
00057
00058 EventRequest* fEventRequests;
00059 EventHandler fEventHandler;
00060
00061 private:
00062
00063
00064 static TMidasOnline* gfMidas;
00065
00066 TMidasOnline();
00067 virtual ~TMidasOnline();
00068
00069 public:
00070
00071
00072
00073 static TMidasOnline* instance();
00074
00075
00076 int connect(const char*hostname,const char*exptname,const char*progname);
00077
00078
00079 int disconnect();
00080
00081
00082 bool poll(int mdelay);
00083
00084
00085
00086
00087 void registerTransitions();
00088
00089
00090 void setTransitionHandlers(TransitionHandler start,TransitionHandler stop,TransitionHandler pause,TransitionHandler resume);
00091
00092
00093 bool checkTransitions();
00094
00095
00096
00097
00098 void setEventHandler(EventHandler handler);
00099
00100
00101 int eventRequest(const char* bufferName,int eventId,int triggerMask,int samplingType,bool poll=false);
00102
00103
00104 void deleteEventRequest(int requestId);
00105
00106
00107 int receiveEvent(int requestId, void* pevent, int size, bool async);
00108
00109
00110 int getBufferLevel();
00111
00112
00113 int getBufferSize();
00114
00115
00116
00117 int odbReadArraySize(const char*name);
00118 int odbReadAny( const char*name, int index, int tid,void* buf, int bufsize = 0);
00119 int odbReadInt( const char*name, int index = 0, int defaultValue = 0);
00120 uint32_t odbReadUint32(const char*name, int index = 0, uint32_t defaultValue = 0);
00121 double odbReadDouble(const char*name, int index = 0, double defaultValue = 0);
00122 float odbReadFloat(const char*name, int index = 0, float defaultValue = 0);
00123 bool odbReadBool( const char*name, int index = 0, bool defaultValue = false);
00124 const char* odbReadString(const char*name, int index = 0,const char* defaultValue = NULL);
00125 };
00126
00127
00128 #endif