MCPcopy Create free account
hub / github.com/NTNU-IHB/PythonFMU / SetString

Method SetString

src/pythonfmu/PySlaveInstance.cpp:368–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

366 }
367
368 void SetString(const fmi2ValueReference* vr, std::size_t nvr, fmi2String const* values) override
369 {
370 py_safe_run([this, &vr, nvr, &values](PyGILState_STATE gilState) {
371 PyObject* vrs = PyList_New(nvr);
372 PyObject* refs = PyList_New(nvr);
373 for (int i = 0; i < nvr; i++) {
374 PyList_SetItem(vrs, i, Py_BuildValue("i", vr[i]));
375 PyList_SetItem(refs, i, Py_BuildValue("s", values[i]));
376 }
377
378 auto f = PyObject_CallMethod(pInstance_, "set_string", "(OO)", vrs, refs);
379 Py_DECREF(vrs);
380 Py_DECREF(refs);
381 if (f == nullptr) {
382 handle_py_exception("[setString] PyObject_CallMethod", gilState);
383 }
384 Py_DECREF(f);
385 clearLogBuffer();
386 });
387 }
388
389 void GetReal(const fmi2ValueReference* vr, std::size_t nvr, fmi2Real* values) const override
390 {

Callers 1

fmi2SetStringFunction · 0.80

Calls 1

py_safe_runFunction · 0.85

Tested by

no test coverage detected