Commit a37a10ae authored by Auke L. Klazema's avatar Auke L. Klazema

Merge branch 'OSB-95-modeswitch' into 'master'

OSB-95: Refactor final mode switch

Closes OSB-95

See merge request ro/lofar!99
parents acf4a70d 091d24ab
......@@ -113,7 +113,7 @@ def issue_rspctl_command(cmd):
out, err = proc.communicate()
if proc.returncode == 0:
out = list(filter(None, out.decode().split('\n')))[1:]
out = list(filter(None, out.decode().split('\n')))
return out, err
else:
raise Exception("Program failed with error: \n" +
......@@ -143,7 +143,7 @@ def parse_clock_output(out, err):
:return: the int value of the clock in Mhz
:rtype: int
"""
match = re.search("\s*Sample frequency: clock=(\d{3})MHz\s*", out)
match = re.search("\s*Sample frequency: clock=(\d{3})MHz\s*", out[0])
if match:
return int(match.group(1))
else:
......@@ -210,7 +210,7 @@ def parse_rcu_output(out, err):
the delay and the attenuation
:rtype: dict
"""
rcu_values = [_f for _f in out.split('\n') if _f] # It filters empty strings
rcu_values = out[1:]
rcu_by_id = {} # list of RCUs listed by ID
for rcu_value in rcu_values:
......@@ -245,7 +245,7 @@ def query_rcu_mode():
return parse_rcu_output(out, err)
# -------Subbands
def parse_subbands_output(rcu_values, err):
def parse_subbands_output(out, err):
"""
Parses the output of rspctl --subbands
......@@ -264,7 +264,7 @@ def parse_subbands_output(rcu_values, err):
the delay and the attenuation
:rtype: dict
"""
rcu_values = out[1:]
rcu_by_id = {}
i_row = 0
......@@ -306,7 +306,7 @@ def query_sub_bands_mode():
return parse_subbands_output(out, err)
# -------XCSub bands
def parse_xcsub_bands_output(rcu_values, err):
def parse_xcsub_bands_output(out, err):
"""
Parses the output of rspctl --xcsubbands
......@@ -342,7 +342,7 @@ def parse_xcsub_bands_output(rcu_values, err):
:return: a dict indexed by the rcu board id containing the list of xcsub bands used
:rtype: dict
"""
rcu_values= out[1:]
rcu_by_id = {}
i_row = 0
......@@ -387,7 +387,7 @@ def query_xcsub_bands_mode():
return parse_xcsub_bands_output(out, err)
# -------Spectral inversion
def parse_spinv_output(board_values, err):
def parse_spinv_output(out, err):
"""
Parses the output of rspctl --spinv
......@@ -426,7 +426,7 @@ def parse_spinv_output(board_values, err):
the delay and the attenuation
:rtype: dict
"""
board_values = out[1:]
rcu_by_id = {}
for board_value in board_values:
temp = board_value.split(":")
......@@ -738,6 +738,10 @@ def setup_logging():
format = '%(asctime)s - %(name)s: %(message)s',
datefmt = "%m/%d/%Y %I:%M:%S %p",
level = logging.DEBUG)
__MODE_NOT_SET_DEFAULT = -2
def init():
"""
......@@ -758,7 +762,7 @@ def setup_command_argument_parser():
parser.add_argument('--wait', type = int, default = [0], nargs = '+')
parser.add_argument('--xcsubband', type = str, default = "")
parser.add_argument('--loops', type = int, default = 1)
parser.add_argument('--mode', type = int, default = -2)
parser.add_argument('--mode', type = int, default = __MODE_NOT_SET_DEFAULT)
return parser
def parse_and_execute_command_arguments():
......@@ -802,7 +806,9 @@ def parse_and_execute_command_arguments():
mode = program_arguments.mode,
add_options = options,
output_directory = program_arguments.directory)
set_mode(0) # SWITCH BACK TO MODE 0 AT THE END
if program_arguments.mode != __MODE_NOT_SET_DEFAULT:
# SWITCH BACK TO MODE 0 AT THE END IF MODE SWITCH WAS SET
set_mode(0)
except Exception as e:
logger.error('error executing rspctl : %s', e)
logger.error('traceback \n%s', traceback.format_exc())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment