diff --git a/gamutrfwaterfall/gamutrfwaterfall/waterfall.py b/gamutrfwaterfall/gamutrfwaterfall/waterfall.py index 786cd271..3abd2d79 100644 --- a/gamutrfwaterfall/gamutrfwaterfall/waterfall.py +++ b/gamutrfwaterfall/gamutrfwaterfall/waterfall.py @@ -623,7 +623,8 @@ def update_fig(config, state, results): scan_time = scan_df.ts.iloc[-1] row_time = datetime.datetime.fromtimestamp(scan_time) - state.scan_times.append(scan_time) + if scan_time not in state.scan_config_history: + state.scan_times.append(scan_time) state.scan_config_history[scan_time] = scan_configs while len(state.scan_times) > config.waterfall_height: remove_time = state.scan_times.pop(0) @@ -1089,6 +1090,15 @@ def start(self): self.process.start() self.zmq_process.start() + def write_predictions_content(self, content): + tmpfile = os.path.join(self.static_folder, "." + self.predictions_file) + with open(tmpfile, "w", encoding="utf8") as f: + f.write( + '
%s' + % (self.refresh, content) + ) + os.rename(tmpfile, os.path.join(self.static_folder, self.predictions_file)) + def poll_zmq(self): zmq_context = zmq.Context() socket = zmq_context.socket(zmq.SUB) @@ -1097,17 +1107,7 @@ def poll_zmq(self): DELIM = "\n\n" json_buffer = "" item_buffer = [] - - def write_content(content): - tmpfile = os.path.join(self.static_folder, "." + self.predictions_file) - with open(tmpfile, "w", encoding="utf8") as f: - f.write( - '%s' - % (self.refresh, content) - ) - os.rename(tmpfile, os.path.join(self.static_folder, self.predictions_file)) - - write_content("no predictions yet") + self.write_predictions_content("no predictions yet") while True: try: @@ -1146,7 +1146,7 @@ def write_content(content): % (style, image, age, style, image) ) if images: - write_content( + self.write_predictions_content( f"{datetime.datetime.now().isoformat()}
" + "".join(images) ) time.sleep(0.1)