@casys/mcp-fmi 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +112 -2
- package/THIRD_PARTY_NOTICES.txt +1096 -0
- package/mcp-fmi.mjs +57526 -0
- package/package.json +10 -4
- package/runtime/run_fmi2.py +388 -0
- package/ui-dist/fmu-checks/index.html +3688 -0
- package/ui-dist/fmu-time-series/index.html +3688 -0
- package/ui-dist/fmu-variables/index.html +3688 -0
- package/ui-dist/fmu-verdict/index.html +3688 -0
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@casys/mcp-fmi",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
}
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Casys MCP server: mcp-fmi (MCP tools + @mcpview Code Mode snippets)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": { "mcp-fmi": "mcp-fmi.mjs" },
|
|
7
|
+
"files": ["mcp-fmi.mjs","LICENSE","README.md","runtime/run_fmi2.py","ui-dist/fmu-checks/index.html","ui-dist/fmu-time-series/index.html","ui-dist/fmu-variables/index.html","ui-dist/fmu-verdict/index.html","THIRD_PARTY_NOTICES.txt"],
|
|
8
|
+
"engines": { "node": ">=20.0.0" },
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": { "type": "git", "url": "git+https://github.com/superWorldSavior/mcp-fmi.git" },
|
|
11
|
+
"keywords": ["mcp", "model-context-protocol", "casys", "mcpview"]
|
|
12
|
+
}
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Generic zero-dependency FMI 2.0 Co-Simulation runner (Python 3 stdlib only).
|
|
3
|
+
|
|
4
|
+
Supports constant `parameters` and `inputs`, piecewise-constant `inputSchedule`
|
|
5
|
+
(`[{"t": float, "inputs": {...}}]`), and selective `outputs` recording.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import ctypes
|
|
11
|
+
import json
|
|
12
|
+
import math
|
|
13
|
+
import pathlib
|
|
14
|
+
import sys
|
|
15
|
+
import tempfile
|
|
16
|
+
import xml.etree.ElementTree as ET
|
|
17
|
+
import zipfile
|
|
18
|
+
|
|
19
|
+
FMI2_COSIMULATION = 1
|
|
20
|
+
FMI2_OK = 0
|
|
21
|
+
FMI2_WARNING = 1
|
|
22
|
+
MAX_STEPS = 100_000
|
|
23
|
+
|
|
24
|
+
LOGGER_CB_TYPE = ctypes.CFUNCTYPE(
|
|
25
|
+
None,
|
|
26
|
+
ctypes.c_void_p,
|
|
27
|
+
ctypes.c_char_p,
|
|
28
|
+
ctypes.c_int32,
|
|
29
|
+
ctypes.c_char_p,
|
|
30
|
+
ctypes.c_char_p,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class Fmi2CallbackFunctions(ctypes.Structure):
|
|
35
|
+
_fields_ = [
|
|
36
|
+
("logger", ctypes.c_void_p),
|
|
37
|
+
("allocateMemory", ctypes.c_void_p),
|
|
38
|
+
("freeMemory", ctypes.c_void_p),
|
|
39
|
+
("stepFinished", ctypes.c_void_p),
|
|
40
|
+
("componentEnvironment", ctypes.c_void_p),
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _check_status(fn_name: str, status: int) -> None:
|
|
45
|
+
if status not in (FMI2_OK, FMI2_WARNING):
|
|
46
|
+
raise RuntimeError(f"FMI 2.0 call {fn_name} failed with status {status}")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _safe_extract_fmu(fmu_path: pathlib.Path, dest_dir: pathlib.Path) -> None:
|
|
50
|
+
root = dest_dir.resolve()
|
|
51
|
+
with zipfile.ZipFile(fmu_path, "r") as zf:
|
|
52
|
+
for info in zf.infolist():
|
|
53
|
+
target = (root / info.filename).resolve()
|
|
54
|
+
if target != root and root not in target.parents:
|
|
55
|
+
raise RuntimeError(f"Unsafe FMU archive entry: {info.filename}")
|
|
56
|
+
zf.extractall(root)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _find_binary(root: pathlib.Path, model_id: str) -> pathlib.Path:
|
|
60
|
+
if sys.platform == "darwin":
|
|
61
|
+
candidates = [
|
|
62
|
+
f"binaries/darwin64/{model_id}.dylib",
|
|
63
|
+
f"binaries/aarch64-darwin/{model_id}.dylib",
|
|
64
|
+
f"binaries/x86_64-darwin/{model_id}.dylib",
|
|
65
|
+
]
|
|
66
|
+
elif sys.platform.startswith("linux"):
|
|
67
|
+
candidates = [
|
|
68
|
+
f"binaries/linux64/{model_id}.so",
|
|
69
|
+
f"binaries/x86_64-linux/{model_id}.so",
|
|
70
|
+
f"binaries/aarch64-linux/{model_id}.so",
|
|
71
|
+
]
|
|
72
|
+
elif sys.platform == "win32":
|
|
73
|
+
candidates = [f"binaries/win64/{model_id}.dll"]
|
|
74
|
+
else:
|
|
75
|
+
raise RuntimeError(f"Unsupported platform for FMI 2.0 binary: {sys.platform}")
|
|
76
|
+
|
|
77
|
+
for rel in candidates:
|
|
78
|
+
path = root / rel
|
|
79
|
+
if path.is_file():
|
|
80
|
+
return path
|
|
81
|
+
found = [
|
|
82
|
+
str(p.relative_to(root))
|
|
83
|
+
for p in (root / "binaries").rglob("*")
|
|
84
|
+
if p.is_file()
|
|
85
|
+
] if (root / "binaries").is_dir() else []
|
|
86
|
+
raise FileNotFoundError(
|
|
87
|
+
f"No FMI 2.0 binary found for {model_id} on {sys.platform}. "
|
|
88
|
+
f"Tried {candidates}; archive contains {found}"
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _parse_model_description(xml_path: pathlib.Path) -> dict:
|
|
93
|
+
tree = ET.parse(xml_path)
|
|
94
|
+
root = tree.getroot()
|
|
95
|
+
fmi_version = root.attrib.get("fmiVersion", "")
|
|
96
|
+
if fmi_version != "2.0":
|
|
97
|
+
raise RuntimeError(f"Unsupported fmiVersion={fmi_version!r}; expected '2.0'")
|
|
98
|
+
model_name = root.attrib.get("modelName", "")
|
|
99
|
+
guid = root.attrib.get("guid", "")
|
|
100
|
+
cs = root.find("CoSimulation")
|
|
101
|
+
if cs is None or not cs.attrib.get("modelIdentifier"):
|
|
102
|
+
raise RuntimeError("FMU modelDescription.xml lacks <CoSimulation modelIdentifier=.../>")
|
|
103
|
+
model_id = cs.attrib["modelIdentifier"]
|
|
104
|
+
|
|
105
|
+
default_exp = root.find("DefaultExperiment")
|
|
106
|
+
defaults = {
|
|
107
|
+
"startTime": float(default_exp.attrib.get("startTime", "0.0")) if default_exp is not None else 0.0,
|
|
108
|
+
"stopTime": float(default_exp.attrib.get("stopTime", "60.0")) if default_exp is not None else 60.0,
|
|
109
|
+
"stepSize": float(default_exp.attrib.get("stepSize", "3.0")) if default_exp is not None else 3.0,
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
real_vrs: dict[str, int] = {}
|
|
113
|
+
output_reals: list[tuple[str, int]] = []
|
|
114
|
+
mv = root.find("ModelVariables")
|
|
115
|
+
if mv is not None:
|
|
116
|
+
for sv in mv.findall("ScalarVariable"):
|
|
117
|
+
name = sv.attrib.get("name")
|
|
118
|
+
vr_raw = sv.attrib.get("valueReference")
|
|
119
|
+
if not name or vr_raw is None:
|
|
120
|
+
continue
|
|
121
|
+
if sv.find("Real") is not None:
|
|
122
|
+
vr = int(vr_raw)
|
|
123
|
+
real_vrs[name] = vr
|
|
124
|
+
if sv.attrib.get("causality") == "output":
|
|
125
|
+
output_reals.append((name, vr))
|
|
126
|
+
|
|
127
|
+
if not output_reals:
|
|
128
|
+
output_reals = list(real_vrs.items())
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
"fmiVersion": fmi_version,
|
|
132
|
+
"modelName": model_name,
|
|
133
|
+
"guid": guid,
|
|
134
|
+
"modelIdentifier": model_id,
|
|
135
|
+
"defaults": defaults,
|
|
136
|
+
"realVrs": real_vrs,
|
|
137
|
+
"outputReals": output_reals,
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def _bind_fmi2(lib: ctypes.CDLL) -> None:
|
|
142
|
+
lib.fmi2Instantiate.argtypes = [
|
|
143
|
+
ctypes.c_char_p,
|
|
144
|
+
ctypes.c_int32,
|
|
145
|
+
ctypes.c_char_p,
|
|
146
|
+
ctypes.c_char_p,
|
|
147
|
+
ctypes.POINTER(Fmi2CallbackFunctions),
|
|
148
|
+
ctypes.c_int32,
|
|
149
|
+
ctypes.c_int32,
|
|
150
|
+
]
|
|
151
|
+
lib.fmi2Instantiate.restype = ctypes.c_void_p
|
|
152
|
+
|
|
153
|
+
lib.fmi2FreeInstance.argtypes = [ctypes.c_void_p]
|
|
154
|
+
lib.fmi2FreeInstance.restype = None
|
|
155
|
+
|
|
156
|
+
lib.fmi2SetupExperiment.argtypes = [
|
|
157
|
+
ctypes.c_void_p,
|
|
158
|
+
ctypes.c_int32,
|
|
159
|
+
ctypes.c_double,
|
|
160
|
+
ctypes.c_double,
|
|
161
|
+
ctypes.c_int32,
|
|
162
|
+
ctypes.c_double,
|
|
163
|
+
]
|
|
164
|
+
lib.fmi2SetupExperiment.restype = ctypes.c_int32
|
|
165
|
+
|
|
166
|
+
lib.fmi2EnterInitializationMode.argtypes = [ctypes.c_void_p]
|
|
167
|
+
lib.fmi2EnterInitializationMode.restype = ctypes.c_int32
|
|
168
|
+
|
|
169
|
+
lib.fmi2ExitInitializationMode.argtypes = [ctypes.c_void_p]
|
|
170
|
+
lib.fmi2ExitInitializationMode.restype = ctypes.c_int32
|
|
171
|
+
|
|
172
|
+
lib.fmi2SetReal.argtypes = [
|
|
173
|
+
ctypes.c_void_p,
|
|
174
|
+
ctypes.POINTER(ctypes.c_uint32),
|
|
175
|
+
ctypes.c_size_t,
|
|
176
|
+
ctypes.POINTER(ctypes.c_double),
|
|
177
|
+
]
|
|
178
|
+
lib.fmi2SetReal.restype = ctypes.c_int32
|
|
179
|
+
|
|
180
|
+
lib.fmi2GetReal.argtypes = [
|
|
181
|
+
ctypes.c_void_p,
|
|
182
|
+
ctypes.POINTER(ctypes.c_uint32),
|
|
183
|
+
ctypes.c_size_t,
|
|
184
|
+
ctypes.POINTER(ctypes.c_double),
|
|
185
|
+
]
|
|
186
|
+
lib.fmi2GetReal.restype = ctypes.c_int32
|
|
187
|
+
|
|
188
|
+
lib.fmi2DoStep.argtypes = [
|
|
189
|
+
ctypes.c_void_p,
|
|
190
|
+
ctypes.c_double,
|
|
191
|
+
ctypes.c_double,
|
|
192
|
+
ctypes.c_int32,
|
|
193
|
+
]
|
|
194
|
+
lib.fmi2DoStep.restype = ctypes.c_int32
|
|
195
|
+
|
|
196
|
+
lib.fmi2Terminate.argtypes = [ctypes.c_void_p]
|
|
197
|
+
lib.fmi2Terminate.restype = ctypes.c_int32
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def _set_reals(lib: ctypes.CDLL, comp: ctypes.c_void_p, real_vrs: dict[str, int], values: dict[str, float]) -> None:
|
|
201
|
+
if not values:
|
|
202
|
+
return
|
|
203
|
+
vrs = []
|
|
204
|
+
vals = []
|
|
205
|
+
for name, raw_val in values.items():
|
|
206
|
+
if name not in real_vrs:
|
|
207
|
+
raise ValueError(f"Unknown Real FMI variable: {name!r}")
|
|
208
|
+
val = float(raw_val)
|
|
209
|
+
if not math.isfinite(val):
|
|
210
|
+
raise ValueError(f"Non-finite value for FMI variable {name!r}")
|
|
211
|
+
vrs.append(real_vrs[name])
|
|
212
|
+
vals.append(val)
|
|
213
|
+
vr_arr = (ctypes.c_uint32 * len(vrs))(*vrs)
|
|
214
|
+
val_arr = (ctypes.c_double * len(vals))(*vals)
|
|
215
|
+
_check_status("fmi2SetReal", lib.fmi2SetReal(comp, vr_arr, len(vrs), val_arr))
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def _normalize_schedule(raw_schedule: object) -> list[tuple[float, dict[str, float]]]:
|
|
219
|
+
if not raw_schedule:
|
|
220
|
+
return []
|
|
221
|
+
if not isinstance(raw_schedule, list):
|
|
222
|
+
raise ValueError("inputSchedule must be an array of { t, inputs } entries")
|
|
223
|
+
entries: list[tuple[float, dict[str, float]]] = []
|
|
224
|
+
for item in raw_schedule:
|
|
225
|
+
if not isinstance(item, dict) or "t" not in item or not isinstance(item.get("inputs"), dict):
|
|
226
|
+
raise ValueError("Each inputSchedule entry must have numeric 't' and object 'inputs'")
|
|
227
|
+
t_val = float(item["t"])
|
|
228
|
+
if not math.isfinite(t_val):
|
|
229
|
+
raise ValueError("inputSchedule entry 't' must be finite")
|
|
230
|
+
entries.append((t_val, {str(k): float(v) for k, v in item["inputs"].items()}))
|
|
231
|
+
entries.sort(key=lambda pair: pair[0])
|
|
232
|
+
return entries
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def run_fmu(req: dict) -> dict:
|
|
236
|
+
fmu_path = pathlib.Path(req["fmuPath"]).resolve()
|
|
237
|
+
if not fmu_path.is_file():
|
|
238
|
+
raise FileNotFoundError(f"FMU archive not found: {fmu_path}")
|
|
239
|
+
|
|
240
|
+
parameters = req.get("parameters") or {}
|
|
241
|
+
inputs = req.get("inputs") or {}
|
|
242
|
+
schedule = _normalize_schedule(req.get("inputSchedule"))
|
|
243
|
+
requested_outputs = req.get("outputs")
|
|
244
|
+
|
|
245
|
+
with tempfile.TemporaryDirectory(prefix="casys-fmi2-") as tmp:
|
|
246
|
+
root = pathlib.Path(tmp)
|
|
247
|
+
_safe_extract_fmu(fmu_path, root)
|
|
248
|
+
md = _parse_model_description(root / "modelDescription.xml")
|
|
249
|
+
lib_path = _find_binary(root, md["modelIdentifier"])
|
|
250
|
+
|
|
251
|
+
start_time = float(req.get("startTime", md["defaults"]["startTime"]))
|
|
252
|
+
stop_time = float(req.get("stopTime", md["defaults"]["stopTime"]))
|
|
253
|
+
step_size = float(req.get("stepSize", md["defaults"]["stepSize"]))
|
|
254
|
+
if not (math.isfinite(start_time) and math.isfinite(stop_time) and math.isfinite(step_size)):
|
|
255
|
+
raise ValueError("startTime, stopTime, and stepSize must be finite numbers")
|
|
256
|
+
if step_size <= 0.0 or stop_time < start_time:
|
|
257
|
+
raise ValueError("Require stepSize > 0 and stopTime >= startTime")
|
|
258
|
+
if (stop_time - start_time) / step_size > MAX_STEPS:
|
|
259
|
+
raise ValueError(f"Simulation exceeds maximum allowed steps ({MAX_STEPS})")
|
|
260
|
+
|
|
261
|
+
if requested_outputs is not None:
|
|
262
|
+
if not isinstance(requested_outputs, list) or len(requested_outputs) == 0:
|
|
263
|
+
raise ValueError("outputs must be a non-empty array of variable names when provided")
|
|
264
|
+
recorded_reals: list[tuple[str, int]] = []
|
|
265
|
+
for name in requested_outputs:
|
|
266
|
+
if name not in md["realVrs"]:
|
|
267
|
+
raise ValueError(f"Unknown Real FMI output variable: {name!r}")
|
|
268
|
+
recorded_reals.append((str(name), md["realVrs"][str(name)]))
|
|
269
|
+
else:
|
|
270
|
+
recorded_reals = md["outputReals"]
|
|
271
|
+
|
|
272
|
+
lib = ctypes.CDLL(str(lib_path))
|
|
273
|
+
_bind_fmi2(lib)
|
|
274
|
+
|
|
275
|
+
@LOGGER_CB_TYPE
|
|
276
|
+
def _noop_logger(_env, _name, _status, _cat, _msg):
|
|
277
|
+
return None
|
|
278
|
+
|
|
279
|
+
libc = ctypes.CDLL(None)
|
|
280
|
+
callbacks = Fmi2CallbackFunctions(
|
|
281
|
+
logger=ctypes.cast(_noop_logger, ctypes.c_void_p),
|
|
282
|
+
allocateMemory=ctypes.cast(libc.calloc, ctypes.c_void_p),
|
|
283
|
+
freeMemory=ctypes.cast(libc.free, ctypes.c_void_p),
|
|
284
|
+
stepFinished=None,
|
|
285
|
+
componentEnvironment=None,
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
resources_uri = (root / "resources").as_uri().encode("utf-8")
|
|
289
|
+
comp = lib.fmi2Instantiate(
|
|
290
|
+
md["modelIdentifier"].encode("utf-8"),
|
|
291
|
+
FMI2_COSIMULATION,
|
|
292
|
+
md["guid"].encode("utf-8"),
|
|
293
|
+
resources_uri,
|
|
294
|
+
ctypes.byref(callbacks),
|
|
295
|
+
0,
|
|
296
|
+
0,
|
|
297
|
+
)
|
|
298
|
+
if not comp:
|
|
299
|
+
raise RuntimeError(f"fmi2Instantiate returned NULL for {md['modelIdentifier']}")
|
|
300
|
+
|
|
301
|
+
terminated = False
|
|
302
|
+
try:
|
|
303
|
+
_check_status(
|
|
304
|
+
"fmi2SetupExperiment",
|
|
305
|
+
lib.fmi2SetupExperiment(comp, 0, 0.0, start_time, 1, stop_time),
|
|
306
|
+
)
|
|
307
|
+
_check_status("fmi2EnterInitializationMode", lib.fmi2EnterInitializationMode(comp))
|
|
308
|
+
|
|
309
|
+
# Apply parameters, constant inputs, and any schedule entry active at or before start_time.
|
|
310
|
+
init_values: dict[str, float] = {**parameters, **inputs}
|
|
311
|
+
sched_idx = 0
|
|
312
|
+
while sched_idx < len(schedule) and schedule[sched_idx][0] <= start_time + 1e-12:
|
|
313
|
+
init_values.update(schedule[sched_idx][1])
|
|
314
|
+
sched_idx += 1
|
|
315
|
+
_set_reals(lib, comp, md["realVrs"], init_values)
|
|
316
|
+
|
|
317
|
+
_check_status("fmi2ExitInitializationMode", lib.fmi2ExitInitializationMode(comp))
|
|
318
|
+
|
|
319
|
+
out_names = [name for name, _ in recorded_reals]
|
|
320
|
+
out_vrs = (ctypes.c_uint32 * len(recorded_reals))(
|
|
321
|
+
*[vr for _, vr in recorded_reals]
|
|
322
|
+
)
|
|
323
|
+
out_buf = (ctypes.c_double * len(recorded_reals))()
|
|
324
|
+
|
|
325
|
+
def sample() -> dict[str, float]:
|
|
326
|
+
_check_status(
|
|
327
|
+
"fmi2GetReal",
|
|
328
|
+
lib.fmi2GetReal(comp, out_vrs, len(out_names), out_buf),
|
|
329
|
+
)
|
|
330
|
+
return {name: float(out_buf[idx]) for idx, name in enumerate(out_names)}
|
|
331
|
+
|
|
332
|
+
t = start_time
|
|
333
|
+
series = [{"t": round(t, 9), "values": sample()}]
|
|
334
|
+
step_count = 0
|
|
335
|
+
while t + 1e-12 < stop_time:
|
|
336
|
+
pending_inputs: dict[str, float] = {}
|
|
337
|
+
while sched_idx < len(schedule) and schedule[sched_idx][0] <= t + 1e-12:
|
|
338
|
+
pending_inputs.update(schedule[sched_idx][1])
|
|
339
|
+
sched_idx += 1
|
|
340
|
+
if pending_inputs:
|
|
341
|
+
_set_reals(lib, comp, md["realVrs"], pending_inputs)
|
|
342
|
+
|
|
343
|
+
dt = min(step_size, stop_time - t)
|
|
344
|
+
_check_status("fmi2DoStep", lib.fmi2DoStep(comp, t, dt, 1))
|
|
345
|
+
t += dt
|
|
346
|
+
step_count += 1
|
|
347
|
+
series.append({"t": round(t, 9), "values": sample()})
|
|
348
|
+
|
|
349
|
+
_check_status("fmi2Terminate", lib.fmi2Terminate(comp))
|
|
350
|
+
terminated = True
|
|
351
|
+
return {
|
|
352
|
+
"fmiVersion": md["fmiVersion"],
|
|
353
|
+
"modelName": md["modelName"],
|
|
354
|
+
"modelIdentifier": md["modelIdentifier"],
|
|
355
|
+
"stepCount": step_count,
|
|
356
|
+
"startTime": start_time,
|
|
357
|
+
"stopTime": stop_time,
|
|
358
|
+
"stepSize": step_size,
|
|
359
|
+
"series": series,
|
|
360
|
+
"finalValues": series[-1]["values"],
|
|
361
|
+
}
|
|
362
|
+
finally:
|
|
363
|
+
if not terminated:
|
|
364
|
+
try:
|
|
365
|
+
lib.fmi2Terminate(comp)
|
|
366
|
+
except Exception:
|
|
367
|
+
pass
|
|
368
|
+
lib.fmi2FreeInstance(comp)
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
def main() -> int:
|
|
372
|
+
raw = sys.stdin.read()
|
|
373
|
+
if not raw.strip():
|
|
374
|
+
print("Expected JSON request on stdin.", file=sys.stderr)
|
|
375
|
+
return 2
|
|
376
|
+
try:
|
|
377
|
+
req = json.loads(raw)
|
|
378
|
+
result = run_fmu(req)
|
|
379
|
+
except Exception as exc:
|
|
380
|
+
print(f"FMI 2.0 runner error: {exc}", file=sys.stderr)
|
|
381
|
+
return 1
|
|
382
|
+
json.dump(result, sys.stdout)
|
|
383
|
+
sys.stdout.write("\n")
|
|
384
|
+
return 0
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
if __name__ == "__main__":
|
|
388
|
+
raise SystemExit(main())
|