vensim & DLL

Use this forum to post Vensim related questions.
Post Reply
gk720421
Junior Member
Posts: 16
Joined: Fri Jul 13, 2007 7:52 am

vensim & DLL

Post by gk720421 »

I use c++ to make a DLL(Fej1023). I want use the DLL in vensim,but the result isn't the same.

I declare several variables in C code to replace variables in vensim , for example: 'double groundW' is computed, and I write functions to show it and the count result in the same interface in vensim , but the 'groundW' and 'gaW' are just out of my expect , become very huge , at first I think it's the problem of over flow , but I find the difference is the same , for each time I enter the same input .
for example , if enter 180 in 'need' of the vensim interface and u enter 180 again , u'll find that the difference of groundW of two times is 8000 , but the number of groundW should be the same if u key in the same 'need' .


thank you for help !(append file is the C code and vensim file)
:D



[Edited on 7-15-2007 by gk720421]

[Edited on 7-15-2007 by gk720421]

[Edited on 7-15-2007 by gk720421]
Attachments
123.rar
(47.03 KiB) Downloaded 271 times
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

I cannot work out what you are trying to do here. All I can really suggest is stepping through the C code using the debugger and see what values Vensim is passing to the DLL. Make sure it is calculating what you expect it to.

All the best,

Tony.
gk720421
Junior Member
Posts: 16
Joined: Fri Jul 13, 2007 7:52 am

Post by gk720421 »

I send the DLL . you can include it in my vensim.

Please help me,thanks.



[Edited on 7-15-2007 by gk720421]
Attachments

[The extension dll has been deactivated and can no longer be displayed.]

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

Post by Administrator »

I was able to build the DLL fine and step through the code using the debugger, I just cannot figure out what you are trying to do.

All the best,

Tony.
gk720421
Junior Member
Posts: 16
Joined: Fri Jul 13, 2007 7:52 am

Post by gk720421 »

ok! thank you~

I meen I use the "fej1023. dll" in "example1" VS. I don't use it in "oriange"

I find the final answers(supply2) are different , I don't know what is wrong.

[Edited on 7-15-2007 by gk720421]

[Edited on 7-15-2007 by gk720421]
Attachments
123.rar
(50.67 KiB) Downloaded 265 times
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

There must be an error in your C code if it is not giving the same answer as you expect. Have you stepped through the code in the debugger to check it is doing what you want?

Tony.
gk720421
Junior Member
Posts: 16
Joined: Fri Jul 13, 2007 7:52 am

Post by gk720421 »

1. I find that at first when I use "Run a Simulation" in example01(with fej1023.dll) VS. oriange
,and the final supply2's answers are correct.

2. If I input other number in "need" in example01 . I must close it, open the example01 again
the supply2' answer VS. oriange is the same.
3. But I find if I can't use "Automatically simulate on change" in 'example01' and 'oriange'
because the final supply2's answers are different.

I don't know what' wrong
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

Do you need to reset the internal variables in the DLL?

static long double groundW=50;
static long double inflow2=20;
static long double gaw=0;


Use the function

CFUNCTION int PASCAL simulation_setup(int iniflag)
{
groundW=50;
inflow2=20;
gaw=0;
return(1) ;
}

Does this now give you what you need?

Tony.
gk720421
Junior Member
Posts: 16
Joined: Fri Jul 13, 2007 7:52 am

Post by gk720421 »

thank you for tell me this information , but I am still testing the code ,
after using the code you give me , the variabls is not jumping any more,
but the result is not right still .
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

>> thank you for tell me this information , but I am still testing
>> the code , after using the code you give me , the variabls
>> is not jumping any more, but the result is not right still .
The problem is in your C code, you need to step through it using the debugger and make sure it is doing what you need it to.

Tony.
Post Reply