From 0d6824ca3083d16b08ab45cddd25ef09a11a8c72 Mon Sep 17 00:00:00 2001 From: "jussi.koskela" Date: Wed, 12 Nov 2014 11:32:10 +0000 Subject: [PATCH] (fixes #5474) Changes in experiment state not applied in order because reads are processed LIFO git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30543 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/manager/OldSysdynExperiment.java | 69 +++++++++---------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/OldSysdynExperiment.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/OldSysdynExperiment.java index 9f1332c2..8ebfb23f 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/OldSysdynExperiment.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/OldSysdynExperiment.java @@ -699,42 +699,35 @@ public class OldSysdynExperiment extends SysdynExperiment { } protected void setSysdynExperimentState(final ExperimentState state) { - sysdynExperimentState = state; - session.asyncRequest(new ReadRequest() { - - @Override - public void run(ReadGraph graph) throws DatabaseException { - VirtualGraphSupport support = graph.getService(VirtualGraphSupport.class); - final Session session = graph.getSession(); - session.asyncRequest(new WriteRequest(support.getWorkspacePersistent("experiments")) { - @Override - public void perform(WriteGraph graph) throws DatabaseException { - Layer0 L0 = Layer0.getInstance(graph); - SimulationResource SR = SimulationResource.getInstance(graph); - graph.deny(model, SR.HasExperimentState); - graph.deny(experiment, SR.HasExperimentState); - - Resource st = graph.newResource(); - switch(state) { - case INITIALIZING: - graph.claim(st, L0.InstanceOf, SR.ExperimentState_Initializing); - break; - case RUNNING: - graph.claim(st, L0.InstanceOf, SR.ExperimentState_Running); - break; - case STOPPED: - graph.claim(st, L0.InstanceOf, SR.ExperimentState_Stopped); - break; - case DISPOSED: - graph.claim(st, L0.InstanceOf, SR.ExperimentState_Disposed); - break; - } - - graph.claim(model, SR.HasExperimentState, st); - graph.claim(experiment, SR.HasExperimentState, st); - }}); - } - }); + sysdynExperimentState = state; + VirtualGraphSupport support = session.getService(VirtualGraphSupport.class); + session.asyncRequest(new WriteRequest(support.getWorkspacePersistent("experiments")) { + @Override + public void perform(WriteGraph graph) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(graph); + SimulationResource SR = SimulationResource.getInstance(graph); + graph.deny(model, SR.HasExperimentState); + graph.deny(experiment, SR.HasExperimentState); + + Resource st = graph.newResource(); + switch(state) { + case INITIALIZING: + graph.claim(st, L0.InstanceOf, SR.ExperimentState_Initializing); + break; + case RUNNING: + graph.claim(st, L0.InstanceOf, SR.ExperimentState_Running); + break; + case STOPPED: + graph.claim(st, L0.InstanceOf, SR.ExperimentState_Stopped); + break; + case DISPOSED: + graph.claim(st, L0.InstanceOf, SR.ExperimentState_Disposed); + break; + } + + graph.claim(model, SR.HasExperimentState, st); + graph.claim(experiment, SR.HasExperimentState, st); + }}); } /** @@ -909,13 +902,13 @@ public class OldSysdynExperiment extends SysdynExperiment { @Override public void simulateDuration(double duration) { - System.out.println("simulateDuartion"); + } @Override public void rewindTo(double time) { - System.out.println("rewindTo"); + } } -- 2.47.1