use of jmri.jmrix.AbstractMRMessage in project JMRI by JMRI.
the class SerialNodeTest method testOutputBits1.
public void testOutputBits1() {
// SMINI with several output bits set
SerialNode g = new SerialNode(5, SerialNode.SMINI, stcs);
Assert.assertTrue("must Send", g.mustSend());
g.resetMustSend();
Assert.assertTrue("must Send off", !(g.mustSend()));
g.setOutputBit(2, false);
g.setOutputBit(1, false);
g.setOutputBit(23, false);
g.setOutputBit(41, false);
g.setOutputBit(31, false);
g.setOutputBit(2, true);
g.setOutputBit(19, false);
g.setOutputBit(5, false);
g.setOutputBit(26, false);
g.setOutputBit(48, false);
Assert.assertTrue("must Send on", g.mustSend());
AbstractMRMessage m = g.createOutPacket();
Assert.assertEquals("packet size", 8, m.getNumDataElements());
Assert.assertEquals("node address", 70, m.getElement(0));
// 'T'
Assert.assertEquals("packet type", 84, m.getElement(1));
Assert.assertEquals("out byte 1", 17, (m.getElement(2) & 0xff));
Assert.assertEquals("out byte 2", 0, (m.getElement(3) & 0xff));
Assert.assertEquals("out byte 3", 68, (m.getElement(4) & 0xff));
Assert.assertEquals("out byte 4", 66, (m.getElement(5) & 0xff));
Assert.assertEquals("out byte 5", 0, (m.getElement(6) & 0xff));
Assert.assertEquals("out byte 6", 129, (m.getElement(7) & 0xff));
}
use of jmri.jmrix.AbstractMRMessage in project JMRI by JMRI.
the class SerialNodeTest method testInitialization1.
public void testInitialization1() {
SerialNode b = new SerialNode(stcs);
// simple SMINI - no oscillating 2-lead searchlights
AbstractMRMessage m = b.createInitPacket();
Assert.assertEquals("packet size", 6, m.getNumDataElements());
Assert.assertEquals("node address", 65, m.getElement(0));
// 'I'
Assert.assertEquals("packet type", 73, m.getElement(1));
// 'M'
Assert.assertEquals("node type", 77, m.getElement(2));
Assert.assertEquals("delay high", 0, m.getElement(3));
Assert.assertEquals("delay low", 0, m.getElement(4));
// No Searchlights
Assert.assertEquals("NS", 0, m.getElement(5));
}
use of jmri.jmrix.AbstractMRMessage in project JMRI by JMRI.
the class SerialNodeTest method testOutputBits1.
public void testOutputBits1() {
// mode with several output bits set
SerialNode g = new SerialNode(5, SerialNode.NODE2002V6);
Assert.assertTrue("must Send", g.mustSend());
g.resetMustSend();
Assert.assertTrue("must Send off", !(g.mustSend()));
g.setOutputBit(2, false);
g.setOutputBit(1, false);
g.setOutputBit(3, false);
g.setOutputBit(4, false);
g.setOutputBit(5, false);
g.setOutputBit(2, true);
g.setOutputBit(9, false);
g.setOutputBit(5, false);
g.setOutputBit(11, false);
g.setOutputBit(10, false);
Assert.assertTrue("must Send on", g.mustSend());
AbstractMRMessage m = g.createOutPacket();
Assert.assertEquals("packet size", 4, m.getNumDataElements());
Assert.assertEquals("node address", 5, m.getElement(0));
// 'T'
Assert.assertEquals("packet type", 17, m.getElement(1));
}
use of jmri.jmrix.AbstractMRMessage in project JMRI by JMRI.
the class AddNodeFrameTest method testCTor.
@Test
public void testCTor() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
IEEE802154TrafficController tc = new IEEE802154TrafficController() {
@Override
public void setInstance() {
}
@Override
protected AbstractMRReply newReply() {
return null;
}
@Override
public IEEE802154Node newNode() {
return new IEEE802154Node() {
@Override
public AbstractMRMessage createInitPacket() {
return null;
}
@Override
public AbstractMRMessage createOutPacket() {
return null;
}
@Override
public boolean getSensorsActive() {
return false;
}
@Override
public boolean handleTimeout(AbstractMRMessage m, AbstractMRListener l) {
return false;
}
@Override
public void resetTimeout(AbstractMRMessage m) {
}
};
}
};
AddNodeFrame t = new AddNodeFrame(tc);
Assert.assertNotNull("exists", t);
}
use of jmri.jmrix.AbstractMRMessage in project JMRI by JMRI.
the class EditNodeFrameTest method testCTor.
@Test
public void testCTor() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
IEEE802154TrafficController tc = new IEEE802154TrafficController() {
@Override
public void setInstance() {
}
@Override
protected AbstractMRReply newReply() {
return null;
}
@Override
public IEEE802154Node newNode() {
return new IEEE802154Node() {
@Override
public AbstractMRMessage createInitPacket() {
return null;
}
@Override
public AbstractMRMessage createOutPacket() {
return null;
}
@Override
public boolean getSensorsActive() {
return false;
}
@Override
public boolean handleTimeout(AbstractMRMessage m, AbstractMRListener l) {
return false;
}
@Override
public void resetTimeout(AbstractMRMessage m) {
}
};
}
};
EditNodeFrame t = new EditNodeFrame(tc, tc.newNode());
Assert.assertNotNull("exists", t);
}
Aggregations