11 const std::vector<std::string>&
fileNames,
12 const size_t framesPerBX,
14 const size_t emptyFramesAtStart,
18 framesPerBX_(framesPerBX),
20 emptyFramesAtStart_(emptyFramesAtStart),
21 channelMap_(channelMap),
33 const size_t tmuxRatio(spec.tmux /
boardTMUX_);
34 if (
indices.size() != tmuxRatio)
37 ", does not match link:board TMUX ratio");
48 if (not boardData.
has(
i))
49 throw std::runtime_error(
"Channel " +
std::to_string(
i) +
" was declared but is missing from file '" +
55 for (
const auto& [
id,
value] : channelMap) {
57 for (
size_t tmuxIndex = 0; tmuxIndex <
indices.size(); tmuxIndex++) {
58 const auto& chanData = boardData.
at(
indices.at(tmuxIndex));
63 const size_t packetLength(eventLength - spec.interpacketGap);
65 for (
size_t j = 0;
j < framesBeforeFirstPacket;
j++) {
66 if (chanData.at(
j).valid)
67 throw std::runtime_error(
"Frame " +
std::to_string(
j) +
" on channel " +
69 std::to_string(framesBeforeFirstPacket) +
"frames should be invalid");
72 for (
size_t j = framesBeforeFirstPacket;
j < chanData.size();
j++) {
76 bool expectValid(((
j - framesBeforeFirstPacket) % eventLength) < packetLength);
79 if (not chanData.at(
j).valid)
80 throw std::runtime_error(
"Frame " +
std::to_string(
j) +
" on channel " +
82 " is invalid, but expected valid frame");
83 }
else if (chanData.at(
j).valid)
84 throw std::runtime_error(
"Frame " +
std::to_string(
j) +
" on channel " +
91 bool eventIncomplete(
false);
92 for (
size_t eventIndex = 0;; eventIndex++) {
95 for (
const auto& [
id,
value] : channelMap) {
101 const size_t packetLength(spec.tmux *
framesPerBX_ - spec.interpacketGap);
103 if (chanData.size() < (framesBeforeEvent + spec.tmux *
framesPerBX_)) {
104 eventIncomplete =
true;
108 std::vector<ap_uint<64>> chanEventData(packetLength);
109 for (
size_t j = 0;
j < packetLength;
j++)
110 chanEventData.at(
j) = chanData.at(framesBeforeEvent +
j).data;
111 eventData.
add(
id, chanEventData);
125 const std::vector<std::string>&
fileNames,
126 const size_t framesPerBX,
128 const size_t emptyFramesAtStart,
130 const std::map<std::string, ChannelSpec>& channelSpecs)
136 throw std::runtime_error(
"Board data reader ran out of events");
142 const std::map<std::string, ChannelSpec>& specMap) {
144 for (
const auto&
x : indexMap)
145 channelMap.at(
x.first) = {specMap.at(
x.first.interface),
x.second};
BoardDataReader(FileFormat, const std::vector< std::string > &, const size_t framesPerBX, const size_t tmux, const size_t emptyFramesAtStart, const ChannelMap_t &)
size_t emptyFramesAtStart_
Logical ID for link within any given time slice (e.g. ["tracks", 0] -> ["tracks", 17] for links from ...
void add(const LinkId &, const std::vector< ap_uint< 64 >> &)
static std::string to_string(const XMLCh *ch)
static ChannelMap_t mergeMaps(const std::map< LinkId, std::vector< size_t >> &, const std::map< std::string, ChannelSpec > &)
std::vector< std::string > fileNames_
std::map< LinkId, std::pair< ChannelSpec, std::vector< size_t > > > ChannelMap_t
BoardData read(const std::string &filePath, const FileFormat)
std::vector< EventData >::const_iterator eventIt_
Class representing information that's stored in the input or output buffers on a phase-2 board...
std::vector< EventData > events_
Class representing information phase-2 ATCA I/O data corresponding to a single event, with logical channel IDs (essentially string-uint pairs, e.g. tracks-0 to tracks-17).