]> gerrit.simantics Code Review - simantics/fmil.git/commitdiff
(refs #6290) Added functions
authorvillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Sun, 31 Jan 2016 20:59:10 +0000 (20:59 +0000)
committervillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Sun, 31 Jan 2016 20:59:10 +0000 (20:59 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/fmi/trunk@32339 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/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/src/org/simantics/fmil/FMIL.java

index 13157f637509a1bcacceccac0704ab10dcc0a4d6..1c48c0080f85efb1d701350e8461c23214c54961 100644 (file)
Binary files a/org.simantics.fmil.win32/libraries/FMUSimulator.dll and b/org.simantics.fmil.win32/libraries/FMUSimulator.dll differ
index 775bfad80b52fa4639fb1ce99fea6e9ce4773368..874787a2cf99aaf32edcab5c44a1c92e8e231c59 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 b65aa9bf7535a9573ae8015f30af21f12f1f83ac..4a2c02768cee44717b6583334ca136257976523c 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 464fdf4ced143b1cb2e09f584ed81f8beddce0c9..65072e1f41f311a1c750eba72259ffcd292fca01 100644 (file)
@@ -8,6 +8,7 @@ extern "C" {
 typedef struct {\r
        char *name;\r
        char *description;\r
+       char *declaredType;\r
        long vr;\r
        // 0 = real\r
        // 1 = integer\r
@@ -29,9 +30,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
index 028fe641f0c076541a94daee4631fde9eeb50ea5..7f860d2e5698c6b176a49e7bc14f5b7e89e7e4f7 100644 (file)
@@ -126,6 +126,9 @@ JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariables_1
 JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableDescriptions_1\r
   (JNIEnv *, jobject, jint);\r
 \r
+JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableDeclaredTypes_1\r
+  (JNIEnv *, jobject, jint);\r
+\r
 JNIEXPORT jintArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableReferences_1\r
   (JNIEnv *, jobject, jint, jintArray);\r
 \r
@@ -138,6 +141,18 @@ JNIEXPORT jintArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableVariabili
 JNIEXPORT jintArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableCausalities_1\r
   (JNIEnv *, jobject, jint, jintArray);\r
 \r
+JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllDeclaredTypes_1\r
+  (JNIEnv *, jobject, jint);\r
+\r
+JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllDeclaredTypeDescriptions_1\r
+  (JNIEnv *, jobject, jint);\r
+\r
+JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllDeclaredTypeQuantities_1\r
+  (JNIEnv *, jobject, jint);\r
+\r
+JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllDeclaredTypeUnits_1\r
+  (JNIEnv *, jobject, jint);\r
+\r
 /*\r
  * Class:     org_simantics_fmu_FMUControlJNI\r
  * Method:    filterVariables_\r
index 45d75862789430ac1562fbda250a77e15c34929c..c5c99412d644fc8752d99d039043115d982a8e1a 100644 (file)
@@ -42,11 +42,17 @@ struct FMI1 {
 \r
        vector<string> variables;\r
        vector<string> descriptions;\r
+       vector<string> declaredTypes;\r
        vector<int> valueReferences;\r
        vector<int> types;\r
        vector<int> variabilities;\r
        vector<int> causalities;\r
 \r
+       vector<string> declaredTypeNames;\r
+       vector<string> typeDescriptions;\r
+       vector<string> quantities;\r
+       vector<string> units;\r
+\r
        vector<int> subscription;\r
        double currentTime;\r
        double timeStep;\r
@@ -120,7 +126,9 @@ JNIEXPORT jint JNICALL Java_org_simantics_fmil_FMIL_loadFMUFile_1
        HMODULE module = NULL;\r
        FMI1 fmi1;\r
        FMIL_Variable *vars;\r
+       FMIL_DeclaredType *types;\r
        int variableCount = 0;\r
+       int typeCount = 0;\r
 \r
     const char *fmuPath = env->GetStringUTFChars(path, 0);\r
        const char *fmuTempDir = env->GetStringUTFChars(tempDir, 0);\r
@@ -138,12 +146,34 @@ JNIEXPORT jint JNICALL Java_org_simantics_fmil_FMIL_loadFMUFile_1
                        fmi1.descriptions.push_back(string(vars[i].description));\r
           else\r
                        fmi1.descriptions.push_back(string(""));\r
+          if(vars[i].declaredType)\r
+                       fmi1.declaredTypes.push_back(string(vars[i].declaredType));\r
+          else\r
+                       fmi1.declaredTypes.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
+   types = FMI1_CS_GET_DECLARED_TYPES(fmi1.fmu, &typeCount);\r
+   for(int i=0;i<typeCount;i++) {\r
+          fmi1.declaredTypeNames.push_back(string(types[i].name));\r
+          if(types[i].description)\r
+                       fmi1.typeDescriptions.push_back(string(types[i].description));\r
+          else\r
+                       fmi1.typeDescriptions.push_back(string(""));\r
+          if(types[i].quantity)\r
+                       fmi1.quantities.push_back(string(types[i].quantity));\r
+          else\r
+                       fmi1.quantities.push_back(string(""));\r
+          if(types[i].unit)\r
+                       fmi1.units.push_back(string(types[i].unit));\r
+          else\r
+                       fmi1.units.push_back(string(""));\r
+   }\r
+\r
+\r
    fmus.push_back(fmi1);\r
 \r
        env->ReleaseStringUTFChars(path, fmuPath);\r
@@ -433,6 +463,21 @@ JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableDescri
 \r
 }\r
 \r
+JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableDeclaredTypes_1\r
+  (JNIEnv *env, jobject obj, jint id) {\r
+\r
+       jobjectArray ret= (jobjectArray)env->NewObjectArray(fmus[id].declaredTypes.size(),  \r
+                       env->FindClass("java/lang/String"),  \r
+                       env->NewStringUTF(""));\r
+   \r
+       for(int i=0;i<fmus[id].declaredTypes.size();i++) {  \r
+               env->SetObjectArrayElement(ret,i,env->NewStringUTF(fmus[id].declaredTypes[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
@@ -513,6 +558,66 @@ JNIEXPORT jintArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableCausaliti
 \r
 }\r
 \r
+JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllDeclaredTypes_1\r
+  (JNIEnv *env, jobject obj, jint id) {\r
+\r
+       jobjectArray ret= (jobjectArray)env->NewObjectArray(fmus[id].declaredTypeNames.size(),  \r
+                       env->FindClass("java/lang/String"),  \r
+                       env->NewStringUTF(""));\r
+   \r
+       for(int i=0;i<fmus[id].declaredTypeNames.size();i++) {  \r
+               env->SetObjectArrayElement(ret,i,env->NewStringUTF(fmus[id].declaredTypeNames[i].c_str()));  \r
+       }  \r
+\r
+       return ret;  \r
+\r
+}\r
+\r
+JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllDeclaredTypeDescriptions_1\r
+  (JNIEnv *env, jobject obj, jint id) {\r
+\r
+       jobjectArray ret= (jobjectArray)env->NewObjectArray(fmus[id].typeDescriptions.size(),  \r
+                       env->FindClass("java/lang/String"),  \r
+                       env->NewStringUTF(""));\r
+   \r
+       for(int i=0;i<fmus[id].typeDescriptions.size();i++) {  \r
+               env->SetObjectArrayElement(ret,i,env->NewStringUTF(fmus[id].typeDescriptions[i].c_str()));  \r
+       }  \r
+\r
+       return ret;  \r
+\r
+}\r
+\r
+JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllDeclaredTypeQuantities_1\r
+  (JNIEnv *env, jobject obj, jint id) {\r
+\r
+       jobjectArray ret= (jobjectArray)env->NewObjectArray(fmus[id].quantities.size(),  \r
+                       env->FindClass("java/lang/String"),  \r
+                       env->NewStringUTF(""));\r
+   \r
+       for(int i=0;i<fmus[id].quantities.size();i++) {  \r
+               env->SetObjectArrayElement(ret,i,env->NewStringUTF(fmus[id].quantities[i].c_str()));  \r
+       }  \r
+\r
+       return ret;  \r
+\r
+}\r
+\r
+JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllDeclaredTypeUnits_1\r
+  (JNIEnv *env, jobject obj, jint id) {\r
+\r
+       jobjectArray ret= (jobjectArray)env->NewObjectArray(fmus[id].units.size(),  \r
+                       env->FindClass("java/lang/String"),  \r
+                       env->NewStringUTF(""));\r
+   \r
+       for(int i=0;i<fmus[id].units.size();i++) {  \r
+               env->SetObjectArrayElement(ret,i,env->NewStringUTF(fmus[id].units[i].c_str()));  \r
+       }  \r
+\r
+       return ret;  \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 1302634970eee16fb7e18ee55a48a7b83c509e3a..24f7b183e0f3b5e3a6b7673e2c0f3194e2b07662 100644 (file)
@@ -107,10 +107,17 @@ public class FMIL {
 \r
        private String[] variableNames;\r
        private String[] variableDescriptions;\r
+       private String[] variableDeclaredTypes;\r
        private int[] variableReferences;\r
        private int[] variableTypes;\r
        private int[] variableCausalities;\r
        private int[] variableVariabilities;\r
+       \r
+       private String[] declaredTypes;\r
+       private String[] declaredTypeDescriptions;\r
+       private String[] declaredTypeQuantities;\r
+       private String[] declaredTypeUnits;\r
+       \r
        private TObjectIntHashMap<String> variableMap = new TObjectIntHashMap<String>();\r
        \r
        private Set<String> subscriptionSet = new HashSet<String>();\r
@@ -607,6 +614,26 @@ public class FMIL {
 \r
     private native String[] getAllVariableDescriptions_(int id);\r
     \r
+    public String[] getAllVariableDeclaredTypes() throws FMILException {\r
+        synchronized(syncObject) {\r
+\r
+            try {\r
+\r
+               if(variableDeclaredTypes == null) {\r
+                       variableDeclaredTypes = getAllVariableDeclaredTypes_(getModelIDNew());\r
+               }\r
+               return variableDeclaredTypes;\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[] getAllVariableDeclaredTypes_(int id);\r
+\r
     public int[] getAllVariableReferences() throws FMILException {\r
         synchronized(syncObject) {\r
 \r
@@ -686,6 +713,91 @@ public class FMIL {
     }\r
 \r
     private native int[] getAllVariableVariabilities_(int id, int[] array);\r
+\r
+    /**\r
+     * Get all variables in a loaded model\r
+     * @return all variables in a loaded model\r
+     */\r
+    public String[] getAllDeclaredTypes() throws FMILException {\r
+        synchronized(syncObject) {\r
+\r
+            try {\r
+\r
+               if(declaredTypes == null) {\r
+                       declaredTypes = getAllDeclaredTypes_(getModelIDNew());\r
+               }\r
+               return declaredTypes;\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[] getAllDeclaredTypes_(int id);\r
+    \r
+    public String[] getAllDeclaredTypeDescriptions() throws FMILException {\r
+        synchronized(syncObject) {\r
+\r
+            try {\r
+\r
+               if(declaredTypeDescriptions == null) {\r
+                       declaredTypeDescriptions = getAllDeclaredTypeDescriptions_(getModelIDNew());\r
+               }\r
+               return declaredTypeDescriptions;\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[] getAllDeclaredTypeDescriptions_(int id);\r
+    \r
+    public String[] getAllDeclaredTypeQuantities() throws FMILException {\r
+        synchronized(syncObject) {\r
+\r
+            try {\r
+\r
+               if(declaredTypeQuantities == null) {\r
+                       declaredTypeQuantities = getAllDeclaredTypeQuantities_(getModelIDNew());\r
+               }\r
+               return declaredTypeQuantities;\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[] getAllDeclaredTypeQuantities_(int id);\r
+\r
+    public String[] getAllDeclaredTypeUnits() throws FMILException {\r
+        synchronized(syncObject) {\r
+\r
+            try {\r
+\r
+               if(declaredTypeUnits == null) {\r
+                       declaredTypeUnits = getAllDeclaredTypeUnits_(getModelIDNew());\r
+               }\r
+               return declaredTypeUnits;\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[] getAllDeclaredTypeUnits_(int id);\r
+    \r
     \r
 //\r
 //    /**\r