import java.util.function.Function;
import java.util.stream.Collectors;
-import net.mograsim.logic.core.components.Component;
import net.mograsim.logic.core.components.gates.AndGate;
+import net.mograsim.logic.core.components.gates.NandGate;
import net.mograsim.logic.core.components.gates.NotGate;
import net.mograsim.logic.core.components.gates.OrGate;
import net.mograsim.logic.core.timeline.Timeline;
import net.mograsim.logic.ui.model.ViewModel;
import net.mograsim.logic.ui.model.components.GUIAndGate;
import net.mograsim.logic.ui.model.components.GUIComponent;
+import net.mograsim.logic.ui.model.components.GUINandGate;
import net.mograsim.logic.ui.model.components.GUINotGate;
import net.mograsim.logic.ui.model.components.GUIOrGate;
import net.mograsim.logic.ui.model.components.SubmodelComponent;
import net.mograsim.logic.ui.model.wires.GUIWire;
import net.mograsim.logic.ui.model.wires.Pin;
import net.mograsim.logic.ui.model.wires.WireCrossPoint;
-import net.mograsim.logic.ui.modeladapter.componentadapters.Am2901NANDBasedAdapter;
+import net.mograsim.logic.ui.modeladapter.componentadapters.AtomicAm2901NANDBasedAdapter;
import net.mograsim.logic.ui.modeladapter.componentadapters.BitDisplayAdapter;
import net.mograsim.logic.ui.modeladapter.componentadapters.ComponentAdapter;
import net.mograsim.logic.ui.modeladapter.componentadapters.ManualSwitchAdapter;
componentAdaptersModifiable.add(new SimpleGateAdapter<>(GUIOrGate.class, OrGate::new));
componentAdaptersModifiable.add(new SimpleGateAdapter<>(GUIAndGate.class, AndGate::new));
componentAdaptersModifiable.add(new SimpleGateAdapter<>(GUINotGate.class, (t, p, o, i) -> new NotGate(t, p, i[0], o)));
+ componentAdaptersModifiable.add(new SimpleGateAdapter<>(GUINandGate.class, NandGate::new));
componentAdaptersModifiable.add(new ManualSwitchAdapter());
componentAdaptersModifiable.add(new BitDisplayAdapter());
- componentAdaptersModifiable.add(new Am2901NANDBasedAdapter());
+ componentAdaptersModifiable.add(new AtomicAm2901NANDBasedAdapter());
// TODO list all adapters here
componentAdapters = Collections.unmodifiableMap(
componentAdaptersModifiable.stream().collect(Collectors.toMap(ComponentAdapter::getSupportedClass, Function.identity())));
else
throw new IllegalArgumentException("Two pins to external wires can't be connected directly");
}
- return new Wire(timeline, e.getKey().logicWidth, params.wireTravelTime);
+ return externalWire == null ? new Wire(timeline, e.getKey().logicWidth, params.wireTravelTime) : externalWire;
}));
return logicWiresPerPin;
}
}
@SuppressWarnings("unchecked")
- private static <G extends GUIComponent> Component createAndLinkComponent(Timeline timeline, LogicModelParameters params,
+ private static <G extends GUIComponent> void createAndLinkComponent(Timeline timeline, LogicModelParameters params,
GUIComponent guiComponent, Map<Pin, Wire> logicWiresPerPin, ComponentAdapter<G> adapter)
{
if (adapter == null)
throw new IllegalArgumentException("Unknown component class: " + guiComponent.getClass());
- return adapter.createAndLinkComponent(timeline, params, (G) guiComponent, logicWiresPerPin);
+ adapter.createAndLinkComponent(timeline, params, (G) guiComponent, logicWiresPerPin);
}
private ViewLogicModelAdapter()