From 36c2af0405008f68adff8deb54b92245d3438176 Mon Sep 17 00:00:00 2001 From: Hendrik Borras Date: Thu, 19 Oct 2017 18:40:34 +0200 Subject: [PATCH] Made enableing the raw output more intuitive --- backend/detector_connect.py | 13 +++++++------ config/CosmicPi.config | 8 ++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/backend/detector_connect.py b/backend/detector_connect.py index 62cb80d..677f90b 100644 --- a/backend/detector_connect.py +++ b/backend/detector_connect.py @@ -91,7 +91,7 @@ class detector(): class CosmicPi_V15(detector, threading.Thread): - def __init__(self, serial_port, baud_rate, sqlite_location, timeout=10, raw_output_file_location=''): + def __init__(self, serial_port, baud_rate, sqlite_location, timeout=10, enable_raw_output=False): detector.__init__(self, "CosmicPi V1.5", "1.5.1", sqlite_location) # todo: put the thread inheritance one higher threading.Thread.__init__(self) @@ -107,9 +107,10 @@ class CosmicPi_V15(detector, threading.Thread): self.baud_rate = baud_rate self.timeout = timeout # setup the writing onto disk + self.enable_raw_output = enable_raw_output self._ouput_file_handler = 0 - if raw_output_file_location is not 'none': - self._ouput_file_handler = open(raw_output_file_location, 'w') + if self.enable_raw_output is True: + self._ouput_file_handler = open("1-5_raw_output.log", 'w') # empty the output file self._ouput_file_handler.write(" ") @@ -159,7 +160,7 @@ class CosmicPi_V15(detector, threading.Thread): print(e) raise RuntimeError("The detector can not function without a serial connection.") line_str = str(line) - if not (self._ouput_file_handler == 0): + if self.enable_raw_output is True: self._ouput_file_handler.write(line_str) # parsing @@ -297,8 +298,8 @@ det = 0 if detector_class == "CosmicPi_V15": serial_port = config.get(detector_class, "serial_port") baud_rate = config.get(detector_class, "baud_rate") - raw_output_file_location = config.get(detector_class, "raw_output_file_location") - det = CosmicPi_V15(serial_port, baud_rate, sqlite_location, raw_output_file_location=raw_output_file_location) + enable_raw_output = config.getboolean(detector_class, "enable_raw_output") + det = CosmicPi_V15(serial_port, baud_rate, sqlite_location, enable_raw_output=enable_raw_output) if det == 0: print("ERROR: Could not find the detector class: " + str(detector_class)) diff --git a/config/CosmicPi.config b/config/CosmicPi.config index a97bbb6..44aa2ff 100644 --- a/config/CosmicPi.config +++ b/config/CosmicPi.config @@ -4,10 +4,10 @@ detector_class = CosmicPi_V15 [CosmicPi_V15] serial_port = COM9 baud_rate = 115200 -# Leaving the raw output turned off can improve performance drastically, -# as well as extending the potential lifetime of the SD-Card. -# the output log can be turned off by setting it to 'none' (without quotation marks) -raw_output_file_location = 1-5_raw_output.log +# Leaving the raw output turned off can improve performance of the data acquisition +# and extend the potential lifetime of the SD-Card. +# The output log can be turned off by setting enable_raw_output = False +enable_raw_output = True [Storage] sqlite_location = ../storage/sqlite_db