]> gerrit.simantics Code Review - simantics/fmil.git/commitdiff
refs #6290
authorjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 24 Mar 2016 09:23:47 +0000 (09:23 +0000)
committerjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 24 Mar 2016 09:23:47 +0000 (09:23 +0000)
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

org.simantics.fmil.feature/feature.xml
org.simantics.fmil/native/FMUSimulator/FMUSimulator.vcxproj
org.simantics.fmil/native/FMUSimulator/fmi_util.c.txt
org.simantics.fmil/native/FMUSimulator/fmilib_shared32.lib [moved from org.simantics.fmil/native/FMUSimulator/fmilib_shared.lib with 100% similarity]
org.simantics.fmil/native/FMUSimulator/fmilib_shared64.lib [new file with mode: 0644]
org.simantics.fmil/src/org/simantics/fmil/FMIL.java
org.simantics.fmil/src/org/simantics/fmil/FMILException.java

index ea3a462cebe5e505eea4cab18ede79e683f59146..6eef9debc580d094edfc12e17718d32c6100545b 100644 (file)
          download-size="0"\r
          install-size="0"\r
          version="0.0.0"\r
+         fragment="true"/>\r
+\r
+   <plugin\r
+         id="org.simantics.fmil.win64"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
          fragment="true"\r
-         unpack="true"/>\r
+         unpack="false"/>\r
 \r
 </feature>\r
index 726cd7bf26ce460f505ce70c302971ea644436ee..ac623b2fecd3e2bbe7495fdca665aee0d1a51242 100644 (file)
       <GenerateDebugInformation>true</GenerateDebugInformation>\r
       <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
       <OptimizeReferences>true</OptimizeReferences>\r
-      <AdditionalDependencies>fmilib_shared.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
+      <AdditionalDependencies>fmilib_shared32.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
     </Link>\r
   </ItemDefinitionGroup>\r
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
       <GenerateDebugInformation>true</GenerateDebugInformation>\r
       <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
       <OptimizeReferences>true</OptimizeReferences>\r
-      <AdditionalDependencies>$(OutDir)zlibwapi.lib;$(OutDir)miniunz.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
+      <AdditionalDependencies>fmilib_shared64.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
     </Link>\r
     <Manifest>\r
       <InputResourceManifests>\r
index caab8ac39cbbc0198635b5277829932406e362ed..ab87846a02cf15539812502cfb41864ddbf4dc4b 100644 (file)
@@ -77,6 +77,7 @@ extern "C" {
 typedef struct {\r
        char *name;\r
        char *description;\r
+       char *declaredType;\r
        long vr;\r
        // 0 = real\r
        // 1 = integer\r
@@ -98,9 +99,17 @@ typedef struct {
        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
@@ -184,12 +193,89 @@ int FMI1_CS_UNLOAD(void *fmu_) {
 \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
@@ -264,6 +350,13 @@ FMIL_Variable *FMI1_CS_GET_VARIABLES(void *fmu, int *count) {
                        \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
@@ -274,6 +367,38 @@ FMIL_Variable *FMI1_CS_GET_VARIABLES(void *fmu, int *count) {
 \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
@@ -330,14 +455,10 @@ int FMI1_CS_STEP(void *fmu, double masterTime, double stepSize) {
 \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
diff --git a/org.simantics.fmil/native/FMUSimulator/fmilib_shared64.lib b/org.simantics.fmil/native/FMUSimulator/fmilib_shared64.lib
new file mode 100644 (file)
index 0000000..191166a
Binary files /dev/null and b/org.simantics.fmil/native/FMUSimulator/fmilib_shared64.lib differ
index 24f7b183e0f3b5e3a6b7673e2c0f3194e2b07662..39b90b1d0e0b474d1a57b0729deda3cf5341b529 100644 (file)
@@ -219,7 +219,7 @@ public class FMIL {
 \r
                 fmuLoaded = true;\r
             } catch (UnsatisfiedLinkError err) {\r
-                throw new FMILException(UNSATISFIED_LINK);\r
+                throw new FMILException(UNSATISFIED_LINK, err);\r
             } catch (Exception e) {\r
                 throw new FMILException(e.getMessage());\r
             }\r
index d015189dc401fb172b9c48b64b42f81cebd01758..5b6f06f2694379315397479db4ff982f0b8dc3a4 100644 (file)
@@ -11,4 +11,8 @@ public class FMILException extends Exception {
     public FMILException(String message) {\r
         super(message);\r
     }\r
+    \r
+    public FMILException(String message, Throwable cause) {\r
+       super(message, cause);\r
+    }\r
 }\r