Browse Source

Added test fmus and fixed issue in controlflow

Casper Thule 4 years ago
parent
commit
e5a65399ac
20 changed files with 3439 additions and 1 deletions
  1. 133 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/.cproject
  2. 523 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/PW_Controller.c
  3. 49 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/PW_Controller.h
  4. 700 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/Powerwindow.c
  5. 124 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/Powerwindow.h
  6. 67 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/PowerwindowRequired.c
  7. 82 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/PowerwindowRequired.h
  8. 6 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/build.ps1
  9. 72 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/fmi2/fmi2.h
  10. 247 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/fmi2/fmi2FunctionTypes.h
  11. 339 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/fmi2/fmi2Functions.h
  12. 115 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/fmi2/fmi2TypesPlatform.h
  13. 15 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/makefile
  14. 71 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/modelDescription.xml
  15. 40 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/sc_types.h
  16. 594 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/sim_support.c
  17. 44 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/sim_support.h
  18. 199 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/test.c
  19. 18 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/window/Window.mo
  20. 1 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/ControlConditionSwitch.xtend

File diff suppressed because it is too large
+ 133 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/.cproject


+ 523 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/PW_Controller.c

@@ -0,0 +1,523 @@
+/* ---------------------------------------------------------------------------*
+ * Sample implementation of an FMU - a power window controller
+ * The code is generated from a Yakindu SC
+ * ---------------------------------------------------------------------------*/
+/*
+Template for a sc FMU
+*/
+
+#define MODEL_IDENTIFIER PW_Controller
+#define MODEL_GUID "{f4893318-1565-4931-b8c8-8a19fb3fcfda}"
+#define FMI2_FUNCTION_PREFIX PW_Controller
+
+
+#include <stdio.h>
+#include <math.h>
+#include "string.h"
+#include "fmi2Functions.h"
+#include <float.h>
+#include "PW_Controller.h"
+#include "PowerwindowRequired.h"
+
+
+#define NUMBER_OF_REALS 0
+#define NUMBER_OF_STRINGS 0
+#define NUMBER_OF_BOOLEANS 11
+#define NUMBER_OF_INTEGERS 0
+/*
+ * The input events:
+ * */
+#define _in_obj_detected 0
+#define _in_driver_up 1
+#define _in_driver_up_stop 2
+#define _in_driver_down 3
+#define _in_driver_down_stop 4
+#define _in_passenger_up 5
+#define _in_passenger_up_stop 6
+#define _in_passenger_down 7
+#define _in_passenger_down_stop 8
+
+/*
+ * The output events
+ */
+#define _motor_up 9
+#define _motor_down 10
+
+
+fmi2Status fmi2SetDebugLogging(fmi2Component fc, fmi2Boolean loggingOn, size_t nCategories, const fmi2String categories[])
+{
+    return fmi2OK;
+}
+
+fmi2Status fmi2SetString(fmi2Component fc, const fmi2ValueReference vr[], size_t nvr, const fmi2String value[])
+{
+    return fmi2Error;
+}
+
+fmi2Status fmi2GetString(fmi2Component fc, const fmi2ValueReference vr[], size_t nvr, fmi2String value[])
+{
+    return fmi2Error;
+}
+
+fmi2Status fmi2SetReal(fmi2Component fc, const fmi2ValueReference vr[], size_t nvr, const fmi2Real value[])
+{
+    return fmi2Error;
+}
+
+fmi2Status fmi2GetReal(fmi2Component fc, const fmi2ValueReference vr[], size_t nvr, fmi2Real value[])
+{
+
+    return fmi2Error;
+}
+
+fmi2Status fmi2SetBoolean(fmi2Component fc, const fmi2ValueReference vr[], size_t nvr, const fmi2Boolean value[])
+{
+	FMUInstance* comp = (FMUInstance *)fc;
+	int i;
+	for (i = 0; i < nvr; i++)
+	{
+		comp->b[vr[i]] = value[i];
+	}
+    return fmi2OK;
+}
+
+fmi2Status fmi2GetBoolean(fmi2Component fc, const fmi2ValueReference vr[], size_t nvr, fmi2Boolean value[])
+{
+	FMUInstance* comp = (FMUInstance *)fc;
+	int i;
+	for (i = 0; i < nvr; i++)
+	{
+		value[i] = comp->b[vr[i]];
+	}
+    return fmi2OK;
+}
+
+fmi2Component fmi2Instantiate(fmi2String instanceName, fmi2Type fmuType, fmi2String fmuGUID, fmi2String fmuLocation, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+
+	//Declare data structure for fmu instance
+    FMUInstance* fi;
+	printf("%s in fmiInstantiate\n",instanceName);
+
+    //Perform checks on passed callback functions
+    if (loggingOn) {
+
+        if (!functions->logger);
+        //return NULL;
+	}
+    //Check for instanceName
+    if (!instanceName || strlen(instanceName)==0) {
+
+        // print (and/or log) instanceName is missing
+        //return NULL;
+    }
+    //Check passed GUID to defined model GUID
+    if (strcmp(fmuGUID, MODEL_GUID))
+	{
+        // print (and/or log) GUID doesn't match
+        //return NULL;
+    }
+
+    //Allocate fmu instance Memory
+    // TODO check if "canNotUseMemoryManagementFunctions == true/false". If false memory allocation not possible
+    fi = (FMUInstance *)functions->allocateMemory(1, sizeof(FMUInstance));
+    fi->functions = functions;
+    if (fi) {
+        // Think about what to do with variable values. Using these structs and pointers slows down simulation computations. Maybe only necessary for input, output and tunable parameters??
+        fi->r = functions->allocateMemory(NUMBER_OF_REALS, sizeof(fmi2Real));
+        fi->i = functions->allocateMemory(NUMBER_OF_INTEGERS, sizeof(fmi2Integer));
+        fi->b = functions->allocateMemory(NUMBER_OF_BOOLEANS, sizeof(fmi2Boolean));
+        fi->s = functions->allocateMemory(NUMBER_OF_STRINGS,  sizeof(fmi2String));
+        fi->Handle = functions->allocateMemory(1,sizeof(Powerwindow));
+        fi->thePWTimer = functions->allocateMemory(1,sizeof(fmi_timer));
+    } // variables in predefined arrays (performance issue) --> makes multiple instances of fmu impossible
+
+    fi->thePWTimer->callback = &powerwindow_raiseTimeEvent;
+    powerwindow_initTimer(fi->thePWTimer);
+    fi->instanceName = functions->allocateMemory(1 + strlen(instanceName), sizeof(char));
+    fi->GUID = functions->allocateMemory(1 + strlen(fmuGUID), sizeof(char));
+
+    strcpy((char*)fi->instanceName, instanceName);
+    strcpy((char*)fi->GUID, fmuGUID);
+    fi->loggingOn = loggingOn;
+    fi->isVisible = visible;
+    fi->state = fmuInstantiated;
+    return fi;
+}
+
+fmi2Status fmi2SetupExperiment(fmi2Component fc, fmi2Boolean toleranceDefined, fmi2Real tolerance,
+                            fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime) {
+
+
+    FMUInstance* fi = (FMUInstance*) fc;
+	printf("%s in fmiSetupExperiment\n",fi->instanceName);
+	if (fi->state != fmuInstantiated)
+	{
+		printf("fmu: %s was not instatiated before calling fmiSetupExperiment\n", fi->instanceName);
+		return fmi2Error;
+	}
+	fi->currentTime = startTime;
+	fi->stopTimeDefined = stopTimeDefined;
+	fi->toleranceDefined = toleranceDefined;
+	if (stopTimeDefined)
+	{
+		fi->stopTime = stopTime;
+	}
+
+	if (toleranceDefined)
+	{
+		fi->tolerance = tolerance;
+	}
+	//TODO
+	//fi->stepSize = getStepSize();
+	fi->state = fmuExperimentSettedUp;
+	fi->next_timer_event = -1;
+    return fmi2OK;
+}
+
+fmi2Status fmi2EnterInitializationMode(fmi2Component fc)
+{
+	FMUInstance* fi = (FMUInstance*) fc;
+	printf("%s in fmiEnterInitializationMode\n",fi->instanceName);
+	if (fi->state != fmuExperimentSettedUp)
+	{
+		printf("fmu: %s experiment was not set-up before calling fmiEnterInitializationMode\n", fi->instanceName);
+		return fmi2Error;
+	}
+
+    fi->state = fmuInitMode;
+    powerwindow_init(fi->Handle);
+    return fmi2OK;
+}
+
+fmi2Status fmi2ExitInitializationMode(fmi2Component fc)
+{
+	FMUInstance* fi = (FMUInstance*) fc;
+	fmi2Status initStatus = fmi2OK;
+	printf("%s in fmiExitInitializationMode\n",fi->instanceName);
+	if (fi->state != fmuInitMode)
+	{
+		printf("fmu: %s did not enter Initialization Mode before calling fmiExitInitializationMode\n", fi->instanceName);
+		fflush(stdout);
+		return fmi2Error;
+	}
+	// TODO
+	//initStatus = calculateInitialUnknownValues();
+	//initialize();
+	powerwindow_enter(fi->Handle);
+    fi->state = fmuInitialized;
+    printf("fmu: %s finish fmiExitInitializationMode\n", fi->instanceName);
+    return initStatus;
+}
+
+fmi2Status fmi2DoStep(fmi2Component fc , fmi2Real currentCommPoint, fmi2Real commStepSize, fmi2Boolean noPrevFMUState)
+{
+	FMUInstance* fi = (FMUInstance *)fc;
+	fmi2Status simStatus = fmi2OK;
+    printf("%s in fmiDoStep(), ct: %f, h:%f\n",fi->instanceName, currentCommPoint, commStepSize);
+
+    /*
+     */
+    int isfin = fi->next_timer_event > 0;
+    if(fi->next_timer_event > 0){
+    	if (is_close(fi->next_timer_event, currentCommPoint+commStepSize, 1e-3, 1e-7)){
+    		powerwindow_timeradvance(fi->thePWTimer, (currentCommPoint+commStepSize)*1000); // yakindu in ms not in s
+    	}else{
+    		if (fi->next_timer_event < currentCommPoint + commStepSize){
+    			simStatus = fmi2Discard;
+    			fi->currentTime = fi->next_timer_event;
+    			return simStatus;
+    		}else{
+    			powerwindow_timeradvance(fi->thePWTimer, (currentCommPoint+commStepSize)*1000);
+    		}
+
+    	}
+    }else{powerwindow_timeradvance(fi->thePWTimer, (currentCommPoint+commStepSize)*1000);}
+
+    if (fi->b[_in_driver_up]){
+    	powerwindowIfaceInput_raise_driver_up(fi->Handle);
+    	printf("raise up driver\n");
+    }
+
+	if(fi->b[_in_driver_down]){
+		powerwindowIfaceInput_raise_driver_down(fi->Handle);
+		printf("raise down driver\n");
+	}
+
+	if(fi->b[_in_driver_up_stop]){
+		powerwindowIfaceInput_raise_stop(fi->Handle);
+		printf("raise up stop\n");
+	}
+	if(fi->b[_in_driver_down_stop]){
+		powerwindowIfaceInput_raise_stop(fi->Handle);
+		printf("raise driver down stop\n");
+	}
+	if(fi->b[_in_passenger_up]){
+		powerwindowIfaceInput_raise_passenger_up(fi->Handle);
+		printf("raise up passenger\n");
+	}
+	if(fi->b[_in_passenger_down]){
+		powerwindowIfaceInput_raise_passenger_down(fi->Handle);
+		printf("raise passenger down\n");
+	}
+	if(fi->b[_in_passenger_up_stop]){
+		powerwindowIfaceInput_raise_stop(fi->Handle);
+		printf("raise passenger up stop\n");
+	}
+	if(fi->b[_in_passenger_down_stop]){
+		powerwindowIfaceInput_raise_stop(fi->Handle);
+		printf("raise passenger down stop\n");
+	}
+	if(fi->b[_in_obj_detected]){
+		powerwindowIfaceInput_raise_obj_detected(fi->Handle);
+		printf("raise object detected\n");
+	}
+
+	powerwindow_runCycle(fi->Handle);
+
+	fi->b[_motor_up] = powerwindowIfaceOutput_get_up(fi->Handle);
+	fi->b[_motor_down] = powerwindowIfaceOutput_get_down(fi->Handle);
+	/*
+	 * Check timers and set
+	 */
+	if(fi->thePWTimer->active){
+		fi->next_timer_event = fi->thePWTimer->nextTime/1000; // yakindu in ms not in s
+	}else{
+		fi->next_timer_event = -1;
+	}
+
+
+	fi->currentTime = currentCommPoint +  commStepSize;
+
+	return fmi2OK;
+}
+
+fmi2Status fmi2Terminate(fmi2Component fc)
+{
+	FMUInstance* fi = (FMUInstance *)fc;
+	printf("%s in fmiTerminate\n",fi->instanceName);
+	// do check if fi may be terminated
+	fi->state = fmuTerminated;
+
+    return fmi2OK;
+}
+
+
+void fmi2FreeInstance(fmi2Component fc)
+{
+
+	FMUInstance* fi = (FMUInstance*) fc;
+	printf("%s in fmiFreeInstance\n",fi->instanceName);
+
+    if (fi) {
+
+        fi->functions->freeMemory(fi->r);
+        fi->functions->freeMemory(fi->i);
+        fi->functions->freeMemory(fi->b);
+        fi->functions->freeMemory(fi->Handle);
+        fi->functions->freeMemory(fi->s);// TODO has to be done with loop
+		fi->functions->freeMemory((void*)fi->instanceName);
+		fi->functions->freeMemory((void*)fi->GUID);
+		fi->functions->freeMemory((void*)fi);
+
+
+    }
+}
+
+//To be implemented
+
+const char* fmi2GetVersion() {
+	printf("Function fmiGetVersion not supported\n");
+    return NULL;
+}
+
+const char* fmi2GetTypesPlatform() {
+	printf("Function fmiGetTypesPlatform not supported\n");
+    return NULL;
+}
+
+fmi2Status fmi2Reset(fmi2Component fc)
+{
+	printf("Function fmiReset not supported\n");
+    return fmi2Error;
+}
+
+
+fmi2Status fmi2SetInteger(fmi2Component fc, const fmi2ValueReference vr[], size_t nvr, const fmi2Integer value[])
+{
+    printf("Function fmiSetInteger not supported\n");
+    return fmi2Error;
+}
+
+fmi2Status fmi2GetInteger(fmi2Component fc, const fmi2ValueReference vr[], size_t nvr, fmi2Integer value[])
+{
+    printf("Function fmiGetInteger not supported\n");
+    return fmi2Error;
+}
+
+
+/*******OWN IMPLEMENTATION OF Get/Set FMU state*******/
+fmi2Status fmi2GetFMUstate (fmi2Component c, fmi2FMUstate* FMUstate) {
+    FMUInstance* orig = (FMUInstance*)c;
+    FMUInstance* fi = (FMUInstance *)FMUstate;
+    fi = orig->functions->allocateMemory(1, sizeof(FMUInstance));
+    *FMUstate = fi;
+    if (fi) {
+        // Think about what to do with variable values. Using these structs and pointers slows down simulation computations. Maybe only necessary for input, output and tunable parameters??
+        fi->r = orig->functions->allocateMemory(NUMBER_OF_REALS, sizeof(fmi2Real));
+        fi->i = orig->functions->allocateMemory(NUMBER_OF_INTEGERS, sizeof(fmi2Integer));
+        fi->b = orig->functions->allocateMemory(NUMBER_OF_BOOLEANS, sizeof(fmi2Boolean));
+        fi->s = orig->functions->allocateMemory(NUMBER_OF_STRINGS,  sizeof(fmi2String));
+        fi->Handle = orig->functions->allocateMemory(1,sizeof(Powerwindow));
+
+    } // variables in predefined arrays (performance issue) --> makes multiple instances of fmu impossible
+    fi->instanceName = orig->functions->allocateMemory(1 + strlen(orig->instanceName), sizeof(char));
+    fi->GUID = orig->functions->allocateMemory(1 + strlen(orig->GUID), sizeof(char));
+
+    strcpy((char *)fi->instanceName, (char *)orig->instanceName);
+    strcpy((char *)fi->GUID, (char *)orig->GUID);
+    fi->functions = orig->functions;
+    fi->loggingOn = orig->loggingOn;
+    fi->isVisible = orig->isVisible;
+    fi->state = orig->state;
+    fi->stepSize = orig->stepSize;
+    fi->startTime = orig->startTime;
+    fi->stopTime = orig->stopTime;
+	fi->currentTime = orig->currentTime;
+	fi->next_timer_event = orig->next_timer_event;
+	powerwindow_copy(orig->Handle, fi->Handle);
+	//copy r
+	int i=0;
+	for (i=0; i< NUMBER_OF_REALS;i++){
+	    printf("Setting real: %i %f\n", i, orig->r[i]);
+        fi->r[i] = orig->r[i];
+        printf("Setted real: %i %f\n", i, fi->r[i]);
+	}
+	//copy s
+	for (i=0; i< NUMBER_OF_STRINGS;i++){
+        fi->s[i] = orig->s[i];
+	}
+	//copy i
+    for (i=0; i< NUMBER_OF_INTEGERS;i++){
+        fi->i[i] = orig->i[i];
+	}
+	//copy b
+	for (i=0; i< NUMBER_OF_BOOLEANS;i++){
+        fi->b[i] = orig->b[i];
+	}
+
+	// copy pw
+
+    return fmi2OK;
+}
+
+
+fmi2Status fmi2SetFMUstate (fmi2Component c, fmi2FMUstate FMUstate) {
+    FMUInstance* orig = (FMUInstance*)FMUstate;
+    FMUInstance* fi = (FMUInstance*)c;
+    //set time etc correct, name and GUID should still be ok ;-)
+    printf("setting time values from %f to %f\n", fi->currentTime, orig->currentTime);
+    fi->state = orig->state;
+    fi->stepSize = orig->stepSize;
+    fi->startTime = orig->startTime;
+    fi->stopTime = orig->stopTime;
+	fi->currentTime = orig->currentTime;
+	fi->next_timer_event = orig->next_timer_event;
+	printf("setting real values\n");
+	//copy r
+	int i=0;
+	for (i=0; i< NUMBER_OF_REALS;i++){
+        fi->r[i] = orig->r[i];
+	}
+	printf("setting string values\n");
+	//copy s
+	for (i=0; i< NUMBER_OF_STRINGS;i++){
+
+        fi->s[i] = orig->s[i];
+	}
+	//copy i
+    for (i=0; i< NUMBER_OF_INTEGERS;i++){
+        fi->i[i] = orig->i[i];
+	}
+	//copy b
+	for (i=0; i< NUMBER_OF_BOOLEANS;i++){
+        fi->b[i] = orig->b[i];
+	}
+	powerwindow_copy(orig->Handle,fi->Handle);
+
+    return fmi2OK;
+
+
+}
+/****************************************************/
+
+fmi2Status fmi2FreeFMUstate(fmi2Component c, fmi2FMUstate* FMUstate) {
+    printf("Function fmiFreeFMUstate not supported\n");
+    return fmi2Error;
+}
+fmi2Status fmi2SerializedFMUstateSize(fmi2Component c, fmi2FMUstate FMUstate, size_t *size) {
+    printf("Function fmiSerializedFMUstateSize not supported\n");
+    return fmi2Error;
+}
+fmi2Status fmi2SerializeFMUstate (fmi2Component c, fmi2FMUstate FMUstate, fmi2Byte serializedState[], size_t size) {
+    printf("Function fmiSerializeFMUstate not supported\n");
+    return fmi2Error;
+}
+fmi2Status fmi2DeSerializeFMUstate (fmi2Component c, const fmi2Byte serializedState[], size_t size, fmi2FMUstate* FMUstate) {
+    printf("Function fmiDeSerializeFMUstate not supported\n");
+    return fmi2Error;
+}
+
+fmi2Status fmi2GetDirectionalDerivative(fmi2Component c, const fmi2ValueReference vUnknown_ref[], size_t nUnknown,
+                const fmi2ValueReference vKnown_ref[] , size_t nKnown, const fmi2Real dvKnown[], fmi2Real dvUnknown[]) {
+    printf("Function fmiGetDirectionalDerivative not supported\n");
+    return fmi2Error;
+}
+
+
+fmi2Status fmi2SetRealInputDerivatives(fmi2Component c, const fmi2ValueReference vr[], size_t nvr,
+                                     const fmi2Integer order[], const fmi2Real value[]) {
+    printf("Function fmiGetDirectionalDerivative not supported\n");
+    return fmi2Error;
+}
+
+fmi2Status fmi2GetRealOutputDerivatives(fmi2Component c, const fmi2ValueReference vr[], size_t nvr,
+                                      const fmi2Integer order[], fmi2Real value[]) {
+    printf("Function fmiGetDirectionalDerivative not supported\n");
+    return fmi2Error;
+}
+
+fmi2Status fmi2CancelStep(fmi2Component c) {
+    printf("Function fmiGetDirectionalDerivative not supported\n");
+    return fmi2Error;
+}
+
+fmi2Status fmi2GetStatus(fmi2Component c, const fmi2StatusKind s, fmi2Status *value) {
+    printf("Function fmiGetStatus not supported\n");
+    return fmi2Error;
+}
+
+fmi2Status fmi2GetRealStatus(fmi2Component c, const fmi2StatusKind s, fmi2Real *value) {
+    if(s == fmi2LastSuccessfulTime){
+        FMUInstance* comp = (FMUInstance*) c;
+        *value = comp->currentTime;
+        return fmi2OK;
+    }
+    printf("Function fmiGetRealStatus not supported\n");
+    return fmi2Error;
+}
+
+fmi2Status fmi2GetIntegerStatus(fmi2Component c, const fmi2StatusKind s, fmi2Integer *value) {
+    printf("Function fmiGetIntegerStatus not supported\n");
+    return fmi2Error;
+}
+
+fmi2Status fmi2GetBooleanStatus(fmi2Component c, const fmi2StatusKind s, fmi2Boolean *value) {
+    printf("Function fmiGetBooleanStatus not supported\n");
+    return fmi2Error;
+}
+
+fmi2Status fmi2GetStringStatus(fmi2Component c, const fmi2StatusKind s, fmi2String *value) {
+    printf("Function fmiGetStringStatus not supported\n");
+    return fmi2Error;
+}

