Skip to content

Commit

Permalink
cleanup, commenting out debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
kdmukai committed Apr 3, 2024
1 parent c1be23f commit fa95387
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
1 change: 0 additions & 1 deletion src/seedsigner/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ def reset_screensaver_timeout(self):
"""
from seedsigner.hardware.buttons import HardwareButtons
HardwareButtons.get_instance().update_last_input_time()
print("reset_screensaver_timeout")


def activate_toast(self, toast_manager_thread: BaseToastOverlayManagerThread):
Expand Down
5 changes: 2 additions & 3 deletions src/seedsigner/gui/screens/scan_screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,15 @@ def run(self):

start_time = time.time()
num_frames = 0
debug = True
debug = False
show_framerate = False # enable for debugging / testing
while self.keep_running:
frame = self.camera.read_video_stream(as_image=True)
if frame is not None:
num_frames += 1
cur_time = time.time()
cur_fps = num_frames / (cur_time - start_time)
print(f"{cur_fps=}")


scan_text = None
progress_percentage = self.decoder.get_percent_complete()
if progress_percentage == 0:
Expand Down
22 changes: 6 additions & 16 deletions src/seedsigner/helpers/ur2/fountain_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def estimated_percent_complete(self, weight_mixed_frames: bool = False):
* counts completed frames
* counts each additional frame that is currently XORed in a mixed frame; its
score is weighted by the number of frames mixed together (1/num frames mixed).
TODO: try just using the largest fraction of the XOR total
"""
if self.is_complete():
return 1
Expand All @@ -104,24 +103,21 @@ def estimated_percent_complete(self, weight_mixed_frames: bool = False):
if index not in mixed_index_scoring:
mixed_index_scoring[index] = 0.0

# metric 1: sum up partial scores
# sum up partial scores
mixed_index_scoring[index] += score

# metric 2: just keep the max
# mixed_index_scoring[index] = max(score, mixed_index_scoring[index])

mixed_score = 0.0
for index, score in mixed_index_scoring.items():
# set a ceiling; don't let an index in a mixed/XOR frame
# achieve equal weight as a fully decoded frame. Also if
# the ceiling is too high, can potentially see your
# reported progress percentage DECREASE during a decode.
mixed_score += min(score, 0.75)

num_complete = len(self.received_part_indexes)
weighted_estimate = (num_complete + mixed_score) / float(parts)
return weighted_estimate


def receive_part(self, encoder_part):
# Don't process the part if we're already done
Expand All @@ -148,11 +144,11 @@ def receive_part(self, encoder_part):
self.processed_parts_count += 1

# self.print_part_end()
self.print_state()
# self.print_state()

if num_complete == len(self.received_part_indexes) and num_mixed_frames == len(self.mixed_parts):
# This part didn't add any new info
print("No new data")
# print("No new data")
return False

return True
Expand All @@ -176,7 +172,7 @@ def process_queue_item(self):
else:
self.process_mixed_part(part)

print(f"Queue processing: {int((time.time() - start)*1000.0)}ms")
# print(f"Queue processing: {int((time.time() - start)*1000.0)}ms")
# self.print_state()

def reduce_mixed_by(self, p):
Expand Down Expand Up @@ -323,9 +319,6 @@ def print_part_end(self):
print("processed: {}, expected: {}, received: {}, percent: {}%".format(self.processed_parts_count, expected, len(self.received_part_indexes), percent))

def print_state(self):
parts = self.expected_part_count() if self.expected_part_indexes != None else 'None'
received = self.indexes_to_string(self.received_part_indexes)

guesstimate = self.estimated_percent_complete(weight_mixed_frames=True)
original_metric = self.estimated_percent_complete()
mixed = []
Expand All @@ -341,10 +334,7 @@ def print_state(self):

mixed_s = "[{}]".format(', '.join(mixed))
queued = len(self.queued_parts)
res = self.result_description()
# print(f"{self.estimated_percent_complete()*100.0:3.1f}%" + 'parts: {}, received: {}, mixed: {}, queued: {}, result: {}'.format(parts, received, mixed_s, queued, res))
print(f"{original_metric*100.0:5.1f}% | {guesstimate*100.0:5.1f}% | done: {num_complete:2d}, mixed: {len(mixed_set):2d}, queued: {queued}, frames: {self.processed_parts_count:2d} | {mixed_s}")
# print(f"{original_metric*100.0:5.1f}% | {guesstimate*100.0:5.1f}% | {mixed_s}")

except Exception as e:
import traceback
Expand Down

0 comments on commit fa95387

Please sign in to comment.