Add simulation server entry point
Create SimulationServer that wires physics engine to all virtual instruments and exposes them over TCP. Add 'serve' CLI command to start the server with configurable ports and physics rate.
This commit is contained in:
@@ -36,5 +36,52 @@ def main(
|
||||
"""py-dvt-ate: Coupled Physics DVT Simulation Platform."""
|
||||
|
||||
|
||||
@app.command()
|
||||
def serve(
|
||||
host: Annotated[
|
||||
str,
|
||||
typer.Option("--host", "-h", help="Host address to bind to."),
|
||||
] = "127.0.0.1",
|
||||
chamber_port: Annotated[
|
||||
int,
|
||||
typer.Option("--chamber-port", help="Port for thermal chamber instrument."),
|
||||
] = 5000,
|
||||
psu_port: Annotated[
|
||||
int,
|
||||
typer.Option("--psu-port", help="Port for power supply instrument."),
|
||||
] = 5001,
|
||||
dmm_port: Annotated[
|
||||
int,
|
||||
typer.Option("--dmm-port", help="Port for multimeter instrument."),
|
||||
] = 5002,
|
||||
physics_rate: Annotated[
|
||||
float,
|
||||
typer.Option("--physics-rate", help="Physics engine update rate in Hz."),
|
||||
] = 100.0,
|
||||
) -> None:
|
||||
"""Start the simulation server with virtual instruments.
|
||||
|
||||
Runs a TCP server hosting virtual SCPI instruments connected to a
|
||||
shared physics engine. Each instrument listens on its own port.
|
||||
"""
|
||||
from py_dvt_ate.simulation.server import main as run_server
|
||||
|
||||
typer.echo(f"Starting simulation server on {host}...")
|
||||
typer.echo(f" Thermal chamber: port {chamber_port}")
|
||||
typer.echo(f" Power supply: port {psu_port}")
|
||||
typer.echo(f" Multimeter: port {dmm_port}")
|
||||
typer.echo(f" Physics rate: {physics_rate} Hz")
|
||||
typer.echo("")
|
||||
typer.echo("Press Ctrl+C to stop.")
|
||||
|
||||
run_server(
|
||||
host=host,
|
||||
chamber_port=chamber_port,
|
||||
psu_port=psu_port,
|
||||
dmm_port=dmm_port,
|
||||
physics_rate=physics_rate,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app()
|
||||
|
||||
Reference in New Issue
Block a user