Changeset 11136
- Timestamp:
- 06/23/11 15:57:53 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/EventBuilderWrapper.h
r11127 r11136 720 720 DimDescribedService fDimCurrentEvent; 721 721 DimDescribedService fDimEventData; 722 DimDescribedService fDimFwVersion; 723 DimDescribedService fDimStatistics; 722 724 723 725 bool fDebugStream; … … 737 739 fDimCurrentEvent("FAD_CONTROL/CURRENT_EVENT", "I:1", ""), 738 740 fDimEventData("FAD_CONTROL/EVENT_DATA", "S:1;I:1;S:1;I:2;S:1;S", ""), 741 fDimFwVersion("FAD_CONTROL/FIRMWARE_VERSION", "F:40", ""), 742 fDimStatistics("FAD_CONTROL/STATISTICS", "X:8", ""), 739 743 fDebugStream(false), fDebugRead(false) 740 744 { … … 746 750 memset(fNumEvts, 0, sizeof(fNumEvts)); 747 751 748 Update(fDimRuns,uint32_t(0));749 Update(fDimCurrentEvent,uint32_t(0));750 Update(fDimEvents,fNumEvts);752 fDimRuns.Update(uint32_t(0)); 753 fDimCurrentEvent.Update(uint32_t(0)); 754 fDimEvents.Update(fNumEvts); 751 755 752 756 for (size_t i=0; i<40; i++) … … 906 910 vector<DataFileImp*> fFiles; 907 911 908 template<class T>909 void Update(DimDescribedService &svc, const T &data) const910 {911 cout << "Update: " << svc.getName() << " (" << sizeof(T) << ")" << endl;912 svc.setData(const_cast<T*>(&data), sizeof(T));913 svc.updateService();914 }915 916 912 FileHandle_t runOpen(uint32_t runid, RUN_HEAD *h, size_t) 917 913 { … … 943 939 fNumEvts[kCurrent] = 0; 944 940 945 Update(fDimRuns,fMaxRun);946 Update(fDimEvents,fNumEvts);947 Update(fDimCurrentEvent,uint32_t(0));948 } 949 950 Update(fDimFiles,fFiles.size());941 fDimRuns.Update(fMaxRun); 942 fDimEvents.Update(fNumEvts); 943 fDimCurrentEvent.Update(uint32_t(0)); 944 } 945 946 fDimFiles.Update(fFiles.size()); 951 947 952 948 return reinterpret_cast<FileHandle_t>(file); … … 962 958 if (file->GetRunId()==fMaxRun) 963 959 { 964 Update(fDimCurrentEvent,e->EventNum);960 fDimCurrentEvent.Update(e->EventNum); 965 961 fNumEvts[kCurrent]++; 966 962 } 967 963 968 964 fNumEvts[kTotal]++; 969 Update(fDimEvents,fNumEvts);965 fDimEvents.Update(fNumEvts); 970 966 971 967 // ===> SignalEvtWritten(runid); … … 998 994 fFiles.erase(it); 999 995 1000 Update(fDimFiles,fFiles.size());996 fDimFiles.Update(fFiles.size()); 1001 997 1002 998 const bool rc = file->Close(tail); … … 1102 1098 1103 1099 template<typename T> 1104 vector<T> Check(const PEVNT_HEADER *fadhd, const T &val, bool &rc) 1105 { 1106 const size_t offset = reinterpret_cast<const char*>(&val)-reinterpret_cast<const char*>(fadhd); 1100 vector<T> CheckVals(const PEVNT_HEADER *fadhd, const T *val, bool &rc) 1101 { 1102 const size_t offset = reinterpret_cast<const char*>(val)-reinterpret_cast<const char*>(fadhd); 1103 1104 cout << "OFFSET=" << offset << endl; 1107 1105 1108 1106 vector<T> vec(40); 1109 1107 1110 vec[0] = val;1108 vec[0] = *val; 1111 1109 1112 1110 rc = true; … … 1115 1113 1116 1114 const T &t = *reinterpret_cast<const T*>(reinterpret_cast<const char*>(fadhd+i)+offset); 1117 if (t!= val)1115 if (t!=*val) 1118 1116 rc = false; 1119 1117 … … 1123 1121 return vec; 1124 1122 } 1125 1123 /* 1126 1124 template<typename T> 1127 1125 vector<uint8_t> CheckBits(const PEVNT_HEADER *fadhd, const T &val, T &rc) … … 1145 1143 rc = ~rc; 1146 1144 return vec; 1147 } 1145 }*/ 1148 1146 1149 1147 … … 1164 1162 bool ok_verno; 1165 1163 bool ok_runno; 1166 uint16_t ok_bitmask; 1167 1168 const vector<uint16_t> verno = Check(fadhd, fadhd->version_no, ok_verno); 1169 const vector<uint32_t> runno = Check(fadhd, fadhd->runnumber, ok_runno); 1170 const vector<uint8_t> bitmask = CheckBits(fadhd, fadhd->PLLLCK, ok_bitmask); 1164 // uint16_t ok_bitmask; 1165 1166 const vector<uint16_t> verno = CheckVals(fadhd, &fadhd->version_no, ok_verno); 1167 const vector<uint32_t> runno = CheckVals(fadhd, &fadhd->runnumber, ok_runno); 1168 // const vector<uint8_t> bitmask = CheckBits(fadhd, &fadhd->PLLLCK, ok_bitmask); 1169 1170 static vector<uint16_t> fStoreVersion; 1171 1172 if (verno!=fStoreVersion) 1173 { 1174 vector<float> data(40); 1175 for (int i=0; i<40; i++) 1176 { 1177 ostringstream ver; 1178 ver << (verno[i]&0xff) << '.' << (verno[i]>>8); // WARNING: No byte-swap yet! 1179 data[i] = atof(ver.str().c_str()); 1180 } 1181 fDimFwVersion.Update(data); 1182 fStoreVersion=verno; 1183 } 1171 1184 1172 1185 /* … … 1230 1243 1231 1244 return 0; 1232 }1233 1234 };1235 1236 EventBuilderWrapper *EventBuilderWrapper::This = 0;1237 1238 // ----------- Event builder callbacks implementation ---------------1239 extern "C"1240 {1241 FileHandle_t runOpen(uint32_t irun, RUN_HEAD *runhd, size_t len)1242 {1243 return EventBuilderWrapper::This->runOpen(irun, runhd, len);1244 }1245 1246 int runWrite(FileHandle_t fileId, EVENT *event, size_t len)1247 {1248 return EventBuilderWrapper::This->runWrite(fileId, event, len);1249 }1250 1251 int runClose(FileHandle_t fileId, RUN_TAIL *runth, size_t len)1252 {1253 return EventBuilderWrapper::This->runClose(fileId, runth, len);1254 1245 } 1255 1246 … … 1265 1256 str << "): " << message; 1266 1257 1267 EventBuilderWrapper::This->fMsg.Update(str, severity);1268 } 1269 1270 void factStat(int severity, int err, const char* message)1271 { 1272 if ( err!=-1)1273 { 1274 f actOut(severity, err, message);1258 fMsg.Update(str, severity); 1259 } 1260 1261 void factStat(int64_t *stat, int len) 1262 { 1263 if (len!=7) 1264 { 1265 fMsg.Warn("factStat received unknown number of values."); 1275 1266 return; 1276 1267 } 1277 1268 1278 static string last; 1279 if (message==last) 1269 vector<int64_t> data(1, g_maxMem); 1270 data.insert(data.end(), stat, stat+len); 1271 1272 static vector<int64_t> last(8); 1273 if (data==last) 1280 1274 return; 1281 1282 last = message; 1283 1284 ostringstream str("Status: "); 1285 str << message; 1286 1287 EventBuilderWrapper::This->fMsg.Update(str, severity); 1275 last = data; 1276 1277 fDimStatistics.Update(data); 1278 1279 // len ist die Laenge des arrays. 1280 // array[4] enthaelt wieviele bytes im Buffer aktuell belegt sind; daran 1281 // kannst Du pruefen, ob die 100MB voll sind .... 1282 1283 /* 1284 stat[0]= qwait; 1285 stat[1]= qskip; 1286 stat[2]= qdel ; 1287 stat[3]= qtot ; 1288 stat[4]= gi_usedMem ; 1289 stat[5]= qread; 1290 stat[6]= qconn; 1291 */ 1292 1293 ostringstream str; 1294 str 1295 << "Wait=" << stat[0] << " " 1296 << "Skip=" << stat[1] << " " 1297 << "Del=" << stat[2] << " " 1298 << "Tot=" << stat[3] << " " 1299 << "Mem=" << stat[4] << "/" << g_maxMem << " " 1300 << "Read=" << stat[5] << " " 1301 << "Conn=" << stat[6]; 1302 1303 1304 fMsg.Info(str); 1305 } 1306 }; 1307 1308 EventBuilderWrapper *EventBuilderWrapper::This = 0; 1309 1310 // ----------- Event builder callbacks implementation --------------- 1311 extern "C" 1312 { 1313 FileHandle_t runOpen(uint32_t irun, RUN_HEAD *runhd, size_t len) 1314 { 1315 return EventBuilderWrapper::This->runOpen(irun, runhd, len); 1316 } 1317 1318 int runWrite(FileHandle_t fileId, EVENT *event, size_t len) 1319 { 1320 return EventBuilderWrapper::This->runWrite(fileId, event, len); 1321 } 1322 1323 int runClose(FileHandle_t fileId, RUN_TAIL *runth, size_t len) 1324 { 1325 return EventBuilderWrapper::This->runClose(fileId, runth, len); 1326 } 1327 1328 void factOut(int severity, int err, const char *message) 1329 { 1330 EventBuilderWrapper::This->factOut(severity, err, message); 1331 } 1332 1333 void factStat(int64_t *array, int len) 1334 { 1335 EventBuilderWrapper::This->factStat(array, len); 1336 } 1337 1338 void debugHead(int i, void *buf) 1339 { 1288 1340 } 1289 1341
Note:
See TracChangeset
for help on using the changeset viewer.