use of jmri.jmrix.AbstractMRMessage in project JMRI by JMRI.
the class OutputBitsTest method testWriteOutputBits1.
public void testWriteOutputBits1() {
OutputBits.setNumOutputBits(48);
obit.setOutputBit(2, false);
obit.setOutputBit(1, false);
obit.setOutputBit(23, false);
obit.setOutputBit(41, false);
obit.setOutputBit(31, false);
obit.setOutputBit(2, true);
obit.setOutputBit(19, false);
obit.setOutputBit(5, false);
obit.setOutputBit(26, false);
obit.setOutputBit(48, false);
AbstractMRMessage m = obit.createOutPacket(1, 48);
Assert.assertEquals("packet size", 62, m.getNumDataElements());
Assert.assertEquals("node address 1", '0', m.getElement(1));
Assert.assertEquals("node address 2", '0', m.getElement(2));
Assert.assertEquals("packet type 1", 'W', m.getElement(3));
Assert.assertEquals("packet type 2", 'C', m.getElement(4));
Assert.assertEquals("TO val 1 f", '1', (m.getElement(10 + 1) & 0xff));
Assert.assertEquals("TO val 2 t", '0', (m.getElement(10 + 2) & 0xff));
Assert.assertEquals("TO val 3 unknown", '0', (m.getElement(10 + 3) & 0xff));
}
use of jmri.jmrix.AbstractMRMessage in project JMRI by JMRI.
the class SerialNodeTest method testInitialization1.
public void testInitialization1() {
// no initialization needed for Maple
AbstractMRMessage m = b.createInitPacket();
Assert.assertEquals("null message", null, m);
}
use of jmri.jmrix.AbstractMRMessage in project JMRI by JMRI.
the class SerialNodeTest method testOutputBits1.
public void testOutputBits1() {
// IO48 with several output bits set
SerialNode g = new SerialNode(5, SerialNode.IO48);
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(21, false);
g.setOutputBit(31, false);
g.setOutputBit(2, true);
g.setOutputBit(19, false);
g.setOutputBit(5, false);
g.setOutputBit(26, false);
g.setOutputBit(28, false);
Assert.assertTrue("must Send on", g.mustSend());
AbstractMRMessage m = g.createOutPacket();
Assert.assertEquals("packet size", 5, 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 SerialNodeTest method testInitialization1.
public void testInitialization1() {
// no initialization in this protocol
AbstractMRMessage m = b.createInitPacket();
Assert.assertEquals("initpacket null", null, m);
}
use of jmri.jmrix.AbstractMRMessage in project JMRI by JMRI.
the class SerialTrafficControllerTest method testSerialOutput.
@Test
public void testSerialOutput() {
SerialTrafficController c = (SerialTrafficController) tc;
SerialNode a = new SerialNode();
SerialNode g = new SerialNode(5, SerialNode.IO24);
Assert.assertNotNull("exists", a);
Assert.assertTrue("must Send", g.mustSend());
g.resetMustSend();
Assert.assertTrue("must Send off", !(g.mustSend()));
c.setSerialOutput("OL5B2", false);
c.setSerialOutput("OL5B1", false);
c.setSerialOutput("OL5B23", false);
c.setSerialOutput("OL5B22", false);
c.setSerialOutput("OL5B21", false);
c.setSerialOutput("OL5B2", true);
c.setSerialOutput("OL5B19", false);
c.setSerialOutput("OL5B5", false);
c.setSerialOutput("OL5B20", false);
c.setSerialOutput("OL5B17", false);
Assert.assertTrue("must Send on", g.mustSend());
AbstractMRMessage m = g.createOutPacket();
Assert.assertEquals("packet size", 5, m.getNumDataElements());
Assert.assertEquals("node address", 5, m.getElement(0));
// 'T'
Assert.assertEquals("packet type", 17, m.getElement(1));
}
Aggregations