Commit 28e5276a authored by Maxime Perrotin's avatar Maxime Perrotin

Support timers properly in SDL instances

parent f930627d
......@@ -67,9 +67,11 @@ void Create_New_SDL_Structure(FV * fv)
}
char *filename = make_string("%s.pr", fv->name);
/* If not already existing, also create an empty system_implementation.pr
/* If not already existing, also create an empty <function>.pr
* file - includes timer declarations, if any.
* Do not create in case the function is an instance of a generic function*/
* Do not create in case the function is an instance of a generic function
* In that case (instance of), timers will be added to the list of signals
* to make them visible at code generation time */
if (!file_exists (path, filename) && (NULL == fv->instance_of)) {
create_file (path, filename, &process);
if (fv->is_component_type == false) {
......@@ -137,6 +139,7 @@ void Add_SDL_Signal(Interface * i)
}
fprintf(f, ");\n\n");
}
}
......@@ -196,18 +199,25 @@ void Build_SDL_Connections(FV * fv)
if (NULL == f)
return;
fprintf(f, "\tCHANNEL c\n");
if (NULL != pi_string)
if (NULL != pi_string) {
fprintf(f, "\t\tFROM ENV TO %s WITH %s;\n", fv->name, pi_string);
if (NULL != ri_string)
}
if (NULL != ri_string) {
fprintf(f, "\t\tFROM %s TO ENV WITH %s;\n", fv->name, ri_string);
}
fprintf(f, "\tENDCHANNEL;\n\n");
fprintf(f, "\tBLOCK %s;\n\n\t\tSIGNALROUTE r\n", fv->name);
if (NULL != pi_string)
fprintf(f, "\t\t\tFROM ENV TO %s WITH %s;\n", fv->name,
pi_string);
if (NULL != ri_string)
fprintf(f, "\t\t\tFROM %s TO ENV WITH %s;\n", fv->name,
ri_string);
if (NULL != pi_string) {
fprintf(f, "\t\t\tFROM ENV TO %s WITH %s;\n", fv->name, pi_string);
}
if (NULL != ri_string) {
fprintf(f, "\t\t\tFROM %s TO ENV WITH %s;\n", fv->name, ri_string);
}
fprintf(f, "\n\t\tCONNECT c and r;\n\n");
if (fv->is_component_type == false) {
......@@ -263,7 +273,20 @@ void GW_SDL_Backend(FV * fv)
Create_New_SDL_Structure(fv);
FOREACH(i, Interface, fv->interfaces, {
GW_SDL_Interface(i);
})
});
if (NULL != fv->instance_of) {
/* component is an instance: declare the timers as signals so that
* opengeode generates code for them, otherwise it would have no
* visibility on them, since they are declared in the code of the
* function type only
*/
FOREACH(timer, String, fv->timer_list, {
fprintf(f, "\tSIGNAL %s;\n", timer);
add_PI_to_string(timer);
});
}
Build_SDL_Connections(fv);
Close_SDL_Structure();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment