Create a C++ file containing all the functions that you want to be able to use from Dymola. In the case of our Delay block the file's name is "DEVSdelay.cpp" and it defines several functions among which also the following one:
#ifndef DEVSdelay_C
#define DEVSdelay_C
#include
double ARRu[1000], ARRmu[1000], ARRpu[1000], ARRtime[1000];
int counterIn=1;
double getSigmaDint(int counterOut, double tim, double delay){
if ((counterOut+1)%1000==counterIn){
return 4e10;
}else{
if (ARRtime[counterOut]+delay-tim < 0){
return counterOut;
}else{
return ARRtime[counterOut]+delay-tim;
}
}
}
[...other functions...]
#endif
Note that it is important to protect Dymola from including the C++ file more than once. This is done using the #ifndef and #endif construct.