]> gerrit.simantics Code Review - simantics/fmil.git/commitdiff
(refs #6290) Import initial FMI Studio codebase
authorvillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 28 Jan 2016 06:36:15 +0000 (06:36 +0000)
committervillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 28 Jan 2016 06:36:15 +0000 (06:36 +0000)
More ontology for variables. Type, description, variability, causality

git-svn-id: https://www.simantics.org/svn/simantics/fmi/trunk@32331 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.fmil.win32/libraries/FMUSimulator.dll
org.simantics.fmil.win32/libraries/fmilib_shared.dll
org.simantics.fmil/native/FMUSimulator/FMUSimulator.vcxproj
org.simantics.fmil/native/FMUSimulator/fmi_util.c.txt
org.simantics.fmil/native/FMUSimulator/fmilib_shared.lib
org.simantics.fmil/native/FMUSimulator/include/fmi1_cs.h
org.simantics.fmil/native/FMUSimulator/include/org_simantics_fmil_FMILJNI.h
org.simantics.fmil/native/FMUSimulator/src/fmu_control.cpp
org.simantics.fmil/native/FMUSimulator/src/sim_support.c
org.simantics.fmil/src/org/simantics/fmil/FMIL.java

index 75711f20eb660ab6538f91342015418dcb530aa6..13157f637509a1bcacceccac0704ab10dcc0a4d6 100644 (file)
Binary files a/org.simantics.fmil.win32/libraries/FMUSimulator.dll and b/org.simantics.fmil.win32/libraries/FMUSimulator.dll differ
index 9e4ba2d3fab4389fc74c0ffee4f3057633a669aa..775bfad80b52fa4639fb1ce99fea6e9ce4773368 100644 (file)
Binary files a/org.simantics.fmil.win32/libraries/fmilib_shared.dll and b/org.simantics.fmil.win32/libraries/fmilib_shared.dll differ
index 3e20673a703c15fddfcf4447ad279a11b99c4365..726cd7bf26ce460f505ce70c302971ea644436ee 100644 (file)
       <GenerateDebugInformation>true</GenerateDebugInformation>\r
       <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
       <OptimizeReferences>true</OptimizeReferences>\r
-      <AdditionalDependencies>$(OutDir)zlibwapi.lib;$(OutDir)miniunz.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
+      <AdditionalDependencies>fmilib_shared.lib;%(AdditionalDependencies)</AdditionalDependencies>\r
     </Link>\r
   </ItemDefinitionGroup>\r
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
index 54b7a4830ed6951702977f68152e7697c5f5911a..caab8ac39cbbc0198635b5277829932406e362ed 100644 (file)
@@ -76,7 +76,26 @@ extern "C" {
 \r
 typedef struct {\r
        char *name;\r
+       char *description;\r
        long vr;\r
+       // 0 = real\r
+       // 1 = integer\r
+       // 2 = boolean\r
+       // 3 = string\r
+       // 4 = enumeration\r
+       int type;\r
+       // 0 = constant\r
+       // 1 = parameter\r
+       // 2 = discrete\r
+       // 3 = continuous\r
+       // 4 = unknown\r
+       int variability;\r
+       // 0 = input\r
+       // 1 = output\r
+       // 2 = internal\r
+       // 3 = none\r
+       // 4 = unknown\r
+       int causality;\r
 } FMIL_Variable;\r
 \r
 __declspec(dllexport) void* FMI1_CS_LOAD(const char *zipFilePath, const char *unzipFolder);\r
@@ -186,8 +205,63 @@ FMIL_Variable *FMI1_CS_GET_VARIABLES(void *fmu, int *count) {
 \r
                } else {\r
 \r
-                       fmi1_base_type_enu_t bt;\r
                        result[i].name = fmi1_import_get_variable_name(var);\r
+                       result[i].description = fmi1_import_get_variable_description(var);\r
+\r
+                       switch  (fmi1_import_get_variability(var)) {\r
+                       case fmi1_variability_enu_constant:\r
+                               result[i].variability = 0;\r
+                               break;\r
+                       case fmi1_variability_enu_parameter:\r
+                               result[i].variability = 1;\r
+                               break;\r
+                       case fmi1_variability_enu_discrete:\r
+                               result[i].variability = 2;\r
+                               break;\r
+                       case fmi1_variability_enu_continuous:\r
+                               result[i].variability = 3;\r
+                               break;\r
+                       case fmi1_variability_enu_unknown:\r
+                               result[i].variability = 4;\r
+                               break;\r
+                       }\r
+\r
+                       switch  (fmi1_import_get_causality(var)) {\r
+                       case fmi1_causality_enu_input:\r
+                               result[i].causality = 0;\r
+                               break;\r
+                       case fmi1_causality_enu_output:\r
+                               result[i].causality = 1;\r
+                               break;\r
+                       case fmi1_causality_enu_internal:\r
+                               result[i].causality = 2;\r
+                               break;\r
+                       case fmi1_causality_enu_none:\r
+                               result[i].causality = 3;\r
+                               break;\r
+                       case fmi1_causality_enu_unknown:\r
+                               result[i].causality = 4;\r
+                               break;\r
+                       }\r
+\r
+                       switch  (fmi1_import_get_variable_base_type(var)) {\r
+                       case fmi1_base_type_real:\r
+                               result[i].type = 0;\r
+                               break;\r
+                       case fmi1_base_type_int:\r
+                               result[i].type = 1;\r
+                               break;\r
+                       case fmi1_base_type_bool:\r
+                               result[i].type = 2;\r
+                               break;\r
+                       case fmi1_base_type_str:\r
+                               result[i].type = 3;\r
+                               break;\r
+                       case fmi1_base_type_enum:\r
+                               result[i].type = 4;\r
+                               break;\r
+                       }\r
+                       \r
                        result[i].vr = fmi1_import_get_variable_vr(var);\r
 \r
                }\r
index 872bfc68e87ffec7072b4ec95dfbb3d94fdff3c2..b65aa9bf7535a9573ae8015f30af21f12f1f83ac 100644 (file)
Binary files a/org.simantics.fmil/native/FMUSimulator/fmilib_shared.lib and b/org.simantics.fmil/native/FMUSimulator/fmilib_shared.lib differ
index 81bc098fd7073028f629f47f591e53c43f183fb2..464fdf4ced143b1cb2e09f584ed81f8beddce0c9 100644 (file)
@@ -7,7 +7,26 @@ extern "C" {
 \r
 typedef struct {\r
        char *name;\r
+       char *description;\r
        long vr;\r
+       // 0 = real\r
+       // 1 = integer\r
+       // 2 = boolean\r
+       // 3 = string\r
+       // 4 = enumeration\r
+       int type;\r
+       // 0 = constant\r
+       // 1 = parameter\r
+       // 2 = discrete\r
+       // 3 = continuous\r
+       // 4 = unknown\r
+       int variability;\r
+       // 0 = input\r
+       // 1 = output\r
+       // 2 = internal\r
+       // 3 = none\r
+       // 4 = unknown\r
+       int causality;\r
 } FMIL_Variable;\r
 \r
 __declspec(dllexport) void* FMI1_CS_LOAD(const char *zipFilePath, const char *unzipFolder);\r
index 0090c0b6844c756b2cfc21eaa61896a2fbb3f883..028fe641f0c076541a94daee4631fde9eeb50ea5 100644 (file)
@@ -123,9 +123,21 @@ JNIEXPORT jdouble JNICALL Java_org_simantics_fmil_FMIL_getTime_1
 JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariables_1\r
   (JNIEnv *, jobject, jint);\r
 \r
+JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableDescriptions_1\r
+  (JNIEnv *, jobject, jint);\r
+\r
 JNIEXPORT jintArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableReferences_1\r
   (JNIEnv *, jobject, jint, jintArray);\r
 \r
+JNIEXPORT jintArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableTypes_1\r
+  (JNIEnv *, jobject, jint, jintArray);\r
+\r
+JNIEXPORT jintArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableVariabilities_1\r
+  (JNIEnv *, jobject, jint, jintArray);\r
+\r
+JNIEXPORT jintArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableCausalities_1\r
+  (JNIEnv *, jobject, jint, jintArray);\r
+\r
 /*\r
  * Class:     org_simantics_fmu_FMUControlJNI\r
  * Method:    filterVariables_\r
index 43fe42c87d05cd1d12071ab4c00038d062e74774..45d75862789430ac1562fbda250a77e15c34929c 100644 (file)
@@ -39,9 +39,15 @@ using namespace std;
 struct FMI1 {\r
 \r
        void *fmu;\r
-       vector<string> variables;       // all variables in an initialized model\r
-       vector<int> valueReferences;            // all value references\r
-       vector<int> subscription;               // subscribed value references\r
+\r
+       vector<string> variables;\r
+       vector<string> descriptions;\r
+       vector<int> valueReferences;\r
+       vector<int> types;\r
+       vector<int> variabilities;\r
+       vector<int> causalities;\r
+\r
+       vector<int> subscription;\r
        double currentTime;\r
        double timeStep;\r
 \r
@@ -128,6 +134,13 @@ JNIEXPORT jint JNICALL Java_org_simantics_fmil_FMIL_loadFMUFile_1
    vars = FMI1_CS_GET_VARIABLES(fmi1.fmu, &variableCount);\r
    for(int i=0;i<variableCount;i++) {\r
           fmi1.variables.push_back(string(vars[i].name));\r
+          if(vars[i].description)\r
+                       fmi1.descriptions.push_back(string(vars[i].description));\r
+          else\r
+                       fmi1.descriptions.push_back(string(""));\r
+          fmi1.types.push_back(vars[i].type);\r
+          fmi1.causalities.push_back(vars[i].causality);\r
+          fmi1.variabilities.push_back(vars[i].variability);\r
           fmi1.valueReferences.push_back(vars[i].vr);\r
    }\r
 \r
@@ -405,6 +418,21 @@ JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariables_1
 \r
 }\r
 \r
+JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableDescriptions_1\r
+  (JNIEnv *env, jobject obj, jint id) {\r
+\r
+       jobjectArray ret= (jobjectArray)env->NewObjectArray(fmus[id].descriptions.size(),  \r
+                       env->FindClass("java/lang/String"),  \r
+                       env->NewStringUTF(""));  \r
+   \r
+       for(int i=0;i<fmus[id].descriptions.size();i++) {  \r
+               env->SetObjectArrayElement(ret,i,env->NewStringUTF(fmus[id].descriptions[i].c_str()));  \r
+       }  \r
+\r
+       return ret;  \r
+\r
+}\r
+\r
 JNIEXPORT jintArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableReferences_1\r
   (JNIEnv *env, jobject obj, jint id, jintArray result) {\r
 \r
@@ -425,6 +453,66 @@ JNIEXPORT jintArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableReference
 \r
 }\r
 \r
+JNIEXPORT jintArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableTypes_1\r
+  (JNIEnv *env, jobject obj, jint id, jintArray result) {\r
+\r
+       jboolean isCopy;\r
+       jint* resultElements = env -> GetIntArrayElements(result, &isCopy);\r
+       jsize n = env -> GetArrayLength(result);\r
+\r
+       int i;\r
+       for (i = 0; i < n; i++) {\r
+               resultElements[i] = fmus[id].types[i];\r
+       } \r
+         \r
+       if (isCopy == JNI_TRUE) {\r
+               env -> ReleaseIntArrayElements(result, resultElements, 0);\r
+       }\r
+\r
+       return result;\r
+\r
+}\r
+\r
+JNIEXPORT jintArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableVariabilities_1\r
+  (JNIEnv *env, jobject obj, jint id, jintArray result) {\r
+\r
+       jboolean isCopy;\r
+       jint* resultElements = env -> GetIntArrayElements(result, &isCopy);\r
+       jsize n = env -> GetArrayLength(result);\r
+\r
+       int i;\r
+       for (i = 0; i < n; i++) {\r
+               resultElements[i] = fmus[id].variabilities[i];\r
+       } \r
+         \r
+       if (isCopy == JNI_TRUE) {\r
+               env -> ReleaseIntArrayElements(result, resultElements, 0);\r
+       }\r
+\r
+       return result;\r
+\r
+}\r
+\r
+JNIEXPORT jintArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableCausalities_1\r
+  (JNIEnv *env, jobject obj, jint id, jintArray result) {\r
+\r
+       jboolean isCopy;\r
+       jint* resultElements = env -> GetIntArrayElements(result, &isCopy);\r
+       jsize n = env -> GetArrayLength(result);\r
+\r
+       int i;\r
+       for (i = 0; i < n; i++) {\r
+               resultElements[i] = fmus[id].causalities[i];\r
+       } \r
+         \r
+       if (isCopy == JNI_TRUE) {\r
+               env -> ReleaseIntArrayElements(result, resultElements, 0);\r
+       }\r
+\r
+       return result;\r
+\r
+}\r
+\r
 /*\r
 JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_filterVariables_1\r
   (JNIEnv *env, jobject obj, jstring id, jstring regexp) {\r
index fba8ac27471129318b2cced69993118da0543db2..5f2cb62170d8aaed5409531bd9b650ed8b19b29f 100644 (file)
@@ -19,7 +19,7 @@
 #endif\r
 \r
 #include "sim_support.h"\r
-#include "fmuExtract.h"\r
+//#include "fmuExtract.h"\r
 \r
 // fileName is an absolute path, e.g. C:\test\a.fmu\r
 // or relative to the current dir, e.g. ..\test\a.fmu\r
index 70d6028a2c410f5f45697bfb3e816c81da1208dd..1302634970eee16fb7e18ee55a48a7b83c509e3a 100644 (file)
@@ -106,7 +106,11 @@ public class FMIL {
     private String dirName;\r
 \r
        private String[] variableNames;\r
+       private String[] variableDescriptions;\r
        private int[] variableReferences;\r
+       private int[] variableTypes;\r
+       private int[] variableCausalities;\r
+       private int[] variableVariabilities;\r
        private TObjectIntHashMap<String> variableMap = new TObjectIntHashMap<String>();\r
        \r
        private Set<String> subscriptionSet = new HashSet<String>();\r
@@ -583,10 +587,26 @@ public class FMIL {
 \r
     private native String[] getAllVariables_(int id);\r
 \r
-    /**\r
-     * Get all variables in a loaded model\r
-     * @return all variables in a loaded model\r
-     */\r
+    public String[] getAllVariableDescriptions() throws FMILException {\r
+        synchronized(syncObject) {\r
+\r
+            try {\r
+\r
+               if(variableDescriptions == null) {\r
+                       variableDescriptions = getAllVariableDescriptions_(getModelIDNew());\r
+               }\r
+               return variableDescriptions;\r
+\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMILException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMILException(e.getMessage());\r
+            }\r
+        }\r
+    }\r
+\r
+    private native String[] getAllVariableDescriptions_(int id);\r
+    \r
     public int[] getAllVariableReferences() throws FMILException {\r
         synchronized(syncObject) {\r
 \r
@@ -606,6 +626,66 @@ public class FMIL {
     }\r
 \r
     private native int[] getAllVariableReferences_(int id, int[] array);\r
+\r
+    public int[] getAllVariableTypes() throws FMILException {\r
+        synchronized(syncObject) {\r
+\r
+            try {\r
+\r
+               if(variableTypes == null) {\r
+                       variableTypes = getAllVariableTypes_(getModelIDNew(), new int[variableNames.length]); \r
+               }\r
+               return variableTypes;\r
+\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMILException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMILException(e.getMessage());\r
+            }\r
+        }\r
+    }\r
+\r
+    private native int[] getAllVariableTypes_(int id, int[] array);\r
+\r
+    public int[] getAllVariableCausalities() throws FMILException {\r
+        synchronized(syncObject) {\r
+\r
+            try {\r
+\r
+               if(variableCausalities == null) {\r
+                       variableCausalities = getAllVariableCausalities_(getModelIDNew(), new int[variableNames.length]); \r
+               }\r
+               return variableCausalities;\r
+\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMILException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMILException(e.getMessage());\r
+            }\r
+        }\r
+    }\r
+\r
+    private native int[] getAllVariableCausalities_(int id, int[] array);\r
+\r
+    public int[] getAllVariableVariabilities() throws FMILException {\r
+        synchronized(syncObject) {\r
+\r
+            try {\r
+\r
+               if(variableVariabilities == null) {\r
+                       variableVariabilities = getAllVariableVariabilities_(getModelIDNew(), new int[variableNames.length]); \r
+               }\r
+               return variableVariabilities;\r
+\r
+            } catch (UnsatisfiedLinkError err) {\r
+                throw new FMILException(UNSATISFIED_LINK);\r
+            } catch (Exception e) {\r
+                throw new FMILException(e.getMessage());\r
+            }\r
+        }\r
+    }\r
+\r
+    private native int[] getAllVariableVariabilities_(int id, int[] array);\r
     \r
 //\r
 //    /**\r