Search in sources :

Example 76 with LocoNetMessage

use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.

the class LocoGenTest method testPacketCreate.

public void testPacketCreate() {
    LocoGenPanel t = new LocoGenPanel();
    LocoNetMessage m = t.createPacket("12 34 AB 3 19 6 B B1");
    Assert.assertEquals("length", 8, m.getNumDataElements());
    Assert.assertEquals("0th byte", 0x12, m.getElement(0) & 0xFF);
    Assert.assertEquals("1st byte", 0x34, m.getElement(1) & 0xFF);
    Assert.assertEquals("2nd byte", 0xAB, m.getElement(2) & 0xFF);
    Assert.assertEquals("3rd byte", 0x03, m.getElement(3) & 0xFF);
    Assert.assertEquals("4th byte", 0x19, m.getElement(4) & 0xFF);
    Assert.assertEquals("5th byte", 0x06, m.getElement(5) & 0xFF);
    Assert.assertEquals("6th byte", 0x0B, m.getElement(6) & 0xFF);
    Assert.assertEquals("7th byte", 0xB1, m.getElement(7) & 0xFF);
}
Also used : LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage)

Example 77 with LocoNetMessage

use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.

the class LocoIOPanelTest method testSetAddr.

public void testSetAddr() {
    // prepare an interface
    LocoNetInterfaceScaffold lnis = new LocoNetInterfaceScaffold();
    // skip the warning dialog box
    LocoIOPanel f = new LocoIOPanel() {

        @Override
        protected int cautionAddrSet() {
            return 1;
        }
    };
    LocoNetSystemConnectionMemo memo = new LocoNetSystemConnectionMemo();
    memo.setLnTrafficController(lnis);
    f.initComponents(memo);
    f.addrField.setText("0134");
    // click button
    f.addrSetButton.doClick();
    // check first message of readAll
    Assert.assertEquals("One message sent", 1, lnis.outbound.size());
    LocoNetMessage msg = lnis.outbound.elementAt(0);
    Assert.assertEquals("message length", 16, msg.getNumDataElements());
    Assert.assertEquals("message opCode", 0xE5, msg.getOpCode());
    Assert.assertEquals("message bytes", "E5 10 50 00 01 00 01 01 00 34 10 00 00 00 00 00", msg.toString());
    // dispose and end operation
    f.dispose();
}
Also used : LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage) LocoNetInterfaceScaffold(jmri.jmrix.loconet.LocoNetInterfaceScaffold) LocoNetSystemConnectionMemo(jmri.jmrix.loconet.LocoNetSystemConnectionMemo)

Example 78 with LocoNetMessage

use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.

the class LocoIOPanelTest method testReadAll.

public void testReadAll() {
    // prepare an interface
    LocoNetInterfaceScaffold lnis = new LocoNetInterfaceScaffold();
    LocoIOPanel f = new LocoIOPanel();
    LocoNetSystemConnectionMemo memo = new LocoNetSystemConnectionMemo();
    memo.setLnTrafficController(lnis);
    f.initComponents(memo);
    // click button
    f.readAllButton.doClick();
    // check first message of ReadAll
    Assert.assertEquals("One message sent", 1, lnis.outbound.size());
    LocoNetMessage msg = lnis.outbound.elementAt(0);
    Assert.assertEquals("message length", 16, msg.getNumDataElements());
    Assert.assertEquals("message opCode", 0xE5, msg.getOpCode());
    Assert.assertEquals("message bytes", "E5 10 50 51 01 00 02 04 00 00 10 00 00 00 00 00", msg.toString());
    // dispose and end operation
    f.dispose();
}
Also used : LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage) LocoNetInterfaceScaffold(jmri.jmrix.loconet.LocoNetInterfaceScaffold) LocoNetSystemConnectionMemo(jmri.jmrix.loconet.LocoNetSystemConnectionMemo)

Example 79 with LocoNetMessage

use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.

the class LocoIOPanelTest method testAddrField.

public void testAddrField() {
    // make sure that the address field does a notify
    // and new address is used
    // prepare an interface
    LocoNetInterfaceScaffold lnis = new LocoNetInterfaceScaffold();
    LocoIOPanel f = new LocoIOPanel();
    LocoNetSystemConnectionMemo memo = new LocoNetSystemConnectionMemo();
    memo.setLnTrafficController(lnis);
    f.initComponents(memo);
    f.addrField.setText("1234");
    f.addrField.postActionEvent();
    // click button
    f.readAllButton.doClick();
    // check first message of readAll
    Assert.assertEquals("One message sent", 1, lnis.outbound.size());
    LocoNetMessage msg = lnis.outbound.elementAt(0);
    Assert.assertEquals("message length", 16, msg.getNumDataElements());
    Assert.assertEquals("message opCode", 0xE5, msg.getOpCode());
    Assert.assertEquals("message bytes", "E5 10 50 34 01 00 02 04 00 00 10 00 00 00 00 00", msg.toString());
    // dispose and end operation
    f.dispose();
}
Also used : LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage) LocoNetInterfaceScaffold(jmri.jmrix.loconet.LocoNetInterfaceScaffold) LocoNetSystemConnectionMemo(jmri.jmrix.loconet.LocoNetSystemConnectionMemo)

Example 80 with LocoNetMessage

use of jmri.jmrix.loconet.LocoNetMessage in project JMRI by JMRI.

the class LlnmonTest method testAliasing.

