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