761689a3d56520f487f6e5d7d4ca4f2bc2a6d0b6
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / modeladapter / componentadapters / NandGateAdapter.java
1 package net.mograsim.logic.ui.modeladapter.componentadapters;
2
3 import java.util.Map;
4
5 import net.mograsim.logic.core.components.gates.AndGate;
6 import net.mograsim.logic.core.components.gates.NotGate;
7 import net.mograsim.logic.core.timeline.Timeline;
8 import net.mograsim.logic.core.wires.Wire;
9 import net.mograsim.logic.ui.model.components.GUINandGate;
10 import net.mograsim.logic.ui.model.wires.Pin;
11 import net.mograsim.logic.ui.modeladapter.LogicModelParameters;
12
13 public class NandGateAdapter implements ComponentAdapter<GUINandGate>
14 {
15         @Override
16         public Class<GUINandGate> getSupportedClass()
17         {
18                 return GUINandGate.class;
19         }
20
21         @Override
22         @SuppressWarnings("unused") // AndGate and NotGate
23         public void createAndLinkComponent(Timeline timeline, LogicModelParameters params, GUINandGate guiComponent,
24                         Map<Pin, Wire> logicWiresPerPin)
25         {
26                 Wire i0 = logicWiresPerPin.get(guiComponent.getInputPins().get(0));
27                 Wire i1 = logicWiresPerPin.get(guiComponent.getInputPins().get(1));
28                 Wire o = logicWiresPerPin.get(guiComponent.getOutputPin());
29                 Wire w = new Wire(timeline, guiComponent.getOutputPin().logicWidth, 1);
30
31                 new AndGate(timeline, 1, w.createReadWriteEnd(), i0.createReadOnlyEnd(), i1.createReadOnlyEnd());
32                 new NotGate(timeline, Math.max(1, params.gateProcessTime - 2), w.createReadOnlyEnd(), o.createReadWriteEnd());
33         }
34 }