X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.fmil%2Fnative%2FFMUSimulator%2Fsrc%2Ffmu_control.cpp;h=c5c99412d644fc8752d99d039043115d982a8e1a;hb=66fb5872ade1db9ea79f072bbb22ed5dcb62f17f;hp=45d75862789430ac1562fbda250a77e15c34929c;hpb=dd1ca5e5d7fae427cae08e16c14e519df4727500;p=simantics%2Ffmil.git diff --git a/org.simantics.fmil/native/FMUSimulator/src/fmu_control.cpp b/org.simantics.fmil/native/FMUSimulator/src/fmu_control.cpp index 45d7586..c5c9941 100644 --- a/org.simantics.fmil/native/FMUSimulator/src/fmu_control.cpp +++ b/org.simantics.fmil/native/FMUSimulator/src/fmu_control.cpp @@ -42,11 +42,17 @@ struct FMI1 { vector variables; vector descriptions; + vector declaredTypes; vector valueReferences; vector types; vector variabilities; vector causalities; + vector declaredTypeNames; + vector typeDescriptions; + vector quantities; + vector units; + vector subscription; double currentTime; double timeStep; @@ -120,7 +126,9 @@ JNIEXPORT jint JNICALL Java_org_simantics_fmil_FMIL_loadFMUFile_1 HMODULE module = NULL; FMI1 fmi1; FMIL_Variable *vars; + FMIL_DeclaredType *types; int variableCount = 0; + int typeCount = 0; const char *fmuPath = env->GetStringUTFChars(path, 0); const char *fmuTempDir = env->GetStringUTFChars(tempDir, 0); @@ -138,12 +146,34 @@ JNIEXPORT jint JNICALL Java_org_simantics_fmil_FMIL_loadFMUFile_1 fmi1.descriptions.push_back(string(vars[i].description)); else fmi1.descriptions.push_back(string("")); + if(vars[i].declaredType) + fmi1.declaredTypes.push_back(string(vars[i].declaredType)); + else + fmi1.declaredTypes.push_back(string("")); fmi1.types.push_back(vars[i].type); fmi1.causalities.push_back(vars[i].causality); fmi1.variabilities.push_back(vars[i].variability); fmi1.valueReferences.push_back(vars[i].vr); } + types = FMI1_CS_GET_DECLARED_TYPES(fmi1.fmu, &typeCount); + for(int i=0;iReleaseStringUTFChars(path, fmuPath); @@ -433,6 +463,21 @@ JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableDescri } +JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableDeclaredTypes_1 + (JNIEnv *env, jobject obj, jint id) { + + jobjectArray ret= (jobjectArray)env->NewObjectArray(fmus[id].declaredTypes.size(), + env->FindClass("java/lang/String"), + env->NewStringUTF("")); + + for(int i=0;iSetObjectArrayElement(ret,i,env->NewStringUTF(fmus[id].declaredTypes[i].c_str())); + } + + return ret; + +} + JNIEXPORT jintArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableReferences_1 (JNIEnv *env, jobject obj, jint id, jintArray result) { @@ -513,6 +558,66 @@ JNIEXPORT jintArray JNICALL Java_org_simantics_fmil_FMIL_getAllVariableCausaliti } +JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllDeclaredTypes_1 + (JNIEnv *env, jobject obj, jint id) { + + jobjectArray ret= (jobjectArray)env->NewObjectArray(fmus[id].declaredTypeNames.size(), + env->FindClass("java/lang/String"), + env->NewStringUTF("")); + + for(int i=0;iSetObjectArrayElement(ret,i,env->NewStringUTF(fmus[id].declaredTypeNames[i].c_str())); + } + + return ret; + +} + +JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllDeclaredTypeDescriptions_1 + (JNIEnv *env, jobject obj, jint id) { + + jobjectArray ret= (jobjectArray)env->NewObjectArray(fmus[id].typeDescriptions.size(), + env->FindClass("java/lang/String"), + env->NewStringUTF("")); + + for(int i=0;iSetObjectArrayElement(ret,i,env->NewStringUTF(fmus[id].typeDescriptions[i].c_str())); + } + + return ret; + +} + +JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllDeclaredTypeQuantities_1 + (JNIEnv *env, jobject obj, jint id) { + + jobjectArray ret= (jobjectArray)env->NewObjectArray(fmus[id].quantities.size(), + env->FindClass("java/lang/String"), + env->NewStringUTF("")); + + for(int i=0;iSetObjectArrayElement(ret,i,env->NewStringUTF(fmus[id].quantities[i].c_str())); + } + + return ret; + +} + +JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_getAllDeclaredTypeUnits_1 + (JNIEnv *env, jobject obj, jint id) { + + jobjectArray ret= (jobjectArray)env->NewObjectArray(fmus[id].units.size(), + env->FindClass("java/lang/String"), + env->NewStringUTF("")); + + for(int i=0;iSetObjectArrayElement(ret,i,env->NewStringUTF(fmus[id].units[i].c_str())); + } + + return ret; + +} + /* JNIEXPORT jobjectArray JNICALL Java_org_simantics_fmil_FMIL_filterVariables_1 (JNIEnv *env, jobject obj, jstring id, jstring regexp) {