+ 49 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/PW_Controller.h

@@ -0,0 +1,49 @@
+/*
+ * PW_Controller.h
+ *
+ *  Created on: Jan 25, 2017
+ *      Author: Joachim
+ */
+
+#ifndef PW_CONTROLLER_H_
+#define PW_CONTROLLER_H_
+
+#include "Powerwindow.h"
+#include "PowerwindowRequired.h"
+
+typedef enum {
+    fmuInstantiated = 0,
+    fmuInitMode  = 1,
+	fmuInitialized = 2,
+    fmuTerminated   = 3,
+    fmuError        = 4,
+    fmuExperimentSettedUp = 5
+} FMUState;
+
+
+
+typedef struct {
+	fmi2Real    *r;
+    fmi2Integer *i;
+    fmi2Boolean *b;
+    fmi2String  *s;
+    fmi2Boolean isVisible;
+    fmi2String instanceName;
+    fmi2String GUID;
+    const fmi2CallbackFunctions* functions;
+    fmi2Boolean loggingOn;
+    FMUState state;
+	fmi2Real stepSize;
+    fmi2Real startTime;
+    fmi2Real stopTime;
+	fmi2Real currentTime;
+	fmi2Real next_timer_event;
+    fmi2Boolean stopTimeDefined;
+    fmi2Real tolerance;
+    fmi2Boolean toleranceDefined;
+    Powerwindow *Handle;
+    fmi_timer *thePWTimer;
+} FMUInstance; // At the moment, most of the variables not really used since multiple instances of an FMU are not supported at the moment (performance issues)
+
+
+#endif /* PW_CONTROLLER_H_ */

+ 700 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/Powerwindow.c

