Search in sources :

Example 1 with Source

use of jmri.jmrit.signalling.entryexit.Source in project JMRI by JMRI.

the class EntryExitPairs method setMultiPointRoute.

private void setMultiPointRoute(PointDetails fromPd, PointDetails toPd) {
    boolean cleardown = false;
    if (fromPd.isRouteFromPointSet() && toPd.isRouteToPointSet()) {
        cleardown = true;
    }
    for (LayoutBlock pro : fromPd.getProtecting()) {
        try {
            jmri.jmrit.display.layoutEditor.LayoutBlockManager lbm = InstanceManager.getDefault(jmri.jmrit.display.layoutEditor.LayoutBlockManager.class);
            LayoutBlock toProt = null;
            if (!toPd.getProtecting().isEmpty()) {
                toProt = toPd.getProtecting().get(0);
            }
            boolean result = lbm.getLayoutBlockConnectivityTools().checkValidDest(fromPd.getFacing(), pro, toPd.getFacing(), toProt, LayoutBlockConnectivityTools.SENSORTOSENSOR);
            if (result) {
                ArrayList<LayoutBlock> blkList = lbm.getLayoutBlockConnectivityTools().getLayoutBlocks(fromPd.getFacing(), toPd.getFacing(), pro, cleardown, LayoutBlockConnectivityTools.NONE);
                if (!blkList.isEmpty()) {
                    List<jmri.NamedBean> beanList = lbm.getLayoutBlockConnectivityTools().getBeansInPath(blkList, fromPd.getPanel(), jmri.Sensor.class);
                    PointDetails fromPoint = fromPd;
                    refCounter++;
                    if (!beanList.isEmpty()) {
                        for (int i = 1; i < beanList.size(); i++) {
                            NamedBean nb = beanList.get(i);
                            PointDetails cur = getPointDetails(nb, fromPd.getPanel());
                            Source s = nxpair.get(fromPoint);
                            if (s != null) {
                                routesToSet.add(new SourceToDest(s, s.getDestForPoint(cur), false, refCounter));
                            }
                            fromPoint = cur;
                        }
                    }
                    Source s = nxpair.get(fromPoint);
                    if (s != null) {
                        routesToSet.add(new SourceToDest(s, s.getDestForPoint(toPd), false, refCounter));
                    }
                    processRoutesToSet();
                    return;
                }
            }
        } catch (jmri.JmriException e) {
        //Can be considered normal if route is blocked
        }
    }
    fromPd.setNXButtonState(NXBUTTONINACTIVE);
    toPd.setNXButtonState(NXBUTTONINACTIVE);
}
Also used : NamedBean(jmri.NamedBean) JmriException(jmri.JmriException) Source(jmri.jmrit.signalling.entryexit.Source) LayoutBlock(jmri.jmrit.display.layoutEditor.LayoutBlock) PointDetails(jmri.jmrit.signalling.entryexit.PointDetails)

Example 2 with Source

use of jmri.jmrit.signalling.entryexit.Source in project JMRI by JMRI.

the class EntryExitPairs method getNxSource.

// Need to sort out the presentation of the name here rather than using the point ID.
// This is used for the creation and display of information in the table.
// The presentation of the name might have to be done at the table level.
public ArrayList<Object> getNxSource(LayoutEditor panel) {
    ArrayList<Object> source = new ArrayList<Object>();
    destinationList = new ArrayList<Object>();
    for (Entry<PointDetails, Source> e : nxpair.entrySet()) {
        PointDetails key = e.getKey();
        LayoutEditor pan = key.getPanel();
        if (pan == panel) {
            List<PointDetails> dest = nxpair.get(key).getDestinationPoints();
            for (int i = 0; i < dest.size(); i++) {
                destinationList.add(dest.get(i).getRefObject());
                source.add(key.getRefObject());
            }
        }
    }
    return source;
}
Also used : LayoutEditor(jmri.jmrit.display.layoutEditor.LayoutEditor) ArrayList(java.util.ArrayList) PointDetails(jmri.jmrit.signalling.entryexit.PointDetails) Source(jmri.jmrit.signalling.entryexit.Source)

Example 3 with Source

use of jmri.jmrit.signalling.entryexit.Source in project JMRI by JMRI.

the class EntryExitPairs method getNxPairNumbers.

public int getNxPairNumbers(LayoutEditor panel) {
    int total = 0;
    for (Entry<PointDetails, Source> e : nxpair.entrySet()) {
        PointDetails key = e.getKey();
        LayoutEditor pan = key.getPanel();
        if (pan == panel) {
            total = total + e.getValue().getNumberOfDestinations();
        }
    // end while
    }
    return total;
}
Also used : LayoutEditor(jmri.jmrit.display.layoutEditor.LayoutEditor) PointDetails(jmri.jmrit.signalling.entryexit.PointDetails) Source(jmri.jmrit.signalling.entryexit.Source)

Example 4 with Source

use of jmri.jmrit.signalling.entryexit.Source in project JMRI by JMRI.

the class EntryExitPairs method getSourceList.

/**
     * Return a list of all source (origin) points on a given
     * Layout Editor panel.
     *
     * @param panel  A Layout Editor panel
     * @return A list of source objects
     */
public List<Object> getSourceList(LayoutEditor panel) {
    List<Object> list = new ArrayList<Object>();
    for (Entry<PointDetails, Source> e : nxpair.entrySet()) {
        Object obj = (e.getKey()).getRefObject();
        LayoutEditor pan = (e.getKey()).getPanel();
        if (pan == panel) {
            if (!list.contains(obj)) {
                list.add(obj);
            }
        }
    // end while
    }
    return list;
}
Also used : LayoutEditor(jmri.jmrit.display.layoutEditor.LayoutEditor) ArrayList(java.util.ArrayList) PointDetails(jmri.jmrit.signalling.entryexit.PointDetails) Source(jmri.jmrit.signalling.entryexit.Source)

Example 5 with Source

use of jmri.jmrit.signalling.entryexit.Source in project JMRI by JMRI.

the class EntryExitPairs method getSourcePanelList.

public ArrayList<LayoutEditor> getSourcePanelList() {
    ArrayList<LayoutEditor> list = new ArrayList<LayoutEditor>();
    for (Entry<PointDetails, Source> e : nxpair.entrySet()) {
        PointDetails key = e.getKey();
        LayoutEditor pan = key.getPanel();
        if (!list.contains(pan)) {
            list.add(pan);
        }
    }
    return list;
}
Also used : LayoutEditor(jmri.jmrit.display.layoutEditor.LayoutEditor) ArrayList(java.util.ArrayList) PointDetails(jmri.jmrit.signalling.entryexit.PointDetails) Source(jmri.jmrit.signalling.entryexit.Source)

Aggregations

Source (jmri.jmrit.signalling.entryexit.Source)7 PointDetails (jmri.jmrit.signalling.entryexit.PointDetails)6 LayoutEditor (jmri.jmrit.display.layoutEditor.LayoutEditor)4 ArrayList (java.util.ArrayList)3 JmriException (jmri.JmriException)1 NamedBean (jmri.NamedBean)1 LayoutBlock (jmri.jmrit.display.layoutEditor.LayoutBlock)1 DestinationPoints (jmri.jmrit.signalling.entryexit.DestinationPoints)1