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