ATLAS Offline Software
Loading...
Searching...
No Matches
Boards.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3__all__ = ['MenuBoardsCollection', 'BoardType']
4
5from enum import Enum
6
7from AthenaCommon.Logging import logging
8log = logging.getLogger(__name__)
9
10class BoardType(Enum):
11 NONE = 1
12 MUCTPI = 2
13 TOPO = 3
14 CTPIN = 4
15 MERGER = 5
16 def __repr__(self):
17 return self.name
18 def __str__(self):
19 return self.name
20 @staticmethod
21 def fromBoardName(name):
22 if 'muctpi' in name.lower():
23 btype = BoardType.MUCTPI
24 elif 'merger' in name.lower():
25 btype = BoardType.MERGER
26 elif 'topo' in name.lower():
27 btype = BoardType.TOPO
28 elif 'ctpin' in name.lower():
29 btype = BoardType.CTPIN
30 else:
31 raise RuntimeError("No BoardType defined for board %s" % name)
32 return btype
33
34
36 def __init__(self):
37 self.boards = {}
38
39 def addBoard(self, boardDef):
40 name = boardDef["name"]
41 btype = BoardType.fromBoardName(name)
42 isLegacy = 'legacy' in boardDef
43 self.boards[name] = Board(name, btype, isLegacy)
44 if "connectors" in boardDef:
45 self.boards[name].addOutputConnectorNames([c["name"] for c in boardDef["connectors"]])
46 return self.boards[name]
47
48 def json(self):
49 confObj = {boardName : self.boards[boardName].json() for boardName in sorted(self.boards)}
50 return confObj
51
52
54 def __init__(self, name, btype, isLegacy = False):
55 self.name = name
56 self.btype = btype
57 self.isLegacy = isLegacy
60
61 def addOutputConnectorNames(self, connName ):
62 self.outputConnectors += connName
63
64 def json(self):
65 confObj = {}
66 confObj["type"] = str(self.btype)
67 if self.isLegacy:
68 confObj["legacy"] = self.isLegacy
69 confObj["connectors"] = self.outputConnectors
70 # inputConnectors only exist for merger boards
71 if confObj["type"] == BoardType.MERGER:
72 confObj["inputConnectors"] = self.inputConnectors
73 return confObj
nlohmann::json json
addOutputConnectorNames(self, connName)
Definition Boards.py:61
__init__(self, name, btype, isLegacy=False)
Definition Boards.py:54