Call vensim

Use this forum to post Vensim related questions.
arraywanted
Member
Posts: 36
Joined: Fri Aug 20, 2010 11:03 am

Post by arraywanted »

I am back with a new problem.

As you remeber, I managed to control Vensim via Matlab on a WinXP computer. Meanwhile, my intership came to an end, so I didn't work with Vensim for some time.

Now I tried again to call Vensim from Matlab on the same computer - and it does not work anymore. I simply cannot load any model, the LOADMODEL command just returns 0 without an window opening up or something like that.

It's quite similar to the situation on my Win7 computer (I explained before), only it did work on this one last time. I can't be completely sure that there hasn't been any modifiying on this computer; but what could anyone have done to cause this problem?

I tried reinstalling Vensim, but that does not help.

It is possible to load the DLL, I also can use the command 'vensim_check_status' (which returns 0), but I cannot load models - which means I can't work.

By the way, I searched for the vendll.err, but didn't find it. Where is it supposed to be on a WinXP computer?

Do you have any ideas? I virtually have no clue why this suddenly wouldn't work anymore.
arraywanted
Member
Posts: 36
Joined: Fri Aug 20, 2010 11:03 am

Post by arraywanted »

There is a file named 'vensimdll.err'. Is that the same as vendll.err?
This file contains the following:

Vensim® DLL(Full) version 5.9e error log starting Wed Nov 17 12:27:15 2010
ERROR: Class °‡ without command.
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

Has Matlab been upgraded on the computer you are working on?
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

It looks like the strings being passed to the DLL are no longer valid. The DLL is getting "°‡ " instead of "SPECIAL>LOADMODEL..." Make sure that the string being passed is a null terminated single byte string with UTF8 encoding (or simply ASCII).
arraywanted
Member
Posts: 36
Joined: Fri Aug 20, 2010 11:03 am

Post by arraywanted »

No, Matlab has not been upgraded.

I can't imagine why the strings being passed would not be valid any more, since I did not change the subroutine I use to load models in any way. But I'll take a look at that, thank you.

I'd still appreciate other ideas, though... this is really important.
arraywanted
Member
Posts: 36
Joined: Fri Aug 20, 2010 11:03 am

Post by arraywanted »

Thank you very much, Bob - your hint pointed in the right direction:

It made me check the function signatures of the library again, and - I have no idea why, maybe someone updated Vensim - they have changed. Previously, the function vensim_command e.g. needed the matlab type VoidPtr as input argument, and now it needs an simple string instead. After I changed all subroutines that used a VoidPtr it works again.

And the best thing is: After I found that out I suspected that this could be the problem with my Win7 computer as well - and I was right. It does now work there, too.

Funny story, though: Vensim was installed on both computers on the very same day - yet still the function signatures differed (well, until now - they're the same now). I cannot really make sense of that.
olive
Member
Posts: 22
Joined: Tue Sep 13, 2011 8:30 pm

Re: Call vensim

Post by olive »

Hi,
I have just seen your last post about loading a Vensim model into Matlab. I'm currently trying to achieve the same thing and noted your comment about the change in input arguments. I'm new to Vensim and have no experience using Matlab to interact with other applications. However, for my current project I need to be able to pass input values and run Vensim from Matlab, do some optimization based on the outputs (in Matlab) and run Vensim again with a different set of input values.

I think I was able to successfully load the Vensim dll but I have questions regarding loading a model. Here is the code I used:

Code: Select all

clear all

if not(libisloaded('VenDLL32'))
    hfile = ['C:\Documents and Settings\All Users\Vensim\dll\vendll.h'];
    dllfile = ['C:\Documents and Settings\All Users\Vensim\dll\vendll32.dll'];
    loadlibrary(dllfile,hfile);
end
libfunctionsview VenDLL32

str=['SPECIAL>LOADMODEL|C:\Documents and Settings\opinon\My Documents\MatlabResearch\rabfox.vpm'];
calllib('VenDLL32','vensim_command',str);

When i run it I get ans = 1. Does this mean that the model has been successfully loaded? I'm wondering because i was expecting Vensim to open or something.
If this is not what I should get, could you please tell me where my mistake is?
Thank you very much for your time and consideration.
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Call vensim

Post by Administrator »

When i run it I get ans = 1. Does this mean that the model has been successfully loaded?
Yes. A 1 indicates success.
I'm wondering because i was expecting Vensim to open or something.
You might just see the Vensim splash screen flash as the DLL loads, but you will not see Vensim itself.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
olive
Member
Posts: 22
Joined: Tue Sep 13, 2011 8:30 pm

Re: Call vensim

Post by olive »

Great! Thank you very much!
Kind regards,
Olivia
Yoller
Junior Member
Posts: 4
Joined: Sun Dec 18, 2011 12:42 pm

Re: Call vensim

Post by Yoller »

Hi,

I am trying to call Vensim from Matlab as well. However, I keep just getting 0 when using the loadmodel function (after having loaded the vensimdll32 library).

The .err file simply says 'Reinstall Vensim' and nothing else.

I reinstalled it but still it doesn't work.

Any suggestion?

Thank you all so much,

Stefano
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Call vensim

Post by Administrator »

Can you post the code that you are using?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Call vensim

Post by tomfid »

The "Reinstall Vensim" message can happen if the .dll can't find its language resource files, which can happen if you have path issues or have copied the .dll to a nonstandard location. Usually this is resolved by reinstalling Vensim. What Vensim version, operating system, and paths are you using?

Tom
Yoller
Junior Member
Posts: 4
Joined: Sun Dec 18, 2011 12:42 pm

Re: Call vensim

Post by Yoller »

tomfid wrote:The "Reinstall Vensim" message can happen if the .dll can't find its language resource files, which can happen if you have path issues or have copied the .dll to a nonstandard location. Usually this is resolved by reinstalling Vensim. What Vensim version, operating system, and paths are you using?

Tom
Thank you Tom!

I am using Vensim 5.9e, Windows 7 and Matlab R2011b(32bit). Should I put the .dll file in a specific folder?
Yoller
Junior Member
Posts: 4
Joined: Sun Dec 18, 2011 12:42 pm

Re: Call vensim

Post by Yoller »

Administrator wrote:Can you post the code that you are using?
I am using a combination of the successfull Matlab functions that some users posted here. basically what olive posted a few months ago.
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Call vensim

Post by Administrator »

Yoller wrote:I am using Vensim 5.9e, Windows 7 and Matlab R2011b(32bit). Should I put the .dll file in a specific folder?
No. Leave it where it is by default or it will not load properly.
Yoller wrote:I am using a combination of the successfull Matlab functions that some users posted here. basically what olive posted a few months ago.
There is little we can suggest unless you can post the calls you are making. There may be something very obvious that is causing it to not work.

And have you got the Vensim DLL demos working? We discussed this via email but still don't know if you have successfully got one of them working yet.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Yoller
Junior Member
Posts: 4
Joined: Sun Dec 18, 2011 12:42 pm

Re: Call vensim

Post by Yoller »

function loademo

if not(libisloaded('VenDLL32'))
hfile=[ 'C:\Users\Desktop\Vensim\Vensim\dll\vendll.h'];
loadlibrary('VenDLL32',hfile);
end

libfunctionsview VenDLL32

str=['SPECIAL>LOADMODEL|C:\Users\Desktop\Vensim\Vensim\dll\rabfox.vpm'];
calllib('VenDLL32','vensim_check_status')
calllib('VenDLL32','vensim_command',str)

Unfortunately I can't load any demos either.
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Call vensim

Post by Administrator »

What happens when you try and run one of the demos? What error messages are you getting?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Post Reply