import net.mograsim.logic.model.model.components.ModelComponent;
import net.mograsim.logic.model.model.components.atomic.ModelClock;
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.serializing.IndirectModelComponentCreator;
import net.mograsim.machine.AssignableMainMemory;
"resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/Am2900.json", "Am2900");
this.amicListeners = new HashSet<>();
- CoreModelParameters params = new CoreModelParameters();
- params.gateProcessTime = 50;
- params.hardcodedComponentProcessTime = params.gateProcessTime * 5;
- params.wireTravelTime = 10;
+ CoreModelParametersBuilder paramsBuilder = new CoreModelParametersBuilder();
+ paramsBuilder.gateProcessTime = 50;
+ paramsBuilder.hardcodedComponentProcessTime = paramsBuilder.gateProcessTime * 5;
+ paramsBuilder.wireTravelTime = 10;
+ CoreModelParameters params = paramsBuilder.build();
+
mainMemory = new AssignableMainMemory(new StandardMainMemory(am2900MachineDefinition.getMainMemoryDefinition()));
instMemory = new AssignableMicroInstructionMemory(
new StandardMicroInstructionMemory(am2900MachineDefinition.getMicroInstructionMemoryDefinition()));
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;
+import net.mograsim.logic.model.modeladapter.CoreModelParameters.CoreModelParametersBuilder;
import net.mograsim.logic.model.modeladapter.LogicCoreAdapter;
import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
IndirectModelComponentCreator.createComponent(model, componentID);
LogicCoreAdapter.gateCountsPerComponentClass.clear();
- LogicCoreAdapter.convert(model, new CoreModelParameters());
+ LogicCoreAdapter.convert(model, new CoreModelParametersBuilder().build());
System.out.println(componentID + ':');
for (Entry<Class<? extends ModelComponent>, Integer> e : LogicCoreAdapter.gateCountsPerComponentClass.entrySet())
import net.mograsim.logic.core.timeline.Timeline;
import net.mograsim.logic.model.model.LogicModelModifiable;
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;
public static void executeVisualisation(Consumer<LogicModelModifiable> setupLogicModel, Consumer<VisualisationObjects> beforeRun)
{
- CoreModelParameters params = new CoreModelParameters();
- params.gateProcessTime = 50;
- params.hardcodedComponentProcessTime = params.gateProcessTime * 5;
- params.wireTravelTime = 10;
- executeVisualisation(setupLogicModel, params, beforeRun);
+ CoreModelParametersBuilder paramsBuilder = new CoreModelParametersBuilder();
+ paramsBuilder.gateProcessTime = 50;
+ paramsBuilder.hardcodedComponentProcessTime = paramsBuilder.gateProcessTime * 5;
+ paramsBuilder.wireTravelTime = 10;
+ executeVisualisation(setupLogicModel, paramsBuilder.build(), beforeRun);
}
public static void executeVisualisation(Consumer<LogicModelModifiable> setupLogicModel, CoreModelParameters params)
public class CoreModelParameters
{
- public int wireTravelTime;
- public int gateProcessTime;
- public int hardcodedComponentProcessTime;
+ public final int wireTravelTime;
+ public final int gateProcessTime;
+ public final int hardcodedComponentProcessTime;
+
+ public CoreModelParameters(int wireTravelTime, int gateProcessTime, int hardcodedComponentProcessTime)
+ {
+ this.wireTravelTime = wireTravelTime;
+ this.gateProcessTime = gateProcessTime;
+ this.hardcodedComponentProcessTime = hardcodedComponentProcessTime;
+ }
+
+ private CoreModelParameters(CoreModelParametersBuilder builder)
+ {
+ this.wireTravelTime = builder.wireTravelTime;
+ this.gateProcessTime = builder.gateProcessTime;
+ this.hardcodedComponentProcessTime = builder.hardcodedComponentProcessTime;
+ }
+
+ public static class CoreModelParametersBuilder
+ {
+ public int wireTravelTime;
+ public int gateProcessTime;
+ public int hardcodedComponentProcessTime;
+
+ public CoreModelParametersBuilder wireTravelTime(int wireTravelTime)
+ {
+ this.wireTravelTime = wireTravelTime;
+ return this;
+ }
+
+ public CoreModelParametersBuilder gateProcessTime(int gateProcessTime)
+ {
+ this.gateProcessTime = gateProcessTime;
+ return this;
+ }
+
+ public CoreModelParametersBuilder hardcodedComponentProcessTime(int hardcodedComponentProcessTime)
+ {
+ this.hardcodedComponentProcessTime = hardcodedComponentProcessTime;
+ return this;
+ }
+
+ public CoreModelParameters build()
+ {
+ return new CoreModelParameters(this);
+ }
+ }
}
\ No newline at end of file
import net.mograsim.logic.model.model.wires.ModelWire;
import net.mograsim.logic.model.model.wires.ModelWireCrossPoint;
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.RenderPreferences;
import net.mograsim.plugin.preferences.EclipseRenderPreferences;
MograsimActivator.instance().getPreferenceStore());
LogicModelModifiable model = new LogicModelModifiable();
- CoreModelParameters params = new CoreModelParameters();
- params.gateProcessTime = 50;
- params.hardcodedComponentProcessTime = params.gateProcessTime * 5;
- params.wireTravelTime = 10;
+
+ CoreModelParametersBuilder paramsBuilder = new CoreModelParametersBuilder();
+ paramsBuilder.gateProcessTime = 50;
+ paramsBuilder.hardcodedComponentProcessTime = paramsBuilder.gateProcessTime * 5;
+ paramsBuilder.wireTravelTime = 10;
+ CoreModelParameters params = paramsBuilder.build();
ModelManualSwitch rIn = new ModelManualSwitch(model, 1);
rIn.moveTo(10, 10);
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;
import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
component.getPins().values().forEach(this::extendModelPin);
// Create core model
- CoreModelParameters params = new CoreModelParameters();
- params.gateProcessTime = 50;
- params.hardcodedComponentProcessTime = params.gateProcessTime * 5;
- params.wireTravelTime = 10;
- timeline = LogicCoreAdapter.convert(logicModel, params);
+ CoreModelParametersBuilder paramsBuilder = new CoreModelParametersBuilder();
+ paramsBuilder.gateProcessTime = 50;
+ paramsBuilder.hardcodedComponentProcessTime = paramsBuilder.gateProcessTime * 5;
+ paramsBuilder.wireTravelTime = 10;
+ timeline = LogicCoreAdapter.convert(logicModel, paramsBuilder.build());
timelineField.ifPresent(f -> setField(f, timeline));
// Bind switches/displays to this test class