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

Method GetReal

src/pythonfmu/PySlaveInstance.cpp:389–410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

387 }
388
389 void GetReal(const fmi2ValueReference* vr, std::size_t nvr, fmi2Real* values) const override
390 {
391 py_safe_run([this, &vr, nvr, &values](PyGILState_STATE gilState) {
392 PyObject* vrs = PyList_New(nvr);
393 for (int i = 0; i < nvr; i++) {
394 PyList_SetItem(vrs, i, Py_BuildValue("i", vr[i]));
395 }
396
397 auto refs = PyObject_CallMethod(pInstance_, "get_real", "O", vrs);
398 Py_DECREF(vrs);
399 if (refs == nullptr) {
400 handle_py_exception("[getReal] PyObject_CallMethod", gilState);
401 }
402
403 for (int i = 0; i < nvr; i++) {
404 PyObject* value = PyList_GetItem(refs, i);
405 values[i] = PyFloat_AsDouble(value);
406 }
407 Py_DECREF(refs);
408 clearLogBuffer();
409 });
410 }
411
412 void GetInteger(const fmi2ValueReference* vr, std::size_t nvr, fmi2Integer* values) const override
413 {

Callers 1

fmi2GetRealFunction · 0.80

Calls 1

py_safe_runFunction · 0.85

Tested by

no test coverage detected