21 uint32_t side, uint32_t version)
23 using namespace Detail;
25 assert(version <= kCurrentVersion);
28 uint32_t maxUnit = (1 << kBits[version][
kStsUnit]) - 1;
30 LOG(error) <<
"Unit Id " << unit <<
" exceeds maximum " << maxUnit;
33 uint32_t maxLadder = (1 << kBits[version][
kStsLadder]) - 1;
34 if (ladder > maxLadder) {
35 LOG(error) <<
"Ladder Id " << ladder <<
" exceeds maximum " << maxLadder;
38 uint32_t maxHalfLadder = (1 << kBits[version][
kStsHalfLadder]) - 1;
39 if (halfladder > maxHalfLadder) {
40 LOG(error) <<
"HalfLadder Id " << halfladder <<
" exceeds maximum " << maxHalfLadder;
43 uint32_t maxModule = (1 << kBits[version][
kStsModule]) - 1;
44 if (module > maxModule) {
45 LOG(error) <<
"Module Id " <<
module << " exceeds maximum " << maxModule;
48 uint32_t maxSensor = (1 << kBits[version][
kStsSensor]) - 1;
49 if (sensor > maxSensor) {
50 LOG(error) <<
"Sensor Id " << sensor <<
" exceeds maximum " << maxSensor;
53 uint32_t maxSide = (1 << kBits[version][
kStsSide]) - 1;
55 LOG(error) <<
"Side Id " << side <<
" exceeds maximum " << maxSide;
61 |
module << kShift[version][kStsModule] | sensor << kShift[version][kStsSensor]
62 | side << kShift[version][kStsSide] | version << kVersionShift;
70 using namespace Detail;
72 assert(version <= kCurrentVersion);
76 uint32_t maxId = (1 << kBits[version][level]) - 1;
77 if (elementId[level] > maxId) {
78 LOG(error) <<
"Id " << elementId[level] <<
" for STS level " << level <<
" exceeds maximum " << maxId;
81 address = address | (elementId[level] << kShift[version][level]);
83 address = address | (version << kVersionShift);
135 using namespace Detail;
137 uint32_t version = GetVersion(address);
138 uint32_t maxId = (1 << kBits[version][level]) - 1;
140 LOG(fatal) <<
"Id " << newId <<
" for STS level " << level <<
" exceeds maximum " << maxId;
143 return (address & (~(kMask[version][level] << kShift[version][level]))) | (newId << kShift[version][level]);
int32_t SetElementId(int32_t address, int32_t level, uint32_t newId)
Set the index of an element, leaving the other element levels untouched.
int32_t GetAddress(uint32_t unit=0, uint32_t ladder=0, uint32_t halfladder=0, uint32_t module=0, uint32_t sensor=0, uint32_t side=0, uint32_t version=kCurrentVersion)
Construct address.