forked from Teststandees/hcal_teststand_scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ts_setup.py
130 lines (124 loc) · 3.15 KB
/
ts_setup.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
####################################################################
# Type: SCRIPT #
# #
# Description: This script performs the basic setup procedure for #
# the desired teststand. #
####################################################################
from hcal_teststand import *
from hcal_teststand.hcal_teststand import teststand
from hcal_teststand.utilities import *
import sys
from os.path import exists
from optparse import OptionParser
# CLASSES:
# /CLASSES
# FUNCTIONS:
# /FUNCTIONS
# MAIN:
if __name__ == "__main__":
# Script arguments:
parser = OptionParser()
parser.add_option("-t", "--teststand", dest="ts",
default="904",
help="The name of the teststand you want to use (default is \"157\").",
metavar="STR"
)
parser.add_option("-v", "--verbose", dest="verbose",
action="store_true",
default=False,
help="Turn on verbose mode (default is off)",
metavar="BOOL"
)
(options, args) = parser.parse_args()
name = options.ts
v = options.verbose
# Set up teststand:
ts = teststand(name)
print "> Setting up the {0} teststand ...".format(ts.name)
# Set up the AMC13:
print "> Setting up the AMC13 ..."
result = amc13.get_status(ts=ts).status
status = True
if result:
if result[0]:
print "> Can ping T1."
else:
print "> [!!] Can't ping T1."
status = False
if result[1]:
print "> Can ping T2."
else:
print "> [!!] Can't ping T1."
status = False
if result[2]:
print "> Can fetch FW versions."
else:
print "> [!!] Can't fetch FW versions."
status = False
if status:
result = amc13.setup(ts=ts, mode=1) # Set up the AMC13 in TTC mode.
if result:
if result[0]:
print "> Initialization succeeded."
else:
print "> [!!] Initialization failed."
status = False
else:
print "> [!!] Initialization failed."
status = False
if status:
print "> [OK] AMC13 set up."
else:
print "> [!!] AMC13 failed to set up."
else:
print "> [!!] AMC13 failed to set up."
status = False
if status:
print "> Setting up the FE backplane ..."
output = ngccm.setup(ts=ts)
results = output["result"]
if v:
for cmd in output["log"]:
print "\t{0} -> {1}".format(cmd["cmd"], cmd["result"])
for b in results:
if b:
print "> Backplane powercycled."
print "> Backplane reset."
else:
status = False
if status:
print "> [OK] Backplane set up."
else:
print "> [!!] Backplane set up failed."
if status:
# if True:
print "> Setting up the uHTRs ..."
for uhtr_slot in ts.uhtr:
print "> Setting up uHTR in slot {0} ...".format(uhtr_slot)
cmds = [
"0",
"clock",
"setup",
"3",
"quit",
"link",
"init",
"1", # Auto realign
"55", # Orbit delay
"0",
"0",
"quit",
"exit",
"-1",
]
output = uhtr.send_commands(ts, uhtr_slot, cmds)["output"]
if output:
print "> uHTR set up."
else:
print "> [!!] uHTR failed to set up."
status = False
if status:
print "> [OK] Teststand set up correctly."
else:
print "> [!!] Set up aborted."
# /MAIN