This developer guide gives an example of how to add a new simulation object and integrate this new Component with GENESIS. As an example we implement the pulsegen object of GENESIS 2 that, for simplicity, we will embed as a new component in the Experiment package.
First we create the following source files for the new object in the correct places in Experiment:
These source files will be filled in with the functionality of the GENESIS 2 pulsegen object.
To keep track of all the data for the new object we define a struct(ure) which contains all of our variables. This structure is set up in the header file experiment/pulsegen.h:
/// An input value referenced via pointer.
/// solved variables
Keeping in mind that the new object is going to be used by a simulation, we need appropriate functions for interaction with the scheduler. The most important functions are: creation and set up of the object’s run-time instance, performing the actions during a single simulation step, and freeing the memory allocated by the object during its lifetime.
struct simobj_PulseGen * PulseGenNew(char *pcName);
int PulseGenAddVariable(struct simobj_PulseGen *ppg, void *pvOutput);
struct simobj_PulseGen *ppg,
int PulseGenReset(struct simobj_PulseGen *ppg);
int PulseGenSingleStep(struct simobj_PulseGen *ppg, double dTime);
int PulseGenFinish(struct simobj_PulseGen *ppg);
Before compiling the new simulation object you must add your source files to targets of the Experiment package Makefile.am.
The new simulation object will be compiled into the Experiment library when a make is performed.