fdhwlib
2.0.25
|
00001 /*************************************************************************** 00002 kaeventloop.h - description 00003 ------------------- 00004 begin : Di Jun 20 2006 00005 copyright : (C) 2006 by 00006 email : 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef KAEVENTLOOP_H 00019 #define KAEVENTLOOP_H 00020 00021 00022 #include <cstdio> 00023 #include <string> 00024 00025 00026 #define PAGE_STACK_LEN 100 // Must be larger than the physical available number 00027 // of pages. 00028 00029 00030 #include <akutil/statistics.h> 00031 00032 #include <Hw/SltTime.h> 00033 #include <Hw/sltpagestatus.h> 00034 00035 #include <Hw/eventloop.h> 00036 00037 #include <katrinhw/kaevent.h> 00038 00039 00040 #ifdef USE_MYSQL 00041 #include <mysql/mysql.h> 00042 #endif // of USE_MYSQL 00043 00044 00045 class keyboard; 00046 class KaSubrack; 00047 class sharedMemory; 00048 class SimpleSocket; 00049 00050 00070 class KaEventLoop : public EventLoop { 00071 public: 00072 KaEventLoop(KaSubrack *s, unsigned short port = 0); 00073 ~KaEventLoop(); 00074 00076 void reset(); 00077 00079 void init(); 00080 00082 void initRun(int n=0); 00083 00085 int stopRun(); 00086 00088 void keyboard_cmds(FILE *fout, char *line); 00089 00091 void displayHeader(FILE *fout); 00092 00102 int getEvent(FILE *fout); 00103 00105 int getEventData(FILE *fout); 00106 00108 void displayEvent(FILE *fout); 00109 00111 void displaySummary(FILE *fout); 00112 00114 void help(FILE *fout); 00115 00117 void setEnergyScaling(int min, int max); 00118 00120 void getEnergyScaling(int *min, int *max); 00121 00123 void setEnergyHist(int no); 00124 00126 void setFilterLength(int len); 00127 00129 void setTriggerSampling(int len); 00130 00131 00139 void checkEvent(KaEvent *ev); 00140 00149 void getEnergyHwFilter(unsigned short *data, int len, int n, int thresh, unsigned long *energy); 00150 00151 void getEnergyShortFilter(unsigned short *data, int len, int n, int thresh, unsigned long *energy); 00152 00163 void getEnergyMeanDiff(unsigned short *data, int len, int n, unsigned long *energy); 00164 00167 void getHistStatistic(unsigned long *data, double *mean, double *var, int *n); 00168 00170 void displayHistogram(FILE *fout, unsigned long *hist, unsigned long min, unsigned long max); 00171 00173 void simPulse(unsigned short *data); 00174 00175 00176 #ifdef USE_MYSQL 00177 00178 void storeEvent(); 00179 #endif 00180 00182 KaEvent ev; 00183 00184 private: 00186 KaSubrack *s; 00187 00189 int lastEventCol; 00190 00192 int lastEventPage[20]; 00193 00195 int trigMode[20][4]; 00196 00198 bool stopAfterEvent; 00199 00201 bool debugMode; 00202 00204 bool scanMem; 00205 00207 int debug; 00208 00210 unsigned long histEnergy[2048]; 00211 00213 unsigned long histPulseHeight[2048]; 00214 00215 int histEnergyMin; 00216 00217 int histEnergyMax; 00218 00228 int histNo; 00229 00231 int histEnergyActualBin; 00232 00234 int histPulseHeightActualBin; 00235 00237 SltTime histTDisplay; 00238 00240 int histNDisplay; 00241 00243 statistics baseline; 00244 00246 statistics pulse; 00247 00249 unsigned long nAdcErrors; 00250 00252 int filterLength; 00253 00255 int simRise; 00256 00258 FILE *fdata; 00259 00261 int T2; 00262 00264 int mTrig; 00265 00266 00267 }; 00268 00269 #endif