Search in sources :

Example 16 with CircuitState

use of com.cburch.logisim.circuit.CircuitState in project logisim-evolution by reds-heig.

the class TestThread method matchPins.

void matchPins() throws TestException {
    int n = vector.columnName.length;
    pin = new Instance[n];
    CircuitState state = new CircuitState(this.project, this.circuit);
    for (int i = 0; i < n; i++) {
        String columnName = vector.columnName[i];
        for (Component comp : circuit.getNonWires()) {
            if (!(comp.getFactory() instanceof Pin))
                continue;
            Instance inst = Instance.getInstanceFor(comp);
            InstanceState pinState = state.getInstanceState(comp);
            String label = pinState.getAttributeValue(StdAttr.LABEL);
            if (label == null || !label.equals(columnName))
                continue;
            if (Pin.FACTORY.getWidth(inst).getWidth() != vector.columnWidth[i].getWidth())
                throw new TestException("test vector column '" + columnName + "' has width " + vector.columnWidth[i] + ", but pin has width " + Pin.FACTORY.getWidth(inst));
            pin[i] = inst;
            break;
        }
        if (pin[i] == null)
            throw new TestException("test vector column '" + columnName + "' has no matching pin");
    }
}
Also used : CircuitState(com.cburch.logisim.circuit.CircuitState) InstanceState(com.cburch.logisim.instance.InstanceState) Pin(com.cburch.logisim.std.wiring.Pin) TestException(com.cburch.logisim.data.TestException) Instance(com.cburch.logisim.instance.Instance) Component(com.cburch.logisim.comp.Component)

Example 17 with CircuitState

use of com.cburch.logisim.circuit.CircuitState in project logisim-evolution by reds-heig.

the class SimulationTreeModel method setCurrentView.

public void setCurrentView(CircuitState value) {
    CircuitState oldView = currentView;
    if (oldView != value) {
        currentView = value;
        SimulationTreeCircuitNode node1 = mapToNode(oldView);
        if (node1 != null)
            fireNodeChanged(node1);
        SimulationTreeCircuitNode node2 = mapToNode(value);
        if (node2 != null)
            fireNodeChanged(node2);
    }
}
Also used : CircuitState(com.cburch.logisim.circuit.CircuitState)

Example 18 with CircuitState

use of com.cburch.logisim.circuit.CircuitState in project logisim-evolution by reds-heig.

the class InstancePokerAdapter method getPokeCaret.

public Caret getPokeCaret(ComponentUserEvent event) {
    if (poker == null) {
        return null;
    } else {
        canvas = event.getCanvas();
        CircuitState circState = event.getCircuitState();
        InstanceStateImpl state = new InstanceStateImpl(circState, comp);
        MouseEvent e = new MouseEvent(event.getCanvas(), MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), 0, event.getX(), event.getY(), 1, false);
        boolean isAccepted = poker.init(state, e);
        if (isAccepted) {
            this.state = state;
            this.context = new ComponentDrawContext(event.getCanvas(), event.getCanvas().getCircuit(), circState, null, null);
            mousePressed(e);
            return this;
        } else {
            poker = null;
            return null;
        }
    }
}
Also used : CircuitState(com.cburch.logisim.circuit.CircuitState) MouseEvent(java.awt.event.MouseEvent) ComponentDrawContext(com.cburch.logisim.comp.ComponentDrawContext)

Example 19 with CircuitState

use of com.cburch.logisim.circuit.CircuitState in project logisim-evolution by reds-heig.

the class InstancePokerAdapter method checkCurrent.

private void checkCurrent() {
    if (state != null && canvas != null) {
        CircuitState s0 = state.getCircuitState();
        CircuitState s1 = canvas.getCircuitState();
        if (s0 != s1) {
            state = new InstanceStateImpl(s1, comp);
        }
    }
}
Also used : CircuitState(com.cburch.logisim.circuit.CircuitState)

Example 20 with CircuitState

use of com.cburch.logisim.circuit.CircuitState in project logisim-evolution by reds-heig.

the class ComponentDrawContext method drawPin.

public void drawPin(Component comp, int i) {
    EndData e = comp.getEnd(i);
    Location pt = e.getLocation();
    Color curColor = g.getColor();
    if (getShowState()) {
        CircuitState state = getCircuitState();
        g.setColor(state.getValue(pt).getColor());
    } else {
        g.setColor(Color.BLACK);
    }
    g.fillOval(pt.getX() - PIN_OFFS, pt.getY() - PIN_OFFS, PIN_RAD, PIN_RAD);
    g.setColor(curColor);
}
Also used : CircuitState(com.cburch.logisim.circuit.CircuitState) Color(java.awt.Color) Location(com.cburch.logisim.data.Location)

Aggregations

CircuitState (com.cburch.logisim.circuit.CircuitState)26 Component (com.cburch.logisim.comp.Component)6 Circuit (com.cburch.logisim.circuit.Circuit)5 ArrayList (java.util.ArrayList)4 ComponentDrawContext (com.cburch.logisim.comp.ComponentDrawContext)3 Location (com.cburch.logisim.data.Location)3 Instance (com.cburch.logisim.instance.Instance)3 InstanceState (com.cburch.logisim.instance.InstanceState)3 Color (java.awt.Color)3 Dimension (java.awt.Dimension)3 Simulator (com.cburch.logisim.circuit.Simulator)2 SubcircuitFactory (com.cburch.logisim.circuit.SubcircuitFactory)2 Bounds (com.cburch.logisim.data.Bounds)2 Value (com.cburch.logisim.data.Value)2 LogisimFile (com.cburch.logisim.file.LogisimFile)2 Graphics (java.awt.Graphics)2 TreePath (javax.swing.tree.TreePath)2 CircuitListener (com.cburch.logisim.circuit.CircuitListener)1 SimulatorEvent (com.cburch.logisim.circuit.SimulatorEvent)1 AppearancePort (com.cburch.logisim.circuit.appear.AppearancePort)1