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;
}
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;
}
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();
}
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();
}
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());
}
}
Aggregations