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 GLOBAL = 6
17 def __repr__(self):
18 return self.name
19 def __str__(self):
20 return self.name
21 @staticmethod
22 def fromBoardName(name):
23 if 'muctpi' in name.lower():
24 btype = BoardType.MUCTPI
25 elif 'merger' in name.lower():
26 btype = BoardType.MERGER
27 elif 'topo' in name.lower():
28 btype = BoardType.TOPO
29 elif 'ctpin' in name.lower():
30 btype = BoardType.CTPIN
31 elif 'global' in name.lower():
32 btype = BoardType.GLOBAL
33 else:
34 raise RuntimeError("No BoardType defined for board %s" % name)
35 return btype
36
37
39 def __init__(self):
40 self.boards = {}
41
42 def addBoard(self, boardDef):
43 name = boardDef["name"]
44 btype = BoardType.fromBoardName(name)
45 isLegacy = 'legacy' in boardDef
46 self.boards[name] = Board(name, btype, isLegacy)
47 if "connectors" in boardDef:
48 self.boards[name].addOutputConnectorNames([c["name"] for c in boardDef["connectors"]])
49 return self.boards[name]
50
51 def json(self):
52 confObj = {boardName : self.boards[boardName].json() for boardName in sorted(self.boards)}
53 return confObj
54
55
56class Board(object):
57 def __init__(self, name, btype, isLegacy = False):
58 self.name = name
59 self.btype = btype
60 self.isLegacy = isLegacy
63
64 def addOutputConnectorNames(self, connName ):
65 self.outputConnectors += connName
66
67 def json(self):
68 confObj = {}
69 confObj["type"] = str(self.btype)
70 if self.isLegacy:
71 confObj["legacy"] = self.isLegacy
72 confObj["connectors"] = self.outputConnectors
73 # inputConnectors only exist for merger boards
74 if confObj["type"] == BoardType.MERGER:
75 confObj["inputConnectors"] = self.inputConnectors
76 return confObj
nlohmann::json json
addOutputConnectorNames(self, connName)
Definition Boards.py:64
__init__(self, name, btype, isLegacy=False)
Definition Boards.py:57