@@ -0,0 +1,700 @@
+
+#include <stdlib.h>
+#include <string.h>
+#include "sc_types.h"
+#include "Powerwindow.h"
+#include "PowerwindowRequired.h"
+/*! \file Implementation of the state machine 'powerwindow'
+*/
+
+/* prototypes of all internal functions */
+static sc_boolean powerwindow_check_main_region_Normal_operation_tr0_tr0(const Powerwindow* handle);
+static sc_boolean powerwindow_check_main_region_Normal_operation_r1_Driver_neutral_tr0_tr0(const Powerwindow* handle);
+static sc_boolean powerwindow_check_main_region_Normal_operation_r1_Driver_neutral_tr1_tr1(const Powerwindow* handle);
+static sc_boolean powerwindow_check_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation_tr0_tr0(const Powerwindow* handle);
+static sc_boolean powerwindow_check_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation_tr1_tr1(const Powerwindow* handle);
+static sc_boolean powerwindow_check_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down_tr0_tr0(const Powerwindow* handle);
+static sc_boolean powerwindow_check_main_region_Normal_operation_r1_Driver_down_tr0_tr0(const Powerwindow* handle);
+static sc_boolean powerwindow_check_main_region_Normal_operation_r1_Driver_up_tr0_tr0(const Powerwindow* handle);
+static sc_boolean powerwindow_check_main_region_Normal_operation_r1_Passenger_up_tr0_tr0(const Powerwindow* handle);
+static sc_boolean powerwindow_check_main_region_Emergency_operation_tr0_tr0(const Powerwindow* handle);
+static void powerwindow_effect_main_region_Normal_operation_tr0(Powerwindow* handle);
+static void powerwindow_effect_main_region_Normal_operation_r1_Driver_neutral_tr0(Powerwindow* handle);
+static void powerwindow_effect_main_region_Normal_operation_r1_Driver_neutral_tr1(Powerwindow* handle);
+static void powerwindow_effect_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation_tr0(Powerwindow* handle);
+static void powerwindow_effect_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation_tr1(Powerwindow* handle);
+static void powerwindow_effect_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down_tr0(Powerwindow* handle);
+static void powerwindow_effect_main_region_Normal_operation_r1_Driver_down_tr0(Powerwindow* handle);
+static void powerwindow_effect_main_region_Normal_operation_r1_Driver_up_tr0(Powerwindow* handle);
+static void powerwindow_effect_main_region_Normal_operation_r1_Passenger_up_tr0(Powerwindow* handle);
+static void powerwindow_effect_main_region_Emergency_operation_tr0(Powerwindow* handle);
+static void powerwindow_enact_main_region_Emergency_operation(Powerwindow* handle);
+static void powerwindow_exact_main_region_Emergency_operation(Powerwindow* handle);
+static void powerwindow_enseq_main_region_Normal_operation_default(Powerwindow* handle);
+static void powerwindow_enseq_main_region_Normal_operation_r1_Driver_neutral_default(Powerwindow* handle);
+static void powerwindow_enseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation_default(Powerwindow* handle);
+static void powerwindow_enseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down_default(Powerwindow* handle);
+static void powerwindow_enseq_main_region_Normal_operation_r1_Driver_down_default(Powerwindow* handle);
+static void powerwindow_enseq_main_region_Normal_operation_r1_Driver_up_default(Powerwindow* handle);
+static void powerwindow_enseq_main_region_Normal_operation_r1_Passenger_up_default(Powerwindow* handle);
+static void powerwindow_enseq_main_region_Emergency_operation_default(Powerwindow* handle);
+static void powerwindow_enseq_main_region_default(Powerwindow* handle);
+static void powerwindow_enseq_main_region_Normal_operation_r1_default(Powerwindow* handle);
+static void powerwindow_enseq_main_region_Normal_operation_r1_Driver_neutral_r1_default(Powerwindow* handle);
+static void powerwindow_exseq_main_region_Normal_operation(Powerwindow* handle);
+static void powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral(Powerwindow* handle);
+static void powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation(Powerwindow* handle);
+static void powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down(Powerwindow* handle);
+static void powerwindow_exseq_main_region_Normal_operation_r1_Driver_down(Powerwindow* handle);
+static void powerwindow_exseq_main_region_Normal_operation_r1_Driver_up(Powerwindow* handle);
+static void powerwindow_exseq_main_region_Normal_operation_r1_Passenger_up(Powerwindow* handle);
+static void powerwindow_exseq_main_region_Emergency_operation(Powerwindow* handle);
+static void powerwindow_exseq_main_region(Powerwindow* handle);
+static void powerwindow_exseq_main_region_Normal_operation_r1(Powerwindow* handle);
+static void powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral_r1(Powerwindow* handle);
+static void powerwindow_react_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation(Powerwindow* handle);
+static void powerwindow_react_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down(Powerwindow* handle);
+static void powerwindow_react_main_region_Normal_operation_r1_Driver_down(Powerwindow* handle);
+static void powerwindow_react_main_region_Normal_operation_r1_Driver_up(Powerwindow* handle);
+static void powerwindow_react_main_region_Normal_operation_r1_Passenger_up(Powerwindow* handle);
+static void powerwindow_react_main_region_Emergency_operation(Powerwindow* handle);
+static void powerwindow_react_main_region__entry_Default(Powerwindow* handle);
+static void powerwindow_react_main_region_Normal_operation_r1__entry_Default(Powerwindow* handle);
+static void powerwindow_react_main_region_Normal_operation_r1_Driver_neutral_r1__entry_Default(Powerwindow* handle);
+static void powerwindow_clearInEvents(Powerwindow* handle);
+static void powerwindow_clearOutEvents(Powerwindow* handle);	
+
+/*Created this myself... -> please */
+void powerwindow_copy(Powerwindow* original, Powerwindow* copy){
+	for (int i = 0; i<POWERWINDOW_MAX_ORTHOGONAL_STATES; i++){
+		copy->stateConfVector[i] =  original->stateConfVector[i];
+	}
+	copy->stateConfVectorPosition = original->stateConfVectorPosition;
+	copy->timeEvents.powerwindow_main_region_Emergency_operation_tev0_raised = original ->timeEvents.powerwindow_main_region_Emergency_operation_tev0_raised;
+	copy->ifaceInput = original->ifaceInput;
+	copy->ifaceOutput = original->ifaceOutput;
+
+}
+
+void powerwindow_init(Powerwindow* handle)
+{
+	sc_integer i;
+
+	for (i = 0; i < POWERWINDOW_MAX_ORTHOGONAL_STATES; ++i) {
+		handle->stateConfVector[i] = Powerwindow_last_state;
+	}
+	
+	
+	handle->stateConfVectorPosition = 0;
+
+	powerwindow_clearInEvents(handle);
+	powerwindow_clearOutEvents(handle);
+
+	/* Default init sequence for statechart powerwindow */
+	handle->ifaceOutput.up = bool_false;
+	handle->ifaceOutput.down = bool_false;
+
+}
+
+void powerwindow_enter(Powerwindow* handle)
+{
+	/* Default enter sequence for statechart powerwindow */
+	powerwindow_enseq_main_region_default(handle);
+}
+
+void powerwindow_exit(Powerwindow* handle)
+{
+	/* Default exit sequence for statechart powerwindow */
+	powerwindow_exseq_main_region(handle);
+}
+
+sc_boolean powerwindow_isActive(const Powerwindow* handle) {
+	sc_boolean result;
+	if (handle->stateConfVector[0] != Powerwindow_last_state)
+	{
+		result =  bool_true;
+	}
+	else
+	{
+		result = bool_false;
+	}
+	return result;
+}
+
+/* 
+ * Always returns 'false' since this state machine can never become final.
+ */
+sc_boolean powerwindow_isFinal(const Powerwindow* handle){
+   return bool_false;
+}
+
+static void powerwindow_clearInEvents(Powerwindow* handle) {
+	handle->ifaceInput.obj_detected_raised = bool_false;
+	handle->ifaceInput.passenger_up_raised = bool_false;
+	handle->ifaceInput.passenger_down_raised = bool_false;
+	handle->ifaceInput.driver_up_raised = bool_false;
+	handle->ifaceInput.driver_down_raised = bool_false;
+	handle->ifaceInput.stop_raised = bool_false;
+	handle->timeEvents.powerwindow_main_region_Emergency_operation_tev0_raised = bool_false; 
+}
+
+static void powerwindow_clearOutEvents(Powerwindow* handle) {
+}
+
+void powerwindow_runCycle(Powerwindow* handle) {
+	
+	powerwindow_clearOutEvents(handle);
+	
+	for (handle->stateConfVectorPosition = 0;
+		handle->stateConfVectorPosition < POWERWINDOW_MAX_ORTHOGONAL_STATES;
+		handle->stateConfVectorPosition++) {
+			
+		switch (handle->stateConfVector[handle->stateConfVectorPosition]) {
+		case Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation : {
+			powerwindow_react_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation(handle);
+			break;
+		}
+		case Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down : {
+			powerwindow_react_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down(handle);
+			break;
+		}
+		case Powerwindow_main_region_Normal_operation_r1_Driver_down : {
+			powerwindow_react_main_region_Normal_operation_r1_Driver_down(handle);
+			break;
+		}
+		case Powerwindow_main_region_Normal_operation_r1_Driver_up : {
+			powerwindow_react_main_region_Normal_operation_r1_Driver_up(handle);
+			break;
+		}
+		case Powerwindow_main_region_Normal_operation_r1_Passenger_up : {
+			powerwindow_react_main_region_Normal_operation_r1_Passenger_up(handle);
+			break;
+		}
+		case Powerwindow_main_region_Emergency_operation : {
+			powerwindow_react_main_region_Emergency_operation(handle);
+			break;
+		}
+		default:
+			break;
+		}
+	}
+	
+	powerwindow_clearInEvents(handle);
+}
+
+void powerwindow_raiseTimeEvent(const Powerwindow* handle, sc_eventid evid) {
+	if ( ((sc_intptr_t)evid) >= ((sc_intptr_t)&(handle->timeEvents))
+		&&  ((sc_intptr_t)evid) < ((sc_intptr_t)&(handle->timeEvents)) + sizeof(PowerwindowTimeEvents)) {
+		*(sc_boolean*)evid = bool_true;
+	}		
+}
+
+sc_boolean powerwindow_isStateActive(const Powerwindow* handle, PowerwindowStates state) {
+	sc_boolean result = bool_false;
+	switch (state) {
+		case Powerwindow_main_region_Normal_operation : 
+			result = (sc_boolean) (handle->stateConfVector[0] >= Powerwindow_main_region_Normal_operation
+				&& handle->stateConfVector[0] <= Powerwindow_main_region_Normal_operation_r1_Passenger_up);
+			break;
+		case Powerwindow_main_region_Normal_operation_r1_Driver_neutral : 
+			result = (sc_boolean) (handle->stateConfVector[0] >= Powerwindow_main_region_Normal_operation_r1_Driver_neutral
+				&& handle->stateConfVector[0] <= Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down);
+			break;
+		case Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation : 
+			result = (sc_boolean) (handle->stateConfVector[0] == Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation
+			);
+			break;
+		case Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down : 
+			result = (sc_boolean) (handle->stateConfVector[0] == Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down
+			);
+			break;
+		case Powerwindow_main_region_Normal_operation_r1_Driver_down : 
+			result = (sc_boolean) (handle->stateConfVector[0] == Powerwindow_main_region_Normal_operation_r1_Driver_down
+			);
+			break;
+		case Powerwindow_main_region_Normal_operation_r1_Driver_up : 
+			result = (sc_boolean) (handle->stateConfVector[0] == Powerwindow_main_region_Normal_operation_r1_Driver_up
+			);
+			break;
+		case Powerwindow_main_region_Normal_operation_r1_Passenger_up : 
+			result = (sc_boolean) (handle->stateConfVector[0] == Powerwindow_main_region_Normal_operation_r1_Passenger_up
+			);
+			break;
+		case Powerwindow_main_region_Emergency_operation : 
+			result = (sc_boolean) (handle->stateConfVector[0] == Powerwindow_main_region_Emergency_operation
+			);
+			break;
+		default: 
+			result = bool_false;
+			break;
+	}
+	return result;
+}
+
+
+
+sc_boolean powerwindowIfaceOutput_get_up(const Powerwindow* handle) {
+	return handle->ifaceOutput.up;
+}
+sc_boolean powerwindowIfaceOutput_get_down(const Powerwindow* handle) {
+	return handle->ifaceOutput.down;
+}
+void powerwindowIfaceInput_raise_obj_detected(Powerwindow* handle) {
+	handle->ifaceInput.obj_detected_raised = bool_true;
+}
+void powerwindowIfaceInput_raise_passenger_up(Powerwindow* handle) {
+	handle->ifaceInput.passenger_up_raised = bool_true;
+}
+void powerwindowIfaceInput_raise_passenger_down(Powerwindow* handle) {
+	handle->ifaceInput.passenger_down_raised = bool_true;
+}
+void powerwindowIfaceInput_raise_driver_up(Powerwindow* handle) {
+	handle->ifaceInput.driver_up_raised = bool_true;
+}
+void powerwindowIfaceInput_raise_driver_down(Powerwindow* handle) {
+	handle->ifaceInput.driver_down_raised = bool_true;
+}
+void powerwindowIfaceInput_raise_stop(Powerwindow* handle) {
+	handle->ifaceInput.stop_raised = bool_true;
+}
+
+
+
+/* implementations of all internal functions */
+
+static sc_boolean powerwindow_check_main_region_Normal_operation_tr0_tr0(const Powerwindow* handle) {
+	return handle->ifaceInput.obj_detected_raised;
+}
+
+static sc_boolean powerwindow_check_main_region_Normal_operation_r1_Driver_neutral_tr0_tr0(const Powerwindow* handle) {
+	return handle->ifaceInput.driver_down_raised;
+}
+
+static sc_boolean powerwindow_check_main_region_Normal_operation_r1_Driver_neutral_tr1_tr1(const Powerwindow* handle) {
+	return handle->ifaceInput.driver_up_raised;
+}
+
+static sc_boolean powerwindow_check_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation_tr0_tr0(const Powerwindow* handle) {
+	return handle->ifaceInput.passenger_down_raised;
+}
+
+static sc_boolean powerwindow_check_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation_tr1_tr1(const Powerwindow* handle) {
+	return handle->ifaceInput.passenger_up_raised;
+}
+
+static sc_boolean powerwindow_check_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down_tr0_tr0(const Powerwindow* handle) {
+	return handle->ifaceInput.stop_raised;
+}
+
+static sc_boolean powerwindow_check_main_region_Normal_operation_r1_Driver_down_tr0_tr0(const Powerwindow* handle) {
+	return handle->ifaceInput.stop_raised;
+}
+
+static sc_boolean powerwindow_check_main_region_Normal_operation_r1_Driver_up_tr0_tr0(const Powerwindow* handle) {
+	return handle->ifaceInput.stop_raised;
+}
+
+static sc_boolean powerwindow_check_main_region_Normal_operation_r1_Passenger_up_tr0_tr0(const Powerwindow* handle) {
+	return handle->ifaceInput.stop_raised;
+}
+
+static sc_boolean powerwindow_check_main_region_Emergency_operation_tr0_tr0(const Powerwindow* handle) {
+	return handle->timeEvents.powerwindow_main_region_Emergency_operation_tev0_raised;
+}
+
+static void powerwindow_effect_main_region_Normal_operation_tr0(Powerwindow* handle) {
+	powerwindow_exseq_main_region_Normal_operation(handle);
+	handle->ifaceOutput.down = bool_true;
+	handle->ifaceOutput.up = bool_false;
+	powerwindow_enseq_main_region_Emergency_operation_default(handle);
+}
+
+static void powerwindow_effect_main_region_Normal_operation_r1_Driver_neutral_tr0(Powerwindow* handle) {
+	powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral(handle);
+	handle->ifaceOutput.down = bool_true;
+	handle->ifaceOutput.up = bool_false;
+	powerwindow_enseq_main_region_Normal_operation_r1_Driver_down_default(handle);
+}
+
+static void powerwindow_effect_main_region_Normal_operation_r1_Driver_neutral_tr1(Powerwindow* handle) {
+	powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral(handle);
+	handle->ifaceOutput.up = bool_true;
+	handle->ifaceOutput.down = bool_false;
+	powerwindow_enseq_main_region_Normal_operation_r1_Driver_up_default(handle);
+}
+
+static void powerwindow_effect_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation_tr0(Powerwindow* handle) {
+	powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation(handle);
+	handle->ifaceOutput.down = bool_true;
+	handle->ifaceOutput.up = bool_false;
+	powerwindow_enseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down_default(handle);
+}
+
+static void powerwindow_effect_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation_tr1(Powerwindow* handle) {
+	powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral(handle);
+	handle->ifaceOutput.up = bool_true;
+	handle->ifaceOutput.down = bool_false;
+	powerwindow_enseq_main_region_Normal_operation_r1_Passenger_up_default(handle);
+}
+
+static void powerwindow_effect_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down_tr0(Powerwindow* handle) {
+	powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down(handle);
+	handle->ifaceOutput.down = bool_true;
+	handle->ifaceOutput.up = bool_false;
+	powerwindow_enseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation_default(handle);
+}
+
+static void powerwindow_effect_main_region_Normal_operation_r1_Driver_down_tr0(Powerwindow* handle) {
+	powerwindow_exseq_main_region_Normal_operation_r1_Driver_down(handle);
+	handle->ifaceOutput.down = bool_false;
+	handle->ifaceOutput.up = bool_false;
+	powerwindow_enseq_main_region_Normal_operation_r1_Driver_neutral_default(handle);
+}
+
+static void powerwindow_effect_main_region_Normal_operation_r1_Driver_up_tr0(Powerwindow* handle) {
+	powerwindow_exseq_main_region_Normal_operation_r1_Driver_up(handle);
+	handle->ifaceOutput.up = bool_false;
+	handle->ifaceOutput.down = bool_false;
+	powerwindow_enseq_main_region_Normal_operation_r1_Driver_neutral_default(handle);
+}
+
+static void powerwindow_effect_main_region_Normal_operation_r1_Passenger_up_tr0(Powerwindow* handle) {
+	powerwindow_exseq_main_region_Normal_operation_r1_Passenger_up(handle);
+	handle->ifaceOutput.up = bool_false;
+	handle->ifaceOutput.down = bool_false;
+	powerwindow_enseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation_default(handle);
+}
+
+static void powerwindow_effect_main_region_Emergency_operation_tr0(Powerwindow* handle) {
+	powerwindow_exseq_main_region_Emergency_operation(handle);
+	handle->ifaceOutput.down = bool_false;
+	handle->ifaceOutput.up = bool_false;
+	powerwindow_enseq_main_region_Normal_operation_default(handle);
+}
+
+/* Entry action for state 'Emergency_operation'. */
+static void powerwindow_enact_main_region_Emergency_operation(Powerwindow* handle) {
+	/* Entry action for state 'Emergency_operation'. */
+	powerwindow_setTimer(handle, (sc_eventid) &(handle->timeEvents.powerwindow_main_region_Emergency_operation_tev0_raised) , 1 * 1000, bool_false);
+}
+
+/* Exit action for state 'Emergency_operation'. */
+static void powerwindow_exact_main_region_Emergency_operation(Powerwindow* handle) {
+	/* Exit action for state 'Emergency_operation'. */
+	powerwindow_unsetTimer(handle, (sc_eventid) &(handle->timeEvents.powerwindow_main_region_Emergency_operation_tev0_raised) );		
+}
+
+/* 'default' enter sequence for state Normal_operation */
+static void powerwindow_enseq_main_region_Normal_operation_default(Powerwindow* handle) {
+	/* 'default' enter sequence for state Normal_operation */
+	powerwindow_enseq_main_region_Normal_operation_r1_default(handle);
+}
+
+/* 'default' enter sequence for state Driver_neutral */
+static void powerwindow_enseq_main_region_Normal_operation_r1_Driver_neutral_default(Powerwindow* handle) {
+	/* 'default' enter sequence for state Driver_neutral */
+	powerwindow_enseq_main_region_Normal_operation_r1_Driver_neutral_r1_default(handle);
+}
+
+/* 'default' enter sequence for state Passenger_operation */
+static void powerwindow_enseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation_default(Powerwindow* handle) {
+	/* 'default' enter sequence for state Passenger_operation */
+	handle->stateConfVector[0] = Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation;
+	handle->stateConfVectorPosition = 0;
+}
+
+/* 'default' enter sequence for state Passenger_down */
+static void powerwindow_enseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down_default(Powerwindow* handle) {
+	/* 'default' enter sequence for state Passenger_down */
+	handle->stateConfVector[0] = Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down;
+	handle->stateConfVectorPosition = 0;
+}
+
+/* 'default' enter sequence for state Driver_down */
+static void powerwindow_enseq_main_region_Normal_operation_r1_Driver_down_default(Powerwindow* handle) {
+	/* 'default' enter sequence for state Driver_down */
+	handle->stateConfVector[0] = Powerwindow_main_region_Normal_operation_r1_Driver_down;
+	handle->stateConfVectorPosition = 0;
+}
+
+/* 'default' enter sequence for state Driver_up */
+static void powerwindow_enseq_main_region_Normal_operation_r1_Driver_up_default(Powerwindow* handle) {
+	/* 'default' enter sequence for state Driver_up */
+	handle->stateConfVector[0] = Powerwindow_main_region_Normal_operation_r1_Driver_up;
+	handle->stateConfVectorPosition = 0;
+}
+
+/* 'default' enter sequence for state Passenger_up */
+static void powerwindow_enseq_main_region_Normal_operation_r1_Passenger_up_default(Powerwindow* handle) {
+	/* 'default' enter sequence for state Passenger_up */
+	handle->stateConfVector[0] = Powerwindow_main_region_Normal_operation_r1_Passenger_up;
+	handle->stateConfVectorPosition = 0;
+}
+
+/* 'default' enter sequence for state Emergency_operation */
+static void powerwindow_enseq_main_region_Emergency_operation_default(Powerwindow* handle) {
+	/* 'default' enter sequence for state Emergency_operation */
+	powerwindow_enact_main_region_Emergency_operation(handle);
+	handle->stateConfVector[0] = Powerwindow_main_region_Emergency_operation;
+	handle->stateConfVectorPosition = 0;
+}
+
+/* 'default' enter sequence for region main region */
+static void powerwindow_enseq_main_region_default(Powerwindow* handle) {
+	/* 'default' enter sequence for region main region */
+	powerwindow_react_main_region__entry_Default(handle);
+}
+
+/* 'default' enter sequence for region r1 */
+static void powerwindow_enseq_main_region_Normal_operation_r1_default(Powerwindow* handle) {
+	/* 'default' enter sequence for region r1 */
+	powerwindow_react_main_region_Normal_operation_r1__entry_Default(handle);
+}
+
+/* 'default' enter sequence for region r1 */
+static void powerwindow_enseq_main_region_Normal_operation_r1_Driver_neutral_r1_default(Powerwindow* handle) {
+	/* 'default' enter sequence for region r1 */
+	powerwindow_react_main_region_Normal_operation_r1_Driver_neutral_r1__entry_Default(handle);
+}
+
+/* Default exit sequence for state Normal_operation */
+static void powerwindow_exseq_main_region_Normal_operation(Powerwindow* handle) {
+	/* Default exit sequence for state Normal_operation */
+	powerwindow_exseq_main_region_Normal_operation_r1(handle);
+}
+
+/* Default exit sequence for state Driver_neutral */
+static void powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral(Powerwindow* handle) {
+	/* Default exit sequence for state Driver_neutral */
+	powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral_r1(handle);
+}
+
+/* Default exit sequence for state Passenger_operation */
+static void powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation(Powerwindow* handle) {
+	/* Default exit sequence for state Passenger_operation */
+	handle->stateConfVector[0] = Powerwindow_last_state;
+	handle->stateConfVectorPosition = 0;
+}
+
+/* Default exit sequence for state Passenger_down */
+static void powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down(Powerwindow* handle) {
+	/* Default exit sequence for state Passenger_down */
+	handle->stateConfVector[0] = Powerwindow_last_state;
+	handle->stateConfVectorPosition = 0;
+}
+
+/* Default exit sequence for state Driver_down */
+static void powerwindow_exseq_main_region_Normal_operation_r1_Driver_down(Powerwindow* handle) {
+	/* Default exit sequence for state Driver_down */
+	handle->stateConfVector[0] = Powerwindow_last_state;
+	handle->stateConfVectorPosition = 0;
+}
+
+/* Default exit sequence for state Driver_up */
+static void powerwindow_exseq_main_region_Normal_operation_r1_Driver_up(Powerwindow* handle) {
+	/* Default exit sequence for state Driver_up */
+	handle->stateConfVector[0] = Powerwindow_last_state;
+	handle->stateConfVectorPosition = 0;
+}
+
+/* Default exit sequence for state Passenger_up */
+static void powerwindow_exseq_main_region_Normal_operation_r1_Passenger_up(Powerwindow* handle) {
+	/* Default exit sequence for state Passenger_up */
+	handle->stateConfVector[0] = Powerwindow_last_state;
+	handle->stateConfVectorPosition = 0;
+}
+
+/* Default exit sequence for state Emergency_operation */
+static void powerwindow_exseq_main_region_Emergency_operation(Powerwindow* handle) {
+	/* Default exit sequence for state Emergency_operation */
+	handle->stateConfVector[0] = Powerwindow_last_state;
+	handle->stateConfVectorPosition = 0;
+	powerwindow_exact_main_region_Emergency_operation(handle);
+}
+
+/* Default exit sequence for region main region */
+static void powerwindow_exseq_main_region(Powerwindow* handle) {
+	/* Default exit sequence for region main region */
+	/* Handle exit of all possible states (of powerwindow.main_region) at position 0... */
+	switch(handle->stateConfVector[ 0 ]) {
+		case Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation : {
+			powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation(handle);
+			break;
+		}
+		case Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down : {
+			powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down(handle);
+			break;
+		}
+		case Powerwindow_main_region_Normal_operation_r1_Driver_down : {
+			powerwindow_exseq_main_region_Normal_operation_r1_Driver_down(handle);
+			break;
+		}
+		case Powerwindow_main_region_Normal_operation_r1_Driver_up : {
+			powerwindow_exseq_main_region_Normal_operation_r1_Driver_up(handle);
+			break;
+		}
+		case Powerwindow_main_region_Normal_operation_r1_Passenger_up : {
+			powerwindow_exseq_main_region_Normal_operation_r1_Passenger_up(handle);
+			break;
+		}
+		case Powerwindow_main_region_Emergency_operation : {
+			powerwindow_exseq_main_region_Emergency_operation(handle);
+			break;
+		}
+		default: break;
+	}
+}
+
+/* Default exit sequence for region r1 */
+static void powerwindow_exseq_main_region_Normal_operation_r1(Powerwindow* handle) {
+	/* Default exit sequence for region r1 */
+	/* Handle exit of all possible states (of powerwindow.main_region.Normal_operation.r1) at position 0... */
+	switch(handle->stateConfVector[ 0 ]) {
+		case Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation : {
+			powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation(handle);
+			break;
+		}
+		case Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down : {
+			powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down(handle);
+			break;
+		}
+		case Powerwindow_main_region_Normal_operation_r1_Driver_down : {
+			powerwindow_exseq_main_region_Normal_operation_r1_Driver_down(handle);
+			break;
+		}
+		case Powerwindow_main_region_Normal_operation_r1_Driver_up : {
+			powerwindow_exseq_main_region_Normal_operation_r1_Driver_up(handle);
+			break;
+		}
+		case Powerwindow_main_region_Normal_operation_r1_Passenger_up : {
+			powerwindow_exseq_main_region_Normal_operation_r1_Passenger_up(handle);
+			break;
+		}
+		default: break;
+	}
+}
+
+/* Default exit sequence for region r1 */
+static void powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral_r1(Powerwindow* handle) {
+	/* Default exit sequence for region r1 */
+	/* Handle exit of all possible states (of powerwindow.main_region.Normal_operation.r1.Driver_neutral.r1) at position 0... */
+	switch(handle->stateConfVector[ 0 ]) {
+		case Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation : {
+			powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation(handle);
+			break;
+		}
+		case Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down : {
+			powerwindow_exseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down(handle);
+			break;
+		}
+		default: break;
+	}
+}
+
+/* The reactions of state Passenger_operation. */
+static void powerwindow_react_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation(Powerwindow* handle) {
+	/* The reactions of state Passenger_operation. */
+	if (powerwindow_check_main_region_Normal_operation_tr0_tr0(handle)) { 
+		powerwindow_effect_main_region_Normal_operation_tr0(handle);
+	}  else {
+		if (powerwindow_check_main_region_Normal_operation_r1_Driver_neutral_tr0_tr0(handle)) { 
+			powerwindow_effect_main_region_Normal_operation_r1_Driver_neutral_tr0(handle);
+		}  else {
+			if (powerwindow_check_main_region_Normal_operation_r1_Driver_neutral_tr1_tr1(handle)) { 
+				powerwindow_effect_main_region_Normal_operation_r1_Driver_neutral_tr1(handle);
+			}  else {
+				if (powerwindow_check_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation_tr0_tr0(handle)) { 
+					powerwindow_effect_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation_tr0(handle);
+				}  else {
+					if (powerwindow_check_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation_tr1_tr1(handle)) { 
+						powerwindow_effect_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation_tr1(handle);
+					} 
+				}
+			}
+		}
+	}
+}
+
+/* The reactions of state Passenger_down. */
+static void powerwindow_react_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down(Powerwindow* handle) {
+	/* The reactions of state Passenger_down. */
+	if (powerwindow_check_main_region_Normal_operation_tr0_tr0(handle)) { 
+		powerwindow_effect_main_region_Normal_operation_tr0(handle);
+	}  else {
+		if (powerwindow_check_main_region_Normal_operation_r1_Driver_neutral_tr0_tr0(handle)) { 
+			powerwindow_effect_main_region_Normal_operation_r1_Driver_neutral_tr0(handle);
+		}  else {
+			if (powerwindow_check_main_region_Normal_operation_r1_Driver_neutral_tr1_tr1(handle)) { 
+				powerwindow_effect_main_region_Normal_operation_r1_Driver_neutral_tr1(handle);
+			}  else {
+				if (powerwindow_check_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down_tr0_tr0(handle)) { 
+					powerwindow_effect_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down_tr0(handle);
+				} 
+			}
+		}
+	}
+}
+
+/* The reactions of state Driver_down. */
+static void powerwindow_react_main_region_Normal_operation_r1_Driver_down(Powerwindow* handle) {
+	/* The reactions of state Driver_down. */
+	if (powerwindow_check_main_region_Normal_operation_tr0_tr0(handle)) { 
+		powerwindow_effect_main_region_Normal_operation_tr0(handle);
+	}  else {
+		if (powerwindow_check_main_region_Normal_operation_r1_Driver_down_tr0_tr0(handle)) { 
+			powerwindow_effect_main_region_Normal_operation_r1_Driver_down_tr0(handle);
+		} 
+	}
+}
+
+/* The reactions of state Driver_up. */
+static void powerwindow_react_main_region_Normal_operation_r1_Driver_up(Powerwindow* handle) {
+	/* The reactions of state Driver_up. */
+	if (powerwindow_check_main_region_Normal_operation_tr0_tr0(handle)) { 
+		powerwindow_effect_main_region_Normal_operation_tr0(handle);
+	}  else {
+		if (powerwindow_check_main_region_Normal_operation_r1_Driver_up_tr0_tr0(handle)) { 
+			powerwindow_effect_main_region_Normal_operation_r1_Driver_up_tr0(handle);
+		} 
+	}
+}
+
+/* The reactions of state Passenger_up. */
+static void powerwindow_react_main_region_Normal_operation_r1_Passenger_up(Powerwindow* handle) {
+	/* The reactions of state Passenger_up. */
+	if (powerwindow_check_main_region_Normal_operation_tr0_tr0(handle)) { 
+		powerwindow_effect_main_region_Normal_operation_tr0(handle);
+	}  else {
+		if (powerwindow_check_main_region_Normal_operation_r1_Passenger_up_tr0_tr0(handle)) { 
+			powerwindow_effect_main_region_Normal_operation_r1_Passenger_up_tr0(handle);
+		} 
+	}
+}
+
+/* The reactions of state Emergency_operation. */
+static void powerwindow_react_main_region_Emergency_operation(Powerwindow* handle) {
+	/* The reactions of state Emergency_operation. */
+	if (powerwindow_check_main_region_Emergency_operation_tr0_tr0(handle)) { 
+		powerwindow_effect_main_region_Emergency_operation_tr0(handle);
+	} 
+}
+
+/* Default react sequence for initial entry  */
+static void powerwindow_react_main_region__entry_Default(Powerwindow* handle) {
+	/* Default react sequence for initial entry  */
+	powerwindow_enseq_main_region_Normal_operation_default(handle);
+}
+
+/* Default react sequence for initial entry  */
+static void powerwindow_react_main_region_Normal_operation_r1__entry_Default(Powerwindow* handle) {
+	/* Default react sequence for initial entry  */
+	powerwindow_enseq_main_region_Normal_operation_r1_Driver_neutral_default(handle);
+}
+
+/* Default react sequence for initial entry  */
+static void powerwindow_react_main_region_Normal_operation_r1_Driver_neutral_r1__entry_Default(Powerwindow* handle) {
+	/* Default react sequence for initial entry  */
+	powerwindow_enseq_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation_default(handle);
+}
+
+

