import pandas as pd import time as ptime from twin.networking.mqtt import MQTTClient TIME_FACTOR = 300 ivef = "results-de2/plan-anomaly.csv" ivef = pd.read_csv(ivef, usecols=["mmsi", "start", "ETA", "source", "target", "task"], dtype={"mmsi": str}) ivef.sort_values("start", inplace=True) initial_start = ivef.iloc[0]["start"] ivef["start"] -= initial_start ivef["ETA"] -= initial_start ivef["start"] /= 1000 ivef["ETA"] /= 1000 client = MQTTClient("ActualObject") client.spin() client.publish("initial_time", [initial_start / 1000, TIME_FACTOR]) time = 0 for ridx, row in ivef.iterrows(): if row["start"] == time: client.publish("tasks", row.to_list()) else: duration = row["start"] - time ptime.sleep(duration / TIME_FACTOR) client.publish("tasks", row.to_list()) time = row["start"]