From 5995c2c9f891ae852a40b4c4736b090d514e7c0a Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Thu, 15 Oct 2020 16:43:52 +0200 Subject: [PATCH] Improved usage of CoreModelParametersBuilder --- .../logic/model/am2900/machine/Am2900Machine.java | 2 +- .../logic/model/examples/CountGatesPerComponent.java | 4 ++-- .../mograsim/logic/model/SimpleLogicUIStandalone.java | 2 +- .../logic/model/modeladapter/CoreModelParameters.java | 9 +++++++++ .../src/net/mograsim/plugin/SimulationPreview.java | 2 +- .../logic/model/am2900/util/TestEnvironmentHelper.java | 3 ++- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900Machine.java b/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900Machine.java index 3d3d6c39..70f6a730 100644 --- a/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900Machine.java +++ b/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/machine/Am2900Machine.java @@ -57,7 +57,7 @@ public class Am2900Machine implements Machine "resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/Am2900.json", "Am2900"); this.amicListeners = new HashSet<>(); - CoreModelParametersBuilder paramsBuilder = new CoreModelParametersBuilder(); + CoreModelParametersBuilder paramsBuilder = CoreModelParameters.builder(); paramsBuilder.gateProcessTime = 50; paramsBuilder.hardcodedComponentProcessTime = paramsBuilder.gateProcessTime * 5; paramsBuilder.wireTravelTime = 10; diff --git a/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/CountGatesPerComponent.java b/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/CountGatesPerComponent.java index b9c73985..679f9d9a 100755 --- a/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/CountGatesPerComponent.java +++ b/plugins/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/CountGatesPerComponent.java @@ -8,7 +8,7 @@ import java.util.Map.Entry; import net.mograsim.logic.model.am2900.Am2900Loader; import net.mograsim.logic.model.model.LogicModelModifiable; import net.mograsim.logic.model.model.components.ModelComponent; -import net.mograsim.logic.model.modeladapter.CoreModelParameters.CoreModelParametersBuilder; +import net.mograsim.logic.model.modeladapter.CoreModelParameters; import net.mograsim.logic.model.modeladapter.LogicCoreAdapter; import net.mograsim.logic.model.serializing.IndirectModelComponentCreator; @@ -29,7 +29,7 @@ public class CountGatesPerComponent IndirectModelComponentCreator.createComponent(model, componentID); LogicCoreAdapter.gateCountsPerComponentClass.clear(); - LogicCoreAdapter.convert(model, new CoreModelParametersBuilder().build()); + LogicCoreAdapter.convert(model, CoreModelParameters.builder().build()); System.out.println(componentID + ':'); for (Entry, Integer> e : LogicCoreAdapter.gateCountsPerComponentClass.entrySet()) diff --git a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/SimpleLogicUIStandalone.java b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/SimpleLogicUIStandalone.java index dab45843..20bfcccb 100644 --- a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/SimpleLogicUIStandalone.java +++ b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/SimpleLogicUIStandalone.java @@ -18,7 +18,7 @@ public class SimpleLogicUIStandalone public static void executeVisualisation(Consumer setupLogicModel, Consumer beforeRun) { - CoreModelParametersBuilder paramsBuilder = new CoreModelParametersBuilder(); + CoreModelParametersBuilder paramsBuilder = CoreModelParameters.builder(); paramsBuilder.gateProcessTime = 50; paramsBuilder.hardcodedComponentProcessTime = paramsBuilder.gateProcessTime * 5; paramsBuilder.wireTravelTime = 10; diff --git a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/modeladapter/CoreModelParameters.java b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/modeladapter/CoreModelParameters.java index 6111e0b2..181f6eff 100644 --- a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/modeladapter/CoreModelParameters.java +++ b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/modeladapter/CoreModelParameters.java @@ -20,12 +20,21 @@ public class CoreModelParameters this.hardcodedComponentProcessTime = builder.hardcodedComponentProcessTime; } + public static CoreModelParametersBuilder builder() + { + return new CoreModelParametersBuilder(); + } + public static class CoreModelParametersBuilder { public int wireTravelTime; public int gateProcessTime; public int hardcodedComponentProcessTime; + private CoreModelParametersBuilder() + { + } + public CoreModelParametersBuilder wireTravelTime(int wireTravelTime) { this.wireTravelTime = wireTravelTime; diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/SimulationPreview.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/SimulationPreview.java index 45d5540a..7b131d58 100644 --- a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/SimulationPreview.java +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/SimulationPreview.java @@ -35,7 +35,7 @@ public class SimulationPreview implements IThemePreview LogicModelModifiable model = new LogicModelModifiable(); - CoreModelParametersBuilder paramsBuilder = new CoreModelParametersBuilder(); + CoreModelParametersBuilder paramsBuilder = CoreModelParameters.builder(); paramsBuilder.gateProcessTime = 50; paramsBuilder.hardcodedComponentProcessTime = paramsBuilder.gateProcessTime * 5; paramsBuilder.wireTravelTime = 10; diff --git a/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/util/TestEnvironmentHelper.java b/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/util/TestEnvironmentHelper.java index 5adf93d0..aeb1becd 100644 --- a/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/util/TestEnvironmentHelper.java +++ b/tests/net.mograsim.logic.model.am2900.tests/src/net/mograsim/logic/model/am2900/util/TestEnvironmentHelper.java @@ -27,6 +27,7 @@ import net.mograsim.logic.model.model.components.atomic.ModelManualSwitch; import net.mograsim.logic.model.model.components.submodels.SubmodelComponent; import net.mograsim.logic.model.model.wires.ModelWire; import net.mograsim.logic.model.model.wires.Pin; +import net.mograsim.logic.model.modeladapter.CoreModelParameters; import net.mograsim.logic.model.modeladapter.CoreModelParameters.CoreModelParametersBuilder; import net.mograsim.logic.model.modeladapter.LogicCoreAdapter; import net.mograsim.logic.model.preferences.DefaultRenderPreferences; @@ -89,7 +90,7 @@ public class TestEnvironmentHelper component.getPins().values().forEach(this::extendModelPin); // Create core model - CoreModelParametersBuilder paramsBuilder = new CoreModelParametersBuilder(); + CoreModelParametersBuilder paramsBuilder = CoreModelParameters.builder(); paramsBuilder.gateProcessTime = 50; paramsBuilder.hardcodedComponentProcessTime = paramsBuilder.gateProcessTime * 5; paramsBuilder.wireTravelTime = 10; -- 2.17.1