Hi Folks,
I am currently in the procss of improving and tidying the interface between Simile and its generated model code in order to make models directly accessible to other applications. I am interested in hearing from potential users of this interface regarding what they might find useful. Currently under development is a new model execution interface, allowing a single procedure call to run the model over many time steps.
In particular I am aware that some users want to interface models to Visual Basic programs, with a view to sharing VB code designed to do this.
--Jasper
Interfacing to Simile models at the .dll level
I'm keen to interface simile models with our Ag System model APSIM. We have already done a similar task with Vensim (and wrote about it! see AgSystems (83)2 135-151), yet ventana's API is restrictive - hard to probe the model for variable names and a there's a very tedious (and error prone) process of connecting apsim variables with vensim variables..
We already have a TCL component in apsim - I am expecting that I can do all the above and more with simile via the existing runControl interface.
Our intended use is in prototyping/development of new modules - at a "module" level (eg insect pest population) and sub-module level (eg a plant submodel implementing a leaf component). The 1st is easy (ie tcl), the 2nd more difficult as there is only a C++ API. If your new API follows the runControl style, I can' t see many problems.
Interfacing to Simile models at the .dll level
Actually (it seems to me) the generated dll from simile exports all the necessary function to do all!
The only little problem is the > calling convention in the support2.cpp, that is not well supported in vb6 (i don't know if in .net something is changed)...
(i see that in the last versions this declarations is, correctly, distributed in the dllcalls.h .)
But, there are some ways to "bypass" this problem ....
A first very simple trick is, to change these in simple __stdcall ! so when you compile the model, you have a fully vb6 compatible dll, and so vb can look into the dll directly! but this, involve to modify the "simile core" and i don't know what can happen then...
Another trick is, to write a very simple "c" dll to make it ! Just the __stdcall functions that open (with windows kernel32 LoadLibrary ) and call the simile dll entries , so vb can be linked to this stub that is linked to original similedll....
another hands is if you want to link dynamically to vb the dll.... in this case you can use the windows kernel32 LoadLibrary function to open dll and GetProcAddress directly from vb just to recover the pointer of every single entry point of simile dll... then with a little "generic" stub dll called it...
In our SimArc and 5D-lsdj interface we have used this last solution....
VB dll
Hey there
i have access to a dll in Visual Basic that describes stem taper
and i want to be able to use this in simile.
the taper function is too complex for me to transcribe into something
i can incorporate into equations/flows etc
so i need to take the diameter of a tree in my model and reference to this dll to find a mid diameter based on the height of that tree.
how could i do that??
Interfacing to Simile models at the .dll level
There is information in Simile's help about how to include your own function, defined as a c++ procedure, in the equation language.
It seems like what you need to do is create a c++ procedure that accesses the .dll containing the function you want. I don't know the details of how to do this with a .dll created by VB; you might need to include an external declaration of the .dll, and edit the command that compiles the model code (in Run/toolbox.tcl) to refer to the directory that contains the .dll -- though Simile should provide some graphical way of setting this up.
Please write again if you need more help
--Jasper