Skip to content

Commit

Permalink
Temp
Browse files Browse the repository at this point in the history
  • Loading branch information
pgleeson committed Jan 21, 2025
1 parent 1d68e05 commit a583feb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sibernetic_c302.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def run(a=None,**kwargs):

env = { "DISPLAY": os.environ.get('DISPLAY') if os.environ.get('DISPLAY') is not None else '',
"XAUTHORITY": os.environ.get('XAUTHORITY') if os.environ.get('XAUTHORITY') is not None else '',
"PYTHONPATH": ".:%s" % (os.path.abspath(sim_dir))}
"PYTHONPATH": ".:%s:%s" % (os.environ.get('PYTHONPATH', '.'), os.path.abspath(sim_dir))}

sim_start = time.time()

Expand Down
13 changes: 12 additions & 1 deletion src/owSignalSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,41 @@ SignalSimulator::SignalSimulator(const std::string &simFileName,
const char *s2 = Py_GetPath();
#endif

printf("[debug] PyPath = \"%s\"\n", s2);
printf("[debug] The PythonPath = \"%s\"\n", s2);

// Import the file as a Python module.
pModule = PyImport_Import(pName);
std::cout << "1111" << std::endl;
if (PyErr_Occurred())
PyErr_Print();

std::cout << "222" << std::endl;
// Build the name of a callable class
if (pModule != nullptr) {
std::cout << "333" << std::endl;
pClass = PyObject_GetAttrString(pModule, simClassName.c_str());
if (PyErr_Occurred())
PyErr_Print();
} else {

std::cout << "444" << std::endl;
throw std::runtime_error("Python module not loaded, have you set "
"PYTHONPATH?\nTry: \n\n export "
"PYTHONPATH=$PYTHONPATH:./src\n");
}
std::cout << "555" << std::endl;
// Create an instance of the class
if (PyCallable_Check(pClass)) {
std::cout << "666" << std::endl;
pInstance = PyObject_CallObject(pClass, nullptr);
if (PyErr_Occurred())
PyErr_Print();
PyObject *dt = Py_BuildValue("f", timeStep); // Create tuple of arguments for initialization
PyObject *pFuncName = Py_BuildValue("s", "set_timestep");
//pInstance = PyObject_CallMethod(pInstance, "set_timestep", "(f)", timeStep);
PyObject_CallMethodObjArgs(pInstance, pFuncName, dt, nullptr);

std::cout << "777" << std::endl;
if (PyErr_Occurred())
PyErr_Print();
Py_DECREF(dt);
Expand All @@ -113,6 +122,8 @@ SignalSimulator::SignalSimulator(const std::string &simFileName,
"callable! Try: export "
"PYTHONPATH=$PYTHONPATH:./src");
}

std::cout << "999" << std::endl;
}

std::vector<float> SignalSimulator::run() {
Expand Down

0 comments on commit a583feb

Please sign in to comment.