DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
timing
python
timing
shells
factory.py
Go to the documentation of this file.
1
from
__future__
import
print_function
2
3
import
timing.cli.toolbox
as
toolbox
4
5
6
# ------------------------------------------------------------------------------
7
class
ShellContext
(object):
8
pass
9
# ------------------------------------------------------------------------------
10
11
12
# ------------------------------------------------------------------------------
13
class
ShellFactory
(object):
14
"""docstring for Factory"""
15
16
__factoryregister__ = {
17
'board'
: {},
18
'design'
: {},
19
}
20
21
@classmethod
22
def
registerBoard
(cls, aId, aCls):
23
if
aId
in
cls.
__factoryregister__
[
'board'
]:
24
raise
RuntimeError(
'Board '
+aId+
' already registered'
)
25
26
cls.
__factoryregister__
[
'board'
][aId] = aCls
27
28
@classmethod
29
def
registerDesign
(cls, aId, aCls):
30
if
aId
in
cls.
__factoryregister__
[
'design'
]:
31
raise
RuntimeError(
'Design '
+aId+
' already registered'
)
32
33
cls.
__factoryregister__
[
'design`'
][aId] = aCls
34
35
@classmethod
36
def
make
(cls, device):
37
lBoardInfo = toolbox.readSubNodes(device.getNode(
'io.config'
),
False
)
38
device.dispatch()
39
boardType = lBoardInfo[
'board_type'
].value()
40
carrierType = lBoardInfo[
'carrier_type'
].value()
41
designType = lBoardInfo[
'design_type'
].value()
42
43
boardcls = cls.
makeBoardShell
(boardType)
44
designcls = cls.
makeBoardShell
(designType)
45
46
if
not
boardcls:
47
raise
RuntimeError(
'Device '
+device.id()+
': Unknown board type'
)
48
if
not
designcls:
49
raise
RuntimeError(
'Device '
+device.id()+
': Unknown design type'
)
50
51
def
ctor(self, device, boardType, carrierType, designType):
52
53
self.
device
= device
54
self.
info
=
ShellContext
()
55
self.
info
.boardType = boardType
56
self.
info
.carrierType = carrierType
57
self.
info
.designType = designType
58
59
super(self.
__class__
, self).__init__()
60
61
# lCls = classmaker()(device.id(), (boardcls, designcls), {'__init__':ctor})
62
lCls = type(device.id(), (boardcls, designcls), {
'__init__'
:ctor})
63
64
return
lCls(device, boardType, carrierType, designType)
65
66
@classmethod
67
def
makeBoardShell
(cls, boardType):
68
return
cls.
__factoryregister__
.get(
'board'
).get(boardType,
None
)
69
70
@classmethod
71
def
makeDesignShell
(cls, designType):
72
return
cls.
__factoryregister__
.get(
'design'
).get(designType,
None
)
73
# ------------------------------------------------------------------------------
timing.shells.factory.ShellContext
Definition
factory.py:7
timing.shells.factory.ShellFactory
Definition
factory.py:13
timing.shells.factory.ShellFactory.registerDesign
registerDesign(cls, aId, aCls)
Definition
factory.py:29
timing.shells.factory.ShellFactory.makeDesignShell
makeDesignShell(cls, designType)
Definition
factory.py:71
timing.shells.factory.ShellFactory.makeBoardShell
makeBoardShell(cls, boardType)
Definition
factory.py:67
timing.shells.factory.ShellFactory.__factoryregister__
dict __factoryregister__
Definition
factory.py:16
timing.shells.factory.ShellFactory.__class__
__class__
Definition
factory.py:59
timing.shells.factory.ShellFactory.device
device
Definition
factory.py:53
timing.shells.factory.ShellFactory.make
make(cls, device)
Definition
factory.py:36
timing.shells.factory.ShellFactory.info
info
Definition
factory.py:54
timing.shells.factory.ShellFactory.registerBoard
registerBoard(cls, aId, aCls)
Definition
factory.py:22
timing.cli.toolbox
Definition
toolbox.py:1
Generated on
for DUNE-DAQ by
1.17.0