public void testAliasing() {
    LocoNetMessage l;
    l = new LocoNetMessage(new int[] { 0xEE, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    assertEquals("aliasing 01", "Get Aliasing Information.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE6, 0x10, 0x00, 0x00, 0x20, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    assertEquals("aliasing 02", "Aliasing Report: 64 aliases supported.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xEE, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    assertEquals("aliasing 03", "Get Alias pair 0.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xEE, 0x10, 0x00, 0x02, 0x01, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    assertEquals("aliasing 04", "Get Alias pair 1.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xEE, 0x10, 0x00, 0x02, 0x02, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    assertEquals("aliasing 05", "Get Alias pair 2.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xEE, 0x10, 0x00, 0x02, 0x04, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    assertEquals("aliasing 06", "Get Alias pair 4.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xEE, 0x10, 0x00, 0x02, 0x08, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    assertEquals("aliasing 07", "Get Alias pair 8.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE6, 0x10, 0x00, 0x02, 0x00, 0x00, 0x0f, 0x12, 0x34, 0x56, 0x00, 0x23, 0x14, 0x32, 0x00, 0x00 });
    assertEquals("aliasing 08", "Report Alias pair 0: 6674 is an alias for 86; 2595 is an alias for 50.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE6, 0x10, 0x00, 0x02, 0x01, 0x00, 0x0f, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    assertEquals("aliasing 09", "Report Alias pair 1: 128 is an alias for 8; 0 is an alias for 0.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE6, 0x10, 0x00, 0x02, 0x02, 0x00, 0x0f, 0x00, 0x02, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    assertEquals("aliasing 10", "Report Alias pair 2: 256 is an alias for 9; 0 is an alias for 0.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE6, 0x10, 0x00, 0x02, 0x03, 0x00, 0x0f, 0x00, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    assertEquals("aliasing 11", "Report Alias pair 3: 512 is an alias for 10; 0 is an alias for 0.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE6, 0x10, 0x00, 0x02, 0x04, 0x00, 0x0f, 0x00, 0x08, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    assertEquals("aliasing 12", "Report Alias pair 4: 1024 is an alias for 11; 0 is an alias for 0.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE6, 0x10, 0x00, 0x02, 0x05, 0x00, 0x0f, 0x00, 0x10, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    assertEquals("aliasing 13", "Report Alias pair 5: 2048 is an alias for 12; 0 is an alias for 0.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE6, 0x10, 0x00, 0x02, 0x06, 0x00, 0x0f, 0x00, 0x20, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    assertEquals("aliasing 14", "Report Alias pair 6: 4096 is an alias for 13; 0 is an alias for 0.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE6, 0x10, 0x00, 0x02, 0x07, 0x00, 0x0f, 0x00, 0x40, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    assertEquals("aliasing 15", "Report Alias pair 7: 8192 is an alias for 14; 0 is an alias for 0.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE6, 0x10, 0x00, 0x02, 0x08, 0x00, 0x0f, 0x01, 0x01, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    assertEquals("aliasing 16", "Report Alias pair 8: 129 is an alias for 15; 0 is an alias for 0.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE6, 0x10, 0x00, 0x02, 0x09, 0x00, 0x0f, 0x7f, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    assertEquals("aliasing 17", "Report Alias pair 9: 255 is an alias for 16; 0 is an alias for 0.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE6, 0x10, 0x00, 0x02, 0x00, 0x00, 0x0f, 0x7f, 0x01, 0x10, 0x00, 0x0A, 0x01, 0x20, 0x00, 0x00 });
    assertEquals("aliasing 18", "Report Alias pair 0: 255 is an alias for 16; 138 is an alias for 32.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE6, 0x10, 0x00, 0x02, 0x00, 0x00, 0x0f, 0x7f, 0x01, 0x10, 0x00, 0x0A, 0x02, 0x21, 0x00, 0x00 });
    assertEquals("aliasing 19", "Report Alias pair 0: 255 is an alias for 16; 266 is an alias for 33.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE6, 0x10, 0x00, 0x02, 0x00, 0x00, 0x0f, 0x7f, 0x01, 0x10, 0x00, 0x21, 0x04, 0x22, 0x00, 0x00 });
    assertEquals("aliasing 20", "Report Alias pair 0: 255 is an alias for 16; 545 is an alias for 34.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xEE, 0x10, 0x00, 0x43, 0x02, 0x00, 0x00, 0x53, 0x01, 0x21, 0x00, 0x21, 0x04, 0x22, 0x00, 0x00 });
    assertEquals("aliasing 21", "Set Alias pair 2: 211 is an alias for 33; 545 is an alias for 34.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xEE, 0x10, 0x00, 0x43, 0x03, 0x00, 0x00, 0x53, 0x01, 0x21, 0x00, 0x20, 0x04, 0x18, 0x00, 0x00 });
    assertEquals("aliasing 22", "Set Alias pair 3: 211 is an alias for 33; 544 is an alias for 24.\n", f.displayMessage(l));
}
Also used : LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage)

Aggregations

LocoNetMessage (jmri.jmrix.loconet.LocoNetMessage)103 Test (org.junit.Test)8 JFrame (javax.swing.JFrame)3 LocoNetInterfaceScaffold (jmri.jmrix.loconet.LocoNetInterfaceScaffold)3 LocoNetSystemConnectionMemo (jmri.jmrix.loconet.LocoNetSystemConnectionMemo)3 LocoStatsPanel (jmri.jmrix.loconet.locostats.swing.LocoStatsPanel)3 JmriJFrame (jmri.util.JmriJFrame)3 LocoNetSlot (jmri.jmrix.loconet.LocoNetSlot)2 SpjFile (jmri.jmrix.loconet.spjfile.SpjFile)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 StringTokenizer (java.util.StringTokenizer)1 LnPacketizer (jmri.jmrix.loconet.LnPacketizer)1 LnReporter (jmri.jmrix.loconet.LnReporter)1 LnTrafficController (jmri.jmrix.loconet.LnTrafficController)1 LnTurnout (jmri.jmrix.loconet.LnTurnout)1