Search in sources :

Example 11 with EntryPoint

use of jmri.EntryPoint in project JMRI by JMRI.

the class DispatcherFrame method connected.

private boolean connected(Section s1, Section s2) {
    if ((s1 != null) && (s2 != null)) {
        ArrayList<EntryPoint> s1Entries = (ArrayList<EntryPoint>) s1.getEntryPointList();
        ArrayList<EntryPoint> s2Entries = (ArrayList<EntryPoint>) s2.getEntryPointList();
        for (int i = 0; i < s1Entries.size(); i++) {
            Block b = s1Entries.get(i).getFromBlock();
            for (int j = 0; j < s2Entries.size(); j++) {
                if (b == s2Entries.get(j).getBlock()) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : ArrayList(java.util.ArrayList) EntryPoint(jmri.EntryPoint) Block(jmri.Block) EntryPoint(jmri.EntryPoint)

Example 12 with EntryPoint

use of jmri.EntryPoint in project JMRI by JMRI.

the class TransitTableAction method reverseConnected.

private boolean reverseConnected(Section s1, Section s2, int restrictedDirection) {
    if ((s1 != null) && (s2 != null)) {
        List<EntryPoint> s1ReverseEntries = s1.getReverseEntryPointList();
        List<EntryPoint> s2Entries = new ArrayList<>();
        if (restrictedDirection == Section.FORWARD) {
            s2Entries = s2.getReverseEntryPointList();
        } else if (restrictedDirection == Section.REVERSE) {
            s2Entries = s2.getForwardEntryPointList();
        } else {
            s2Entries = s2.getEntryPointList();
        }
        for (int i = 0; i < s1ReverseEntries.size(); i++) {
            Block b1 = s1ReverseEntries.get(i).getFromBlock();
            for (int j = 0; j < s2Entries.size(); j++) {
                Block b2 = s2Entries.get(j).getFromBlock();
                if ((b1 == s2Entries.get(j).getBlock()) && (b2 == s1ReverseEntries.get(i).getBlock())) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : ArrayList(java.util.ArrayList) EntryPoint(jmri.EntryPoint) Block(jmri.Block) EntryPoint(jmri.EntryPoint)

Example 13 with EntryPoint

use of jmri.EntryPoint in project JMRI by JMRI.

the class AutoActiveTrain method addAllocatedSection.

private void addAllocatedSection(AllocatedSection as) {
    _allocatedSectionList.add(as);
    if (!_initialized) {
        // this is first allocated section, get things started
        _initialized = true;
        _nextSection = as.getSection();
        _currentBlock = _activeTrain.getStartBlock();
        if (as.getSection().containsBlock(_currentBlock)) {
            // starting Block is in this allocated section - find next Block
            setNewCurrentSection(as);
            _nextBlock = getNextBlock(_currentBlock, as);
        } else if (as.getSection().connectsToBlock(_currentBlock)) {
            // starting Block is connected to a Block in this allocated section
            EntryPoint ep = as.getSection().getEntryPointFromBlock(_currentBlock, as.getDirection());
            if (ep != null) {
                _nextBlock = ep.getBlock();
            } else {
                log.error("failure to get entry point to Transit from Block " + _currentBlock.getSystemName());
            }
        }
        if (_nextBlock != null) {
            // set up new current signal
            setupNewCurrentSignal(as);
        }
    }
    // if train is stopping for lack of an allocation, set flag to restart it
    if (!_pausingActive && (_lastAllocatedSection == _currentAllocatedSection) && isStopping() && (_activeTrain.getStatus() == ActiveTrain.RUNNING)) {
        _needSetSpeed = true;
    }
    // request next allocation if appropriate--Dispatcher must decide whether to allocate it and when
    if ((!DispatcherFrame.instance().getAutoAllocate()) && ((_lastAllocatedSection == null) || (_lastAllocatedSection.getNextSection() == as.getSection()))) {
        // if AutoAllocate, this is now done in DispatcherFrame.java for all trains
        _lastAllocatedSection = as;
        if (as.getNextSection() != null) {
            Section nSection = as.getNextSection();
            int nextSeq = as.getNextSectionSequence();
            int nextDir = _activeTrain.getAllocationDirectionFromSectionAndSeq(nSection, nextSeq);
            DispatcherFrame.instance().requestAllocation(_activeTrain, nSection, nextDir, nextSeq, true, null);
        }
    }
}
Also used : EntryPoint(jmri.EntryPoint) Section(jmri.Section) EntryPoint(jmri.EntryPoint)

Aggregations

EntryPoint (jmri.EntryPoint)13 Block (jmri.Block)10 ArrayList (java.util.ArrayList)5 Section (jmri.Section)4 Path (jmri.Path)2 SectionManager (jmri.SectionManager)2 Element (org.jdom2.Element)2 ConfigureManager (jmri.ConfigureManager)1 Memory (jmri.Memory)1 Sensor (jmri.Sensor)1 Transit (jmri.Transit)1 Turnout (jmri.Turnout)1 ConnectivityUtil (jmri.jmrit.display.layoutEditor.ConnectivityUtil)1 LayoutSlip (jmri.jmrit.display.layoutEditor.LayoutSlip)1 LayoutTurnout (jmri.jmrit.display.layoutEditor.LayoutTurnout)1