Update glory simulator
This commit is contained in:
@ -143,14 +143,16 @@ class GlorySimulator:
|
||||
|
||||
if cmd == "GT":
|
||||
# Get batch total
|
||||
# If no counts, generate random simulation data
|
||||
# if not self.batch_counts and self.motor_has_run:
|
||||
if True:
|
||||
# For simulator: reset and generate new counts for each GT request
|
||||
# This simulates a fresh batch counting session
|
||||
logger.info("GT received - resetting batch and simulating new count")
|
||||
self.batch_counts = {}
|
||||
self._simulate_counting()
|
||||
|
||||
total = sum(self.batch_counts.values())
|
||||
response = f"BT{total:08d}"
|
||||
logger.info(f"Get batch total: {total} coins")
|
||||
|
||||
return self.create_message(response)
|
||||
|
||||
elif cmd == "GS":
|
||||
@ -225,10 +227,11 @@ class GlorySimulator:
|
||||
cmd = data.decode("ascii", errors="ignore").strip()
|
||||
|
||||
if cmd == "MG":
|
||||
# Start motor
|
||||
# Start motor - reset batch counts for new counting session
|
||||
self.motor_running = True
|
||||
self.motor_has_run = True
|
||||
logger.info("Motor started")
|
||||
self.batch_counts = {} # Reset batch for new counting session
|
||||
logger.info("Motor started - batch counts reset")
|
||||
# Simulate coin counting
|
||||
self._simulate_counting()
|
||||
elif cmd == "MS":
|
||||
@ -318,18 +321,18 @@ class GlorySimulator:
|
||||
"""Simulate coin counting when motor runs"""
|
||||
# Generate random counts for simulation
|
||||
# Standard denominations with realistic count distributions
|
||||
# All ranges start at 1 to ensure non-zero counts
|
||||
denominations = {
|
||||
"001": (20, 150), # Pennies - high count
|
||||
"005": (10, 100), # Nickels
|
||||
"010": (10, 80), # Dimes
|
||||
"025": (5, 60), # Quarters
|
||||
"050": (0, 20), # Half dollars - rare
|
||||
"100": (0, 10), # Dollar coins - rare
|
||||
"050": (1, 20), # Half dollars - rare (changed from 0)
|
||||
"100": (1, 10), # Dollar coins - rare (changed from 0)
|
||||
}
|
||||
|
||||
for denom, (min_count, max_count) in denominations.items():
|
||||
count = random.randint(min_count, max_count)
|
||||
if count > 0:
|
||||
# Update batch counts
|
||||
self.batch_counts[denom] = self.batch_counts.get(denom, 0) + count
|
||||
# Update partial counts
|
||||
|
||||
Reference in New Issue
Block a user