Search in sources :

Example 46 with SignalMast

use of jmri.SignalMast in project JMRI by JMRI.

the class DefaultSignalMastLogic method areBlocksIncluded.

@Override
public boolean areBlocksIncluded(ArrayList<Block> blks) {
    Enumeration<SignalMast> en = destList.keys();
    while (en.hasMoreElements()) {
        SignalMast dm = en.nextElement();
        boolean included = false;
        for (int i = 0; i < blks.size(); i++) {
            included = destList.get(dm).isBlockIncluded(blks.get(i));
            if (included) {
                return true;
            }
            included = destList.get(dm).isAutoBlockIncluded(blks.get(i));
            if (included) {
                return true;
            }
        }
    }
    return false;
}
Also used : SignalMast(jmri.SignalMast)

Example 47 with SignalMast

use of jmri.SignalMast in project JMRI by JMRI.

the class SignalHeadSignalMastXml method load.

@Override
public boolean load(Element shared, Element perNode) {
    SignalMast m;
    String sys = getSystemName(shared);
    try {
        m = InstanceManager.getDefault(jmri.SignalMastManager.class).provideSignalMast(sys);
    } catch (Exception e) {
        log.error("An error occured while trying to create the signal '" + sys + "' " + e.toString());
        return false;
    }
    if (getUserName(shared) != null) {
        m.setUserName(getUserName(shared));
    }
    loadCommon(m, shared);
    if (shared.getChild("unlit") != null) {
        Element unlit = shared.getChild("unlit");
        if (unlit.getAttribute("allowed") != null) {
            if (unlit.getAttribute("allowed").getValue().equals("no")) {
                m.setAllowUnLit(false);
            } else {
                m.setAllowUnLit(true);
            }
        }
    }
    Element e = shared.getChild("disabledAspects");
    if (e != null) {
        List<Element> list = e.getChildren("disabledAspect");
        for (Element aspect : list) {
            ((SignalHeadSignalMast) m).setAspectDisabled(aspect.getText());
        }
    }
    return true;
}
Also used : Element(org.jdom2.Element) SignalMast(jmri.SignalMast) SignalHeadSignalMast(jmri.implementation.SignalHeadSignalMast) SignalHeadSignalMast(jmri.implementation.SignalHeadSignalMast)

Example 48 with SignalMast

use of jmri.SignalMast in project JMRI by JMRI.

the class DefaultSignalAppearanceMapTest method testTwoHead.

@Test
public void testTwoHead() {
    SignalMast s = new SignalHeadSignalMast("IF$shsm:basic:two-searchlight:h1:h2") {

        @Override
        void configureAspectTable(String signalSystemName, String aspectMapName) {
            map = new DefaultSignalAppearanceMap("sys", "user");
        }
    };
    DefaultSignalAppearanceMap t = (DefaultSignalAppearanceMap) s.getAppearanceMap();
    t.addAspect("meh", new int[] { SignalHead.LUNAR, SignalHead.DARK });
    t.addAspect("biff", new int[] { SignalHead.GREEN, SignalHead.GREEN });
    s.setAspect("meh");
    Assert.assertEquals("meh 1 is LUNAR", SignalHead.LUNAR, h1.getAppearance());
    Assert.assertEquals("meh 2 is LUNAR", SignalHead.DARK, h2.getAppearance());
    s.setAspect("biff");
    Assert.assertEquals("biff 1 is GREEN", SignalHead.GREEN, h1.getAppearance());
    Assert.assertEquals("biff 2 is GREEN", SignalHead.GREEN, h2.getAppearance());
    InstanceManager.getDefault(jmri.SignalMastManager.class).deregister(s);
    s.dispose();
}
Also used : SignalMast(jmri.SignalMast) Test(org.junit.Test)

Example 49 with SignalMast

use of jmri.SignalMast in project JMRI by JMRI.

the class DefaultSignalAppearanceMapTest method testDefaultMap.

@Test
public void testDefaultMap() {
    SignalMast s = InstanceManager.getDefault(jmri.SignalMastManager.class).provideSignalMast("IF$shsm:basic:one-searchlight:h1");
    DefaultSignalAppearanceMap t = (DefaultSignalAppearanceMap) s.getAppearanceMap();
    t.loadDefaults();
    s.setAspect("Stop");
    Assert.assertEquals("Stop is RED", SignalHead.RED, h1.getAppearance());
    s.setAspect("Approach");
    Assert.assertEquals("Approach is YELLOW", SignalHead.YELLOW, h1.getAppearance());
    s.setAspect("Clear");
    Assert.assertEquals("Clear is GREEN", SignalHead.GREEN, h1.getAppearance());
    InstanceManager.getDefault(jmri.SignalMastManager.class).deregister(s);
    s.dispose();
}
Also used : SignalMast(jmri.SignalMast) Test(org.junit.Test)

Example 50 with SignalMast

use of jmri.SignalMast in project JMRI by JMRI.

the class LogixTableAction method loadJComboBoxWithMastAspects.

/**
     * Fetch valid aspects for a given Signal Mast.
     * <p>
     * Warn if mast is not found.
     *
     * @param box the comboBox on the setup pane to fill
     * @param mastName user or system name of the Signal Mast
     */
void loadJComboBoxWithMastAspects(JComboBox<String> box, String mastName) {
    box.removeAllItems();
    log.debug("loadJComboBoxWithMastAspects called with name: " + mastName);
    SignalMast m = InstanceManager.getDefault(jmri.SignalMastManager.class).getSignalMast(mastName);
    if (m == null) {
        box.addItem(rbx.getString("PromptLoadMastName"));
    } else {
        java.util.Vector<String> v = m.getValidAspects();
        for (int i = 0; i < v.size(); i++) {
            box.addItem(v.get(i));
        }
        box.setSelectedItem(m.getAspect());
    }
}
Also used : SignalMastManager(jmri.SignalMastManager) SignalMast(jmri.SignalMast)

Aggregations

SignalMast (jmri.SignalMast)80 Test (org.junit.Test)19 NamedBean (jmri.NamedBean)11 Sensor (jmri.Sensor)11 SignalHead (jmri.SignalHead)11 Turnout (jmri.Turnout)10 SignalMastManager (jmri.SignalMastManager)9 JsonException (jmri.server.json.JsonException)9 ArrayList (java.util.ArrayList)8 JmriException (jmri.JmriException)8 Block (jmri.Block)7 SignalMastLogic (jmri.SignalMastLogic)7 Hashtable (java.util.Hashtable)6 Element (org.jdom2.Element)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 IOException (java.io.IOException)4 NamedBeanHandle (jmri.NamedBeanHandle)4 Section (jmri.Section)4 LayoutTurnout (jmri.jmrit.display.layoutEditor.LayoutTurnout)4 PropertyChangeEvent (java.beans.PropertyChangeEvent)3