From: jussi.koskela Date: Thu, 9 Oct 2014 07:31:42 +0000 (+0000) Subject: (fixes #5379) Loading IC publishes intermediate results for each change X-Git-Tag: v1.29.0~165 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=ddd40f3bbd6121d0646b16d7c4de0384a4e829ca;p=simantics%2Fsysdyn.git (fixes #5379) Loading IC publishes intermediate results for each change git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30389 ac1ea38d-2e2b-0410-8846-a27921b304fc --- 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 0a2868a2..9f1332c2 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/OldSysdynExperiment.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/OldSysdynExperiment.java @@ -847,10 +847,16 @@ public class OldSysdynExperiment extends SysdynExperiment { public void resultsChanged() { resultsChanged(false); } + + protected void onPublishResults() { + resultsChanged(true); + } public void setPublishResults(boolean value) { publishResults = value; - if(publishResults) resultsChanged(true); + if(publishResults) { + onPublishResults(); + } } public void resultsChanged(boolean force) { diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java index a2d35c7d..0253f9a5 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java @@ -318,8 +318,13 @@ public class SysdynExperiments { Variable base = Variables.getVariable(graph, run); + SysdynExperiments.setPublishResults(graph, base, false); + PartialIC data = graph.getPossibleRelatedValue(ic, SYSDYN.InitialCondition_HasInitialValues, PartialIC.BINDING); data.apply(graph, base); + + SysdynExperiments.setPublishResults(graph, base, true); + } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperimentBase.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperimentBase.java index c4de04a1..31314bbd 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperimentBase.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperimentBase.java @@ -18,10 +18,12 @@ import java.util.Collection; import java.util.HashMap; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.jobs.Job; import org.simantics.db.AsyncReadGraph; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; +import org.simantics.db.common.utils.Logger; import org.simantics.db.exception.DatabaseException; import org.simantics.db.procedure.AsyncListener; import org.simantics.db.request.Read; @@ -214,5 +216,16 @@ abstract public class SysdynGameExperimentBase extends OldSysdynExperiment { } } + + @Override + protected void onPublishResults() { + try { + setSubscribedResults(new NullProgressMonitor(), getSolver().getTime()); + } catch (FMUJNIException e) { + Logger.defaultLogError(e); + } + ((MemoryResult)getCurrentResult()).setResult(new GameResult(this, this.results, this.subscription)); + super.onPublishResults(); + } } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperimentInternal.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperimentInternal.java index 1dfc9a8d..71025a73 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperimentInternal.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperimentInternal.java @@ -153,9 +153,11 @@ public class SysdynGameExperimentInternal extends SysdynGameExperimentBase { @Override public void refresh() { try { - setSubscribedResults(new NullProgressMonitor(), solver.getTime()); - - ((MemoryResult)getCurrentResult()).setResult(new GameResult(this, this.results, this.subscription)); + + if(publishResults) { + setSubscribedResults(new NullProgressMonitor(), solver.getTime()); + ((MemoryResult)getCurrentResult()).setResult(new GameResult(this, this.results, this.subscription)); + } resultsChanged(true); } catch (Exception e) {