Changeset 11162
- Timestamp:
- 06/24/11 12:25:38 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/EventBuilderWrapper.h
r11153 r11162 739 739 fDimCurrentEvent("FAD_CONTROL/CURRENT_EVENT", "I:1", ""), 740 740 fDimEventData("FAD_CONTROL/EVENT_DATA", "S:1;I:1;S:1;I:2;S:1;S", ""), 741 fDimFwVersion("FAD_CONTROL/FIRMWARE_VERSION", "F:4 0", ""),741 fDimFwVersion("FAD_CONTROL/FIRMWARE_VERSION", "F:43", ""), 742 742 fDimStatistics("FAD_CONTROL/STATISTICS", "X:8", ""), 743 743 fDebugStream(false), fDebugRead(false) … … 1191 1191 bool ok_runno; 1192 1192 // uint16_t ok_bitmask; 1193 1193 /* 1194 1194 const vector<uint16_t> verno = CheckVals(fadhd, &fadhd->version_no, ok_verno); 1195 1195 const vector<uint32_t> runno = CheckVals(fadhd, &fadhd->runnumber, ok_runno); … … 1210 1210 fStoreVersion=verno; 1211 1211 } 1212 1212 */ 1213 1213 /* 1214 1214 uint16_t start_package_flag; … … 1332 1332 } 1333 1333 1334 boost::array<FAD::EventHeader, 40> fVecHeader; 1335 1336 template<typename T> 1337 pair<bool,boost::array<T, 43>> Compare(const FAD::EventHeader *h, const T *t, const uint64_t mask=~0, const uint8_t shift=0) 1338 { 1339 const int offset = reinterpret_cast<const char *>(t) - reinterpret_cast<const char *>(h); 1340 1341 const T *min = NULL; 1342 const T *val = NULL; 1343 const T *max = NULL; 1344 1345 boost::array<T, 43> vec; 1346 1347 bool rc = true; 1348 for (int i=0; i<40; i++) 1349 { 1350 const char *base = reinterpret_cast<const char*>(&fVecHeader[i]); 1351 const T *ref = reinterpret_cast<const T*>(base+offset); 1352 1353 vec[i+3] = *ref; 1354 1355 if (gi_NumConnect[i/7]!=7) 1356 continue; 1357 1358 if (!val) 1359 { 1360 min = ref; 1361 val = ref; 1362 max = ref; 1363 } 1364 1365 if (*val<*min) 1366 min = val; 1367 1368 if (*val>*max) 1369 max = val; 1370 1371 if ((*val&mask)!=(*ref&mask)) 1372 rc = false; 1373 } 1374 1375 if (!val) 1376 return make_pair(false, vec); 1377 1378 vec[0] = *min; 1379 vec[1] = (*val&mask)>>shift; 1380 vec[2] = *max; 1381 1382 return make_pair(rc, vec); 1383 } 1384 1385 template<typename T> 1386 void Update(DimDescribedService &svc, const pair<bool,boost::array<T, 43>> &data) 1387 { 1388 svc.setQuality(data.first); 1389 svc.setData(const_cast<T*>(data.second.data()), sizeof(T)*43); 1390 svc.updateService(); 1391 } 1392 1393 template<typename T> 1394 void Print(const char *name, const pair<bool,boost::array<T, 43>> &data) 1395 { 1396 cout << name << "|" << data.first << "|" << data.second[1] << "|" << data.second[0] << "<x<" << data.second[1] << ":"; 1397 for (int i=0; i<40;i++) 1398 cout << " " << data.second[i+3]; 1399 cout << endl; 1400 } 1401 1334 1402 void debugHead(int socket, const FAD::EventHeader &h) 1335 1403 { 1336 cout << h; 1404 const uint16_t id = h.Id(); 1405 if (id>39) // WARNING 1406 return; 1407 1408 const FAD::EventHeader old = fVecHeader[id]; 1409 1410 fVecHeader[id] = h; 1411 1412 if (old.fVersion != h.fVersion) 1413 { 1414 const pair<bool, boost::array<uint16_t,43>> ver = Compare(&h, &h.fVersion); 1415 //Print("Ver", ver); 1416 1417 pair<bool, boost::array<float,43>> data; 1418 data.first = ver.first; 1419 1420 for (int i=0; i<43; i++) 1421 { 1422 ostringstream str; 1423 str << (ver.second[i]>>8) << '.' << (ver.second[i]&0xff); 1424 data.second[i] = atof(str.str().c_str()); 1425 } 1426 Update(fDimFwVersion, data); 1427 } 1428 1429 if (old.fTriggerType != h.fTriggerType) 1430 { 1431 const pair<bool, boost::array<uint16_t,43>> typ = Compare(&h, &h.fTriggerType); 1432 Print("Typ", typ); 1433 } 1434 1435 if (old.fRunNumber != h.fRunNumber) 1436 { 1437 const pair<bool, boost::array<uint32_t,43>> run = Compare(&h, &h.fRunNumber); 1438 Print("Run", run); 1439 } 1440 1441 if (old.PLLLCK() != h.PLLLCK()) 1442 { 1443 const pair<bool, boost::array<uint16_t,43>> pll = Compare(&h, &h.fStatus, 0xf<<12, 12); 1444 Print("Pll", pll); 1445 } 1446 1447 if (old.HasDenable() != h.HasDenable()) 1448 { 1449 const pair<bool, boost::array<uint16_t,43>> drs = Compare(&h, &h.fStatus, FAD::EventHeader::kDenable); 1450 Print("Drs", drs); 1451 } 1452 1453 if (old.HasDwrite() != h.HasDwrite()) 1454 { 1455 const pair<bool, boost::array<uint16_t,43>> wri = Compare(&h, &h.fStatus, FAD::EventHeader::kDwrite); 1456 Print("Wri", wri); 1457 } 1458 1459 if (old.IsRefClockTooLow() != h.IsRefClockTooLow()) 1460 { 1461 const pair<bool, boost::array<uint16_t,43>> owf = Compare(&h, &h.fStatus, FAD::EventHeader::kRefClkTooLow); 1462 Print("Owf", owf); 1463 } 1464 1465 if (old.IsDcmLocked() != h.IsDcmLocked()) 1466 { 1467 const pair<bool, boost::array<uint16_t,43>> lck = Compare(&h, &h.fStatus, FAD::EventHeader::kDcmLocked); 1468 Print("Lck", lck); 1469 } 1470 1471 if (old.IsDcmReady() != h.IsDcmReady()) 1472 { 1473 const pair<bool, boost::array<uint16_t,43>> rdy = Compare(&h, &h.fStatus, FAD::EventHeader::kDcmReady); 1474 Print("Rdy", rdy); 1475 } 1476 1477 if (old.HasSpiSclk() != h.HasSpiSclk()) 1478 { 1479 const pair<bool, boost::array<uint16_t,43>> spi = Compare(&h, &h.fStatus, FAD::EventHeader::kSpiSclk); 1480 Print("Spi", spi); 1481 } 1482 1483 if (old.HasBusy() != h.HasBusy()) 1484 { 1485 const pair<bool, boost::array<uint16_t,43>> bsy = Compare(&h, &h.fStatus, FAD::EventHeader::kBusy); 1486 Print("Bsy", bsy); 1487 } 1488 1489 if (old.HasTriggerEnabled() != h.HasTriggerEnabled()) 1490 { 1491 const pair<bool, boost::array<uint16_t,43>> trg = Compare(&h, &h.fStatus, FAD::EventHeader::kTriggerLine); 1492 Print("Trg", trg); 1493 } 1494 1495 if (old.HasContTriggerEnabled() != h.HasContTriggerEnabled()) 1496 { 1497 const pair<bool, boost::array<uint16_t,43>> cnt = Compare(&h, &h.fStatus, FAD::EventHeader::kContTrigger); 1498 Print("Cnt", cnt); 1499 } 1500 1501 if (old.IsInSock17Mode() != h.IsInSock17Mode()) 1502 { 1503 const pair<bool, boost::array<uint16_t,43>> sck = Compare(&h, &h.fStatus, FAD::EventHeader::kSock17); 1504 Print("Sck", sck); 1505 } 1506 1507 1508 1509 //Update(fDimFwVersion, ver); 1510 //Update(fDimFwVersion, trg); 1511 //Update(fDimFwVersion, run); 1512 // frq send only min/max 1513 1514 //const pair<bool, boost::array<uint32_t,43>> frq = Compare(&h, &h.fFreqRefClock); 1515 //Print("Frq", frq); 1337 1516 } 1338 1517 };
Note:
See TracChangeset
for help on using the changeset viewer.