Skip to content

Commit 8dc1e72

Browse files
committed
hack for loop file replay without RDH orbit update
1 parent 7f65f1f commit 8dc1e72

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

src/DataBlock.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,17 @@ struct DataBlockHeader {
6262
uint32_t timeframeOrbitLast; ///< from timeframe
6363
uint8_t flagEndOfTimeframe; ///< flag to signal this is the last TF block
6464
uint8_t isRdhFormat; ///< flag set when payload is RDH-formatted
65+
uint32_t orbitOffset; ///< set when RDH orbits should be added given offset to match TFid
6566

6667
uint8_t userSpace[DataBlockHeaderUserSpace]; ///< spare area for user data
6768
};
6869

6970
// Version of this header
7071
// with DB marker for DataBlock start, 1st byte in header little-endian
71-
const uint32_t DataBlockVersion = 0x0002DBDB;
72+
const uint32_t DataBlockVersion = 0x0003DBDB;
7273

7374
// DataBlockHeader instance with all default fields
74-
const DataBlockHeader defaultDataBlockHeader = { .headerVersion = DataBlockVersion, .headerSize = sizeof(DataBlockHeader), .dataSize = 0, .blockId = undefinedBlockId, .pipelineId = undefinedBlockId, .timeframeId = undefinedTimeframeId, .runNumber = undefinedRunNumber, .systemId = undefinedSystemId, .feeId = undefinedFeeId, .equipmentId = undefinedEquipmentId, .linkId = undefinedLinkId, .timeframeOrbitFirst = undefinedOrbit, .timeframeOrbitLast = undefinedOrbit, .flagEndOfTimeframe = 0, .isRdhFormat = 1, .userSpace = { 0 } };
75+
const DataBlockHeader defaultDataBlockHeader = { .headerVersion = DataBlockVersion, .headerSize = sizeof(DataBlockHeader), .dataSize = 0, .blockId = undefinedBlockId, .pipelineId = undefinedBlockId, .timeframeId = undefinedTimeframeId, .runNumber = undefinedRunNumber, .systemId = undefinedSystemId, .feeId = undefinedFeeId, .equipmentId = undefinedEquipmentId, .linkId = undefinedLinkId, .timeframeOrbitFirst = undefinedOrbit, .timeframeOrbitLast = undefinedOrbit, .flagEndOfTimeframe = 0, .isRdhFormat = 1, .orbitOffset = undefinedOrbit, .userSpace = { 0 } };
7576

7677
// DataBlock
7778
// Pair of header + payload data

src/ReadoutEquipment.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,9 @@ int ReadoutEquipment::tagDatablockFromRdh(RdhHandle& h, DataBlockHeader& bh)
634634
isError = 1;
635635
} else {
636636
// timeframe ID
637-
hbOrbit = h.getHbOrbit();
637+
hbOrbit = h.getHbOrbit() + bh.orbitOffset;
638638
tfId = getTimeframeFromOrbit(hbOrbit);
639+
// printf("orbit %X + offset %X = %X -> TFid %d\n",(int)h.getHbOrbit(), (int)bh.orbitOffset, (int)hbOrbit, (int)tfId);
639640

640641
// system ID
641642
systemId = h.getSystemId();
@@ -661,6 +662,9 @@ int ReadoutEquipment::tagDatablockFromRdh(RdhHandle& h, DataBlockHeader& bh)
661662
bh.equipmentId = equipmentId;
662663
bh.linkId = linkId;
663664
getTimeframeOrbitRange(tfId, bh.timeframeOrbitFirst, bh.timeframeOrbitLast);
665+
bh.timeframeOrbitFirst -= bh.orbitOffset;
666+
bh.timeframeOrbitLast -= bh.orbitOffset;
667+
// printf("TF %d eq %d link %d : orbits %X - %X\n", (int)bh.timeframeId, (int)bh.equipmentId, (int)bh.linkId, (int)bh.timeframeOrbitFirst, (int)bh.timeframeOrbitLast);
664668
return isError;
665669
}
666670

src/ReadoutEquipmentPlayer.cxx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class ReadoutEquipmentPlayer : public ReadoutEquipment
5454
PacketHeader lastPacketHeader; // keep track of last packet header
5555

5656
uint32_t orbitOffset = 0; // to be applied to orbit after 1st loop
57+
int cfgUpdateOrbits = 1; // when set, all RDHs are modified to update orbit, according to orbitOffset
5758

