From b91e512b56d4238307b8e0bad82ea3b5f3aefc70 Mon Sep 17 00:00:00 2001 From: Hendrik Borras Date: Sat, 14 Oct 2017 17:13:02 +0200 Subject: [PATCH] Discard events appearing twice --- backend/detector_connect.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/detector_connect.py b/backend/detector_connect.py index b40899b..2cc39e1 100644 --- a/backend/detector_connect.py +++ b/backend/detector_connect.py @@ -147,7 +147,7 @@ class CosmicPi_V15(detector, threading.Thread): # when there is an event store it if event_bool: - #print("DEBUG: Sending event") + print("DEBUG: Sending event") self._commit_event_dict(self._event_dict) def _read_parse_and_check_for_event(self): @@ -262,9 +262,13 @@ class CosmicPi_V15(detector, threading.Thread): sub_sec_string = sub_sec_string.split(';')[0] # currently we are getting micros() here # so divide them by - self._event_dict['SubSeconds'] = float(sub_sec_string) / 1000000.0 - # make sure we have a connection to the GPS - return True + current_subSeconds = float(sub_sec_string) / 1000000.0 + # make sure we are actually seeing something new + if (self._event_dict['SubSeconds'] == current_subSeconds): + return False + else: + self._event_dict['SubSeconds'] = current_subSeconds + return True return False except IndexError as e: print("WARNING: Error while accessing the result of splitting a the following line:" + str(line_str))