Project
Loading...
Searching...
No Matches
FEEIdConfig.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_FEEIDCONFIG_H
17#define O2_MID_FEEIDCONFIG_H
18
19#include <cstdint>
20#include <unordered_map>
21#include <vector>
22
23namespace o2
24{
25namespace mid
26{
28{
29 public:
31 FEEIdConfig(const char* filename);
32 ~FEEIdConfig() = default;
33
34 uint16_t getGBTUniqueId(uint32_t linkUniqueId) const;
35
36 inline const std::vector<uint16_t>& getGBTUniqueIdsInLink(uint16_t feeId) const { return mGBTUniqueIdsInLink.find(feeId)->second; }
37
39 uint16_t getGBTUniqueId(uint8_t linkId, uint8_t endPointId, uint16_t cruId) const { return getGBTUniqueId(getLinkUniqueId(linkId, endPointId, cruId)); }
40
42 inline uint32_t getLinkUniqueId(uint8_t linkId, uint8_t endPointId, uint16_t cruId) const { return (linkId + 1) << ((endPointId == 1) ? 8U : 0U) | (cruId << 16U); }
43
45 inline uint16_t getCRUId(uint32_t linkUniqueId) const { return linkUniqueId >> 16; }
47 inline uint8_t getEndPointId(uint32_t linkUniqueId) const { return (linkUniqueId & 0xFF00) ? 1 : 0; }
49 inline uint8_t getLinkId(uint32_t linkUniqueId) const { return ((linkUniqueId >> (8U * getEndPointId(linkUniqueId))) & 0xFF) - 1; }
51 uint16_t getFEEId(uint16_t gbtUniqueId) const;
52
53 std::vector<uint16_t> getConfiguredGBTUniqueIDs() const;
54 std::vector<uint32_t> getConfiguredLinkUniqueIDs() const;
55 std::vector<uint16_t> getConfiguredFEEIDs() const;
56
57 void write(const char* filename) const;
58
59 private:
60 bool load(const char* filename);
61 void add(uint16_t gbtUniqueId, uint8_t linkId, uint8_t epId, uint16_t cruId, uint16_t feeId);
62 void add(uint16_t gbtUniqueId, uint8_t linkId, uint8_t epId, uint16_t cruId);
63
64 std::unordered_map<uint32_t, uint16_t> mLinkUniqueIdToGBTUniqueId{};
65 std::unordered_map<uint16_t, uint16_t> mGBTUniqueIdToFeeId{};
66 std::unordered_map<uint16_t, std::vector<uint16_t>> mGBTUniqueIdsInLink{};
67};
68} // namespace mid
69} // namespace o2
70
71#endif /* O2_MID_FEEIDCONFIG_H */
uint16_t getFEEId(uint16_t gbtUniqueId) const
Gets the FEE ID from the GBT unique ID.
std::vector< uint32_t > getConfiguredLinkUniqueIDs() const
std::vector< uint16_t > getConfiguredGBTUniqueIDs() const
uint32_t getLinkUniqueId(uint8_t linkId, uint8_t endPointId, uint16_t cruId) const
Gets a uniqueID from the combination of linkId, endPointId and cruId;.
Definition FEEIdConfig.h:42
void write(const char *filename) const
uint16_t getCRUId(uint32_t linkUniqueId) const
Gets the CRU ID.
Definition FEEIdConfig.h:45
const std::vector< uint16_t > & getGBTUniqueIdsInLink(uint16_t feeId) const
Definition FEEIdConfig.h:36
uint16_t getGBTUniqueId(uint32_t linkUniqueId) const
uint8_t getEndPointId(uint32_t linkUniqueId) const
Gets the end point id.
Definition FEEIdConfig.h:47
uint16_t getGBTUniqueId(uint8_t linkId, uint8_t endPointId, uint16_t cruId) const
Gets the GBT unique ID from the physical ID of the link.
Definition FEEIdConfig.h:39
uint8_t getLinkId(uint32_t linkUniqueId) const
Gets the Link ID.
Definition FEEIdConfig.h:49
std::vector< uint16_t > getConfiguredFEEIDs() const
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string filename()