Copyright VirtualSim 2004-2020 - All rights reserved
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.
Header
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"
Declaration
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;
Initialization
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().