示例#1
0
  public void testDCCppSensorCreate() {
    DCCppInterfaceScaffold xnis = new DCCppInterfaceScaffold(new DCCppCommandStation());
    DCCppSensor t = new DCCppSensor("DCCPPS042", xnis);

    // created in UNKNOWN state
    Assert.assertTrue(t.getKnownState() == jmri.Sensor.UNKNOWN);
  }
示例#2
0
  // DCCppSensor test for setting state
  public void testDCCppSensorSetState() throws jmri.JmriException {
    DCCppInterfaceScaffold xnis = new DCCppInterfaceScaffold(new DCCppCommandStation());
    DCCppSensor t = new DCCppSensor("DCCPPS043", xnis);

    t.setKnownState(jmri.Sensor.ACTIVE);
    Assert.assertTrue(t.getKnownState() == jmri.Sensor.ACTIVE);
    t.setKnownState(jmri.Sensor.INACTIVE);
    Assert.assertTrue(t.getKnownState() == jmri.Sensor.INACTIVE);
  }
示例#3
0
  // DCCppSensor test for incoming status message
  public void testDCCppSensorStatusMsg() {
    DCCppInterfaceScaffold xnis = new DCCppInterfaceScaffold(new DCCppCommandStation());
    Assert.assertNotNull("exists", xnis);

    DCCppSensor t = new DCCppSensor("DCCPPS04", xnis);
    DCCppReply m;

    // Verify this was created in UNKNOWN state
    Assert.assertTrue(t.getKnownState() == jmri.Sensor.UNKNOWN);

    // notify the Sensor that somebody else changed it...
    m = DCCppReply.parseDCCppReply("Q 4");
    t.message(m);
    Assert.assertEquals("Known state after activate ", jmri.Sensor.ACTIVE, t.getKnownState());

    m = DCCppReply.parseDCCppReply("q 4");
    t.message(m);

    Assert.assertEquals("Known state after inactivate ", jmri.Sensor.INACTIVE, t.getKnownState());
  }