#include "nx/Iterator.h" nx::Iterator::Iterator(int fmt) : base::Iterator(fmt), fEpoch(0), fMsg(), fConv(), fCorrecion(false), fLastNxHit(), fNxTmDistance(0), fVerifyRes(0) { // we have 14 bits for stamp and 32 bits for epoch fConv.SetTimeSystem(14+32, 1e-9); } nx::Iterator::~Iterator() { } void nx::Iterator::SetCorrection(bool enabled, unsigned nxmask, unsigned nx_distance) { fCorrecion = enabled; fNxTmDistance = nx_distance; fLastNxHit.clear(); if (fCorrecion) { unsigned numnx(0); while (nxmask != 0) { numnx++; nxmask = nxmask >> 1; } if (numnx < 4) numnx = 4; for (unsigned n=0;n>11)&0x7)) res = -5; else // if message too far in past relative to previous if (fulltm + fNxTmDistance < fLastNxHit[nxid]) res = -1; else // we decide that lastepoch bit is set correctly res = 1; } else { // imperical 800 ns value if (fulltm + fNxTmDistance < fLastNxHit[nxid]) { if (fMsg.getNxTs() < 30) res = -2; else res = -3; } } fLastNxHit[nxid] = fulltm; if ((res==-1) || (res==-5)) { fLastNxHit[nxid] += 16*1024; fMsg.setNxLastEpoch(0); } fVerifyRes = res; } void nx::Iterator::setRocNumber(uint16_t rocnum) { if (fFormat == base::formatEth2) fMsg.setRocNumber(rocnum); } void nx::Iterator::printMessage(unsigned kind) { msg().printData(kind, fEpoch, getMsgTime()); } void nx::Iterator::printMessages(unsigned cnt, unsigned kind) { while (cnt-- > 0) { if (!next()) return; msg().printData(kind, fEpoch, getMsgTime()); } }