in agora/contoso_motors/src/mqtt-simulator/mqtt_simulator.py [0:0]
def generate_batteriesdata():
# Get the current time in ISO format
current_time = datetime.datetime.utcnow().isoformat() + "Z"
waste_reasons = ["", "Parts broken", "Wrong parts", "Machine Error"]
lost_time_reasons = ["", "Machine Breakdown", "Raw Material Shortage", "Power Outage"]
# Prepare the JSON payload
return {
"Timestamp": current_time,
"MakeupArea": "Plant Germany - Build",
"Line": "Line 1 - Battery",
"Product": "Battery",
"Process": "Pack Production",
"Batch": random.randint(1, 10),
"CurrentShift": random.choice(["Shift 1", "Shift 2", "Shift 3"]),
"CurrentCellAssemblyPerMinutes": random.randint(130, 150),
"TargetCellAssemblyPerMinutes": 145,
"StartTime": current_time,
"FinishTime": (datetime.datetime.now() + datetime.timedelta(minutes=1)).strftime('%d-%m-%Y %H:%M:%S.%f'),
"Waste": random.uniform(1, 2),
"WasteReason": random.choice(waste_reasons),
"LostTime": "SPT",
"LostTimeReason": random.choice(lost_time_reasons),
"LostTimeTimeCount": random.randint(90, 100),
"ScheduledBatteries": random.randint(8, 12),
"CompletedBatteries": random.randint(3, 7),
"ScheduledBatteriesPerHour": random.randint(280, 320),
"Temperature": random.uniform(230, 240),
"ImpactTest": random.uniform(780, 790),
"VibrationTest": random.uniform(6, 7),
"CellTest": random.uniform(400, 410),
"DownTime": random.randint(2, 6),
"Thruput": random.randint(28, 32),
"OverallEfficiency": random.randint(88, 92),
"Availability": random.randint(93, 97),
"Performance": random.randint(93, 97),
"Quality": random.randint(93, 97),
"PlannedProductionTime": random.randint(58, 62),
"ActualRuntime": random.randint(960, 965),
"UnplannedDowntime": random.randint(295, 300),
"PlannedDowntime": 0,
"PlannedQuantity": random.randint(290, 310),
"ActualQuantity": random.randint(280, 290),
"RejectedQuantity": random.randint(10, 20),
"OEE_GoalbyPlant": random.uniform(78, 82),
"OEE_Seattle": random.uniform(95, 96),
"OEE_Detroit": random.uniform(95, 96),
"OEE_Hannover": random.uniform(95, 96),
"OEE_USA": random.uniform(95, 96),
"OEE_Mexico": random.uniform(95, 96),
"OEE_GoalbyProduct": random.uniform(78, 82),
"OEE_BatteryA": random.uniform(96, 97),
"OEE_BatteryB": random.uniform(94, 95),
"OEE_BatteryC": random.uniform(95, 96),
"OEE_GoalbyShift": random.uniform(78, 82),
"OEE_MorningShift": random.uniform(92, 94),
"OEE_DayShift": random.uniform(86, 88),
"OEE_NightShift": random.uniform(88, 90)
}