JNIEXPORT jstring JNICALL Java_org_simantics_modelica_fmi_FMUControlJNI_getLastErrorMessage_1\r
(JNIEnv *, jobject);\r
\r
+/*\r
+ * Class: org_simantics_modelica_fmi_FMUControlJNI\r
+ * Method: getRealValue_\r
+ * Signature: (Ljava/lang/String;)D\r
+ */\r
+JNIEXPORT jdouble JNICALL Java_org_simantics_modelica_fmi_FMUControlJNI_getRealValue_1\r
+ (JNIEnv *, jobject, jstring);\r
+\r
#ifdef __cplusplus\r
}\r
#endif\r
VirtualGraphSupport support = session.getService(VirtualGraphSupport.class);\r
\r
support.getWorkspacePersistent("experiments");\r
+ support.getWorkspacePersistent("profiles");\r
+// support.getWorkspacePersistent("preferences");\r
+ support.getWorkspacePersistent("issues");\r
\r
} catch (DatabaseException e) {\r
\r
| "break" | "encapsulated" | "if" | "output" | "true"\r
| "class" | "end" | "import" | "package" | "type"\r
| "connect" | "enumeration" | "in" | "parameter" | "when"\r
-| "connector" | "equation" | "initial" | "partial" | "while"\r
+| "connector" | "equation" | /*"initial" |*/ "partial" | "while"\r
| "constant" | "expandable" | "inner" | "protected" | "within"\r
| "constrainedby" | "extends" | "input" | "public"\r
-| "der" | "external" | "loop" | "record"\r
+| /*"der" |*/ "external" | "loop" | "record"\r
| "(" | ")" | "{" | "}" | "[" | "]" | "." | ":" | ";" | ","\r
| "<" | "<=" | ">" | ">=" | "==" | "<>"\r
| "+" | "-" | ".+" | ".-"\r
\r
// Initialize results\r
results.clear();\r
- results.put("time", new ArrayList<Double>());\r
- results.get("time").add(control.getTime());\r
\r
double[] initialValues = new double[subscription.length];\r
initialValues = control.getSubscribedResults(initialValues);\r
while(control.getTime() < (eTime - 1e-9)) { // Substract a very small number, because OpenModelica is not very precise with its Real numbers\r
control.simulateStep();\r
results = control.getSubscribedResults(results);\r
- this.results.get("time").add(control.getTime());\r
for(int k = 0; k < subscription.length; k++) {\r
this.results.get(subscription[k]).add(results[k]);\r
}\r
import org.simantics.sysdyn.representation.ModuleType;\r
import org.simantics.sysdyn.representation.Stock;\r
import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.utils.RepresentationUtils;\r
\r
/**\r
* ModelicaWriter writes Sysdyn model representations (objmap) into Modelica code.\r
*/\r
private static void writeConfiguration(Configuration configuration, StringBuilder b) {\r
String app;\r
+ \r
+ boolean game = RepresentationUtils.isGameExperimentActive();\r
\r
// Lists for storing different configuration elements\r
ArrayList<IndependentVariable> variables = new ArrayList<IndependentVariable>();\r
app = variable.getDeclaration();\r
if (app != null) b.append(app);\r
}\r
+ \r
+ \r
+ // Time variable for FMU (game) simulations\r
+ if(game) {\r
+ if(configuration.getModel() != null)\r
+ // Parameter for model root. Values changed in FMU simulator\r
+ b.append("parameter Real time = 0;\n");\r
+ else\r
+ // Continuous variable for module instances\r
+ b.append("Real time;\n");\r
+\r
+ }\r
\r
if(!modules.isEmpty()) {\r
b.append("// Module definitions\n");\r
b.append(" " + moduleLabel + "." + input.getName() + " = " + input.getDefaultInputValue(moduleLabel) + ";\n");\r
}\r
}\r
+ \r
+ if(game && !modules.isEmpty()) {\r
+ b.append("// Time values for module\n");\r
+ for(Module m : modules) {\r
+ b.append(" " + m.getName() + ".time = time;\n");\r
+ }\r
+ }\r
\r
b.append("end ").append(className).append(";\n\n");\r
\r
* @return Variabilty of a variable\r
*/\r
static public Variability getVariability(IndependentVariable variable) {\r
- if(RepresentationUtils.isGameExperimentActive())\r
+ if(RepresentationUtils.isGameExperimentActive() && !(variable instanceof Stock))\r
// FIXME: Game experiment may not be runnable even if normal experiments are. \r
return getVariability(variable, false, null);\r
else\r
}\r
}\r
} catch (ParseException e) {\r
+ e.printStackTrace();\r
}\r
return true;\r
}\r
if(useStartValue(variable))\r
return null;\r
// format the initial equation for modelica execution \r
- String equation = FormatUtils.formatExpressionForModelica(variable, initialEquation);\r
+ String equation = FormatUtils.formatExpressionForModelica(variable, initialEquation, false);\r
String range = IndexUtils.rangeToIndexes(variable, this.getArrayRange());\r
if(range == null)\r
range = "";\r