From: jsimomaa Date: Thu, 24 Mar 2016 09:23:47 +0000 (+0000) Subject: refs #6290 X-Git-Tag: v1.26.0~11 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=2f1722c73a054adc1df1fcd07a61c82ad96b2063;p=simantics%2Ffmil.git refs #6290 Compiled 64-bit FMI Library and necessary changes git-svn-id: https://www.simantics.org/svn/simantics/fmi/trunk@32613 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.fmil.feature/feature.xml b/org.simantics.fmil.feature/feature.xml index ea3a462..6eef9de 100644 --- a/org.simantics.fmil.feature/feature.xml +++ b/org.simantics.fmil.feature/feature.xml @@ -31,7 +31,14 @@ download-size="0" install-size="0" version="0.0.0" + fragment="true"/> + + + unpack="false"/> diff --git a/org.simantics.fmil/native/FMUSimulator/FMUSimulator.vcxproj b/org.simantics.fmil/native/FMUSimulator/FMUSimulator.vcxproj index 726cd7b..ac623b2 100644 --- a/org.simantics.fmil/native/FMUSimulator/FMUSimulator.vcxproj +++ b/org.simantics.fmil/native/FMUSimulator/FMUSimulator.vcxproj @@ -136,7 +136,7 @@ true true true - fmilib_shared.lib;%(AdditionalDependencies) + fmilib_shared32.lib;%(AdditionalDependencies) @@ -157,7 +157,7 @@ true true true - $(OutDir)zlibwapi.lib;$(OutDir)miniunz.lib;%(AdditionalDependencies) + fmilib_shared64.lib;%(AdditionalDependencies) diff --git a/org.simantics.fmil/native/FMUSimulator/fmi_util.c.txt b/org.simantics.fmil/native/FMUSimulator/fmi_util.c.txt index caab8ac..ab87846 100644 --- a/org.simantics.fmil/native/FMUSimulator/fmi_util.c.txt +++ b/org.simantics.fmil/native/FMUSimulator/fmi_util.c.txt @@ -77,6 +77,7 @@ extern "C" { typedef struct { char *name; char *description; + char *declaredType; long vr; // 0 = real // 1 = integer @@ -98,9 +99,17 @@ typedef struct { int causality; } FMIL_Variable; +typedef struct { + char *name; + char *description; + char *quantity; + char *unit; +} FMIL_DeclaredType; + __declspec(dllexport) void* FMI1_CS_LOAD(const char *zipFilePath, const char *unzipFolder); __declspec(dllexport) int FMI1_CS_UNLOAD(void* fmu); __declspec(dllexport) FMIL_Variable *FMI1_CS_GET_VARIABLES(void* fmu, int *count); +__declspec(dllexport) FMIL_DeclaredType *FMI1_CS_GET_DECLARED_TYPES(void* fmu, int *count); __declspec(dllexport) int FMI1_CS_INSTANTIATE(void* fmu); __declspec(dllexport) int FMI1_CS_INITIALIZE(void* fmu); __declspec(dllexport) int FMI1_CS_STEP(void* fmu, double masterTime, double stepSize); @@ -184,12 +193,89 @@ int FMI1_CS_UNLOAD(void *fmu_) { } +/* + if(!vt) { + printf("No type definition\n"); + return; + } + + quan = fmi1_import_get_type_quantity(vt); + + printf("Type %s\n description: %s\n", fmi1_import_get_type_name(vt), fmi1_import_get_type_description(vt)); + + printf("Base type: %s\n", fmi1_base_type_to_string(fmi1_import_get_base_type(vt))); + + if(quan) { + printf("Quantity: %s\n", quan); + } + switch(fmi1_import_get_base_type(vt)) { + case fmi1_base_type_real: { + fmi1_import_real_typedef_t* rt = fmi1_import_get_type_as_real(vt); + fmi1_real_t min = fmi1_import_get_real_type_min(rt); + fmi1_real_t max = fmi1_import_get_real_type_max(rt); + fmi1_real_t nom = fmi1_import_get_real_type_nominal(rt); + fmi1_import_unit_t* u = fmi1_import_get_real_type_unit(rt); + fmi1_import_display_unit_t* du = fmi1_import_get_type_display_unit(rt); + + printf("Min %g, max %g, nominal %g\n", min, max, nom); + + if(u) { + printf("Unit: %s\n", fmi1_import_get_unit_name(u)); + } + if(du) { + printf("Display unit: %s, gain: %g, offset: %g, is relative: %s", + fmi1_import_get_display_unit_name(du), + fmi1_import_get_display_unit_gain(du), + fmi1_import_get_display_unit_offset(du), + fmi1_import_get_real_type_is_relative_quantity(rt)?"yes":"no" + ); + } + + break; + } + case fmi1_base_type_int:{ + fmi1_import_integer_typedef_t* it = fmi1_import_get_type_as_int(vt); + int min = fmi1_import_get_integer_type_min(it); + int max = fmi1_import_get_integer_type_max(it); + printf("Min %d, max %d\n", min, max); + break; + } + case fmi1_base_type_bool:{ + break; + } + case fmi1_base_type_str:{ + break; + } + case fmi1_base_type_enum:{ + fmi1_import_enumeration_typedef_t* et = fmi1_import_get_type_as_enum(vt); + int min = fmi1_import_get_enum_type_min(et); + int max = fmi1_import_get_enum_type_max(et); + printf("Min %d, max %d\n", min, max); + { + size_t ni; + unsigned i; + ni = fmi1_import_get_enum_type_size(et); + i = (unsigned)(ni); + assert( i == ni); + printf("There are %u items \n",(unsigned)ni); + for(i = 0; i < ni; i++) { + 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)); + } + } + break; + } + default: + printf("Error in fmiGetBaseType()\n"); + } +*/ + FMIL_Variable *FMI1_CS_GET_VARIABLES(void *fmu, int *count) { int i; FMIL_Variable *result; fmi1_import_variable_list_t* vl = fmi1_import_get_variable_list((fmi1_import_t *)fmu); + fmi1_import_variable_typedef_t* type; count[0] = fmi1_import_get_variable_list_size(vl); @@ -264,6 +350,13 @@ FMIL_Variable *FMI1_CS_GET_VARIABLES(void *fmu, int *count) { result[i].vr = fmi1_import_get_variable_vr(var); + type = fmi1_import_get_variable_declared_type(var); + if(type) { + result[i].declaredType = fmi1_import_get_type_name(type); + } else { + result[i].declaredType = 0; + } + } } @@ -274,6 +367,38 @@ FMIL_Variable *FMI1_CS_GET_VARIABLES(void *fmu, int *count) { } +FMIL_DeclaredType *FMI1_CS_GET_DECLARED_TYPES(void *fmu, int *count) { + + FMIL_DeclaredType *result; + fmi1_import_type_definitions_t* td = fmi1_import_get_type_definitions((fmi1_import_t *)fmu); + fmi1_import_variable_typedef_t* type; + unsigned i, ntd = (unsigned)fmi1_import_get_type_definition_number(td); + + count[0] = ntd; + + result = (FMIL_DeclaredType *)malloc(count[0]*sizeof(FMIL_DeclaredType)); + + for(i = 0; i < ntd; i++) { + type = fmi1_import_get_typedef(td, i); + result[i].name = fmi1_import_get_type_name(type); + result[i].description = fmi1_import_get_type_description(type); + result[i].quantity = fmi1_import_get_type_quantity(type); + result[i].unit = 0; + + switch(fmi1_import_get_base_type(type)) { + case fmi1_base_type_real: { + fmi1_import_real_typedef_t* rt = fmi1_import_get_type_as_real(type); + fmi1_import_unit_t* u = fmi1_import_get_real_type_unit(rt); + if(u) result[i].unit = fmi1_import_get_unit_name(u); + } + } + + } + + return result; + +} + #define INSTANCE_NAME "kekkeli" int FMI1_CS_INSTANTIATE(void *fmu) { @@ -330,14 +455,10 @@ int FMI1_CS_STEP(void *fmu, double masterTime, double stepSize) { status = fmi1_import_do_step((fmi1_import_t *)fmu, (fmi1_real_t)masterTime, (fmi1_real_t)stepSize, fmi1_true); if (status == fmi1_status_error || status == fmi1_status_fatal) { - printf("fmi1_capi_do_step: Failed\n"); - return 0; + return 1; } else { - printf("fmi1_capi_do_step: Success\n"); + return 0; } - - return 0; - } int FMI1_CS_SET_REAL(void *fmu, long valueId, double value) { diff --git a/org.simantics.fmil/native/FMUSimulator/fmilib_shared.lib b/org.simantics.fmil/native/FMUSimulator/fmilib_shared32.lib similarity index 100% rename from org.simantics.fmil/native/FMUSimulator/fmilib_shared.lib rename to org.simantics.fmil/native/FMUSimulator/fmilib_shared32.lib diff --git a/org.simantics.fmil/native/FMUSimulator/fmilib_shared64.lib b/org.simantics.fmil/native/FMUSimulator/fmilib_shared64.lib new file mode 100644 index 0000000..191166a Binary files /dev/null and b/org.simantics.fmil/native/FMUSimulator/fmilib_shared64.lib differ diff --git a/org.simantics.fmil/src/org/simantics/fmil/FMIL.java b/org.simantics.fmil/src/org/simantics/fmil/FMIL.java index 24f7b18..39b90b1 100644 --- a/org.simantics.fmil/src/org/simantics/fmil/FMIL.java +++ b/org.simantics.fmil/src/org/simantics/fmil/FMIL.java @@ -219,7 +219,7 @@ public class FMIL { fmuLoaded = true; } catch (UnsatisfiedLinkError err) { - throw new FMILException(UNSATISFIED_LINK); + throw new FMILException(UNSATISFIED_LINK, err); } catch (Exception e) { throw new FMILException(e.getMessage()); } diff --git a/org.simantics.fmil/src/org/simantics/fmil/FMILException.java b/org.simantics.fmil/src/org/simantics/fmil/FMILException.java index d015189..5b6f06f 100644 --- a/org.simantics.fmil/src/org/simantics/fmil/FMILException.java +++ b/org.simantics.fmil/src/org/simantics/fmil/FMILException.java @@ -11,4 +11,8 @@ public class FMILException extends Exception { public FMILException(String message) { super(message); } + + public FMILException(String message, Throwable cause) { + super(message, cause); + } }