SimpleRectangularHardcodedGUIComponent now supports HighLevelStates
[Mograsim.git] / net.mograsim.logic.model.am2900 / src / net / mograsim / logic / model / am2900 / components / GUInor12.java
index 22800a3..1948c67 100644 (file)
@@ -14,6 +14,8 @@ import net.mograsim.logic.core.wires.Wire.ReadWriteEnd;
 import net.mograsim.logic.model.model.ViewModelModifiable;
 import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
 import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
+import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
 import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
 
 public class GUInor12 extends SimpleRectangularHardcodedGUIComponent
@@ -22,12 +24,12 @@ public class GUInor12 extends SimpleRectangularHardcodedGUIComponent
        {
                super(model, name, "=0");
                setSize(35, 20);
-               addPin(new Pin(this, "D", 12, 0, 10), Usage.INPUT, Position.RIGHT);
-               addPin(new Pin(this, "Y", 1, 30, 10), Usage.OUTPUT, Position.LEFT);
+               addPin(new Pin(this, "D", 12, PinUsage.INPUT, 0, 10), Position.RIGHT);
+               addPin(new Pin(this, "Y", 1, PinUsage.OUTPUT, 35, 10), Position.LEFT);
        }
 
        @Override
-       protected Object recalculate(Object lastState, Map<String, ReadEnd> readEnds, Map<String, ReadWriteEnd> readWriteEnds)
+       public Object recalculate(Object lastState, Map<String, ReadEnd> readEnds, Map<String, ReadWriteEnd> readWriteEnds)
        {
                readWriteEnds.get("Y").feedSignals(getResult(readEnds.get("D").getValues().getBits()));
                return null;
@@ -49,4 +51,9 @@ public class GUInor12 extends SimpleRectangularHardcodedGUIComponent
                                return X;
                return ONE;
        }
+
+       static
+       {
+               IndirectGUIComponentCreator.setComponentSupplier(GUInor12.class.getCanonicalName(), (m, p, n) -> new GUInor12(m, n));
+       }
 }
\ No newline at end of file