gridresilience-studio-offli.../adapters/simulator_adapter.py

29 lines
864 B
Python

"""Starter microgrid simulator adapter scaffold for GridResilience Studio."""
from __future__ import annotations
from typing import Any, Dict
class SimulatorAdapter:
def __init__(self, name: str = "sim-bridge") -> None:
self.name = name
self.running = False
def start(self) -> bool:
self.running = True
return True
def stop(self) -> None:
self.running = False
def get_signals(self) -> Dict[str, Any]:
if not self.running:
return {}
# Return a tiny synthetic signal set for demonstration
return {"sim_voltage": 230.0, "sim_freq": 50.0}
def apply_command(self, obj_id: str, command: Dict[str, Any]) -> Dict[str, Any]:
if not self.running:
return {"status": "stopped"}
return {"status": "applied", "object": obj_id, "command": command}