diff --git a/config.py b/config.py index df1978259482d173741797aee7e32d7b2a3b58d9..c0ee048cce3410946cea8ccfe7007c5d3c0e0623 100644 --- a/config.py +++ b/config.py @@ -35,7 +35,7 @@ EXEC_LOGGING_CONFIG = { # Data logging configuration DATA_LOGGING_CONFIG = { 'logging_level': logging.INFO, - 'logging_to_console': False, + 'logging_to_console': True, 'file_name': 'data_log', 'max_bytes': 16777216, 'backup_count': 1024, diff --git a/ohmpi.py b/ohmpi.py index 32fc29325910c0b3ed942bb92c116d5493e0a8c5..d133104efb066dc08825a145834e1f385a3b3a79 100644 --- a/ohmpi.py +++ b/ohmpi.py @@ -84,21 +84,22 @@ class OhmPi(object): # default acquisition settings self.settings = { 'injection_duration': 0.2, - 'nbr_meas': 100, + 'nbr_meas': 1, 'sequence_delay': 1, 'nb_stack': 1, 'export_path': 'data/measurement.csv' } - + print(self.settings) # read in acquisition settings if settings is not None: self._update_acquisition_settings(settings) - self.exec_logger.debug('Initialized with configuration:' + str(self.settings)) + print(self.settings) + self.exec_logger.debug('Initialized with settings:' + str(self.settings)) # read quadrupole sequence if sequence is None: - self.sequence = np.array([[1, 2, 3, 4]]) + self.sequence = np.array([[1, 2, 3, 4]], dtype=np.int32) else: self.read_quad(sequence) @@ -119,7 +120,7 @@ class OhmPi(object): # Starts the command processing thread self.cmd_thread = threading.Thread(target=self.process_commands) self.cmd_thread.start() - #self.process_commands() + def _update_acquisition_settings(self, config): """Update acquisition settings from a json file or dictionary. @@ -234,7 +235,7 @@ class OhmPi(object): sequence : numpy.array Array of shape (number quadrupoles * 4). """ - sequence = np.loadtxt(filename, delimiter=" ", dtype=int) # load quadrupole file + sequence = np.loadtxt(filename, delimiter=" ", dtype=np.int32) # load quadrupole file if sequence is not None: self.exec_logger.debug('Sequence of {:d} quadrupoles read.'.format(sequence.shape[0])) @@ -498,8 +499,7 @@ class OhmPi(object): } else: # for testing, generate random data d = {'time': datetime.now().isoformat(), 'A': quad[0], 'B': quad[1], 'M': quad[2], 'N': quad[3], - 'R [ohm]': np.abs(np.random.randn(1)) - } + 'R [ohm]': np.abs(np.random.randn(1)).tolist()} # round number to two decimal for nicer string output output = [f'{k}\t' for k in d.keys()] @@ -512,7 +512,14 @@ class OhmPi(object): output += f'{val}\t' output = output[:-1] self.exec_logger.debug(output) - self.data_logger.info(json.loads(d)) + dd = d.copy() + dd.update({'A': str(dd['A'])}) + dd.update({'B': str(dd['B'])}) + dd.update({'M': str(dd['M'])}) + dd.update({'N': str(dd['N'])}) + print(np.dtype(d['A'])) + print(json.dumps(dd)) + self.data_logger.info(json.dumps(dd)) time.sleep(1) # NOTE: why this? return d @@ -807,4 +814,4 @@ if __name__ == "__main__": ohmpi = OhmPi(settings='ohmpi_param.json') - \ No newline at end of file + diff --git a/ohmpi_param.json b/ohmpi_settings.json similarity index 100% rename from ohmpi_param.json rename to ohmpi_settings.json