To register a function to be called between each event, use CSIM_AddEventLoopFunc, which is formally defined as:
void CSIM_AddEventLoopFunc( EventLoopFunc func, void *data );Example Usage:
/* In DEFINE_GLOBAL area. */
void my_event_function( int x )
{ printf("Next event. %d\n", x); }...
/* Somewhere in your model code under or called by a model-thread, */
CSIM_AddEventLoopFunc( my_event_function, aparameter );
To register a function to be called when the simulation exits, use CSIM_AddExitFunc, which is formally defined as:
void CSIM_AddExitFunc( EventLoopFunc func, void *data )Note that for many simulations, the CSIM_EndOfSim synchron can be used as an alterntive to registering an exit function. It triggers your closing threads to print final results and close files. However, that method applies to simulations having activity for only finite durations. Simulations which have no definite ending, -which produce events forever-, will never activate the CSIM_EndOfSim synchron. For indefinite duration simulations, registering an exit function may be more useful.
Example Usage:
/* In DEFINE_GLOBAL area. */
void my_exit_function( int x )
{ printf("Closing time. Experiment %d.\n", x); }...
/* Somewhere in your model code under or called by a model-thread, */
CSIM_AddExitFunc( my_exit_function, casenumber );