Spaces:
Configuration error
Configuration error
File size: 1,121 Bytes
f7a6add | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | from __future__ import annotations
from datetime import datetime
from typing import Any
from .project import ProjectService
from .utils import safe_count, safe_text
class SimulationService:
def __init__(self, pcpy: Any, project: ProjectService):
self._pcpy = pcpy
self._project = project
def run(self) -> dict[str, Any]:
self._project.require_open()
started = datetime.now()
self._pcpy.SWMM.run()
finished = datetime.now()
try:
graph_file_count = safe_count(self._pcpy.Graph.Files)
except Exception:
graph_file_count = 0
return {
"status": "completed",
"started_at": started.isoformat(timespec="seconds"),
"finished_at": finished.isoformat(timespec="seconds"),
"elapsed_seconds": round((finished - started).total_seconds(), 3),
"run_status": safe_text(self._pcpy.SWMM.RunStatus),
"graph_file_count": graph_file_count,
}
def refresh_output(self):
self._project.require_open()
self._pcpy.SWMM.refresh_output()
|