+ 124 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/Powerwindow.h

@@ -0,0 +1,124 @@
+
+#ifndef POWERWINDOW_H_
+#define POWERWINDOW_H_
+
+#include "sc_types.h"
+
+#ifdef __cplusplus
+extern "C" { 
+#endif 
+
+/*! \file Header of the state machine 'powerwindow'.
+*/
+
+/*! Enumeration of all states */ 
+typedef enum {
+	Powerwindow_main_region_Normal_operation,
+	Powerwindow_main_region_Normal_operation_r1_Driver_neutral,
+	Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation,
+	Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down,
+	Powerwindow_main_region_Normal_operation_r1_Driver_down,
+	Powerwindow_main_region_Normal_operation_r1_Driver_up,
+	Powerwindow_main_region_Normal_operation_r1_Passenger_up,
+	Powerwindow_main_region_Emergency_operation,
+	Powerwindow_last_state
+} PowerwindowStates;
+
+/*! Type definition of the data structure for the PowerwindowIfaceOutput interface scope. */
+typedef struct {
+	sc_boolean up;
+	sc_boolean down;
+} PowerwindowIfaceOutput;
+
+/*! Type definition of the data structure for the PowerwindowIfaceInput interface scope. */
+typedef struct {
+	sc_boolean obj_detected_raised;
+	sc_boolean passenger_up_raised;
+	sc_boolean passenger_down_raised;
+	sc_boolean driver_up_raised;
+	sc_boolean driver_down_raised;
+	sc_boolean stop_raised;
+} PowerwindowIfaceInput;
+
+/*! Type definition of the data structure for the PowerwindowTimeEvents interface scope. */
+typedef struct {
+	sc_boolean powerwindow_main_region_Emergency_operation_tev0_raised;
+} PowerwindowTimeEvents;
+
+
+/*! Define dimension of the state configuration vector for orthogonal states. */
+#define POWERWINDOW_MAX_ORTHOGONAL_STATES 1
+
+/*! 
+ * Type definition of the data structure for the Powerwindow state machine.
+ * This data structure has to be allocated by the client code. 
+ */
+typedef struct {
+	PowerwindowStates stateConfVector[POWERWINDOW_MAX_ORTHOGONAL_STATES];
+	sc_ushort stateConfVectorPosition; 
+	
+	PowerwindowIfaceOutput ifaceOutput;
+	PowerwindowIfaceInput ifaceInput;
+	PowerwindowTimeEvents timeEvents;
+} Powerwindow;
+
+void powerwindow_copy(Powerwindow* original, Powerwindow* copy);
+
+/*! Initializes the Powerwindow state machine data structures. Must be called before first usage.*/
+extern void powerwindow_init(Powerwindow* handle);
+
+/*! Activates the state machine */
+extern void powerwindow_enter(Powerwindow* handle);
+
+/*! Deactivates the state machine */
+extern void powerwindow_exit(Powerwindow* handle);
+
+/*! Performs a 'run to completion' step. */
+extern void powerwindow_runCycle(Powerwindow* handle);
+
+/*! Raises a time event. */
+extern void powerwindow_raiseTimeEvent(const Powerwindow* handle, sc_eventid evid);
+
+/*! Gets the value of the variable 'up' that is defined in the interface scope 'output'. */ 
+extern sc_boolean powerwindowIfaceOutput_get_up(const Powerwindow* handle);
+/*! Gets the value of the variable 'down' that is defined in the interface scope 'output'. */ 
+extern sc_boolean powerwindowIfaceOutput_get_down(const Powerwindow* handle);
+/*! Raises the in event 'obj_detected' that is defined in the interface scope 'input'. */ 
+extern void powerwindowIfaceInput_raise_obj_detected(Powerwindow* handle);
+
+/*! Raises the in event 'passenger_up' that is defined in the interface scope 'input'. */ 
+extern void powerwindowIfaceInput_raise_passenger_up(Powerwindow* handle);
+
+/*! Raises the in event 'passenger_down' that is defined in the interface scope 'input'. */ 
+extern void powerwindowIfaceInput_raise_passenger_down(Powerwindow* handle);
+
+/*! Raises the in event 'driver_up' that is defined in the interface scope 'input'. */ 
+extern void powerwindowIfaceInput_raise_driver_up(Powerwindow* handle);
+
+/*! Raises the in event 'driver_down' that is defined in the interface scope 'input'. */ 
+extern void powerwindowIfaceInput_raise_driver_down(Powerwindow* handle);
+
+/*! Raises the in event 'stop' that is defined in the interface scope 'input'. */ 
+extern void powerwindowIfaceInput_raise_stop(Powerwindow* handle);
+
+
+/*!
+ * Checks if the statemachine is active (until 2.4.1 this method was used for states).
+ * A statemachine is active if it was entered. It is inactive if it has not been entered at all or if it was exited.
+ */
+extern sc_boolean powerwindow_isActive(const Powerwindow* handle);
+
+/*!
+ * Checks if all active states are final. 
+ * If there are no active states then the statemachine is considered as inactive and this method returns false.
+ */
+extern sc_boolean powerwindow_isFinal(const Powerwindow* handle);
+
+/*! Checks if the specified state is active (until 2.4.1 the used method for states was calles isActive()). */
+extern sc_boolean powerwindow_isStateActive(const Powerwindow* handle, PowerwindowStates state);
+
+#ifdef __cplusplus
+}
+#endif 
+
+#endif /* POWERWINDOW_H_ */

+ 67 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/PowerwindowRequired.c

@@ -0,0 +1,67 @@
+/*
+ * PowerwindowRequired.c
+ *
+ *  Created on: Jan 26, 2017
+ *      Author: Joachim
+ */
+
+
+#include "PowerwindowRequired.h"
+#include <math.h>
+
+/*
+ * I only check on the bigger than compare with the double
+ * This should be changed
+ */
+
+ double relativeError(double a, double b){
+	double rv = fabs((a - b) / a);
+	return rv;
+}
+
+/*
+ * Helper function for absolute error
+ */
+ double absoluteError(double a, double b){
+	double rv=fabs(a - b);
+	return rv;
+}
+
+/*
+ * is_close function for double comparison
+ */
+ int is_close(double a, double b, double REL_TOL, double ABS_TOL){
+	 int ae = absoluteError(a,b)<ABS_TOL;
+	 int re = relativeError(a,b)<REL_TOL;
+	return (ae && re);
+}
+
+void powerwindow_timeradvance(fmi_timer *theTimer, double currentTime){
+	theTimer->currentTime = currentTime;
+	if (theTimer->active && is_close(theTimer->nextTime, theTimer->currentTime,1e-4,1e-8)){
+		/* We have a timer event */
+		theTimer->callback(theTimer->handle, theTimer->evid);
+		if(theTimer->isPeriodic){
+			theTimer->nextTime = currentTime + theTimer->period;
+		}else{
+			theTimer->active = 0;
+		}
+	}
+}
+
+void powerwindow_initTimer(fmi_timer *timer){
+	thePWTimer = timer;
+}
+
+void powerwindow_setTimer(Powerwindow* handle, const sc_eventid evid, const sc_integer time_ms, const sc_boolean periodic){
+	thePWTimer->active = 1;
+	thePWTimer->handle = handle;
+	thePWTimer->evid = evid;
+	thePWTimer->period = time_ms;
+	thePWTimer->nextTime = thePWTimer->currentTime + time_ms;
+	thePWTimer->isPeriodic = periodic;
+}
+
+void powerwindow_unsetTimer(Powerwindow* handle, const sc_eventid evid){
+	thePWTimer->active = 0;
+}

+ 82 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/PowerwindowRequired.h

@@ -0,0 +1,82 @@
+
+#ifndef POWERWINDOWREQUIRED_H_
+#define POWERWINDOWREQUIRED_H_
+
+#include "sc_types.h"
+#include "Powerwindow.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif 
+
+/*! \file This header defines prototypes for all functions that are required by the state machine implementation.
+
+This is a state machine uses time events which require access to a timing service. Thus the function prototypes:
+	- powerwindow_setTimer and
+	- powerwindow_unsetTimer
+are defined.
+
+These functions will be called during a 'run to completion step' (runCycle) of the statechart. 
+There are some constraints that have to be considered for the implementation of these functions:
+	- never call the statechart API functions from within these functions.
+	- make sure that the execution time is as short as possible.
+ 
+*/
+
+/*
+ * This is a simple hack; for a real FMI code gen for Yakindu, make this a bit more generic
+ */
+
+
+double relativeError(double a, double b);
+
+/*
+* Helper function for absolute error
+*/
+double absoluteError(double a, double b);
+
+/*
+* is_close function for double comparison
+*/
+int is_close(double a, double b, double REL_TOL, double ABS_TOL);
+
+typedef struct{
+	double nextTime;
+	double currentTime;
+	Powerwindow * handle;
+	sc_eventid evid;
+	int period;
+	int isPeriodic;
+	int active;
+	void (*callback) (const Powerwindow*, sc_eventid evid);
+}fmi_timer;
+
+fmi_timer *thePWTimer;
+
+void powerwindow_timeradvance(fmi_timer *theTimer, double currentTime);
+void powerwindow_initTimer(fmi_timer *timer);
+/*!
+ * This is a timed state machine that requires timer services
+ */ 
+
+/*! This function has to set up timers for the time events that are required by the state machine. */
+/*! 
+	This function will be called for each time event that is relevant for a state when a state will be entered.
+	\param evid An unique identifier of the event.
+	\time_ms The time in milli seconds
+	\periodic Indicates the the time event must be raised periodically until the timer is unset 
+*/
+extern void powerwindow_setTimer(Powerwindow* handle, const sc_eventid evid, const sc_integer time_ms, const sc_boolean periodic);
+
+/*! This function has to unset timers for the time events that are required by the state machine. */
+/*! 
+	This function will be called for each time event taht is relevant for a state when a state will be left.
+	\param evid An unique identifier of the event.
+*/
+extern void powerwindow_unsetTimer(Powerwindow* handle, const sc_eventid evid);
+
+#ifdef __cplusplus
+}
+#endif 
+
+#endif /* POWERWINDOWREQUIRED_H_ */

+ 6 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/build.ps1

@@ -0,0 +1,6 @@
+rm "Debug\*"
+
+mingw32-make clean makefile
+mingw32-make lib makefile
+
+pause

+ 72 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/fmi2/fmi2.h

