Search in sources :

Example 71 with Turnout

use of jmri.Turnout in project JMRI by JMRI.

the class MatrixSignalMastTest method testCtor1.

@Test
// it11 etc. are indirectly used as NamedBeans IT11 etc.
@SuppressWarnings("unused")
public void testCtor1() {
    // provide 3 turnouts:
    Turnout it11 = InstanceManager.turnoutManagerInstance().provideTurnout("11");
    Turnout it12 = InstanceManager.turnoutManagerInstance().provideTurnout("12");
    Turnout it13 = InstanceManager.turnoutManagerInstance().provideTurnout("13");
    MatrixSignalMast m = new MatrixSignalMast("IF$xsm:basic:one-low($0001)-3t", "user");
    m.setBitNum(3);
    m.setOutput("output1", "IT11");
    m.setOutput("output2", "IT12");
    m.setOutput("output3", "IT13");
    Assert.assertEquals("system name", "IF$xsm:basic:one-low($0001)-3t", m.getSystemName());
    Assert.assertEquals("user name", "user", m.getUserName());
    //System.out.println(it11.getFullyFormattedDisplayName()); //debug
    Assert.assertEquals("output2", "IT12", m.outputsToBeans.get("output2").getName());
}
Also used : Turnout(jmri.Turnout) Test(org.junit.Test)

Example 72 with Turnout

use of jmri.Turnout in project JMRI by JMRI.

the class TripleOutputSignalHeadTest method testCTor.

@Test
public void testCTor() {
    Turnout it = (InstanceManager.getDefault(TurnoutManager.class)).provideTurnout("IT1");
    NamedBeanHandle<Turnout> green = new NamedBeanHandle<>("green handle", it);
    Turnout it2 = (InstanceManager.getDefault(TurnoutManager.class)).provideTurnout("IT3");
    NamedBeanHandle<Turnout> red = new NamedBeanHandle<>("red handle", it2);
    Turnout it3 = (InstanceManager.getDefault(TurnoutManager.class)).provideTurnout("IT2");
    NamedBeanHandle<Turnout> yellow = new NamedBeanHandle<>("yellow handle", it3);
    TripleOutputSignalHead t = new TripleOutputSignalHead("Test Head", green, red, yellow);
    Assert.assertNotNull("exists", t);
}
Also used : Turnout(jmri.Turnout) NamedBeanHandle(jmri.NamedBeanHandle) Test(org.junit.Test)

Example 73 with Turnout

use of jmri.Turnout in project JMRI by JMRI.

the class TripleTurnoutSignalHeadTest method testCTor.

@Test
public void testCTor() {
    Turnout it = (InstanceManager.getDefault(TurnoutManager.class)).provideTurnout("IT1");
    NamedBeanHandle<Turnout> green = new NamedBeanHandle<>("green handle", it);
    Turnout it2 = (InstanceManager.getDefault(TurnoutManager.class)).provideTurnout("IT3");
    NamedBeanHandle<Turnout> red = new NamedBeanHandle<>("red handle", it2);
    Turnout it3 = (InstanceManager.getDefault(TurnoutManager.class)).provideTurnout("IT2");
    NamedBeanHandle<Turnout> yellow = new NamedBeanHandle<>("yellow handle", it3);
    TripleTurnoutSignalHead t = new TripleTurnoutSignalHead("Test Head", green, red, yellow);
    Assert.assertNotNull("exists", t);
}
Also used : Turnout(jmri.Turnout) NamedBeanHandle(jmri.NamedBeanHandle) Test(org.junit.Test)

Example 74 with Turnout

use of jmri.Turnout in project JMRI by JMRI.

the class SingleTurnoutSignalHeadTest method testDarkValidTypes1.

public void testDarkValidTypes1() {
    Turnout t = InstanceManager.turnoutManagerInstance().provideTurnout("IT1");
    SingleTurnoutSignalHead h = new SingleTurnoutSignalHead("IH1", new jmri.NamedBeanHandle<Turnout>("IT1", t), SignalHead.DARK, SignalHead.RED);
    int[] states = h.getValidStates();
    Assert.assertEquals(3, states.length);
    Assert.assertEquals(SignalHead.DARK, states[0]);
    Assert.assertEquals(SignalHead.RED, states[1]);
    Assert.assertEquals(SignalHead.FLASHRED, states[2]);
    String[] names = h.getValidStateNames();
    Assert.assertEquals(3, names.length);
    Assert.assertEquals("Dark", names[0]);
    Assert.assertEquals("Red", names[1]);
    Assert.assertEquals("Flashing Red", names[2]);
    h.setAppearance(SignalHead.DARK);
    Assert.assertEquals(SignalHead.DARK, h.getAppearance());
    Assert.assertEquals("Dark", h.getAppearanceName());
    h.setAppearance(SignalHead.FLASHRED);
    Assert.assertEquals(SignalHead.FLASHRED, h.getAppearance());
    Assert.assertEquals("Flashing Red", h.getAppearanceName());
    // stops flash timer
    h.setAppearance(SignalHead.RED);
    Assert.assertEquals(SignalHead.RED, h.getAppearance());
    Assert.assertEquals("Red", h.getAppearanceName());
}
Also used : Turnout(jmri.Turnout)

Example 75 with Turnout

use of jmri.Turnout in project JMRI by JMRI.

the class SingleTurnoutSignalHeadTest method testNoDarkValidTypes.

public void testNoDarkValidTypes() {
    Turnout t = InstanceManager.turnoutManagerInstance().provideTurnout("IT1");
    SingleTurnoutSignalHead h = new SingleTurnoutSignalHead("IH1", new jmri.NamedBeanHandle<Turnout>("IT1", t), SignalHead.GREEN, SignalHead.RED);
    int[] states = h.getValidStates();
    Assert.assertEquals(2, states.length);
    Assert.assertEquals(SignalHead.GREEN, states[0]);
    Assert.assertEquals(SignalHead.RED, states[1]);
    String[] names = h.getValidStateNames();
    Assert.assertEquals(2, names.length);
    Assert.assertEquals("Green", names[0]);
    Assert.assertEquals("Red", names[1]);
    h.setAppearance(SignalHead.GREEN);
    Assert.assertEquals(SignalHead.GREEN, h.getAppearance());
    Assert.assertEquals("Green", h.getAppearanceName());
    h.setAppearance(SignalHead.RED);
    Assert.assertEquals(SignalHead.RED, h.getAppearance());
    Assert.assertEquals("Red", h.getAppearanceName());
}
Also used : Turnout(jmri.Turnout)

Aggregations

Turnout (jmri.Turnout)221 Test (org.junit.Test)63 Sensor (jmri.Sensor)26 SignalHead (jmri.SignalHead)20 Element (org.jdom2.Element)20 TurnoutManager (jmri.TurnoutManager)17 JmriException (jmri.JmriException)11 Light (jmri.Light)10 SignalMast (jmri.SignalMast)10 ActionEvent (java.awt.event.ActionEvent)9 NamedBeanHandle (jmri.NamedBeanHandle)9 JsonException (jmri.server.json.JsonException)9 ActionListener (java.awt.event.ActionListener)8 Block (jmri.Block)7 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 NamedBean (jmri.NamedBean)6 Route (jmri.Route)6 AbstractTurnout (jmri.implementation.AbstractTurnout)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5