Project
Loading...
Searching...
No Matches
ELinkManager.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
16#ifndef O2_MID_ELINKMANAGER_H
17#define O2_MID_ELINKMANAGER_H
18
19#include <cstdint>
20#if defined(MID_RAW_VECTORS)
21#include <vector>
22#else
23#include <unordered_map>
24#endif
26#include "MIDRaw/ELinkDecoder.h"
28#include "MIDRaw/FEEIdConfig.h"
29
30namespace o2
31{
32namespace mid
33{
35{
36 public:
37 void init(uint16_t feeId, bool isDebugMode, bool isBare = false, const ElectronicsDelay& electronicsDelay = ElectronicsDelay(), const FEEIdConfig& feeIdConfig = FEEIdConfig());
38
39 void set(uint32_t orbit, uint32_t trigger);
40
42 inline void onDone(const ELinkDecoder& decoder, uint8_t boardUniqueId, std::vector<ROBoard>& data, std::vector<ROFRecord>& rofs) { return onDone(decoder, raw::getCrateId(boardUniqueId), raw::getLocId(boardUniqueId), data, rofs); }
43
45 inline void onDone(const ELinkDecoder& decoder, std::vector<ROBoard>& data, std::vector<ROFRecord>& rofs) { return onDone(decoder, decoder.getCrateId(), decoder.getId(), data, rofs); }
46
47#if defined(MID_RAW_VECTORS)
49 inline ELinkDecoder& getDecoder(uint8_t boardUniqueId, bool isLoc) { return mDecoders[mIndex(raw::getCrateId(boardUniqueId), raw::getLocId(boardUniqueId), isLoc)]; }
50
52 inline void onDone(const ELinkDecoder& decoder, uint8_t crateId, uint8_t locId, std::vector<ROBoard>& data, std::vector<ROFRecord>& rofs)
53 {
54 return mDataShapers[mIndex(crateId, locId, raw::isLoc(decoder.getStatusWord()))].onDone(decoder, data, rofs);
55 }
56
57 private:
58 std::function<size_t(uint8_t, uint8_t, bool)> mIndex{};
59 std::vector<ELinkDataShaper> mDataShapers;
60 std::vector<ELinkDecoder> mDecoders;
61
62#else
64 inline ELinkDecoder& getDecoder(uint8_t boardUniqueId, bool isLoc) { return mDecoders.find(makeUniqueId(isLoc, boardUniqueId))->second; }
65
67 void onDone(const ELinkDecoder& decoder, uint8_t crateId, uint8_t locId, std::vector<ROBoard>& data, std::vector<ROFRecord>& rofs);
68
69 private:
71 inline uint16_t makeUniqueId(bool isLoc, uint8_t uniqueId) { return (isLoc ? 0 : (1 << 8)) | uniqueId; }
72 std::unordered_map<uint16_t, ELinkDataShaper> mDataShapers;
73 std::unordered_map<uint16_t, ELinkDecoder> mDecoders;
74 std::unordered_map<uint16_t, unsigned long int> mErrors;
75 uint16_t mFeeId;
76
77#endif
78};
79} // namespace mid
80} // namespace o2
81
82#endif /* O2_MID_ELINKMANAGER_H */
Properly formats and sets the absolute timestamp of the raw data.
MID e-link decoder.
Delay parameters for MID electronics.
Hardware Id to FeeId mapper.
uint64_t orbit
Definition RawEventData.h:6
uint8_t getCrateId() const
Gets the crate ID when available.
uint8_t getId() const
Gets the card ID.
ELinkDecoder & getDecoder(uint8_t boardUniqueId, bool isLoc)
Returns the decoder.
void init(uint16_t feeId, bool isDebugMode, bool isBare=false, const ElectronicsDelay &electronicsDelay=ElectronicsDelay(), const FEEIdConfig &feeIdConfig=FEEIdConfig())
void onDone(const ELinkDecoder &decoder, uint8_t boardUniqueId, std::vector< ROBoard > &data, std::vector< ROFRecord > &rofs)
Main function to be executed when decoding is done.
void onDone(const ELinkDecoder &decoder, std::vector< ROBoard > &data, std::vector< ROFRecord > &rofs)
Main function to be executed when decoding is done.
void set(uint32_t orbit, uint32_t trigger)
GLboolean * data
Definition glcorearb.h:298
uint8_t getCrateId(uint8_t uniqueLocId)
Definition ROBoard.h:75
bool isLoc(uint8_t statusWord)
Definition ROBoard.h:65
uint8_t getLocId(uint8_t uniqueLocId)
Definition ROBoard.h:80
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...