@@ -0,0 +1,72 @@
+/* -------------------------------------------------------------------------
+ * fmi.h
+ * Struct with the corresponding function pointers for FMI 2.0.
+ * Copyright QTronic GmbH. All rights reserved.
+ * -------------------------------------------------------------------------*/
+
+#ifndef FMI_H
+#define FMI_H
+
+#include "fmi2Functions.h"
+
+typedef struct {
+//    ModelDescription* modelDescription;
+
+    void  *dllHandle; // fmu.so handle
+    /***************************************************
+    Common Functions
+    ****************************************************/
+    fmi2GetTypesPlatformTYPE         *getTypesPlatform;
+    fmi2GetVersionTYPE               *getVersion;
+    fmi2SetDebugLoggingTYPE          *setDebugLogging;
+    fmi2InstantiateTYPE              *instantiate;
+    fmi2FreeInstanceTYPE             *freeInstance;
+    fmi2SetupExperimentTYPE          *setupExperiment;
+    fmi2EnterInitializationModeTYPE  *enterInitializationMode;
+    fmi2ExitInitializationModeTYPE   *exitInitializationMode;
+    fmi2TerminateTYPE                *terminate;
+    fmi2ResetTYPE                    *reset;
+    fmi2GetRealTYPE                  *getReal;
+    fmi2GetIntegerTYPE               *getInteger;
+    fmi2GetBooleanTYPE               *getBoolean;
+    fmi2GetStringTYPE                *getString;
+    fmi2SetRealTYPE                  *setReal;
+    fmi2SetIntegerTYPE               *setInteger;
+    fmi2SetBooleanTYPE               *setBoolean;
+    fmi2SetStringTYPE                *setString;
+    fmi2GetFMUstateTYPE              *getFMUstate;
+    fmi2SetFMUstateTYPE              *setFMUstate;
+    fmi2FreeFMUstateTYPE             *freeFMUstate;
+    fmi2SerializedFMUstateSizeTYPE   *serializedFMUstateSize;
+    fmi2SerializeFMUstateTYPE        *serializeFMUstate;
+    fmi2DeSerializeFMUstateTYPE      *deSerializeFMUstate;
+    fmi2GetDirectionalDerivativeTYPE *getDirectionalDerivative;
+    /***************************************************
+    Functions for FMI2 for Co-Simulation
+    ****************************************************/
+    fmi2SetRealInputDerivativesTYPE  *setRealInputDerivatives;
+    fmi2GetRealOutputDerivativesTYPE *getRealOutputDerivatives;
+    fmi2DoStepTYPE                   *doStep;
+    fmi2CancelStepTYPE               *cancelStep;
+    fmi2GetStatusTYPE                *getStatus;
+    fmi2GetRealStatusTYPE            *getRealStatus;
+    fmi2GetIntegerStatusTYPE         *getIntegerStatus;
+    fmi2GetBooleanStatusTYPE         *getBooleanStatus;
+    fmi2GetStringStatusTYPE          *getStringStatus;
+    /***************************************************
+    Functions for FMI2 for Model Exchange
+    ****************************************************/
+    fmi2EnterEventModeTYPE                *enterEventMode;
+    fmi2NewDiscreteStatesTYPE             *newDiscreteStates;
+    fmi2EnterContinuousTimeModeTYPE       *enterContinuousTimeMode;
+    fmi2CompletedIntegratorStepTYPE       *completedIntegratorStep;
+    fmi2SetTimeTYPE                       *setTime;
+    fmi2SetContinuousStatesTYPE           *setContinuousStates;
+    fmi2GetDerivativesTYPE                *getDerivatives;
+    fmi2GetEventIndicatorsTYPE            *getEventIndicators;
+    fmi2GetContinuousStatesTYPE           *getContinuousStates;
+    fmi2GetNominalsOfContinuousStatesTYPE *getNominalsOfContinuousStates;
+} FMU;
+
+#endif // FMI_H
+

+ 247 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/fmi2/fmi2FunctionTypes.h

@@ -0,0 +1,247 @@
+#ifndef fmi2FunctionTypes_h
+#define fmi2FunctionTypes_h
+
+#include "fmi2TypesPlatform.h"
+
+/* This header file must be utilized when compiling an FMU or an FMI master.
+   It declares data and function types for FMI 2.0
+
+   Revisions:
+   - Apr.  9, 2014: all prefixes "fmi" renamed to "fmi2" (decision from April 8)
+   - Apr.  3, 2014: Added #include <stddef.h> for size_t definition
+   - Mar. 27, 2014: Added #include "fmiTypesPlatform.h" (#179)
+   - Mar. 26, 2014: Introduced function argument "void" for the functions (#171)
+                      fmiGetTypesPlatformTYPE and fmiGetVersionTYPE
+   - Oct. 11, 2013: Functions of ModelExchange and CoSimulation merged:
+                      fmiInstantiateModelTYPE , fmiInstantiateSlaveTYPE  -> fmiInstantiateTYPE
+                      fmiFreeModelInstanceTYPE, fmiFreeSlaveInstanceTYPE -> fmiFreeInstanceTYPE
+                      fmiEnterModelInitializationModeTYPE, fmiEnterSlaveInitializationModeTYPE -> fmiEnterInitializationModeTYPE
+                      fmiExitModelInitializationModeTYPE , fmiExitSlaveInitializationModeTYPE  -> fmiExitInitializationModeTYPE
+                      fmiTerminateModelTYPE , fmiTerminateSlaveTYPE  -> fmiTerminate
+                      fmiResetSlave -> fmiReset (now also for ModelExchange and not only for CoSimulation)
+                    Functions renamed
+                      fmiUpdateDiscreteStatesTYPE -> fmiNewDiscreteStatesTYPE
+                    Renamed elements of the enumeration fmiEventInfo
+                      upcomingTimeEvent             -> nextEventTimeDefined // due to generic naming scheme: varDefined + var
+                      newUpdateDiscreteStatesNeeded -> newDiscreteStatesNeeded;
+   - June 13, 2013: Changed type fmiEventInfo
+                    Functions removed:
+                       fmiInitializeModelTYPE
+                       fmiEventUpdateTYPE
+                       fmiCompletedEventIterationTYPE
+                       fmiInitializeSlaveTYPE
+                    Functions added:
+                       fmiEnterModelInitializationModeTYPE
+                       fmiExitModelInitializationModeTYPE
+                       fmiEnterEventModeTYPE
+                       fmiUpdateDiscreteStatesTYPE
+                       fmiEnterContinuousTimeModeTYPE
+                       fmiEnterSlaveInitializationModeTYPE;
+                       fmiExitSlaveInitializationModeTYPE;
+   - Feb. 17, 2013: Added third argument to fmiCompletedIntegratorStepTYPE
+                    Changed function name "fmiTerminateType" to "fmiTerminateModelType" (due to #113)
+                    Changed function name "fmiGetNominalContinuousStateTYPE" to
+                                          "fmiGetNominalsOfContinuousStatesTYPE"
+                    Removed fmiGetStateValueReferencesTYPE.
+   - Nov. 14, 2011: First public Version
+
+
+   Copyright (C) 2011 MODELISAR consortium,
+               2012-2013 Modelica Association Project "FMI"
+               All rights reserved.
+   This file is licensed by the copyright holders under the BSD 2-Clause License
+   (http://www.opensource.org/licenses/bsd-license.html):
+
+   ----------------------------------------------------------------------------
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are met:
+
+   - Redistributions of source code must retain the above copyright notice,
+     this list of conditions and the following disclaimer.
+   - Redistributions in binary form must reproduce the above copyright notice,
+     this list of conditions and the following disclaimer in the documentation
+     and/or other materials provided with the distribution.
+   - Neither the name of the copyright holders nor the names of its
+     contributors may be used to endorse or promote products derived
+     from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+   ----------------------------------------------------------------------------
+
+   with the extension:
+
+   You may distribute or publicly perform any modification only under the
+   terms of this license.
+   (Note, this means that if you distribute a modified file,
+    the modified file must also be provided under this license).
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* make sure all compiler use the same alignment policies for structures */
+#if defined _MSC_VER || defined __GNUC__
+#pragma pack(push,8)
+#endif
+
+/* Include stddef.h, in order that size_t etc. is defined */
+#include <stddef.h>
+
+
+/* Type definitions */
+typedef enum {
+    fmi2OK,
+    fmi2Warning,
+    fmi2Discard,
+    fmi2Error,
+    fmi2Fatal,
+    fmi2Pending
+} fmi2Status;
+
+typedef enum {
+    fmi2ModelExchange,
+    fmi2CoSimulation
+} fmi2Type;
+
+typedef enum {
+    fmi2DoStepStatus,
+    fmi2PendingStatus,
+    fmi2LastSuccessfulTime,
+    fmi2Terminated
+} fmi2StatusKind;
+
+typedef void      (*fmi2CallbackLogger)        (fmi2ComponentEnvironment, fmi2String, fmi2Status, fmi2String, fmi2String, ...);
+typedef void*     (*fmi2CallbackAllocateMemory)(size_t, size_t);
+typedef void      (*fmi2CallbackFreeMemory)    (void*);
+typedef void      (*fmi2StepFinished)          (fmi2ComponentEnvironment, fmi2Status);
+
+typedef struct {
+   const fmi2CallbackLogger         logger;
+   const fmi2CallbackAllocateMemory allocateMemory;
+   const fmi2CallbackFreeMemory     freeMemory;
+   const fmi2StepFinished           stepFinished;
+   const fmi2ComponentEnvironment   componentEnvironment;
+} fmi2CallbackFunctions;
+
+typedef struct {
+   fmi2Boolean newDiscreteStatesNeeded;
+   fmi2Boolean terminateSimulation;
+   fmi2Boolean nominalsOfContinuousStatesChanged;
+   fmi2Boolean valuesOfContinuousStatesChanged;
+   fmi2Boolean nextEventTimeDefined;
+   fmi2Real    nextEventTime;
+} fmi2EventInfo;
+
+
+/* reset alignment policy to the one set before reading this file */
+#if defined _MSC_VER || defined __GNUC__
+#pragma pack(pop)
+#endif
+
+
+/* Define fmi2 function pointer types to simplify dynamic loading */
+
+/***************************************************
+Types for Common Functions
+****************************************************/
+
+/* Inquire version numbers of header files and setting logging status */
+   typedef const char* fmi2GetTypesPlatformTYPE(void);
+   typedef const char* fmi2GetVersionTYPE(void);
+   typedef fmi2Status  fmi2SetDebugLoggingTYPE(fmi2Component, fmi2Boolean, size_t, const fmi2String[]);
+
+/* Creation and destruction of FMU instances and setting debug status */
+   typedef fmi2Component fmi2InstantiateTYPE (fmi2String, fmi2Type, fmi2String, fmi2String, const fmi2CallbackFunctions*, fmi2Boolean, fmi2Boolean);
+   typedef void          fmi2FreeInstanceTYPE(fmi2Component);
+
+/* Enter and exit initialization mode, terminate and reset */
+   typedef fmi2Status fmi2SetupExperimentTYPE        (fmi2Component, fmi2Boolean, fmi2Real, fmi2Real, fmi2Boolean, fmi2Real);
+   typedef fmi2Status fmi2EnterInitializationModeTYPE(fmi2Component);
+   typedef fmi2Status fmi2ExitInitializationModeTYPE (fmi2Component);
+   typedef fmi2Status fmi2TerminateTYPE              (fmi2Component);
+   typedef fmi2Status fmi2ResetTYPE                  (fmi2Component);
+
+/* Getting and setting variable values */
+   typedef fmi2Status fmi2GetRealTYPE   (fmi2Component, const fmi2ValueReference[], size_t, fmi2Real   []);
+   typedef fmi2Status fmi2GetIntegerTYPE(fmi2Component, const fmi2ValueReference[], size_t, fmi2Integer[]);
+   typedef fmi2Status fmi2GetBooleanTYPE(fmi2Component, const fmi2ValueReference[], size_t, fmi2Boolean[]);
+   typedef fmi2Status fmi2GetStringTYPE (fmi2Component, const fmi2ValueReference[], size_t, fmi2String []);
+
+   typedef fmi2Status fmi2SetRealTYPE   (fmi2Component, const fmi2ValueReference[], size_t, const fmi2Real   []);
+   typedef fmi2Status fmi2SetIntegerTYPE(fmi2Component, const fmi2ValueReference[], size_t, const fmi2Integer[]);
+   typedef fmi2Status fmi2SetBooleanTYPE(fmi2Component, const fmi2ValueReference[], size_t, const fmi2Boolean[]);
+   typedef fmi2Status fmi2SetStringTYPE (fmi2Component, const fmi2ValueReference[], size_t, const fmi2String []);
+
+/* Getting and setting the internal FMU state */
+   typedef fmi2Status fmi2GetFMUstateTYPE           (fmi2Component, fmi2FMUstate*);
+   typedef fmi2Status fmi2SetFMUstateTYPE           (fmi2Component, fmi2FMUstate);
+   typedef fmi2Status fmi2FreeFMUstateTYPE          (fmi2Component, fmi2FMUstate*);
+   typedef fmi2Status fmi2SerializedFMUstateSizeTYPE(fmi2Component, fmi2FMUstate, size_t*);
+   typedef fmi2Status fmi2SerializeFMUstateTYPE     (fmi2Component, fmi2FMUstate, fmi2Byte[], size_t);
+   typedef fmi2Status fmi2DeSerializeFMUstateTYPE   (fmi2Component, const fmi2Byte[], size_t, fmi2FMUstate*);
+
+/* Getting partial derivatives */
+   typedef fmi2Status fmi2GetDirectionalDerivativeTYPE(fmi2Component, const fmi2ValueReference[], size_t,
+                                                                   const fmi2ValueReference[], size_t,
+                                                                   const fmi2Real[], fmi2Real[]);
+
+/***************************************************
+Types for Functions for FMI2 for Model Exchange
+****************************************************/
+
+/* Enter and exit the different modes */
+   typedef fmi2Status fmi2EnterEventModeTYPE         (fmi2Component);
+   typedef fmi2Status fmi2NewDiscreteStatesTYPE      (fmi2Component, fmi2EventInfo*);
+   typedef fmi2Status fmi2EnterContinuousTimeModeTYPE(fmi2Component);
+   typedef fmi2Status fmi2CompletedIntegratorStepTYPE(fmi2Component, fmi2Boolean, fmi2Boolean*, fmi2Boolean*);
+
+/* Providing independent variables and re-initialization of caching */
+   typedef fmi2Status fmi2SetTimeTYPE            (fmi2Component, fmi2Real);
+   typedef fmi2Status fmi2SetContinuousStatesTYPE(fmi2Component, const fmi2Real[], size_t);
+
+/* Evaluation of the model equations */
+   typedef fmi2Status fmi2GetDerivativesTYPE               (fmi2Component, fmi2Real[], size_t);
+#ifdef FMU_EXPERIMENTAL
+   typedef fmi2Status fmi2GetSpecificDerivativesTYPE       (fmi2Component, fmi2Real[], const fmi2ValueReference [], size_t);
+#endif
+
+   typedef fmi2Status fmi2GetEventIndicatorsTYPE           (fmi2Component, fmi2Real[], size_t);
+   typedef fmi2Status fmi2GetContinuousStatesTYPE          (fmi2Component, fmi2Real[], size_t);
+   typedef fmi2Status fmi2GetNominalsOfContinuousStatesTYPE(fmi2Component, fmi2Real[], size_t);
+
+
+/***************************************************
+Types for Functions for FMI2 for Co-Simulation
+****************************************************/
+
+/* Simulating the slave */
+   typedef fmi2Status fmi2SetRealInputDerivativesTYPE (fmi2Component, const fmi2ValueReference [], size_t, const fmi2Integer [], const fmi2Real []);
+   typedef fmi2Status fmi2GetRealOutputDerivativesTYPE(fmi2Component, const fmi2ValueReference [], size_t, const fmi2Integer [], fmi2Real []);
+
+   typedef fmi2Status fmi2DoStepTYPE     (fmi2Component, fmi2Real, fmi2Real, fmi2Boolean);
+   typedef fmi2Status fmi2CancelStepTYPE (fmi2Component);
+
+/* Inquire slave status */
+   typedef fmi2Status fmi2GetStatusTYPE       (fmi2Component, const fmi2StatusKind, fmi2Status* );
+   typedef fmi2Status fmi2GetRealStatusTYPE   (fmi2Component, const fmi2StatusKind, fmi2Real*   );
+   typedef fmi2Status fmi2GetIntegerStatusTYPE(fmi2Component, const fmi2StatusKind, fmi2Integer*);
+   typedef fmi2Status fmi2GetBooleanStatusTYPE(fmi2Component, const fmi2StatusKind, fmi2Boolean*);
+   typedef fmi2Status fmi2GetStringStatusTYPE (fmi2Component, const fmi2StatusKind, fmi2String* );
+
+
+#ifdef __cplusplus
+}  /* end of extern "C" { */
+#endif
+
+#endif /* fmi2FunctionTypes_h */

+ 339 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/fmi2/fmi2Functions.h

