Made enableing the raw output more intuitive
This commit is contained in:
parent
286e78e51b
commit
36c2af0405
2 changed files with 11 additions and 10 deletions
|
|
@ -91,7 +91,7 @@ class detector():
|
||||||
|
|
||||||
|
|
||||||
class CosmicPi_V15(detector, threading.Thread):
|
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)
|
detector.__init__(self, "CosmicPi V1.5", "1.5.1", sqlite_location)
|
||||||
# todo: put the thread inheritance one higher
|
# todo: put the thread inheritance one higher
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
@ -107,9 +107,10 @@ class CosmicPi_V15(detector, threading.Thread):
|
||||||
self.baud_rate = baud_rate
|
self.baud_rate = baud_rate
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
# setup the writing onto disk
|
# setup the writing onto disk
|
||||||
|
self.enable_raw_output = enable_raw_output
|
||||||
self._ouput_file_handler = 0
|
self._ouput_file_handler = 0
|
||||||
if raw_output_file_location is not 'none':
|
if self.enable_raw_output is True:
|
||||||
self._ouput_file_handler = open(raw_output_file_location, 'w')
|
self._ouput_file_handler = open("1-5_raw_output.log", 'w')
|
||||||
# empty the output file
|
# empty the output file
|
||||||
self._ouput_file_handler.write(" ")
|
self._ouput_file_handler.write(" ")
|
||||||
|
|
||||||
|
|
@ -159,7 +160,7 @@ class CosmicPi_V15(detector, threading.Thread):
|
||||||
print(e)
|
print(e)
|
||||||
raise RuntimeError("The detector can not function without a serial connection.")
|
raise RuntimeError("The detector can not function without a serial connection.")
|
||||||
line_str = str(line)
|
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)
|
self._ouput_file_handler.write(line_str)
|
||||||
|
|
||||||
# parsing
|
# parsing
|
||||||
|
|
@ -297,8 +298,8 @@ det = 0
|
||||||
if detector_class == "CosmicPi_V15":
|
if detector_class == "CosmicPi_V15":
|
||||||
serial_port = config.get(detector_class, "serial_port")
|
serial_port = config.get(detector_class, "serial_port")
|
||||||
baud_rate = config.get(detector_class, "baud_rate")
|
baud_rate = config.get(detector_class, "baud_rate")
|
||||||
raw_output_file_location = config.get(detector_class, "raw_output_file_location")
|
enable_raw_output = config.getboolean(detector_class, "enable_raw_output")
|
||||||
det = CosmicPi_V15(serial_port, baud_rate, sqlite_location, raw_output_file_location=raw_output_file_location)
|
det = CosmicPi_V15(serial_port, baud_rate, sqlite_location, enable_raw_output=enable_raw_output)
|
||||||
if det == 0:
|
if det == 0:
|
||||||
print("ERROR: Could not find the detector class: " + str(detector_class))
|
print("ERROR: Could not find the detector class: " + str(detector_class))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@ detector_class = CosmicPi_V15
|
||||||
[CosmicPi_V15]
|
[CosmicPi_V15]
|
||||||
serial_port = COM9
|
serial_port = COM9
|
||||||
baud_rate = 115200
|
baud_rate = 115200
|
||||||
# Leaving the raw output turned off can improve performance drastically,
|
# Leaving the raw output turned off can improve performance of the data acquisition
|
||||||
# as well as extending the potential lifetime of the SD-Card.
|
# and extend the potential lifetime of the SD-Card.
|
||||||
# the output log can be turned off by setting it to 'none' (without quotation marks)
|
# The output log can be turned off by setting enable_raw_output = False
|
||||||
raw_output_file_location = 1-5_raw_output.log
|
enable_raw_output = True
|
||||||
|
|
||||||
[Storage]
|
[Storage]
|
||||||
sqlite_location = ../storage/sqlite_db
|
sqlite_location = ../storage/sqlite_db
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue