I am trying to interface with a dynamic simulation software (Vensim) with python. The software has a header file, vendll.h, that I'd like to be able to use.
I've been looking through the ctypes module for this but haven't found anything. I'd also like to avoid using cython but I'll see how this goes. Here's an example of the file provided with the software on how to utilize this file in matlab. You'll probably get the gist of what I want to be able to replicate in python more or less.
clear all
%*********************LOAD THE MODEL *************************
if not(libisloaded('VenDLL32'))
hfile = ['C:\Users\Public\Vensim\dll\vendll.h'];
loadlibrary('VenDLL32',hfile);
end
% Display Vensim DDL function calls and signatures
libfunctionsview VenDLL32
%% *********************EXECUTE SIMULATION *************************
% check calllib returns to verify initiation
str=['SPECIAL>LOADMODEL|RABFOX.vpm'];
calllib('VenDLL32','vensim_check_status')
calllib('VenDLL32','vensim_command',str)
str=['MENU>RUN|o'];
calllib('VenDLL32','vensim_command',str)
%% *********************RETRIEVE DATA *************************
% retrieve data from the post simulation execution
tnum = 201;
timepts = int32(tnum);
mytime = zeros(1,tnum);
mytimePtr1 = libpointer('singlePtr', mytime);
myrabpop = zeros(1,tnum);
myrabpopPtr1 = libpointer('singlePtr', myrabpop);
% vensim get data command
[int32_status, cstring_vdf, cstring_var1, cstring_var2, singlePtr_var1, ...
singlePtr_var2] = calllib('VenDLL32','vensim_get_data','CURRENT.vdf', ...
'Rabbit Population','time',myrabpopPtr1(1),mytimePtr1(1),timepts);
myrabpopPtr1(1).Value'
mytimePtr1(1).Value'
%% ******************** UNLOAD VENSIM DLL ********************
% unload the library
unloadlibrary VenDLL32
Seems straightforward in matlab so should be a piece of cake in python right?
How can I load the header file and access its contents via python?
There is also an equivalent static link library (.lib) file (I don't see any .dll) named vendll32.lib. Is there a way to utilize this file in a similar way if I'm not able to make use of the header file?