@@ -0,0 +1,339 @@
+#ifndef fmi2Functions_h
+#define fmi2Functions_h
+
+/* This header file must be utilized when compiling a FMU.
+   It defines all functions of the
+         FMI 2.0 Model Exchange and Co-Simulation Interface.
+
+   In order to have unique function names even if several FMUs
+   are compiled together (e.g. for embedded systems), every "real" function name
+   is constructed by prepending the function name by "FMI2_FUNCTION_PREFIX".
+   Therefore, the typical usage is:
+
+      #define FMI2_FUNCTION_PREFIX MyModel_
+      #include "fmi2Functions.h"
+
+   As a result, a function that is defined as "fmi2GetDerivatives" in this header file,
+   is actually getting the name "MyModel_fmi2GetDerivatives".
+
+   This only holds if the FMU is shipped in C source code, or is compiled in a
+   static link library. For FMUs compiled in a DLL/sharedObject, the "actual" function
+   names are used and "FMI2_FUNCTION_PREFIX" must not be defined.
+
+   Revisions:
+   - Apr.  9, 2014: all prefixes "fmi" renamed to "fmi2" (decision from April 8)
+   - Mar. 26, 2014: FMI_Export set to empty value if FMI_Export and FMI_FUNCTION_PREFIX
+                    are not defined (#173)
+   - Oct. 11, 2013: Functions of ModelExchange and CoSimulation merged:
+                      fmiInstantiateModel , fmiInstantiateSlave  -> fmiInstantiate
+                      fmiFreeModelInstance, fmiFreeSlaveInstance -> fmiFreeInstance
+                      fmiEnterModelInitializationMode, fmiEnterSlaveInitializationMode -> fmiEnterInitializationMode
+                      fmiExitModelInitializationMode , fmiExitSlaveInitializationMode  -> fmiExitInitializationMode
+                      fmiTerminateModel, fmiTerminateSlave  -> fmiTerminate
+                      fmiResetSlave -> fmiReset (now also for ModelExchange and not only for CoSimulation)
+                    Functions renamed:
+                      fmiUpdateDiscreteStates -> fmiNewDiscreteStates
+   - June 13, 2013: Functions removed:
+                       fmiInitializeModel
+                       fmiEventUpdate
+                       fmiCompletedEventIteration
+                       fmiInitializeSlave
+                    Functions added:
+                       fmiEnterModelInitializationMode
+                       fmiExitModelInitializationMode
+                       fmiEnterEventMode
+                       fmiUpdateDiscreteStates
+                       fmiEnterContinuousTimeMode
+                       fmiEnterSlaveInitializationMode;
+                       fmiExitSlaveInitializationMode;
+   - Feb. 17, 2013: Portability improvements:
+                       o DllExport changed to FMI_Export
+                       o FUNCTION_PREFIX changed to FMI_FUNCTION_PREFIX
+                       o Allow undefined FMI_FUNCTION_PREFIX (meaning no prefix is used)
+                    Changed function name "fmiTerminate" to "fmiTerminateModel" (due to #113)
+                    Changed function name "fmiGetNominalContinuousState" to
+                                          "fmiGetNominalsOfContinuousStates"
+                    Removed fmiGetStateValueReferences.
+   - Nov. 14, 2011: Adapted to FMI 2.0:
+                       o Split into two files (fmiFunctions.h, fmiTypes.h) in order
+                         that code that dynamically loads an FMU can directly
+                         utilize the header files).
+                       o Added C++ encapsulation of C-part, in order that the header
+                         file can be directly utilized in C++ code.
+                       o fmiCallbackFunctions is passed as pointer to fmiInstantiateXXX
+                       o stepFinished within fmiCallbackFunctions has as first
+                         argument "fmiComponentEnvironment" and not "fmiComponent".
+                       o New functions to get and set the complete FMU state
+                         and to compute partial derivatives.
+   - Nov.  4, 2010: Adapted to specification text:
+                       o fmiGetModelTypesPlatform renamed to fmiGetTypesPlatform
+                       o fmiInstantiateSlave: Argument GUID     replaced by fmuGUID
+                                              Argument mimetype replaced by mimeType
+                       o tabs replaced by spaces
+   - Oct. 16, 2010: Functions for FMI for Co-simulation added
+   - Jan. 20, 2010: stateValueReferencesChanged added to struct fmiEventInfo (ticket #27)
+                    (by M. Otter, DLR)
+                    Added WIN32 pragma to define the struct layout (ticket #34)
+                    (by J. Mauss, QTronic)
+   - Jan.  4, 2010: Removed argument intermediateResults from fmiInitialize
+                    Renamed macro fmiGetModelFunctionsVersion to fmiGetVersion
+                    Renamed macro fmiModelFunctionsVersion to fmiVersion
+                    Replaced fmiModel by fmiComponent in decl of fmiInstantiateModel
+                    (by J. Mauss, QTronic)
+   - Dec. 17, 2009: Changed extension "me" to "fmi" (by Martin Otter, DLR).
+   - Dez. 14, 2009: Added eventInfo to meInitialize and added
+                    meGetNominalContinuousStates (by Martin Otter, DLR)
+   - Sept. 9, 2009: Added DllExport (according to Peter Nilsson's suggestion)
+                    (by A. Junghanns, QTronic)
+   - Sept. 9, 2009: Changes according to FMI-meeting on July 21:
+                    meInquireModelTypesVersion     -> meGetModelTypesPlatform
+                    meInquireModelFunctionsVersion -> meGetModelFunctionsVersion
+                    meSetStates                    -> meSetContinuousStates
+                    meGetStates                    -> meGetContinuousStates
+                    removal of meInitializeModelClass
+                    removal of meGetTime
+                    change of arguments of meInstantiateModel
+                    change of arguments of meCompletedIntegratorStep
+                    (by Martin Otter, DLR):
+   - July 19, 2009: Added "me" as prefix to file names (by Martin Otter, DLR).
+   - March 2, 2009: Changed function definitions according to the last design
+                    meeting with additional improvements (by Martin Otter, DLR).
+   - Dec. 3 , 2008: First version by Martin Otter (DLR) and Hans Olsson (Dynasim).
+
+   Copyright (C) 2008-2011 MODELISAR consortium,
+               2012-2013 Modelica Association Project "FMI"
+               All rights reserved.
+   This file is licensed by the copyright holders under the BSD 2-Clause License
+   (http://www.opensource.org/licenses/bsd-license.html):
+
+   ----------------------------------------------------------------------------
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are met:
+
+   - Redistributions of source code must retain the above copyright notice,
+     this list of conditions and the following disclaimer.
+   - Redistributions in binary form must reproduce the above copyright notice,
+     this list of conditions and the following disclaimer in the documentation
+     and/or other materials provided with the distribution.
+   - Neither the name of the copyright holders nor the names of its
+     contributors may be used to endorse or promote products derived
+     from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+   ----------------------------------------------------------------------------
+
+   with the extension:
+
+   You may distribute or publicly perform any modification only under the
+   terms of this license.
+   (Note, this means that if you distribute a modified file,
+    the modified file must also be provided under this license).
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "fmi2TypesPlatform.h"
+#include "fmi2FunctionTypes.h"
+#include <stdlib.h>
+
+
+/*
+  Export FMI2 API functions on Windows and under GCC.
+  If custom linking is desired then the FMI2_Export must be
+  defined before including this file. For instance,
+  it may be set to __declspec(dllimport).
+*/
+#if !defined(FMI2_Export)
+  #if !defined(FMI2_FUNCTION_PREFIX)
+    #if defined _WIN32 || defined __CYGWIN__
+     /* Note: both gcc & MSVC on Windows support this syntax. */
+        #define FMI2_Export __declspec(dllexport)
+    #else
+      #if __GNUC__ >= 4
+        #define FMI2_Export __attribute__ ((visibility ("default")))
+      #else
+        #define FMI2_Export
+      #endif
+    #endif
+  #else
+    #define FMI2_Export
+  #endif
+#endif
+
+/* Macros to construct the real function name
+   (prepend function name by FMI2_FUNCTION_PREFIX) */
+#if defined(FMI2_FUNCTION_PREFIX)
+  #define fmi2Paste(a,b)     a ## b
+  #define fmi2PasteB(a,b)    fmi2Paste(a,b)
+  #define fmi2FullName(name) fmi2PasteB(FMI2_FUNCTION_PREFIX, name)
+#else
+  #define fmi2FullName(name) name
+#endif
+
+/***************************************************
+Common Functions
+****************************************************/
+#define fmi2GetTypesPlatform         fmi2FullName(fmi2GetTypesPlatform)
+#define fmi2GetVersion               fmi2FullName(fmi2GetVersion)
+#define fmi2SetDebugLogging          fmi2FullName(fmi2SetDebugLogging)
+#define fmi2Instantiate              fmi2FullName(fmi2Instantiate)
+#define fmi2FreeInstance             fmi2FullName(fmi2FreeInstance)
+#define fmi2SetupExperiment          fmi2FullName(fmi2SetupExperiment)
+#define fmi2EnterInitializationMode  fmi2FullName(fmi2EnterInitializationMode)
+#define fmi2ExitInitializationMode   fmi2FullName(fmi2ExitInitializationMode)
+#define fmi2Terminate                fmi2FullName(fmi2Terminate)
+#define fmi2Reset                    fmi2FullName(fmi2Reset)
+#define fmi2GetReal                  fmi2FullName(fmi2GetReal)
+#define fmi2GetInteger               fmi2FullName(fmi2GetInteger)
+#define fmi2GetBoolean               fmi2FullName(fmi2GetBoolean)
+#define fmi2GetString                fmi2FullName(fmi2GetString)
+#define fmi2SetReal                  fmi2FullName(fmi2SetReal)
+#define fmi2SetInteger               fmi2FullName(fmi2SetInteger)
+#define fmi2SetBoolean               fmi2FullName(fmi2SetBoolean)
+#define fmi2SetString                fmi2FullName(fmi2SetString)
+#define fmi2GetFMUstate              fmi2FullName(fmi2GetFMUstate)
+#define fmi2SetFMUstate              fmi2FullName(fmi2SetFMUstate)
+#define fmi2FreeFMUstate             fmi2FullName(fmi2FreeFMUstate)
+#define fmi2SerializedFMUstateSize   fmi2FullName(fmi2SerializedFMUstateSize)
+#define fmi2SerializeFMUstate        fmi2FullName(fmi2SerializeFMUstate)
+#define fmi2DeSerializeFMUstate      fmi2FullName(fmi2DeSerializeFMUstate)
+#define fmi2GetDirectionalDerivative fmi2FullName(fmi2GetDirectionalDerivative)
+
+
+/***************************************************
+Functions for FMI2 for Model Exchange
+****************************************************/
+#define fmi2EnterEventMode                fmi2FullName(fmi2EnterEventMode)
+#define fmi2NewDiscreteStates             fmi2FullName(fmi2NewDiscreteStates)
+#define fmi2EnterContinuousTimeMode       fmi2FullName(fmi2EnterContinuousTimeMode)
+#define fmi2CompletedIntegratorStep       fmi2FullName(fmi2CompletedIntegratorStep)
+#define fmi2SetTime                       fmi2FullName(fmi2SetTime)
+#define fmi2SetContinuousStates           fmi2FullName(fmi2SetContinuousStates)
+#define fmi2GetDerivatives                fmi2FullName(fmi2GetDerivatives)
+#ifdef FMU_EXPERIMENTAL
+#define fmi2GetSpecificDerivatives        fmi2FullName(fmi2GetSpecificDerivatives)
+#endif
+#define fmi2GetEventIndicators            fmi2FullName(fmi2GetEventIndicators)
+#define fmi2GetContinuousStates           fmi2FullName(fmi2GetContinuousStates)
+#define fmi2GetNominalsOfContinuousStates fmi2FullName(fmi2GetNominalsOfContinuousStates)
+
+
+/***************************************************
+Functions for FMI2 for Co-Simulation
+****************************************************/
+#define fmi2SetRealInputDerivatives      fmi2FullName(fmi2SetRealInputDerivatives)
+#define fmi2GetRealOutputDerivatives     fmi2FullName(fmi2GetRealOutputDerivatives)
+#define fmi2DoStep                       fmi2FullName(fmi2DoStep)
+#define fmi2CancelStep                   fmi2FullName(fmi2CancelStep)
+#define fmi2GetStatus                    fmi2FullName(fmi2GetStatus)
+#define fmi2GetRealStatus                fmi2FullName(fmi2GetRealStatus)
+#define fmi2GetIntegerStatus             fmi2FullName(fmi2GetIntegerStatus)
+#define fmi2GetBooleanStatus             fmi2FullName(fmi2GetBooleanStatus)
+#define fmi2GetStringStatus              fmi2FullName(fmi2GetStringStatus)
+
+/* Version number */
+#define fmi2Version "2.0"
+
+
+/***************************************************
+Common Functions
+****************************************************/
+
+/* Inquire version numbers of header files */
+   FMI2_Export fmi2GetTypesPlatformTYPE fmi2GetTypesPlatform;
+   FMI2_Export fmi2GetVersionTYPE       fmi2GetVersion;
+   FMI2_Export fmi2SetDebugLoggingTYPE  fmi2SetDebugLogging;
+
+/* Creation and destruction of FMU instances */
+   FMI2_Export fmi2InstantiateTYPE  fmi2Instantiate;
+   FMI2_Export fmi2FreeInstanceTYPE fmi2FreeInstance;
+
+/* Enter and exit initialization mode, terminate and reset */
+   FMI2_Export fmi2SetupExperimentTYPE         fmi2SetupExperiment;
+   FMI2_Export fmi2EnterInitializationModeTYPE fmi2EnterInitializationMode;
+   FMI2_Export fmi2ExitInitializationModeTYPE  fmi2ExitInitializationMode;
+   FMI2_Export fmi2TerminateTYPE               fmi2Terminate;
+   FMI2_Export fmi2ResetTYPE                   fmi2Reset;
+
+/* Getting and setting variables values */
+   FMI2_Export fmi2GetRealTYPE    fmi2GetReal;
+   FMI2_Export fmi2GetIntegerTYPE fmi2GetInteger;
+   FMI2_Export fmi2GetBooleanTYPE fmi2GetBoolean;
+   FMI2_Export fmi2GetStringTYPE  fmi2GetString;
+
+   FMI2_Export fmi2SetRealTYPE    fmi2SetReal;
+   FMI2_Export fmi2SetIntegerTYPE fmi2SetInteger;
+   FMI2_Export fmi2SetBooleanTYPE fmi2SetBoolean;
+   FMI2_Export fmi2SetStringTYPE  fmi2SetString;
+
+/* Getting and setting the internal FMU state */
+   FMI2_Export fmi2GetFMUstateTYPE            fmi2GetFMUstate;
+   FMI2_Export fmi2SetFMUstateTYPE            fmi2SetFMUstate;
+   FMI2_Export fmi2FreeFMUstateTYPE           fmi2FreeFMUstate;
+   FMI2_Export fmi2SerializedFMUstateSizeTYPE fmi2SerializedFMUstateSize;
+   FMI2_Export fmi2SerializeFMUstateTYPE      fmi2SerializeFMUstate;
+   FMI2_Export fmi2DeSerializeFMUstateTYPE    fmi2DeSerializeFMUstate;
+
+/* Getting partial derivatives */
+   FMI2_Export fmi2GetDirectionalDerivativeTYPE fmi2GetDirectionalDerivative;
+
+
+/***************************************************
+Functions for FMI2 for Model Exchange
+****************************************************/
+
+/* Enter and exit the different modes */
+   FMI2_Export fmi2EnterEventModeTYPE               fmi2EnterEventMode;
+   FMI2_Export fmi2NewDiscreteStatesTYPE            fmi2NewDiscreteStates;
+   FMI2_Export fmi2EnterContinuousTimeModeTYPE      fmi2EnterContinuousTimeMode;
+   FMI2_Export fmi2CompletedIntegratorStepTYPE      fmi2CompletedIntegratorStep;
+
+/* Providing independent variables and re-initialization of caching */
+   FMI2_Export fmi2SetTimeTYPE             fmi2SetTime;
+   FMI2_Export fmi2SetContinuousStatesTYPE fmi2SetContinuousStates;
+
+/* Evaluation of the model equations */
+   FMI2_Export fmi2GetDerivativesTYPE                fmi2GetDerivatives;
+#ifdef FMU_EXPERIMENTAL
+   FMI2_Export fmi2GetSpecificDerivativesTYPE        fmi2GetSpecificDerivatives;
+#endif
+   FMI2_Export fmi2GetEventIndicatorsTYPE            fmi2GetEventIndicators;
+   FMI2_Export fmi2GetContinuousStatesTYPE           fmi2GetContinuousStates;
+   FMI2_Export fmi2GetNominalsOfContinuousStatesTYPE fmi2GetNominalsOfContinuousStates;
+
+
+/***************************************************
+Functions for FMI2 for Co-Simulation
+****************************************************/
+
+/* Simulating the slave */
+   FMI2_Export fmi2SetRealInputDerivativesTYPE  fmi2SetRealInputDerivatives;
+   FMI2_Export fmi2GetRealOutputDerivativesTYPE fmi2GetRealOutputDerivatives;
+
+   FMI2_Export fmi2DoStepTYPE     fmi2DoStep;
+   FMI2_Export fmi2CancelStepTYPE fmi2CancelStep;
+
+/* Inquire slave status */
+   FMI2_Export fmi2GetStatusTYPE        fmi2GetStatus;
+   FMI2_Export fmi2GetRealStatusTYPE    fmi2GetRealStatus;
+   FMI2_Export fmi2GetIntegerStatusTYPE fmi2GetIntegerStatus;
+   FMI2_Export fmi2GetBooleanStatusTYPE fmi2GetBooleanStatus;
+   FMI2_Export fmi2GetStringStatusTYPE  fmi2GetStringStatus;
+
+#ifdef __cplusplus
+}  /* end of extern "C" { */
+#endif
+
+#endif /* fmi2Functions_h */

+ 115 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/fmi2/fmi2TypesPlatform.h

