import org.simantics.db.common.ResourceArray;\r
import org.simantics.db.common.request.ReadRequest;\r
import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
import org.simantics.modeling.ComponentUtils;\r
import org.simantics.modeling.ModelingResources;\r
import org.simantics.modeling.ui.Activator;\r
import org.simantics.db.layer0.variable.Variables;\r
import org.simantics.db.service.LifecycleSupport;\r
import org.simantics.db.service.SerialisationSupport;\r
-import org.simantics.layer0.Layer0;\r
import org.simantics.operation.Layer0X;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.icons.ImageDescriptorProvider;\r
if (!exists)\r
throw new Nonexistant();\r
\r
- Layer0 L0 = Layer0.getInstance(g);\r
// 2. Validate modelURI\r
if (getModelURI() != null) {\r
Layer0X L0X = Layer0X.getInstance(g);\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.layer0.variable.Variable;\r
import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
import org.simantics.modeling.ui.features.EditorNamingService2;\r
import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.ui.workbench.IResourceEditorInput2;\r
*\r
*/\r
public class SysdynEditorNamingService extends EditorNamingService2 {\r
- \r
- @Override\r
- public String getName(ReadGraph g, String editorId, IEditorInput in) throws DatabaseException {\r
- if(in instanceof IResourceEditorInput2) {\r
- IResourceEditorInput2 input = (IResourceEditorInput2) in;\r
- \r
\r
- if(!input.getRVI().isEmpty()) {\r
- Resource model = g.getPossibleResource(input.getModelURI());\r
- if(model != null) {\r
- Resource configuration = g.getPossibleObject(model, SimulationResource.getInstance(g).HasConfiguration);\r
- String configurationName = NameUtils.getSafeName(g, configuration);\r
- String uri = input.getModelURI() + "/" + configurationName + input.getRVI();\r
- Variable v = Variables.getPossibleVariable(g, uri);\r
- if(v != null) {\r
- String name = input.getRVI();\r
- if(name.contains("/"))\r
- name = name.substring(name.lastIndexOf("/") + 1);\r
- \r
- String instanceOf = super.getName(g, editorId, in);\r
- return name + " : " + instanceOf;\r
- }\r
- }\r
- } \r
- }\r
- return super.getName(g, editorId, in);\r
- }\r
+ @Override\r
+ public String getName(ReadGraph g, String editorId, IEditorInput in) throws DatabaseException {\r
+ if(in instanceof IResourceEditorInput2) {\r
+ IResourceEditorInput2 input = (IResourceEditorInput2) in;\r
+\r
+ if(!input.getRVI().isEmpty()) {\r
+ Resource model = g.getPossibleResource(input.getModelURI());\r
+ if(model != null) {\r
+ Resource configuration = g.getPossibleObject(model, SimulationResource.getInstance(g).HasConfiguration);\r
+ String configurationName = NameUtils.getSafeName(g, configuration);\r
+ String uri = input.getModelURI() + "/" + configurationName + input.getRVI();\r
+ Variable v = Variables.getPossibleVariable(g, uri);\r
+ if(v != null) {\r
+ String name = input.getRVI();\r
+ if(name.contains("/"))\r
+ name = name.substring(name.lastIndexOf("/") + 1);\r
+\r
+ Resource instanceOf = g.getPossibleObject(v.getRepresents(g), Layer0.getInstance(g).InstanceOf);\r
+ return name + " : " + NameUtils.getSafeName(g, instanceOf);\r
+ }\r
+ }\r
+ } else {\r
+ ModelingResources mr = ModelingResources.getInstance(g);\r
+ Resource conf = g.getPossibleObject(input.getResource(), mr.DiagramToComposite);\r
+ if(conf != null) {\r
+ Resource module = g.getPossibleObject(conf, Layer0.getInstance(g).PartOf);\r
+ if(module != null) \r
+ return NameUtils.getSafeName(g, module);\r
+ }\r
+ }\r
+ }\r
+ return super.getName(g, editorId, in);\r
+ }\r
\r
}\r
*******************************************************************************/\r
package org.simantics.sysdyn.ui.trend.chart.properties;\r
\r
+import java.util.HashMap;\r
import java.util.Iterator;\r
import java.util.LinkedHashMap;\r
import java.util.List;\r
import org.simantics.db.management.ISessionContext;\r
import org.simantics.db.procedure.Listener;\r
import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
import org.simantics.sysdyn.JFreeChartResource;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.ui.trend.chart.ChartUtils;\r
Variable v = Variables.getVariable(graph, realizationURI + rvi.trim());\r
if(v == null)\r
return null;\r
+ \r
+ // Find all enumeration replacements in the variable's path\r
+ HashMap<Resource, Resource> redeclarations = new HashMap<Resource, Resource>();\r
+ Variable parent = v;\r
+ while((parent = parent.getParent(graph)) != null) {\r
+ Resource represents = parent.getRepresents(graph);\r
+ Resource type = graph.getSingleObject(represents, Layer0.getInstance(graph).InstanceOf);\r
+ if(!graph.isInheritedFrom(type, sr.Module))\r
+ break;\r
+ \r
+ for(Resource redeclaration : graph.getObjects(represents, sr.Module_redeclaration)) {\r
+ redeclarations.put(\r
+ graph.getPossibleObject(redeclaration, sr.Redeclaration_replacedEnumeration), \r
+ graph.getPossibleObject(redeclaration, sr.Redeclaration_replacingEnumeration)\r
+ );\r
+ }\r
+ }\r
+ \r
+ \r
+ \r
+ \r
Resource variable = v.getRepresents(graph);\r
\r
// Return the enumerations assigned to that variable\r
if(arrayIndexes != null) {\r
LinkedHashMap<String, Resource> result = new LinkedHashMap<String, Resource>();\r
for(Resource enumeration : OrderedSetUtils.toList(graph, arrayIndexes)) {\r
- String enumerationName = NameUtils.getSafeName(graph, enumeration);\r
- result.put(enumerationName, enumeration);\r
+ \r
+ // Find possible redeclarations for enumeration\r
+ Resource redeclaration = enumeration;\r
+ while(redeclarations.get(redeclaration) != null)\r
+ redeclaration = redeclarations.get(redeclaration);\r
+ \r
+ String enumerationName = NameUtils.getSafeName(graph, redeclaration);\r
+ result.put(enumerationName, redeclaration);\r
}\r
return result;\r
}\r
* @param configuration configuration where the variable is located\r
*/\r
static public void validateExpressionFields(final Resource variable, IExpression expression, Table variableTable) {\r
-\r
+ if(variable == null || expression == null || variableTable == null)\r
+ return;\r
+ \r
Resource configuration = null;\r
try {\r
configuration = SimanticsUI.getSession().syncRequest(new Read<Resource>() {\r
\r
\r
try {\r
- long t = System.currentTimeMillis();\r
- long oldT;\r
- \r
control.setStepLength(stepLength); // Set step length each time in case there has been changes\r
\r
double time = control.getTime();\r
\r
while(control.getTime() < (eTime - 1e-9)) { // Substract a very small number, because OpenModelica is not very precise with its Real numbers\r
\r
- oldT = t;\r
- t = System.currentTimeMillis();\r
- System.out.println("step start ----------------------------------------- ");\r
- \r
control.simulateStep();\r
\r
- System.out.println("simulate step \t\t " + (System.currentTimeMillis() - oldT));\r
-\r
-\r
results = control.getSubscribedResults(results);\r
\r
- System.out.println("results\t\t\t " + (System.currentTimeMillis() - oldT));\r
- \r
for(int k = 0; k < subscription.length; k++) {\r
this.results.get(subscription[k]).add(results[k]);\r
}\r
- \r
- oldT = t;\r
- t = System.currentTimeMillis(); \r
- System.out.println("step complete\t " + (t - oldT));\r
}\r
\r
- oldT = t;\r
- t = System.currentTimeMillis();\r
- System.out.println("results ready ------------------------------- ");\r
- \r
- \r
sysdynModel.getSysdynResult().setResult(new GameResult(this.results, this.subscription));\r
sysdynModel.resultChanged();\r
\r
- oldT = t;\r
- t = System.currentTimeMillis();\r
- System.out.println("results changed\t " + (t - oldT));\r
- \r
-\r
} catch (FMUJNIException e) {\r
System.err.println("SysdynGameExperiment simulateDuration failed: \n\t" + e.getMessage());\r
}\r