forked from lspestrip/striptease
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram_reference_test2.py
More file actions
executable file
·115 lines (95 loc) · 3.37 KB
/
program_reference_test2.py
File metadata and controls
executable file
·115 lines (95 loc) · 3.37 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
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
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
# Procedura 2: accensione progressiva
import logging as log
from calibration import CalibrationTables
from reference_test import (
proc_1,
)
from striptease import (
STRIP_BOARD_NAMES,
polarimeter_iterator,
PhswPinMode,
StripProcedure,
StripTag,
wait_with_tag,
)
from turnon import TurnOnOffProcedure
DEFAULT_WAIT_TIME_S = 120.0
class ReferenceTestProcedure(StripProcedure):
def __init__(self, wait_time_s):
super(ReferenceTestProcedure, self).__init__()
self.calib = CalibrationTables()
self.wait_time_s = wait_time_s
def run(self):
# turn on polarimeter
turnon_proc = TurnOnOffProcedure(waittime_s=1.0, turnon=True)
for cur_board, pol_idx, polname in polarimeter_iterator(args.board):
with StripTag(conn=self.command_emitter, name=f"ref2_turnon_pol_{polname}"):
turnon_proc.set_board_horn_polarimeter(
new_board=cur_board,
new_horn=polname,
new_pol=None,
)
turnon_proc.run()
self.command_emitter.command_list += turnon_proc.get_command_list()
turnon_proc.clear_command_list()
proc_1(self, polname, cur_board, 2, wait_time_s=self.wait_time_s)
self.conn.log(message="ref2_set phsw state to default bias")
# set phsw modulation to default bias
with StripTag(
conn=self.command_emitter,
name=f"ref2_set_pol{polname}_phsw_default_end",
):
for h in range(4):
self.conn.set_phsw_status(
polarimeter=polname,
phsw_index=h,
status=PhswPinMode.DEFAULT_STATE,
)
self.conn.set_hk_scan(boards=cur_board, allboards=False, time_ms=500)
wait_with_tag(
conn=self.conn,
seconds=self.wait_time_s,
name=f"ref2_acquisition_pol{polname}_phsw_default_end",
)
if __name__ == "__main__":
from argparse import ArgumentParser, RawDescriptionHelpFormatter
parser = ArgumentParser(
description="Procedure a command sequence to turn on the boards",
formatter_class=RawDescriptionHelpFormatter,
epilog=""""
python3 amalia_reference.py
""",
)
parser.add_argument(
"--output",
"-o",
metavar="FILENAME",
type=str,
dest="output_filename",
default="",
help="Name of the file where to write the output (in JSON format)."
"If not provided, the output will be sent to stdout",
)
parser.add_argument(
"--wait-time-s",
"-w",
metavar="SECONDS",
type=float,
dest="wait_time_s",
default=DEFAULT_WAIT_TIME_S,
help="Time to spend in each stable configuration (default: {DEFAULT_WAIT_TIME_S})",
)
parser.add_argument(
"board",
type=str,
nargs="?",
default=STRIP_BOARD_NAMES,
help="ref_turn on one or more boards",
)
args = parser.parse_args()
log.basicConfig(level=log.INFO, format="[%(asctime)s %(levelname)s]%(message)s")
proc = ReferenceTestProcedure(wait_time_s=args.wait_time_s)
proc.run()
proc.output_json(args.output_filename)