vensim & DLL
vensim & DLL
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)
[Edited on 7-15-2007 by gk720421]
[Edited on 7-15-2007 by gk720421]
[Edited on 7-15-2007 by gk720421]
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)
[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
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
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]
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
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
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
,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
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
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.
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.
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
>> 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.
>> 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.