5859
void copyFileDataToPage(void* page); // fill given page with file data according to current settings
5960
};
@@ -97,11 +98,16 @@ ReadoutEquipmentPlayer::ReadoutEquipmentPlayer(ConfigFile& cfg, std::string cfgE
9798
cfg.getOptionalValue<int>(cfgEntryPoint + ".fillPage", fillPage, 1);
9899
// configuration parameter: | equipment-player-* | autoChunk | int | 0 | When set, the file is replayed once, and cut automatically in data pages compatible with memory bank settings and RDH information. In this mode the preLoad and fillPage options have no effect. |
99100
cfg.getOptionalValue<int>(cfgEntryPoint + ".autoChunk", autoChunk, 0);
100-
// configuration parameter: | equipment-player-* | autoChunkLoop | int | 0 | When set, the file is replayed in loops. Trigger orbit counter in RDH are modified for iterations after the first one, so that they keep increasing. If value is negative, only that number of loop is executed (-5 -> 5x replay). |
101+
// configuration parameter: | equipment-player-* | autoChunkLoop | int | 0 | When set, the file is replayed in loops. If value is negative, only that number of loop is executed (-5 -> 5x replay). |
101102
cfg.getOptionalValue<int>(cfgEntryPoint + ".autoChunkLoop", autoChunkLoop, 0);
103+
// configuration parameter: | equipment-player-* | updateOrbits | int | 1 | When set, trigger orbit counters in all RDH are modified for iterations after the first one (in file loop replay mode), so that they keep increasing. |
104+
cfg.getOptionalValue<int>(cfgEntryPoint + ".updateOrbits", cfgUpdateOrbits, 1);
102105

103106
// log config summary
104-
theLog.log(LogInfoDevel_(3002), "Equipment %s: using data source file=%s preLoad=%d fillPage=%d autoChunk=%d autoChunkLoop=%d", name.c_str(), filePath.c_str(), preLoad, fillPage, autoChunk, autoChunkLoop);
107+
theLog.log(LogInfoDevel_(3002), "Equipment %s: using data source file=%s preLoad=%d fillPage=%d autoChunk=%d autoChunkLoop=%d updateOrbits=%d", name.c_str(), filePath.c_str(), preLoad, fillPage, autoChunk, autoChunkLoop, cfgUpdateOrbits);
108+
if ((!cfgUpdateOrbits)&&(autoChunkLoop)) {
109+
theLog.log(LogWarningDevel_(3104), "Equipment %s: RDH orbits auto-update is disabled, generated data will be inconsistent (TFid and orbit counters mismatch)", name.c_str());
110+
}
105111

106112
// open data file
107113
fp = fopen(filePath.c_str(), "rb");
@@ -205,6 +211,10 @@ DataBlockContainerReference ReadoutEquipmentPlayer::getNextBlock()
205211
// no need to fill header defaults, this is done by getNewDataBlockContainer()
206212
// only adjust payload size
207213
b->header.dataSize = 0;
214+
// and possibly set orbit offset
215+
if (!cfgUpdateOrbits) {
216+
b->header.orbitOffset = orbitOffset;
217+
}
208218

209219
if (autoChunk) {
210220
bool isOk = 1;
@@ -231,6 +241,7 @@ DataBlockContainerReference ReadoutEquipmentPlayer::getNextBlock()
231241
loopCount++;
232242
fileOffset = 0;
233243
orbitOffset = lastPacketHeader.timeframeId * getTimeframePeriodOrbits();
244+
// printf("loop %d: offset = %X\n",(int)loopCount, (int)orbitOffset);
234245
isOk = 1;
235246
}
236247
}
@@ -251,7 +262,7 @@ DataBlockContainerReference ReadoutEquipmentPlayer::getNextBlock()
251262
isOk = 0;
252263
break;
253264
}
254-
if (orbitOffset) {
265+
if (cfgUpdateOrbits) {
255266
// update RDH orbit when applicable
256267
h.incrementHbOrbit(orbitOffset);
257268
}
@@ -261,7 +272,7 @@ DataBlockContainerReference ReadoutEquipmentPlayer::getNextBlock()
261272
currentPacketHeader.linkId = (int)h.getLinkId();
262273
currentPacketHeader.equipmentId = (int)(h.getCruId() * 10 + h.getEndPointId());
263274

264-
int hbOrbit = h.getHbOrbit();
275+
int hbOrbit = h.getHbOrbit() + b->header.orbitOffset;
265276
currentPacketHeader.timeframeId = getTimeframeFromOrbit(hbOrbit);
266277

267278
// fill page metadata

src/readoutErrorCodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
{ 3101, "A feature is configured but not supported by this readout build.", nullptr},
3434
{ 3102, "Syntax error in configuration.", nullptr},
3535
{ 3103, "Inconsistent parameters in configuration.", nullptr},
36+
{ 3104, "Some valid but unsafe configuration parameters are used.", nullptr},
3637
3738
{ 3210, "Logbook problem", nullptr},
3839
{ 3220, "Timeframe server problem", nullptr},

0 commit comments

Comments
 (0)