vsTASKER 7 User Manual
×
Menu
Index

DLL

 
A Component can be local to the database, external to a library or compiled as a DLL and loaded by the simulation engine at runtime.
 
 
Create the DLL header interface (here accel.h)
 
 typedef int (__stdcall* AccelFunc)(float speed, float acc, float& result);
 
Specify it into the Definition panel of the DLL component
 
 #include "../model/dll/accel.h"
 
 
In the Declaration panel, create all the DLL function pointers as defined in the header as a typedef, any data that is needed for interfacing the Component with the simulation engine and user.
 
 AccelFunc pAccel;
 float acc; //&&  DEF[30]
 HMODULE hDll;
 
 
In the Initialization panel, the compiled DLL file must be loaded and its embedded function must be extracted and allocated the the Component function pointers.
Once this is done at simulation load (INIT), the DLL functions can be used either in the Component methods or the runtime tic().
 
   case INIT: {    // at first start
     hDll = LoadLibrary(strAdd(vsTaskerDir(),"/bin/accel.dll"));
     pAccel= (AccelFunc) GetProcAddress(hDll, "accel");
  } break;
 
 
The DLL functions will be used according to their interface defined in the header.
For i.e:
 
   pAccel(current_spd, acceleration, new_speed);