@@ -0,0 +1,115 @@
+#ifndef fmi2TypesPlatform_h
+#define fmi2TypesPlatform_h
+
+/* Standard header file to define the argument types of the
+   functions of the Functional Mock-up Interface 2.0.
+   This header file must be utilized both by the model and
+   by the simulation engine.
+
+   Revisions:
+   - Apr.  9, 2014: all prefixes "fmi" renamed to "fmi2" (decision from April 8)
+   - Mar   31, 2014: New datatype fmiChar introduced.
+   - Feb.  17, 2013: Changed fmiTypesPlatform from "standard32" to "default".
+                     Removed fmiUndefinedValueReference since no longer needed
+                     (because every state is defined in ScalarVariables).
+   - March 20, 2012: Renamed from fmiPlatformTypes.h to fmiTypesPlatform.h
+   - Nov.  14, 2011: Use the header file "fmiPlatformTypes.h" for FMI 2.0
+                     both for "FMI for model exchange" and for "FMI for co-simulation"
+                     New types "fmiComponentEnvironment", "fmiState", and "fmiByte".
+                     The implementation of "fmiBoolean" is change from "char" to "int".
+                     The #define "fmiPlatform" changed to "fmiTypesPlatform"
+                     (in order that #define and function call are consistent)
+   - Oct.   4, 2010: Renamed header file from "fmiModelTypes.h" to fmiPlatformTypes.h"
+                     for the co-simulation interface
+   - Jan.   4, 2010: Renamed meModelTypes_h to fmiModelTypes_h (by Mauss, QTronic)
+   - Dec.  21, 2009: Changed "me" to "fmi" and "meModel" to "fmiComponent"
+                     according to meeting on Dec. 18 (by Martin Otter, DLR)
+   - Dec.   6, 2009: Added meUndefinedValueReference (by Martin Otter, DLR)
+   - Sept.  9, 2009: Changes according to FMI-meeting on July 21:
+                     Changed "version" to "platform", "standard" to "standard32",
+                     Added a precise definition of "standard32" as comment
+                     (by Martin Otter, DLR)
+   - July  19, 2009: Added "me" as prefix to file names, added meTrue/meFalse,
+                     and changed meValueReferenced from int to unsigned int
+                     (by Martin Otter, DLR).
+   - March  2, 2009: Moved enums and function pointer definitions to
+                     ModelFunctions.h (by Martin Otter, DLR).
+   - Dec.  3, 2008 : First version by Martin Otter (DLR) and
+                     Hans Olsson (Dynasim).
+
+
+   Copyright (C) 2008-2011 MODELISAR consortium,
+               2012-2013 Modelica Association Project "FMI"
+               All rights reserved.
+   This file is licensed by the copyright holders under the BSD 2-Clause License
+   (http://www.opensource.org/licenses/bsd-license.html):
+
+   ----------------------------------------------------------------------------
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are met:
+
+   - Redistributions of source code must retain the above copyright notice,
+     this list of conditions and the following disclaimer.
+   - Redistributions in binary form must reproduce the above copyright notice,
+     this list of conditions and the following disclaimer in the documentation
+     and/or other materials provided with the distribution.
+   - Neither the name of the copyright holders nor the names of its
+     contributors may be used to endorse or promote products derived
+     from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+   ----------------------------------------------------------------------------
+
+   with the extension:
+
+   You may distribute or publicly perform any modification only under the
+   terms of this license.
+   (Note, this means that if you distribute a modified file,
+    the modified file must also be provided under this license).
+*/
+
+/* Platform (unique identification of this header file) */
+#define fmi2TypesPlatform "default"
+
+/* Type definitions of variables passed as arguments
+   Version "default" means:
+
+   fmi2Component           : an opaque object pointer
+   fmi2ComponentEnvironment: an opaque object pointer
+   fmi2FMUstate            : an opaque object pointer
+   fmi2ValueReference      : handle to the value of a variable
+   fmi2Real                : double precision floating-point data type
+   fmi2Integer             : basic signed integer data type
+   fmi2Boolean             : basic signed integer data type
+   fmi2Char                : character data type
+   fmi2String              : a pointer to a vector of fmi2Char characters
+                             ('\0' terminated, UTF8 encoded)
+   fmi2Byte                : smallest addressable unit of the machine, typically one byte.
+*/
+   typedef void*           fmi2Component;               /* Pointer to FMU instance       */
+   typedef void*           fmi2ComponentEnvironment;    /* Pointer to FMU environment    */
+   typedef void*           fmi2FMUstate;                /* Pointer to internal FMU state */
+   typedef unsigned int    fmi2ValueReference;
+   typedef double          fmi2Real   ;
+   typedef int             fmi2Integer;
+   typedef int             fmi2Boolean;
+   typedef char            fmi2Char;
+   typedef const fmi2Char* fmi2String;
+   typedef char            fmi2Byte;
+
+/* Values for fmi2Boolean  */
+#define fmi2True  1
+#define fmi2False 0
+
+
+#endif /* fmi2TypesPlatform_h */

+ 15 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/makefile

@@ -0,0 +1,15 @@
+CC=gcc
+CFLAGS=-IC:fmi2 -O0 -g3 -Wall -c -fmessage-length=0
+DEPS = $(wildcard *.h)
+SOURCES = $(wildcard *.c)
+OBJECTS = $(SOURCES:.c=.o)
+LIB = libFMI_controller.dll
+
+lib: $(OBJECTS)
+	$(CC) -shared -o Debug\$(LIB) $(OBJECTS) 
+
+%.o: %.c $(DEPS)
+	$(CC) -c -o $@ $< $(CFLAGS)
+
+clean:
+	rm -f Debug\$(LIB) $(OBJECTS)

+ 71 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/modelDescription.xml

@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<fmiModelDescription
+  fmiVersion="2.0"
+  modelName="PW_Controller"
+  guid='{f4893318-1565-4931-b8c8-8a19fb3fcfda}'
+  numberOfEventIndicators="1">
+
+<CoSimulation
+  modelIdentifier="PW_Controller"
+  canHandleVariableCommunicationStepSize="true"/>
+
+<LogCategories>
+  <Category name="logAll"/>
+  <Category name="logError"/>
+  <Category name="logFmiCall"/>
+  <Category name="logEvent"/>
+</LogCategories>
+
+
+<ModelVariables>
+  <ScalarVariable name="driver_up" valueReference="0" description="driver push up button = 1; no push = 0"
+                  causality="input" variability="enum" initial="exact">
+    <Boolean start="0"/>
+  </ScalarVariable>
+  <ScalarVariable name="driver_down" valueReference="1" description="driver push down button = 1"
+                  causality="input" variability="discrete" initial="exact">
+    <Boolean start="0"/>
+  </ScalarVariable>
+  <ScalarVariable name="driver_up_stop" valueReference="2" description="driver stops push up button = 1"
+                  causality="input" variability="discrete" initial="exact">
+    <Boolean start="0"/>
+  </ScalarVariable>
+    <ScalarVariable name="driver_down_stop" valueReference="3" description="driver stops push down button = 1"
+                  causality="input" variability="discrete" initial="exact">
+    <Boolean start="0"/>
+  </ScalarVariable>
+    <ScalarVariable name="passenger_up" valueReference="4" description="passenger  push up button = 1"
+                  causality="input" variability="discrete" initial="exact">
+    <Boolean start="0"/>
+  </ScalarVariable>
+    <ScalarVariable name="passenger_down" valueReference="5" description="passenger  push down button = 1"
+                  causality="input" variability="discrete" initial="exact">
+    <Boolean start="0"/>
+  </ScalarVariable>
+    <ScalarVariable name="passenger_up_stop" valueReference="6" description="passenger stop push up button = 1"
+                  causality="input" variability="discrete" initial="exact">
+    <Boolean start="0"/>
+  </ScalarVariable>
+    <ScalarVariable name="passenger_down_stop" valueReference="7" description="passenger stop push down button = 1"
+                  causality="input" variability="discrete" initial="exact">
+    <Boolean start="0"/>
+  </ScalarVariable>
+      <ScalarVariable name="obj_detected" valueReference="8" description="Object detected"
+                  causality="input" variability="discrete" initial="exact">
+    <Boolean start="0"/>
+  </ScalarVariable>
+        <ScalarVariable name="motor_up" valueReference="9" description="motor command up = 1"
+                  causality="output" variability="discrete" initial="exact">
+    <Boolean start="0"/>
+  </ScalarVariable>
+        <ScalarVariable name="motor_down" valueReference="10" description="motor command down = 1"
+                  causality="output" variability="discrete" initial="exact">
+    <Boolean start="0"/>
+  </ScalarVariable>
+</ModelVariables>
+
+
+<ModelStructure>
+</ModelStructure>
+
+</fmiModelDescription>

+ 40 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/sc_types.h

@@ -0,0 +1,40 @@
+
+#ifndef SC_TYPES_H_
+#define SC_TYPES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif 
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#define sc_string		char*
+ 
+typedef bool			sc_boolean;
+typedef int_fast16_t	sc_short;
+typedef uint_fast16_t	sc_ushort;
+typedef int32_t			sc_integer; 
+typedef uint32_t		sc_uinteger; 
+typedef double			sc_real;
+
+typedef void*			sc_eventid;
+
+typedef intptr_t		sc_intptr_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifndef null
+	#ifdef __cplusplus
+		#define null 0
+	#else
+		#define null ((void *)0)
+	#endif
+#endif
+
+#define bool_true true
+#define bool_false false
+
+#endif /* SC_TYPES_H_ */

+ 594 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/lazy/FMI_controller/sim_support.c

