From 7cb728c807a6e9961a4676e4ff540f7cc9bd3731 Mon Sep 17 00:00:00 2001 From: glmdev Date: Sun, 10 Feb 2019 02:00:51 -0600 Subject: [PATCH] add freq control --- .idea/workspace.xml | 16 ++++++++++------ index.py | 3 +-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 3286bfb..0a1018c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,7 +2,6 @@ - + + + poll_t + + @@ -113,8 +117,8 @@ @@ -283,8 +287,8 @@ - - + + diff --git a/index.py b/index.py index e36f24a..67e196c 100644 --- a/index.py +++ b/index.py @@ -40,7 +40,6 @@ def poll(): color_reference = image_tools.average_color(stall_obj['locationX'], stall_obj['locationY'], stall_obj['width'], stall_obj['height'], reference) color_compare = image_tools.average_color(stall_obj['locationX'], stall_obj['locationY'], stall_obj['width'], stall_obj['height'], img) stall_occupied = image_tools.threshold(image_tools.differences(color_reference, color_compare), float(doc_conf['e_hat'])) - print(doc_conf['e_hat']) stall_obj['open'] = not stall_occupied print("Updated: "+stall.id) @@ -51,7 +50,7 @@ start_time = time.time() while True: poll() - poll_time = float(os.getenv('POLL_FREQUENCY')) doc_conf = db.collection('configurations').document(os.getenv('CONFIG_CODE')).get().to_dict() print(doc_conf) + poll_time = float(doc_conf('frequency')) time.sleep(poll_time - ((time.time() - start_time) % poll_time))