Launching of simulation application
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
from bedit_core.models import Component
|
||||
|
||||
from .openmodelica import OpenModelicaRunner
|
||||
from .simulation import ModelBuildResult, Simulation
|
||||
|
||||
|
||||
async def compile_component(component: Component, working_directory: str | Path, *, omc_command: str = "omc", timeout: float | None = None) -> ModelBuildResult:
|
||||
"""Compose and compile a component without creating a GUI application."""
|
||||
simulation = Simulation(OpenModelicaRunner(omc_command, timeout=timeout))
|
||||
await simulation.load(component)
|
||||
return await simulation.compile(working_directory)
|
||||
|
||||
|
||||
def compile_component_sync(component: Component, working_directory: str | Path, *, omc_command: str = "omc", timeout: float | None = None) -> ModelBuildResult:
|
||||
"""Synchronous entry point for scripts and non-async suite applications."""
|
||||
return asyncio.run(compile_component(component, working_directory, omc_command=omc_command, timeout=timeout))
|
||||
Reference in New Issue
Block a user