@@ -0,0 +1,594 @@
+/* -------------------------------------------------------------------------
+ * sim_support.c
+ * Functions used by both FMU simulators fmu20sim_me and fmu20sim_cs
+ * to parse command-line arguments, to unzip and load an fmu,
+ * to write CSV file, and more.
+ *
+ * Revision history
+ *  07.03.2014 initial version released in FMU SDK 2.0.0
+ *  10.04.2014 use FMI 2.0 headers that prefix function and type names with 'fmi2'.
+ *             When 'fmi2' functions are not found in loaded DLL, look also for
+ *             FMI 2.0 RC1 function names.
+ *
+ * Author: Adrian Tirea
+ * Copyright QTronic GmbH. All rights reserved.
+ * -------------------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <dlfcn.h>
+#include "fmi2.h"
+#include "sim_support.h"
+
+#define FMI_COSIMULATION
+extern FMU fmu;
+
+
+//int unzip(const char *zipPath, const char *outPath) {
+//    int code;
+//    char cwd[BUFSIZE];
+//    char binPath[BUFSIZE];
+//    int n = strlen(UNZIP_CMD) + strlen(outPath) + 3 +  strlen(zipPath) + 9;
+//    char* cmd = (char*)calloc(sizeof(char), n);
+//
+//    // remember current directory
+//    if (!GetCurrentDirectory(BUFSIZE, cwd)) {
+//        printf ("error: Could not get current directory\n");
+//        return 0; // error
+//    }
+//
+//    // change to %FMUSDK_HOME%\bin to find 7z.dll and 7z.exe
+//    if (!GetEnvironmentVariable("FMUSDK_HOME", binPath, BUFSIZE)) {
+//        if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
+//            printf ("error: Environment variable FMUSDK_HOME not defined\n");
+//        }
+//        else {
+//            printf ("error: Could not get value of FMUSDK_HOME\n");
+//        }
+//        return 0; // error
+//    }
+//    strcat(binPath, "\\bin");
+//    if (!SetCurrentDirectory(binPath)) {
+//        printf ("error: could not change to directory '%s'\n", binPath);
+//        return 0; // error
+//    }
+//
+//    // run the unzip command
+//    // remove "> NUL" to see the unzip protocol
+//    sprintf(cmd, "%s\"%s\" \"%s\" > NUL", UNZIP_CMD, outPath, zipPath);
+//    // printf("cmd='%s'\n", cmd);
+//    code = system(cmd);
+//    free(cmd);
+//    if (code != SEVEN_ZIP_NO_ERROR) {
+//        printf("7z: ");
+//        switch (code) {
+//            case SEVEN_ZIP_WARNING:            printf("warning\n"); break;
+//            case SEVEN_ZIP_ERROR:              printf("error\n"); break;
+//            case SEVEN_ZIP_COMMAND_LINE_ERROR: printf("command line error\n"); break;
+//            case SEVEN_ZIP_OUT_OF_MEMORY:      printf("out of memory\n"); break;
+//            case SEVEN_ZIP_STOPPED_BY_USER:    printf("stopped by user\n"); break;
+//            default: printf("unknown problem\n");
+//        }
+//    }
+//
+//    // restore current directory
+//    SetCurrentDirectory(cwd);
+//    return (code == SEVEN_ZIP_NO_ERROR || code == SEVEN_ZIP_WARNING) ? 1 : 0;
+//}
+//
+//// fileName is an absolute path, e.g. C:\test\a.fmu
+//// or relative to the current dir, e.g. ..\test\a.fmu
+//// Does not check for existence of the file
+//static char* getFmuPath(const char* fileName){
+//    char pathName[MAX_PATH];
+//    int n = GetFullPathName(fileName, MAX_PATH, pathName, NULL);
+//    return n ? strdup(pathName) : NULL;
+//}
+//
+//static char* getTmpPath() {
+//    char tmpPath[BUFSIZE];
+//    if(! GetTempPath(BUFSIZE, tmpPath)) {
+//        printf ("error: Could not find temporary disk space\n");
+//        return NULL;
+//    }
+//    strcat(tmpPath, "fmu\\");
+//    return strdup(tmpPath);
+//}
+//
+//char *getTempResourcesLocation() {
+//    char *tempPath = getTmpPath();
+//    char *resourcesLocation = (char *)calloc(sizeof(char), 9 + strlen(RESOURCES_DIR) + strlen(tempPath));
+//    strcpy(resourcesLocation, "file:///");
+//    strcat(resourcesLocation, tempPath);
+//    strcat(resourcesLocation, RESOURCES_DIR);
+//    free(tempPath);
+//    return resourcesLocation;
+//}
+
+static void *getAdr(int *success, void *dllHandle, const char *functionName, const char* preamble) {
+
+    int length = strlen(preamble) + strlen(functionName) + 1;
+    char* new_name = malloc(length);  // allocate memory
+    strcpy(new_name, preamble);  // copy first string
+    strcat(new_name, functionName);
+    void* fp = dlsym(dllHandle, new_name);
+    if (!fp) {
+        printf("warning: Function %s not found in dll\n", new_name);
+        *success = 0;
+    }
+    free(new_name);
+    return fp;
+}
+
+// Load the given dll and set function pointers in fmu
+// Return 0 to indicate failure
+int loadDll(const char* dllPath, FMU *fmu, const char* preamble) {
+    int x = 1, s = 1;
+    //HMODULE h = LoadLibrary(dllPath);
+    void *h = dlopen(dllPath, RTLD_LAZY);
+    printf("%s", dlerror());
+    if (!h) {
+        printf("error: Could not load %s\n", dllPath);
+        return 0; // failure
+    }
+    fmu->dllHandle = h;
+    fmu->getTypesPlatform          = (fmi2GetTypesPlatformTYPE *)      getAdr(&s, h, "fmi2GetTypesPlatform", preamble);
+    fmu->getVersion                = (fmi2GetVersionTYPE *)            getAdr(&s, h, "fmi2GetVersion", preamble);
+    fmu->setDebugLogging           = (fmi2SetDebugLoggingTYPE *)       getAdr(&s, h, "fmi2SetDebugLogging",preamble);
+    fmu->instantiate               = (fmi2InstantiateTYPE *)           getAdr(&s, h, "fmi2Instantiate", preamble);
+    fmu->freeInstance              = (fmi2FreeInstanceTYPE *)          getAdr(&s, h, "fmi2FreeInstance", preamble);
+    fmu->setupExperiment           = (fmi2SetupExperimentTYPE *)       getAdr(&s, h, "fmi2SetupExperiment", preamble);
+    fmu->enterInitializationMode   = (fmi2EnterInitializationModeTYPE *) getAdr(&s, h, "fmi2EnterInitializationMode", preamble);
+    fmu->exitInitializationMode    = (fmi2ExitInitializationModeTYPE *) getAdr(&s, h, "fmi2ExitInitializationMode", preamble);
+    fmu->terminate                 = (fmi2TerminateTYPE *)             getAdr(&s, h, "fmi2Terminate", preamble);
+    fmu->reset                     = (fmi2ResetTYPE *)                 getAdr(&s, h, "fmi2Reset", preamble);
+    fmu->getReal                   = (fmi2GetRealTYPE *)               getAdr(&s, h, "fmi2GetReal", preamble);
+    fmu->getInteger                = (fmi2GetIntegerTYPE *)            getAdr(&s, h, "fmi2GetInteger", preamble);
+    fmu->getBoolean                = (fmi2GetBooleanTYPE *)            getAdr(&s, h, "fmi2GetBoolean", preamble);
+    fmu->getString                 = (fmi2GetStringTYPE *)             getAdr(&s, h, "fmi2GetString", preamble);
+    fmu->setReal                   = (fmi2SetRealTYPE *)               getAdr(&s, h, "fmi2SetReal", preamble);
+    fmu->setInteger                = (fmi2SetIntegerTYPE *)            getAdr(&s, h, "fmi2SetInteger", preamble);
+    fmu->setBoolean                = (fmi2SetBooleanTYPE *)            getAdr(&s, h, "fmi2SetBoolean", preamble);
+    fmu->setString                 = (fmi2SetStringTYPE *)             getAdr(&s, h, "fmi2SetString", preamble);
+    fmu->getFMUstate               = (fmi2GetFMUstateTYPE *)           getAdr(&s, h, "fmi2GetFMUstate", preamble);
+    fmu->setFMUstate               = (fmi2SetFMUstateTYPE *)           getAdr(&s, h, "fmi2SetFMUstate", preamble);
+    fmu->freeFMUstate              = (fmi2FreeFMUstateTYPE *)          getAdr(&s, h, "fmi2FreeFMUstate", preamble);
+    fmu->serializedFMUstateSize    = (fmi2SerializedFMUstateSizeTYPE *) getAdr(&s, h, "fmi2SerializedFMUstateSize", preamble);
+    fmu->serializeFMUstate         = (fmi2SerializeFMUstateTYPE *)     getAdr(&s, h, "fmi2SerializeFMUstate", preamble);
+    fmu->deSerializeFMUstate       = (fmi2DeSerializeFMUstateTYPE *)   getAdr(&s, h, "fmi2DeSerializeFMUstate", preamble);
+    fmu->getDirectionalDerivative  = (fmi2GetDirectionalDerivativeTYPE *) getAdr(&s, h, "fmi2GetDirectionalDerivative", preamble);
+#ifdef FMI_COSIMULATION
+    fmu->setRealInputDerivatives   = (fmi2SetRealInputDerivativesTYPE *) getAdr(&s, h, "fmi2SetRealInputDerivatives", preamble);
+    fmu->getRealOutputDerivatives  = (fmi2GetRealOutputDerivativesTYPE *) getAdr(&s, h, "fmi2GetRealOutputDerivatives", preamble);
+    fmu->doStep                    = (fmi2DoStepTYPE *)                getAdr(&s, h, "fmi2DoStep", preamble);
+    fmu->cancelStep                = (fmi2CancelStepTYPE *)            getAdr(&s, h, "fmi2CancelStep", preamble);
+    fmu->getStatus                 = (fmi2GetStatusTYPE *)             getAdr(&s, h, "fmi2GetStatus", preamble);
+    fmu->getRealStatus             = (fmi2GetRealStatusTYPE *)         getAdr(&s, h, "fmi2GetRealStatus", preamble);
+    fmu->getIntegerStatus          = (fmi2GetIntegerStatusTYPE *)      getAdr(&s, h, "fmi2GetIntegerStatus", preamble);
+    fmu->getBooleanStatus          = (fmi2GetBooleanStatusTYPE *)      getAdr(&s, h, "fmi2GetBooleanStatus", preamble);
+    fmu->getStringStatus           = (fmi2GetStringStatusTYPE *)       getAdr(&s, h, "fmi2GetStringStatus", preamble);
+#else // FMI2 for Model Exchange
+    fmu->enterEventMode            = (fmi2EnterEventModeTYPE *)        getAdr(&s, h, "fmi2EnterEventMode", preamble);
+    fmu->newDiscreteStates         = (fmi2NewDiscreteStatesTYPE *)     getAdr(&s, h, "fmi2NewDiscreteStates", preamble);
+    fmu->enterContinuousTimeMode   = (fmi2EnterContinuousTimeModeTYPE *) getAdr(&s, h, "fmi2EnterContinuousTimeMode", preamble);
+    fmu->completedIntegratorStep   = (fmi2CompletedIntegratorStepTYPE *) getAdr(&s, h, "fmi2CompletedIntegratorStep", preamble);
+    fmu->setTime                   = (fmi2SetTimeTYPE *)               getAdr(&s, h, "fmi2SetTime", preamble);
+    fmu->setContinuousStates       = (fmi2SetContinuousStatesTYPE *)   getAdr(&s, h, "fmi2SetContinuousStates", preamble);
+    fmu->getDerivatives            = (fmi2GetDerivativesTYPE *)        getAdr(&s, h, "fmi2GetDerivatives", preamble);
+    fmu->getEventIndicators        = (fmi2GetEventIndicatorsTYPE *)    getAdr(&s, h, "fmi2GetEventIndicators", preamble);
+    fmu->getContinuousStates       = (fmi2GetContinuousStatesTYPE *)   getAdr(&s, h, "fmi2GetContinuousStates", preamble);
+    fmu->getNominalsOfContinuousStates = (fmi2GetNominalsOfContinuousStatesTYPE *) getAdr(&s, h, "fmi2GetNominalsOfContinuousStates", preamble);
+#endif
+
+    if (fmu->getVersion == NULL && fmu->instantiate == NULL) {
+        printf("warning: Functions from FMI 2.0 could not be found in %s\n", dllPath);
+        printf("warning: Simulator will look for FMI 2.0 RC1 functions names...\n");
+        fmu->getTypesPlatform          = (fmi2GetTypesPlatformTYPE *)      getAdr(&s, h, "fmiGetTypesPlatform", preamble);
+        fmu->getVersion                = (fmi2GetVersionTYPE *)            getAdr(&s, h, "fmiGetVersion", preamble);
+        fmu->setDebugLogging           = (fmi2SetDebugLoggingTYPE *)       getAdr(&s, h, "fmiSetDebugLogging", preamble);
+        fmu->instantiate               = (fmi2InstantiateTYPE *)           getAdr(&s, h, "fmiInstantiate", preamble);
+        fmu->freeInstance              = (fmi2FreeInstanceTYPE *)          getAdr(&s, h, "fmiFreeInstance", preamble);
+        fmu->setupExperiment           = (fmi2SetupExperimentTYPE *)       getAdr(&s, h, "fmiSetupExperiment", preamble);
+        fmu->enterInitializationMode   = (fmi2EnterInitializationModeTYPE *) getAdr(&s, h, "fmiEnterInitializationMode", preamble);
+        fmu->exitInitializationMode    = (fmi2ExitInitializationModeTYPE *) getAdr(&s, h, "fmiExitInitializationMode", preamble);
+        fmu->terminate                 = (fmi2TerminateTYPE *)             getAdr(&s, h, "fmiTerminate", preamble);
+        fmu->reset                     = (fmi2ResetTYPE *)                 getAdr(&s, h, "fmiReset", preamble);
+        fmu->getReal                   = (fmi2GetRealTYPE *)               getAdr(&s, h, "fmiGetReal", preamble);
+        fmu->getInteger                = (fmi2GetIntegerTYPE *)            getAdr(&s, h, "fmiGetInteger", preamble);
+        fmu->getBoolean                = (fmi2GetBooleanTYPE *)            getAdr(&s, h, "fmiGetBoolean", preamble);
+        fmu->getString                 = (fmi2GetStringTYPE *)             getAdr(&s, h, "fmiGetString", preamble);
+        fmu->setReal                   = (fmi2SetRealTYPE *)               getAdr(&s, h, "fmiSetReal", preamble);
+        fmu->setInteger                = (fmi2SetIntegerTYPE *)            getAdr(&s, h, "fmiSetInteger", preamble);
+        fmu->setBoolean                = (fmi2SetBooleanTYPE *)            getAdr(&s, h, "fmiSetBoolean", preamble);
+        fmu->setString                 = (fmi2SetStringTYPE *)             getAdr(&s, h, "fmiSetString", preamble);
+        fmu->getFMUstate               = (fmi2GetFMUstateTYPE *)           getAdr(&s, h, "fmiGetFMUstate", preamble);
+        fmu->setFMUstate               = (fmi2SetFMUstateTYPE *)           getAdr(&s, h, "fmiSetFMUstate", preamble);
+        fmu->freeFMUstate              = (fmi2FreeFMUstateTYPE *)          getAdr(&s, h, "fmiFreeFMUstate", preamble);
+        fmu->serializedFMUstateSize    = (fmi2SerializedFMUstateSizeTYPE *) getAdr(&s, h, "fmiSerializedFMUstateSize", preamble);
+        fmu->serializeFMUstate         = (fmi2SerializeFMUstateTYPE *)     getAdr(&s, h, "fmiSerializeFMUstate", preamble);
+        fmu->deSerializeFMUstate       = (fmi2DeSerializeFMUstateTYPE *)   getAdr(&s, h, "fmiDeSerializeFMUstate", preamble);
+        fmu->getDirectionalDerivative  = (fmi2GetDirectionalDerivativeTYPE *) getAdr(&s, h, "fmiGetDirectionalDerivative", preamble);
+    #ifdef FMI_COSIMULATION
+        fmu->setRealInputDerivatives   = (fmi2SetRealInputDerivativesTYPE *) getAdr(&s, h, "fmiSetRealInputDerivatives", preamble);
+        fmu->getRealOutputDerivatives  = (fmi2GetRealOutputDerivativesTYPE *) getAdr(&s, h, "fmiGetRealOutputDerivatives", preamble);
+        fmu->doStep                    = (fmi2DoStepTYPE *)                getAdr(&s, h, "fmiDoStep", preamble);
+        fmu->cancelStep                = (fmi2CancelStepTYPE *)            getAdr(&s, h, "fmiCancelStep", preamble);
+        fmu->getStatus                 = (fmi2GetStatusTYPE *)             getAdr(&s, h, "fmiGetStatus", preamble);
+        fmu->getRealStatus             = (fmi2GetRealStatusTYPE *)         getAdr(&s, h, "fmiGetRealStatus", preamble);
+        fmu->getIntegerStatus          = (fmi2GetIntegerStatusTYPE *)      getAdr(&s, h, "fmiGetIntegerStatus", preamble);
+        fmu->getBooleanStatus          = (fmi2GetBooleanStatusTYPE *)      getAdr(&s, h, "fmiGetBooleanStatus", preamble);
+        fmu->getStringStatus           = (fmi2GetStringStatusTYPE *)       getAdr(&s, h, "fmiGetStringStatus", preamble);
+    #else // FMI2 for Model Exchange
+        fmu->enterEventMode            = (fmi2EnterEventModeTYPE *)        getAdr(&s, h, "fmiEnterEventMode", preamble);
+        fmu->newDiscreteStates         = (fmi2NewDiscreteStatesTYPE *)     getAdr(&s, h, "fmiNewDiscreteStates", preamble);
+        fmu->enterContinuousTimeMode   = (fmi2EnterContinuousTimeModeTYPE *) getAdr(&s, h, "fmiEnterContinuousTimeMode", preamble);
+        fmu->completedIntegratorStep   = (fmi2CompletedIntegratorStepTYPE *) getAdr(&s, h, "fmiCompletedIntegratorStep", preamble);
+        fmu->setTime                   = (fmi2SetTimeTYPE *)               getAdr(&s, h, "fmiSetTime", preamble);
+        fmu->setContinuousStates       = (fmi2SetContinuousStatesTYPE *)   getAdr(&s, h, "fmiSetContinuousStates", preamble);
+        fmu->getDerivatives            = (fmi2GetDerivativesTYPE *)        getAdr(&s, h, "fmiGetDerivatives", preamble);
+        fmu->getEventIndicators        = (fmi2GetEventIndicatorsTYPE *)    getAdr(&s, h, "fmiGetEventIndicators", preamble);
+        fmu->getContinuousStates       = (fmi2GetContinuousStatesTYPE *)   getAdr(&s, h, "fmiGetContinuousStates", preamble);
+        fmu->getNominalsOfContinuousStates = (fmi2GetNominalsOfContinuousStatesTYPE *) getAdr(&s, h, "fmiGetNominalsOfContinuousStates", preamble);
+    #endif
+    }
+    return s;
+}
+
+//static void printModelDescription(ModelDescription* md){
+//    Element* e = (Element*)md;
+//    int i;
+//    int n; // number of attributes
+//    const char **attributes = getAttributesAsArray(e, &n);
+//    Component *component;
+//
+//    if (!attributes) {
+//        printf("ModelDescription printing aborted.");
+//        return;
+//    }
+//    printf("%s\n", getElementTypeName(e));
+//    for (i = 0; i < n; i += 2) {
+//        printf("  %s=%s\n", attributes[i], attributes[i+1]);
+//    }
+//    free((void *)attributes);
+//
+//#ifdef FMI_COSIMULATION
+//    component = getCoSimulation(md);
+//    if (!component) {
+//        printf("error: No CoSimulation element found in model description. This FMU is not for Co-Simulation.\n");
+//        exit(EXIT_FAILURE);
+//    }
+//#else // FMI_MODEL_EXCHANGE
+//    component = getModelExchange(md);
+//    if (!component) {
+//        printf("error: No ModelExchange element found in model description. This FMU is not for Model Exchange.\n");
+//        exit(EXIT_FAILURE);
+//    }
+//#endif
+//    printf("%s\n", getElementTypeName((Element *)component));
+//    attributes = getAttributesAsArray((Element *)component, &n);
+//    if (!attributes) {
+//        printf("ModelDescription printing aborted.");
+//        return;
+//    }
+//    for (i = 0; i < n; i += 2) {
+//        printf("  %s=%s\n", attributes[i], attributes[i+1]);
+//    }
+//
+//    free((void *)attributes);
+//}
+//
+//void loadFMU(const char* fmuFileName) {
+//    char* fmuPath;
+//    char* tmpPath;
+//    char* xmlPath;
+//    char* dllPath;
+//    const char *modelId;
+//
+//    // get absolute path to FMU, NULL if not found
+//    fmuPath = getFmuPath(fmuFileName);
+//    if (!fmuPath) exit(EXIT_FAILURE);
+//
+//    // unzip the FMU to the tmpPath directory
+//    tmpPath = getTmpPath();
+//    if (!unzip(fmuPath, tmpPath)) exit(EXIT_FAILURE);
+//
+//    // parse tmpPath\modelDescription.xml
+//    xmlPath = calloc(sizeof(char), strlen(tmpPath) + strlen(XML_FILE) + 1);
+//    sprintf(xmlPath, "%s%s", tmpPath, XML_FILE);
+//    fmu.modelDescription = parse(xmlPath);
+//    free(xmlPath);
+//    if (!fmu.modelDescription) exit(EXIT_FAILURE);
+//    printModelDescription(fmu.modelDescription);
+//#ifdef FMI_COSIMULATION
+//    modelId = getAttributeValue((Element *)getCoSimulation(fmu.modelDescription), att_modelIdentifier);
+//#else // FMI_MODEL_EXCHANGE
+//    modelId = getAttributeValue((Element *)getModelExchange(fmu.modelDescription), att_modelIdentifier);
+//#endif
+//    // load the FMU dll
+//    dllPath = calloc(sizeof(char), strlen(tmpPath) + strlen(DLL_DIR)
+//        + strlen(modelId) +  strlen(".dll") + 1);
+//    sprintf(dllPath, "%s%s%s.dll", tmpPath, DLL_DIR, modelId);
+//    if (!loadDll(dllPath, &fmu)) {
+//        exit(EXIT_FAILURE);
+//    }
+//    free(dllPath);
+//    free(fmuPath);
+//    free(tmpPath);
+//}
+//
+//void deleteUnzippedFiles() {
+//    const char *fmuTempPath = getTmpPath();
+//    char *cmd = (char *)calloc(15 + strlen(fmuTempPath), sizeof(char));
+//    sprintf(cmd, "rmdir /S /Q %s", fmuTempPath);
+//    system(cmd);
+//    free(cmd);
+//}
+//
+//static void doubleToCommaString(char* buffer, double r){
+//    char* comma;
+//    sprintf(buffer, "%.16g", r);
+//    comma = strchr(buffer, '.');
+//    if (comma) *comma = ',';
+//}
+//
+//// output time and all variables in CSV format
+//// if separator is ',', columns are separated by ',' and '.' is used for floating-point numbers.
+//// otherwise, the given separator (e.g. ';' or '\t') is to separate columns, and ',' is used
+//// as decimal dot in floating-point numbers.
+//void outputRow(FMU *fmu, fmi2Component c, double time, FILE* file, char separator, fmi2Boolean header) {
+//    int k;
+//    fmi2Real r;
+//    fmi2Integer i;
+//    fmi2Boolean b;
+//    fmi2String s;
+//    fmi2ValueReference vr;
+//    int n = getScalarVariableSize(fmu->modelDescription);
+//    char buffer[32];
+//
+//    // print first column
+//    if (header) {
+//        fprintf(file, "time");
+//    } else {
+//        if (separator==',')
+//            fprintf(file, "%.16g", time);
+//        else {
+//            // separator is e.g. ';' or '\t'
+//            doubleToCommaString(buffer, time);
+//            fprintf(file, "%s", buffer);
+//        }
+//    }
+//
+//    // print all other columns
+//    for (k = 0; k < n; k++) {
+//        ScalarVariable *sv = getScalarVariable(fmu->modelDescription, k);
+//        if (header) {
+//            // output names only
+//            if (separator == ',') {
+//                // treat array element, e.g. print a[1, 2] as a[1.2]
+//                const char *s = getAttributeValue((Element *)sv, att_name);
+//                fprintf(file, "%c", separator);
+//                while (*s) {
+//                    if (*s != ' ') {
+//                        fprintf(file, "%c", *s == ',' ? '.' : *s);
+//                    }
+//                    s++;
+//                }