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
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
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
\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
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
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
\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
\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
\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
\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
}\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