25template <
typename FORMAT,
typename CHARGESUM,
int VERSION = 0>
28 using type =
struct PayloadDecoderImplReturnType {
29 void process(uint32_t, gsl::span<const std::byte>);
35template <
typename CHARGESUM,
int VERSION>
45template <
typename CHARGESUM>
51 auto solarId = fee2solar(feeLinkId);
52 if (!solarId.has_value()) {
53 throw std::logic_error(fmt::format(
"{} could not get solarId from feelinkid={}\n", __PRETTY_FUNCTION__,
asString(feeLinkId)));
59template <
typename FORMAT,
typename CHARGESUM,
int VERSION = 0>
64 mFee2SolarMapper(fee2solar)
70 const void* rdhP =
reinterpret_cast<const void*
>(page.data());
72 throw std::invalid_argument(
"page does not start with a valid RDH");
75 auto feeId = o2::raw::RDHUtils::getFEEID(rdhP);
76 auto linkId = o2::raw::RDHUtils::getLinkID(rdhP);
80 auto p = mPayloadDecoders.find(feeLinkId);
81 if (p == mPayloadDecoders.end()) {
83 p = mPayloadDecoders.find(feeLinkId);
86 uint32_t
orbit = o2::raw::RDHUtils::getHeartBeatOrbit(rdhP);
87 auto rdhSize = o2::raw::RDHUtils::getHeaderSize(rdhP);
88 auto payloadSize = o2::raw::RDHUtils::getMemorySize(rdhP) - rdhSize;
90 if (payloadSize > 0) {
91 p->second.process(
orbit, page.subspan(rdhSize, payloadSize));
98 std::map<FeeLinkId, typename PayloadDecoderImpl<FORMAT, CHARGESUM, VERSION>::type> mPayloadDecoders;
105 const void* rdhP =
reinterpret_cast<const void*
>(rdhBuffer.data());
108 throw std::invalid_argument(
"rdhBuffer does not point to a valid RDH !");
110 auto linkId = o2::raw::RDHUtils::getLinkID(rdhP);
111 auto feeId = o2::raw::RDHUtils::getFEEID(rdhP);
114 if (
f.ulFormatVersion != 0 &&
f.ulFormatVersion != 1) {
115 throw std::logic_error(fmt::format(
"ulFormatVersion {} is unknown",
static_cast<int>(
f.ulFormatVersion)));
118 if (
f.ulFormatVersion == 0) {
120 }
else if (
f.ulFormatVersion == 1) {
124 if (
f.ulFormatVersion == 0) {
126 }
else if (
f.ulFormatVersion == 1) {
164 const void* rdhP =
reinterpret_cast<const void*
>(
buffer.data());
167 throw std::invalid_argument(
"buffer does not start with a valid RDH !");
169 auto rdhSize = o2::raw::RDHUtils::getHeaderSize(rdhP);
170 while (
pos <
buffer.size_bytes() - rdhSize) {
171 const void* rdhP =
reinterpret_cast<const void*
>(
buffer.data() +
pos);
174 throw std::invalid_argument(fmt::format(
"buffer at pos {} does not point to a valid RDH !",
pos));
176 auto payloadSize = o2::raw::RDHUtils::getMemorySize(rdhP) - rdhSize;
177 pageDecoder(
buffer.subspan(
pos, rdhSize + payloadSize));
178 pos += o2::raw::RDHUtils::getOffsetToNext(rdhP);
A BareGBTDecoder groups 40 ElinkDecoder objects.
A UserLogicEndpointDecoder groups 12 x (40 UserLogicElinkDecoder objects)
PageDecoderImpl(DecodedDataHandlers decodedDataHandlers, FeeLink2SolarMapper fee2solar)
void operator()(Page page)
gsl::span< const std::byte > RawBuffer
PageParser createPageParser()
std::function< std::optional< uint16_t >(FeeLinkId)> createFeeLink2SolarMapper< ElectronicMapperGenerated >()
std::function< void(Page buffer)> PageDecoder
gsl::span< const std::byte > Page
std::function< void(DsElecId dsId, DualSampaChannelId channel, SampaCluster)> SampaChannelHandler
std::function< std::optional< uint16_t >(FeeLinkId id)> FeeLink2SolarMapper
From (feeId,linkId) to solarId.
PageDecoder createPageDecoder(RawBuffer rdhBuffer, DecodedDataHandlers decodedDataHandlers)
will be called for each decoded Sampa packet and in case of decoding errors
std::string asString(const SampaCluster &sc)
std::function< void(RawBuffer buffer, PageDecoder pageDecoder)> PageParser
SampaChannelHandler sampaChannelHandler
PayloadDecoderImplReturnType { void process(uint32_t, gsl::span< const std::byte >) type
type operator()(const FeeLinkId &feeLinkId, DecodedDataHandlers decodedDataHandlers, FeeLink2SolarMapper fee2solar)
static bool checkRDH(const RDHv4 &rdh, bool verbose=true, bool checkZeros=false)