Search in sources :

Example 36 with SignalHead

use of jmri.SignalHead in project JMRI by JMRI.

the class LayoutTurnout method setSignalA3Name.

public void setSignalA3Name(String signalHead) {
    if (signalHead == null || signalHead.equals("")) {
        signalA3HeadNamed = null;
        return;
    }
    SignalHead head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(signalHead);
    if (head != null) {
        signalA3HeadNamed = InstanceManager.getDefault(jmri.NamedBeanHandleManager.class).getNamedBeanHandle(signalHead, head);
    } else {
        signalA3HeadNamed = null;
        log.error("Signal Head " + signalHead + " Not found for turnout " + getTurnoutName());
    }
}
Also used : SignalHead(jmri.SignalHead)

Example 37 with SignalHead

use of jmri.SignalHead in project JMRI by JMRI.

the class LayoutTurnout method setSignalA1Name.

public void setSignalA1Name(String signalHead) {
    if (signalHead == null || signalHead.equals("")) {
        signalA1HeadNamed = null;
        return;
    }
    SignalHead head = InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(signalHead);
    if (head != null) {
        signalA1HeadNamed = InstanceManager.getDefault(jmri.NamedBeanHandleManager.class).getNamedBeanHandle(signalHead, head);
    } else {
        signalA1HeadNamed = null;
        log.error("Signal Head " + signalHead + " Not found for turnout " + getTurnoutName());
    }
}
Also used : SignalHead(jmri.SignalHead)

Example 38 with SignalHead

use of jmri.SignalHead in project JMRI by JMRI.

the class TripleTurnoutSignalHeadXml method load.

@Override
public boolean load(Element shared, Element perNode) {
    List<Element> l = shared.getChildren("turnoutname");
    if (l.size() == 0) {
        l = shared.getChildren("turnout");
    }
    NamedBeanHandle<Turnout> green = loadTurnout(l.get(0));
    NamedBeanHandle<Turnout> yellow = loadTurnout(l.get(1));
    NamedBeanHandle<Turnout> red = loadTurnout(l.get(2));
    // put it together
    String sys = getSystemName(shared);
    String uname = getUserName(shared);
    SignalHead h;
    if (uname == null) {
        h = new TripleTurnoutSignalHead(sys, green, yellow, red);
    } else {
        h = new TripleTurnoutSignalHead(sys, uname, green, yellow, red);
    }
    loadCommon(h, shared);
    InstanceManager.getDefault(jmri.SignalHeadManager.class).register(h);
    return true;
}
Also used : TripleTurnoutSignalHead(jmri.implementation.TripleTurnoutSignalHead) Element(org.jdom2.Element) TripleTurnoutSignalHead(jmri.implementation.TripleTurnoutSignalHead) SignalHead(jmri.SignalHead) Turnout(jmri.Turnout)

Example 39 with SignalHead

use of jmri.SignalHead in project JMRI by JMRI.

the class BlockOrderTest method testBlockMembers.

/* tests OBlocks more than BlockOrders,
     *  but adds to coverage if tested here.
     */
@Test
public void testBlockMembers() {
    OBlock block = _blkMgr.provideOBlock("OB1");
    PortalManager portalMgr = InstanceManager.getDefault(PortalManager.class);
    Portal portal = portalMgr.providePortal("foop");
    portal.setToBlock(block, true);
    SignalHead sh = new jmri.implementation.VirtualSignalHead("IH1", "sig1");
    Assert.assertNotNull("signal", sh);
    sh.setAppearance(SignalHead.YELLOW);
    OPath p = new OPath(block, "path");
    portal.setProtectSignal(sh, 20, block);
    block.addPath(p);
    block.addPortal(portal);
    BlockOrder bo = new BlockOrder(block, "path", "foop", null);
    Assert.assertEquals("OPath", p, bo.getPath());
    Assert.assertEquals("Entry portal", portal, bo.getEntryPortal());
    Assert.assertNull("Exit portal", bo.getExitPortal());
    Assert.assertEquals("signal", sh, bo.getSignal());
    Assert.assertEquals("Entrance speedType", "Medium", bo.getPermissibleEntranceSpeed());
    Assert.assertEquals(20, bo.getEntranceSpace(), 0);
}
Also used : SignalHead(jmri.SignalHead) Test(org.junit.Test)

Example 40 with SignalHead

use of jmri.SignalHead in project JMRI by JMRI.

the class SignalHeadSignalMast method setDelayedAppearances.

private void setDelayedAppearances(final HashMap<SignalHead, Integer> delaySet, final int delay) {
    for (SignalHead head : delaySet.keySet()) {
        final SignalHead thrHead = head;
        Runnable r = new Runnable() {

            @Override
            public void run() {
                try {
                    thrHead.setAppearance(delaySet.get(thrHead));
                    if (log.isDebugEnabled()) {
                        log.debug("Setting " + thrHead.getSystemName() + " to " + thrHead.getAppearanceName(delaySet.get(thrHead)));
                    }
                    Thread.sleep(delay);
                } catch (InterruptedException ex) {
                    Thread.currentThread().interrupt();
                }
            }
        };
        Thread thr = new Thread(r);
        thr.setName(getDisplayName());
        thr.setDaemon(true);
        try {
            thr.start();
            thr.join();
        } catch (java.lang.IllegalThreadStateException ex) {
            log.error(ex.toString());
        } catch (InterruptedException ex) {
            log.error(ex.toString());
        }
    }
}
Also used : SignalHead(jmri.SignalHead)

Aggregations

SignalHead (jmri.SignalHead)73 Turnout (jmri.Turnout)20 Element (org.jdom2.Element)13 SignalMast (jmri.SignalMast)12 Sensor (jmri.Sensor)11 JsonException (jmri.server.json.JsonException)8 Test (org.junit.Test)7 NamedBean (jmri.NamedBean)6 DoubleTurnoutSignalHead (jmri.implementation.DoubleTurnoutSignalHead)6 QuadOutputSignalHead (jmri.implementation.QuadOutputSignalHead)6 SingleTurnoutSignalHead (jmri.implementation.SingleTurnoutSignalHead)6 TripleOutputSignalHead (jmri.implementation.TripleOutputSignalHead)6 TripleTurnoutSignalHead (jmri.implementation.TripleTurnoutSignalHead)6 SignalHeadManager (jmri.SignalHeadManager)5 DccSignalHead (jmri.implementation.DccSignalHead)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 JmriException (jmri.JmriException)4 Light (jmri.Light)4 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)3 ActionEvent (java.awt.event.ActionEvent)3