1 package net.mograsim.logic.model.am2900.util;
3 import net.mograsim.logic.core.components.BitDisplay;
4 import net.mograsim.logic.core.components.ManualSwitch;
5 import net.mograsim.logic.core.types.BitVector;
6 import net.mograsim.logic.model.model.ViewModelModifiable;
7 import net.mograsim.logic.model.model.components.atomic.GUIBitDisplay;
8 import net.mograsim.logic.model.model.components.atomic.GUIManualSwitch;
9 import net.mograsim.logic.model.model.wires.Pin;
10 import net.mograsim.logic.model.model.wires.WireCrossPoint;
11 import net.mograsim.logic.model.util.ModellingTool;
13 public class SwitchWithDisplay
15 private final Pin pin;
16 private final GUIBitDisplay guiBitDisplay;
17 private final GUIManualSwitch guiManualSwitch;
19 public SwitchWithDisplay(ViewModelModifiable model, Pin target)
22 guiBitDisplay = new GUIBitDisplay(model, pin.logicWidth);
23 guiManualSwitch = new GUIManualSwitch(model, pin.logicWidth);
25 ModellingTool tool = ModellingTool.createFor(model);
26 WireCrossPoint crossPoint = new WireCrossPoint(model, pin.logicWidth);
27 tool.connect(guiBitDisplay.getInputPin(), crossPoint);
28 tool.connect(guiManualSwitch.getOutputPin(), crossPoint);
31 public final BitVector getDisplayedValue()
33 return guiBitDisplay.getBitDisplay().getDisplayedValue();
36 public final void setState(BitVector bits)
38 guiManualSwitch.getManualSwitch().setState(bits);
41 public final Pin getPin()
46 public final BitDisplay getBitDisplay()
48 return guiBitDisplay.getBitDisplay();
51 public final ManualSwitch getManualSwitch()
53 return guiManualSwitch.getManualSwitch();
56 final GUIBitDisplay getGuiBitDisplay()
61 final GUIManualSwitch getGuiManualSwitch()
63 return guiManualSwitch;