Search in sources :

Example 6 with LevelXing

use of jmri.jmrit.display.layoutEditor.LevelXing in project JMRI by JMRI.

the class AddEntryExitPairPanel method selectPointsFromPanel.

private void selectPointsFromPanel() {
    if (selectPanel.getSelectedIndex() == -1) {
        return;
    }
    if (panel == panels.get(selectPanel.getSelectedIndex())) {
        return;
    }
    panel = panels.get(selectPanel.getSelectedIndex());
    fromPoint.removeAllItems();
    toPoint.removeAllItems();
    for (PositionablePoint pp : panel.pointList) {
        addPointToCombo(pp.getWestBoundSignalMastName(), pp.getWestBoundSensorName());
        addPointToCombo(pp.getEastBoundSignalMastName(), pp.getEastBoundSensorName());
    }
    for (LayoutTurnout t : panel.turnoutList) {
        addPointToCombo(t.getSignalAMastName(), t.getSensorAName());
        addPointToCombo(t.getSignalBMastName(), t.getSensorBName());
        addPointToCombo(t.getSignalCMastName(), t.getSensorCName());
        addPointToCombo(t.getSignalDMastName(), t.getSensorDName());
    }
    for (LevelXing xing : panel.xingList) {
        addPointToCombo(xing.getSignalAMastName(), xing.getSensorAName());
        addPointToCombo(xing.getSignalBMastName(), xing.getSensorBName());
        addPointToCombo(xing.getSignalCMastName(), xing.getSensorCName());
        addPointToCombo(xing.getSignalDMastName(), xing.getSensorDName());
    }
    for (LayoutSlip slip : panel.slipList) {
        addPointToCombo(slip.getSignalAMastName(), slip.getSensorAName());
        addPointToCombo(slip.getSignalBMastName(), slip.getSensorBName());
        addPointToCombo(slip.getSignalCMastName(), slip.getSensorCName());
        addPointToCombo(slip.getSignalDMastName(), slip.getSensorDName());
    }
}
Also used : LayoutSlip(jmri.jmrit.display.layoutEditor.LayoutSlip) LevelXing(jmri.jmrit.display.layoutEditor.LevelXing) LayoutTurnout(jmri.jmrit.display.layoutEditor.LayoutTurnout) PositionablePoint(jmri.jmrit.display.layoutEditor.PositionablePoint)

Example 7 with LevelXing

use of jmri.jmrit.display.layoutEditor.LevelXing in project JMRI by JMRI.

the class PointDetails method getSensor.

