import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
import net.mograsim.logic.ui.model.ViewModelModifiable;
-import net.mograsim.logic.ui.model.components.GUINandGate;
-import net.mograsim.logic.ui.model.components.SimpleRectangularSubmodelComponent;
+import net.mograsim.logic.ui.model.components.atomic.GUINandGate;
+import net.mograsim.logic.ui.model.components.submodels.SimpleRectangularSubmodelComponent;
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.serializing.IndirectGUIComponentCreator;
public class GUIdlatch extends SimpleRectangularSubmodelComponent
{
+ private GUI_rsLatch _rsLatch;
+
public GUIdlatch(ViewModelModifiable model)
{
super(model, 1, "GUIdlatch");
GUINandGate nand1 = new GUINandGate(submodelModifiable, 1);
GUINandGate nand2 = new GUINandGate(submodelModifiable, 1);
- GUI_rsLatch _rsLatch = new GUI_rsLatch(submodelModifiable);
+ _rsLatch = new GUI_rsLatch(submodelModifiable);
WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
WireCrossPoint cp2 = new WireCrossPoint(submodelModifiable, 1);
new GUIWire(submodelModifiable, nand2.getPin("Y"), _rsLatch.getPin("_R"), new Point(40, 37.5), new Point(40, 22.5));
new GUIWire(submodelModifiable, _rsLatch.getPin("Q"), Q, new Point[0]);
new GUIWire(submodelModifiable, _rsLatch.getPin("_Q"), _Q);
+
+ addAtomicHighLevelStateID("q");
+ }
+
+ @Override
+ public void setAtomicHighLevelState(String stateID, Object newState)
+ {
+ switch (stateID)
+ {
+ case "q":
+ _rsLatch.setHighLevelState("q", newState);
+ break;
+ default:
+ // should not happen because we tell SubmodelComponent to only allow these state IDs.
+ throw new IllegalStateException("Illegal atomic state ID: " + stateID);
+ }
+ }
+
+ @Override
+ public Object getAtomicHighLevelState(String stateID)
+ {
+ switch (stateID)
+ {
+ case "q":
+ return _rsLatch.getHighLevelState("q");
+ default:
+ // should not happen because we tell SubmodelComponent to only allow these state IDs.
+ throw new IllegalStateException("Illegal atomic state ID: " + stateID);
+ }
+ }
+
+ static
+ {
+ IndirectGUIComponentCreator.setComponentProvider(GUIdlatch.class.getCanonicalName(), (m, p) -> new GUIdlatch(m));
}
}
\ No newline at end of file