-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDCR.py
More file actions
44 lines (32 loc) · 1.42 KB
/
DCR.py
File metadata and controls
44 lines (32 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from Manager import Manager
class DCR(Manager):
"Responsible for turning config and if path info into DCR params"
def __init__(self, config, ifPaths):
super(DCR, self).__init__(config)
self.ifPaths = ifPaths
self.numChannels = 16
self.mgrName = 'DCR'
def findDCRParams(self):
"Convert config and if path info into parameters"
# last node of each path tells us what channels to select
selectedPorts = []
banks = []
for path in self.ifPaths.paths:
backendNode = path.getBackendNode() #path[-1]
assert backendNode.type == 'Backend'
assert backendNode.device == self.mgrName
selectedPorts.append(backendNode.getPortNumber())
banks.append(backendNode.getBankName())
# DCR Channel,11 0
# DCR Bank Bank_A
for i in range(1, self.numChannels+1):
onBool = i in selectedPorts
on = 1 if onBool else 0
# TBF: we can't check each DCR channel because of the
# arbitrary difference in paths taken between our code
# and production!
# params.append(('DCR,Channel,%d' % i, on))
self.seq.add_param(self.mgrName, 'Channel,%d' %i, on)
# TBF: handle better
self.seq.add_param(self.mgrName, 'Bank', "Bank_%s" % banks[0])
self.seq.add_param(self.mgrName, 'CyclesPerIntegration', 1)