typedef struct {\r
char *name;\r
char *description;\r
+ char *declaredType;\r
long vr;\r
// 0 = real\r
// 1 = integer\r
int causality;\r
} FMIL_Variable;\r
\r
+typedef struct {\r
+ char *name;\r
+ char *description;\r
+ char *quantity;\r
+ char *unit;\r
+} FMIL_DeclaredType;\r
+\r
__declspec(dllexport) void* FMI1_CS_LOAD(const char *zipFilePath, const char *unzipFolder);\r
__declspec(dllexport) int FMI1_CS_UNLOAD(void* fmu);\r
__declspec(dllexport) FMIL_Variable *FMI1_CS_GET_VARIABLES(void* fmu, int *count);\r
+__declspec(dllexport) FMIL_DeclaredType *FMI1_CS_GET_DECLARED_TYPES(void* fmu, int *count);\r
__declspec(dllexport) int FMI1_CS_INSTANTIATE(void* fmu);\r
__declspec(dllexport) int FMI1_CS_INITIALIZE(void* fmu);\r
__declspec(dllexport) int FMI1_CS_STEP(void* fmu, double masterTime, double stepSize);\r
\r
}\r
\r
+/*\r
+ if(!vt) {\r
+ printf("No type definition\n");\r
+ return;\r
+ }\r
+\r
+ quan = fmi1_import_get_type_quantity(vt);\r
+\r
+ printf("Type %s\n description: %s\n", fmi1_import_get_type_name(vt), fmi1_import_get_type_description(vt));\r
+\r
+ printf("Base type: %s\n", fmi1_base_type_to_string(fmi1_import_get_base_type(vt)));\r
+\r
+ if(quan) {\r
+ printf("Quantity: %s\n", quan);\r
+ }\r
+ switch(fmi1_import_get_base_type(vt)) {\r
+ case fmi1_base_type_real: {\r
+ fmi1_import_real_typedef_t* rt = fmi1_import_get_type_as_real(vt);\r
+ fmi1_real_t min = fmi1_import_get_real_type_min(rt);\r
+ fmi1_real_t max = fmi1_import_get_real_type_max(rt);\r
+ fmi1_real_t nom = fmi1_import_get_real_type_nominal(rt);\r
+ fmi1_import_unit_t* u = fmi1_import_get_real_type_unit(rt);\r
+ fmi1_import_display_unit_t* du = fmi1_import_get_type_display_unit(rt);\r
+\r
+ printf("Min %g, max %g, nominal %g\n", min, max, nom);\r
+\r
+ if(u) {\r
+ printf("Unit: %s\n", fmi1_import_get_unit_name(u));\r
+ }\r
+ if(du) {\r
+ printf("Display unit: %s, gain: %g, offset: %g, is relative: %s",\r
+ fmi1_import_get_display_unit_name(du),\r
+ fmi1_import_get_display_unit_gain(du),\r
+ fmi1_import_get_display_unit_offset(du),\r
+ fmi1_import_get_real_type_is_relative_quantity(rt)?"yes":"no"\r
+ );\r
+ }\r
+\r
+ break;\r
+ }\r
+ case fmi1_base_type_int:{\r
+ fmi1_import_integer_typedef_t* it = fmi1_import_get_type_as_int(vt);\r
+ int min = fmi1_import_get_integer_type_min(it);\r
+ int max = fmi1_import_get_integer_type_max(it);\r
+ printf("Min %d, max %d\n", min, max);\r
+ break;\r
+ }\r
+ case fmi1_base_type_bool:{\r
+ break;\r
+ }\r
+ case fmi1_base_type_str:{\r
+ break;\r
+ }\r
+ case fmi1_base_type_enum:{\r
+ fmi1_import_enumeration_typedef_t* et = fmi1_import_get_type_as_enum(vt);\r
+ int min = fmi1_import_get_enum_type_min(et);\r
+ int max = fmi1_import_get_enum_type_max(et);\r
+ printf("Min %d, max %d\n", min, max);\r
+ {\r
+ size_t ni;\r
+ unsigned i;\r
+ ni = fmi1_import_get_enum_type_size(et);\r
+ i = (unsigned)(ni);\r
+ assert( i == ni);\r
+ printf("There are %u items \n",(unsigned)ni);\r
+ for(i = 0; i < ni; i++) {\r
+ printf("[%u] %s (%s) \n", (unsigned)i+1, fmi1_import_get_enum_type_item_name(et, i), fmi1_import_get_enum_type_item_description(et, i));\r
+ }\r
+ }\r
+ break;\r
+ }\r
+ default:\r
+ printf("Error in fmiGetBaseType()\n");\r
+ }\r
+*/\r
+\r
\r
FMIL_Variable *FMI1_CS_GET_VARIABLES(void *fmu, int *count) {\r
\r
int i;\r
FMIL_Variable *result;\r
fmi1_import_variable_list_t* vl = fmi1_import_get_variable_list((fmi1_import_t *)fmu);\r
+ fmi1_import_variable_typedef_t* type;\r
\r
count[0] = fmi1_import_get_variable_list_size(vl);\r
\r
\r
result[i].vr = fmi1_import_get_variable_vr(var);\r
\r
+ type = fmi1_import_get_variable_declared_type(var);\r
+ if(type) {\r
+ result[i].declaredType = fmi1_import_get_type_name(type);\r
+ } else {\r
+ result[i].declaredType = 0;\r
+ }\r
+\r
}\r
\r
}\r
\r
}\r
\r
+FMIL_DeclaredType *FMI1_CS_GET_DECLARED_TYPES(void *fmu, int *count) {\r
+\r
+ FMIL_DeclaredType *result;\r
+ fmi1_import_type_definitions_t* td = fmi1_import_get_type_definitions((fmi1_import_t *)fmu);\r
+ fmi1_import_variable_typedef_t* type;\r
+ unsigned i, ntd = (unsigned)fmi1_import_get_type_definition_number(td);\r
+\r
+ count[0] = ntd;\r
+\r
+ result = (FMIL_DeclaredType *)malloc(count[0]*sizeof(FMIL_DeclaredType));\r
+\r
+ for(i = 0; i < ntd; i++) {\r
+ type = fmi1_import_get_typedef(td, i);\r
+ result[i].name = fmi1_import_get_type_name(type);\r
+ result[i].description = fmi1_import_get_type_description(type);\r
+ result[i].quantity = fmi1_import_get_type_quantity(type);\r
+ result[i].unit = 0;\r
+\r
+ switch(fmi1_import_get_base_type(type)) {\r
+ case fmi1_base_type_real: {\r
+ fmi1_import_real_typedef_t* rt = fmi1_import_get_type_as_real(type);\r
+ fmi1_import_unit_t* u = fmi1_import_get_real_type_unit(rt);\r
+ if(u) result[i].unit = fmi1_import_get_unit_name(u);\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+ return result;\r
+\r
+}\r
+\r
#define INSTANCE_NAME "kekkeli"\r
\r
int FMI1_CS_INSTANTIATE(void *fmu) {\r
\r
status = fmi1_import_do_step((fmi1_import_t *)fmu, (fmi1_real_t)masterTime, (fmi1_real_t)stepSize, fmi1_true);\r
if (status == fmi1_status_error || status == fmi1_status_fatal) {\r
- printf("fmi1_capi_do_step: Failed\n");\r
- return 0;\r
+ return 1;\r
} else {\r
- printf("fmi1_capi_do_step: Success\n");\r
+ return 0;\r
}\r
-\r
- return 0;\r
-\r
}\r
\r
int FMI1_CS_SET_REAL(void *fmu, long valueId, double value) {\r