Sensor getSensor() {
    if (getRefObject() == null) {
        return null;
    }
    if ((getPanel() != null) && (!getPanel().isEditable()) && (sensor != null)) {
        return sensor;
    }
    if (getRefObject() instanceof Sensor) {
        setSensor((Sensor) getRefObject());
        return (Sensor) getRefObject();
    }
    Object objLoc = getRefLocation();
    Object objRef = getRefObject();
    SignalHead head = null;
    SignalMast mast = null;
    String username = "";
    String systemname = "";
    Sensor foundSensor = null;
    if (objRef instanceof SignalMast) {
        mast = (SignalMast) objRef;
    }
    if (objRef instanceof SignalHead) {
        head = (SignalHead) objRef;
        username = head.getUserName();
        systemname = head.getSystemName();
    }
    jmri.SensorManager sm = InstanceManager.sensorManagerInstance();
    if (objLoc instanceof PositionablePoint) {
        PositionablePoint p = (PositionablePoint) objLoc;
        if (mast != null) {
            if (p.getEastBoundSignalMast() == objRef) {
                foundSensor = p.getEastBoundSensor();
            } else if (p.getWestBoundSignalMast() == objRef) {
                foundSensor = p.getWestBoundSensor();
            }
        } else if (head != null) {
            if ((p.getEastBoundSignal().equals(username)) || p.getEastBoundSignal().equals(systemname)) {
                foundSensor = p.getEastBoundSensor();
            } else if ((p.getWestBoundSignal().equals(username)) || p.getWestBoundSignal().equals(systemname)) {
                foundSensor = p.getWestBoundSensor();
            }
        }
    } else if (objLoc instanceof LayoutTurnout) {
        LayoutTurnout t = (LayoutTurnout) objLoc;
        if (mast != null) {
            if (t.getSignalAMast() == objRef) {
                foundSensor = t.getSensorA();
            } else if (t.getSignalBMast() == objRef) {
                foundSensor = t.getSensorB();
            } else if (t.getSignalCMast() == objRef) {
                foundSensor = t.getSensorC();
            } else if (t.getSignalDMast() == objRef) {
                foundSensor = t.getSensorD();
            }
        }
        if (head != null) {
            if ((t.getSignalA1Name().equals(username)) || (t.getSignalA1Name().equals(systemname))) {
                foundSensor = t.getSensorA();
            } else if ((t.getSignalA2Name().equals(username)) || (t.getSignalA2Name().equals(systemname))) {
                foundSensor = t.getSensorA();
            } else if ((t.getSignalA3Name().equals(username)) || (t.getSignalA3Name().equals(systemname))) {
                foundSensor = t.getSensorA();
            } else if ((t.getSignalB1Name().equals(username)) || (t.getSignalB1Name().equals(systemname))) {
                foundSensor = t.getSensorB();
            } else if ((t.getSignalB2Name().equals(username)) || (t.getSignalB2Name().equals(systemname))) {
                foundSensor = t.getSensorB();
            } else if ((t.getSignalC1Name().equals(username)) || (t.getSignalC1Name().equals(systemname))) {
                foundSensor = t.getSensorC();
            } else if ((t.getSignalC2Name().equals(username)) || (t.getSignalC2Name().equals(systemname))) {
                foundSensor = t.getSensorC();
            } else if ((t.getSignalD1Name().equals(username)) || (t.getSignalD1Name().equals(systemname))) {
                foundSensor = t.getSensorD();
            } else if ((t.getSignalD2Name().equals(username)) || (t.getSignalD2Name().equals(systemname))) {
                foundSensor = t.getSensorD();
            }
        }
    } else if (objLoc instanceof LevelXing) {
        LevelXing x = (LevelXing) objLoc;
        if (mast != null) {
            if (x.getSignalAMast() == objRef) {
                foundSensor = x.getSensorA();
            } else if (x.getSignalBMast() == objRef) {
                foundSensor = x.getSensorB();
            } else if (x.getSignalCMast() == objRef) {
                foundSensor = x.getSensorC();
            } else if (x.getSignalDMast() == objRef) {
                foundSensor = x.getSensorD();
            }
        }
        if (head != null) {
            if ((x.getSignalAName().equals(username)) || (x.getSignalAName().equals(systemname))) {
                foundSensor = x.getSensorA();
            } else if ((x.getSignalBName().equals(username)) || (x.getSignalBName().equals(systemname))) {
                foundSensor = x.getSensorB();
            } else if ((x.getSignalCName().equals(username)) || (x.getSignalCName().equals(systemname))) {
                foundSensor = x.getSensorC();
            } else if ((x.getSignalDName().equals(username)) || (x.getSignalDName().equals(systemname))) {
                foundSensor = x.getSensorD();
            }
        }
    } else if (objLoc instanceof LayoutSlip) {
        LayoutSlip sl = (LayoutSlip) objLoc;
        if (mast != null) {
            if (sl.getSignalAMast() == objRef) {
                foundSensor = sl.getSensorA();
            } else if (sl.getSignalBMast() == objRef) {
                foundSensor = sl.getSensorB();
            } else if (sl.getSignalCMast() == objRef) {
                foundSensor = sl.getSensorC();
            } else if (sl.getSignalDMast() == objRef) {
                foundSensor = sl.getSensorD();
            }
        }
        if (head != null) {
            if ((sl.getSignalA1Name().equals(username)) || (sl.getSignalA1Name().equals(systemname))) {
                foundSensor = sm.getSensor(sl.getSensorAName());
            } else if ((sl.getSignalB1Name().equals(username)) || (sl.getSignalB1Name().equals(systemname))) {
                foundSensor = sm.getSensor(sl.getSensorBName());
            } else if ((sl.getSignalC1Name().equals(username)) || (sl.getSignalC1Name().equals(systemname))) {
                foundSensor = sm.getSensor(sl.getSensorCName());
            } else if ((sl.getSignalD1Name().equals(username)) || (sl.getSignalD1Name().equals(systemname))) {
                foundSensor = sm.getSensor(sl.getSensorDName());
            }
        }
    }
    setSensor(foundSensor);
    return foundSensor;
}
Also used : LayoutSlip(jmri.jmrit.display.layoutEditor.LayoutSlip) LevelXing(jmri.jmrit.display.layoutEditor.LevelXing) LayoutTurnout(jmri.jmrit.display.layoutEditor.LayoutTurnout) SignalHead(jmri.SignalHead) SignalMast(jmri.SignalMast) PositionablePoint(jmri.jmrit.display.layoutEditor.PositionablePoint) Sensor(jmri.Sensor)

Aggregations

LevelXing (jmri.jmrit.display.layoutEditor.LevelXing)7 LayoutSlip (jmri.jmrit.display.layoutEditor.LayoutSlip)4 LayoutTurnout (jmri.jmrit.display.layoutEditor.LayoutTurnout)4 PositionablePoint (jmri.jmrit.display.layoutEditor.PositionablePoint)4 Point2D (java.awt.geom.Point2D)2 Sensor (jmri.Sensor)2 SignalHead (jmri.SignalHead)2 SignalMast (jmri.SignalMast)2 Block (jmri.Block)1 NamedBean (jmri.NamedBean)1 ConnectivityUtil (jmri.jmrit.display.layoutEditor.ConnectivityUtil)1 LayoutBlock (jmri.jmrit.display.layoutEditor.LayoutBlock)1 LayoutBlockManager (jmri.jmrit.display.layoutEditor.LayoutBlockManager)1 LayoutEditor (jmri.jmrit.display.layoutEditor.LayoutEditor)1 TrackNode (jmri.jmrit.display.layoutEditor.TrackNode)1 TrackSegment (jmri.jmrit.display.layoutEditor.TrackSegment)1 Attribute (org.jdom2.Attribute)1 Element (org.jdom2.Element)1