adapted that start and end time are not required

This commit is contained in:
tillraab 2022-12-13 09:27:45 +01:00
parent 876ba42d7f
commit 2af579448c

View File

@ -33,7 +33,7 @@ class Configuration():
# timestamps # timestamps
self.now = datetime.datetime.now() self.now = datetime.datetime.now()
self.start_clock = None self.start_clock = [datetime.datetime.now().hour, datetime.datetime.now().minute]
self.end_clock = None self.end_clock = None
# paths # paths
@ -90,9 +90,11 @@ class Configuration():
self.gain = int(line.split(':')[1].strip()) self.gain = int(line.split(':')[1].strip())
# ToDo: add option to start now !!! # ToDo: add option to start now !!!
elif 'StartTime' in line: elif 'StartTime' in line:
self.start_clock = np.array(line.strip().replace(' ', '').split(':')[1:], dtype=int) if len(np.array(line.strip().replace(' ', '').split(':')[1:])) > 1:
self.start_clock = np.array(line.strip().replace(' ', '').split(':')[1:], dtype=int)
elif 'EndTime' in line: elif 'EndTime' in line:
self.end_clock = np.array(line.strip().replace(' ', '').split(':')[1:], dtype=int) if len(np.array(line.strip().replace(' ', '').split(':')[1:])) > 1:
self.end_clock = np.array(line.strip().replace(' ', '').split(':')[1:], dtype=int)
elif 'Gain' in line: elif 'Gain' in line:
self.gain = int(line.split(':')[1].strip()) self.gain = int(line.split(':')[1].strip())
self.channels = self.n_rows * self.n_cols + self.n_extra self.channels = self.n_rows * self.n_cols + self.n_extra
@ -262,6 +264,7 @@ class Recorder():
self.record() self.record()
def record(self): def record(self):
while True: while True:
if datetime.datetime.now().hour == self.config.start_clock[0] and datetime.datetime.now().minute == self.config.start_clock[1]: if datetime.datetime.now().hour == self.config.start_clock[0] and datetime.datetime.now().minute == self.config.start_clock[1]:
break break
@ -377,11 +380,12 @@ class Recorder():
else: else:
(np.array(data[last_idx:], dtype=np.float32) / self.config.gain).tofile(self.f) (np.array(data[last_idx:], dtype=np.float32) / self.config.gain).tofile(self.f)
if datetime.datetime.now().hour * 60 + datetime.datetime.now().minute >= self.config.end_clock[0] * 60 + self.config.end_clock[1]: if hasattr(self.config.end_clock, '__len__'):
self.f.flush() if datetime.datetime.now().hour * 60 + datetime.datetime.now().minute >= self.config.end_clock[0] * 60 + self.config.end_clock[1]:
GPIO.output(self.LED1_pin, GPIO.LOW) self.f.flush()
GPIO.output(self.LED_out_pin, GPIO.LOW) GPIO.output(self.LED1_pin, GPIO.LOW)
break GPIO.output(self.LED_out_pin, GPIO.LOW)
break
(np.array(data[:index], dtype=np.float32) / self.config.gain).tofile(self.f) (np.array(data[:index], dtype=np.float32) / self.config.gain).tofile(self.f)
self.f.flush() self.f.flush()