|
|
@@ -4,6 +4,7 @@ from pathlib import Path
|
|
|
from typing import Any
|
|
|
import arklog
|
|
|
import magic
|
|
|
+import requests
|
|
|
from fastapi import APIRouter, Query, Request, Response
|
|
|
from fastapi.responses import JSONResponse
|
|
|
from OMPython import OMCSessionZMQ, ModelicaSystem
|
|
|
@@ -23,7 +24,8 @@ def single_simulation_om_python(model_file_path, test_frequency, test_amplitude,
|
|
|
sampling_frequency = test_frequency * sampling_ratio
|
|
|
omc = OMCSessionZMQ()
|
|
|
model = ModelicaSystem(str(model_file_path),model_file_path.stem)
|
|
|
- model.buildModel("(V_in.v)|(V_out.v)")
|
|
|
+ # model.buildModel("(V_in.v)|(V_out.v)")
|
|
|
+ model.buildModel()
|
|
|
model.setSimulationOptions([
|
|
|
f"stepSize={1/sampling_frequency}",
|
|
|
f"tolerance={tolerance}",
|
|
|
@@ -109,9 +111,9 @@ class NotchRouter(APIRouter):
|
|
|
arklog.debug(f"{output_stabilisation_time=}")
|
|
|
arklog.debug(f"{output=}")
|
|
|
artefact_file_path = single_simulation_om_python(model_file_path, frequency, amplitude, sampling_ratio, tolerance,data_cycles,output_stabilisation_time, output)
|
|
|
- data = base64.b64encode(artefact_file_path.read_bytes()).decode()
|
|
|
+ requests.put(f"http://localhost:5000/files/file/{artefact_file_path.name}", data=artefact_file_path.read_bytes())
|
|
|
mime = magic.Magic(mime=True).from_file(artefact_file_path)
|
|
|
- simulation_artefact = Artefact("inline", data, artefact_file_path.name, mime)
|
|
|
+ simulation_artefact = Artefact("reference", f"http://localhost:5000/files/file/{artefact_file_path.name}", artefact_file_path.name, mime)
|
|
|
return JSONResponse(status_code=200, content={"ctrl": "ok", "output": {"experiment": simulation_artefact.as_dict()}})
|
|
|
|
|
|
@self.put("/simulation/")
|