readd location_item attrs
This commit is contained in:
BIN
Binary file not shown.
@@ -1,6 +1,5 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import psutil
|
import psutil
|
||||||
import datetime
|
|
||||||
import math
|
import math
|
||||||
import random
|
import random
|
||||||
import traceback
|
import traceback
|
||||||
@@ -212,6 +211,16 @@ class SimulationService:
|
|||||||
if isinstance(data, dict)
|
if isinstance(data, dict)
|
||||||
else getattr(data, "address", None)
|
else getattr(data, "address", None)
|
||||||
)
|
)
|
||||||
|
item_type = (
|
||||||
|
data.get("type")
|
||||||
|
if isinstance(data, dict)
|
||||||
|
else getattr(data, "type", None)
|
||||||
|
)
|
||||||
|
instruction = (
|
||||||
|
data.get("instruction")
|
||||||
|
if isinstance(data, dict)
|
||||||
|
else getattr(data, "instruction", None)
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
delay = self.parse_delay_seconds(delay)
|
delay = self.parse_delay_seconds(delay)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
@@ -259,16 +268,24 @@ class SimulationService:
|
|||||||
"status": "queued",
|
"status": "queued",
|
||||||
"start": new_time.isoformat(),
|
"start": new_time.isoformat(),
|
||||||
"address": address,
|
"address": address,
|
||||||
|
"instruction": instruction,
|
||||||
|
"type": item_type,
|
||||||
}
|
}
|
||||||
resp = {
|
resp = {
|
||||||
"command_status": "OK",
|
"command_status": "OK",
|
||||||
"command_class": "simulation_control",
|
"command_class": "simulation_control",
|
||||||
"command": "add",
|
"command": "add",
|
||||||
"message": f"Location {loc_id} added to the queue",
|
"message": f"Location {loc_id} added to the queue",
|
||||||
"data": {
|
"data":
|
||||||
"simulation": self.get_simulation_status(),
|
{
|
||||||
"location_item": location_item,
|
"simulation":
|
||||||
},
|
{
|
||||||
|
"data":
|
||||||
|
{
|
||||||
|
loc_id: location_item,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.add_item(loc_id, location_item)
|
self.add_item(loc_id, location_item)
|
||||||
await self.enqueue_next_simulation_item()
|
await self.enqueue_next_simulation_item()
|
||||||
@@ -566,8 +583,8 @@ class SimulationService:
|
|||||||
|
|
||||||
def get_uptime(self) -> float:
|
def get_uptime(self) -> float:
|
||||||
boot_time_timestamp = psutil.boot_time()
|
boot_time_timestamp = psutil.boot_time()
|
||||||
boot_time = datetime.datetime.fromtimestamp(boot_time_timestamp)
|
boot_time = datetime.fromtimestamp(boot_time_timestamp)
|
||||||
uptime = datetime.datetime.now() - boot_time
|
uptime = datetime.now() - boot_time
|
||||||
return uptime
|
return uptime
|
||||||
|
|
||||||
def get_status(self) -> dict:
|
def get_status(self) -> dict:
|
||||||
|
|||||||
Reference in New Issue
Block a user