in agora/cerebral_simulator/src/previous_version/app.py [0:0]
def generate_equipment_data(equipment_type, device_id, pk):
data = {"id": pk, "device_id": device_id}
if equipment_type == "Refrigerator":
data.update({
"temperature_celsius": round(random.uniform(1, 5), 2),
"door_open": random.choice([True, False]),
"power_usage_kwh": round(random.uniform(1.5, 3.5), 2),
})
elif equipment_type == "Scale":
data.update({
"weight_kg": round(random.uniform(0.5, 20), 2),
"tare_weight_kg": round(random.uniform(0.05, 0.5), 2),
})
elif equipment_type == "POS":
data.update({
"transaction_id": f"txn_{random.randint(1000, 9999)}",
"items_sold": float(random.randint(1, 10)), # Convert to float
"total_amount_usd": round(random.uniform(10, 500), 2),
"payment_method": random.choice(["credit_card", "cash", "mobile_payment"]),
})
elif equipment_type == "SmartShelf":
data.update({
"product_id": f"prod_{random.randint(1000, 9999)}",
"stock_level": float(random.randint(0, 100)), # Convert to float
"threshold_stock_level": float(random.randint(10, 20)), # Convert to float
"last_restocked": (datetime.utcnow() - timedelta(hours=random.randint(0, 48))).isoformat(),
})
elif equipment_type == "HVAC":
data.update({
"temperature_celsius": round(random.uniform(18, 24), 2),
"humidity_percent": round(random.uniform(40, 60), 2),
"power_usage_kwh": round(random.uniform(2, 4), 2),
"operating_mode": random.choice(["heating", "cooling"]),
})
elif equipment_type == "LightingSystem":
data.update({
"brightness_level": round(random.uniform(0, 100), 2),
"power_usage_kwh": round(random.uniform(0.05, 1.5), 2),
"status": random.choice(["on", "off"]),
})
elif equipment_type == "AutomatedCheckout":
data.update({
"transaction_id": f"txn_{random.randint(1000, 9999)}",
"items_scanned": float(random.randint(1, 10)), # Convert to float
"total_amount_usd": round(random.uniform(10, 500), 2),
"payment_method": random.choice(["credit_card", "cash", "mobile_payment"]),
"errors": float(random.randint(0, 5)), # Convert to float
})
else:
# Default case for unknown equipment types
data.update({
"status": random.choice(["active", "inactive", "maintenance"]),
"last_maintenance": (datetime.utcnow() - timedelta(days=random.randint(0, 30))).isoformat(),
})
return data