diff --git a/scripts/AMDC.py b/scripts/AMDC.py index 9c86c36c..878e1ad2 100644 --- a/scripts/AMDC.py +++ b/scripts/AMDC.py @@ -191,7 +191,6 @@ def cmd(self, cmd_str, timeout_sec = 1): except BlockingIOError: # Could not read enough data pass - if len(retdata) > 0: # Convert byte array into chars retdata_chars = retdata.decode("utf-8").split('\r\n') diff --git a/scripts/AMDC_Logger.py b/scripts/AMDC_Logger.py index 57898f30..3f95330f 100644 --- a/scripts/AMDC_Logger.py +++ b/scripts/AMDC_Logger.py @@ -15,19 +15,15 @@ # Date: 06/30/2020 ######################################################### -LogVar = namedtuple(typename = 'LogVar', field_names = 'name index var_type samples_per_sec memory_addr') +LogVar = namedtuple(typename = 'LogVar', field_names = 'name index var_type samples_per_sec') class AMDC_Logger(): default_max_slots = 32 - def __init__(self, AMDC, mapfile): + def __init__(self, AMDC): - if mapfile == None: - raise Exception("Could not find map file") - self.amdc = AMDC - self.mapfile = Mapfile(mapfile) self.available_indices = list(range(AMDC_Logger.default_max_slots))[-1::-1] self.log_vars = {} @@ -78,7 +74,7 @@ def register(self, log_vars, samples_per_sec = 1000, var_type = 'double'): print(e) else: #send command to AMDC - cmd = f'log reg {LV.index} {LV.name} {LV.memory_addr} {LV.samples_per_sec} {LV.var_type}' + cmd = f'log reg {LV.index} {LV.name} {LV.samples_per_sec} {LV.var_type}' out = self.amdc.cmd(cmd) if out[1] == 'FAILURE': self._pop(LV) @@ -280,29 +276,20 @@ def load(self, file): def _create_log_var(self, name, samples_per_sec, var_type, manual_index = None): - memory_addr = int(self.mapfile.address(name), 0) - - if memory_addr == 0: - raise Exception(f"ERROR: couldn't find memory address for '{name}'") - - else: - if name not in self.log_vars.keys(): #check if variable name already registered + if name not in self.log_vars.keys(): #check if variable name already registered - if manual_index is None: - idx = self.available_indices.pop() #extract next available index - else: - #remove index from list of available indices - loc = self.available_indices.index(manual_index) - idx = self.available_indices.pop(loc) - - #create LogVar object and append it to logvars - LV = LogVar(name = name, index = idx, var_type = var_type, samples_per_sec = samples_per_sec, memory_addr = memory_addr) - self.log_vars[name] = LV - - return LV - + if manual_index is None: + idx = self.available_indices.pop() #extract next available index else: - raise Exception('Error: Variable already exists') + #remove index from list of available indices + loc = self.available_indices.index(manual_index) + idx = self.available_indices.pop(loc) + + #create LogVar object and append it to logvars + LV = LogVar(name = name, index = idx, var_type = var_type, samples_per_sec = samples_per_sec) + self.log_vars[name] = LV + + return LV def _pop(self, log_var): @@ -461,6 +448,7 @@ def _dump_single_bin(self, var, print_output = True): elif data_type == 2 or data_type == 3: s = struct.Struct('