Skip to content

Commit 24017d2

Browse files
committed
Uncomment code so it hopefuly works
1 parent da7e605 commit 24017d2

1 file changed

Lines changed: 19 additions & 20 deletions

File tree

weight_predict/weight_predict.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -164,26 +164,25 @@ def main():
164164

165165
shelf = mac_address_to_shelves[mac_address]
166166
slot = shelf.slots[json_data['slot_id']]
167-
print(f"delta: {json_data['delta_g']}")
168-
169-
# # item_changes = slot.predict_most_likely_item(json_data['delta_g'])
170-
#
171-
# for item_change in item_changes:
172-
# # Construct out JSON
173-
# json_data = {
174-
# 'id': item_change.item_id,
175-
# 'quantity': -item_change.quantity # Note that UI expects positive = add to cart, negative = remove from cart
176-
# }
177-
# json_str = json.dumps(json_data) + "\n"
178-
#
179-
# # Send it to pi
180-
# pi_uart_port.write(json_str.encode('utf-8'))
181-
#
182-
# time_str = time.strftime("%H:%M:%S.") + f"{int((time.time() * 1000) % 1000):03d}"
183-
# if item_change.quantity > 0:
184-
# print(f"{time_str}: Remove {abs(item_change.quantity)} {item_change.name} from cart")
185-
# else:
186-
# print(f"{time_str}: Add {abs(item_change.quantity)} {item_change.name} to cart")
167+
168+
item_changes = slot.predict_most_likely_item(json_data['delta_g'])
169+
170+
for item_change in item_changes:
171+
# Construct out JSON
172+
json_data = {
173+
'id': item_change.item_id,
174+
'quantity': -item_change.quantity # Note that UI expects positive = add to cart, negative = remove from cart
175+
}
176+
json_str = json.dumps(json_data) + "\n"
177+
178+
# Send it to pi
179+
pi_uart_port.write(json_str.encode('utf-8'))
180+
181+
time_str = time.strftime("%H:%M:%S.") + f"{int((time.time() * 1000) % 1000):03d}"
182+
if item_change.quantity > 0:
183+
print(f"{time_str}: Remove {abs(item_change.quantity)} {item_change.name} from cart")
184+
else:
185+
print(f"{time_str}: Add {abs(item_change.quantity)} {item_change.name} to cart")
187186

188187
else:
189188
# New shelf

0 commit comments

Comments
 (0)