Search in sources :

Example 1 with LnReporter

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

the class LlnmonTest method testTransponding.

public void testTransponding() {
    LocoNetMessage l;
    l = new LocoNetMessage(new int[] { 0xD0, 0x01, 0x20, 0x08, 0x20, 0x26 });
    assertEquals("out A", "Transponder address 1056 absent at LR161 () (BDL16x Board ID 11 RX4 zone A).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xD0, 0x21, 0x20, 0x08, 0x20, 0x04 });
    assertEquals(" in A", "Transponder address 1056 present at LR161 () (BDL16x Board ID 11 RX4 zone A).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xD0, 0x21, 0x22, 0x08, 0x20, 0x24 });
    assertEquals(" in B", "Transponder address 1056 present at LR163 () (BDL16x Board ID 11 RX4 zone B).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xD0, 0x21, 0x24, 0x7d, 0x70, 0x04 });
    assertEquals(" in C", "Transponder address 112(short) (b2) present at LR165 () (BDL16x Board ID 11 RX4 zone C).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xD0, 0x21, 0x26, 0x08, 0x20, 0x04 });
    assertEquals(" in D", "Transponder address 1056 present at LR167 () (BDL16x Board ID 11 RX4 zone D).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xD0, 0x21, 0x28, 0x08, 0x20, 0x04 });
    assertEquals(" in E", "Transponder address 1056 present at LR169 () (BDL16x Board ID 11 RX4 zone E).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xD0, 0x21, 0x2A, 0x08, 0x20, 0x04 });
    assertEquals(" in F", "Transponder address 1056 present at LR171 () (BDL16x Board ID 11 RX4 zone F).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xD0, 0x21, 0x2C, 0x08, 0x20, 0x04 });
    assertEquals(" in G", "Transponder address 1056 present at LR173 () (BDL16x Board ID 11 RX4 zone G).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xD0, 0x20, 0x2E, 0x08, 0x20, 0x04 });
    assertEquals(" in H", "Transponder address 1056 present at LR47 () (BDL16x Board ID 3 RX4 zone H).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xD0, 0x20, 0x2E, 0x7d, 0x01, 0x04 });
    assertEquals("another in H", "Transponder address 1(short) present at LR47 () (BDL16x Board ID 3 RX4 zone H).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE5, 0x09, 0x40, 0x7D, 0x03, 0x00, 0x00, 0x00, 0x2D });
    assertEquals("find loco 3(short)", "Transponding Find query for loco address 3(short).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE5, 0x09, 0x00, 0x7D, 0x03, 0x00, 0x12, 0x00, 0x7F });
    assertEquals(" in H", "Transponder Find report: address 3(short) present at LR19 (BDL16x Board 2 RX4 zone B).\n", f.displayMessage(l));
    LnReporter r = (LnReporter) lnrm.provideReporter("LR19");
    l = new LocoNetMessage(new int[] { 0xE5, 0x09, 0x00, 0x7D, 0x03, 0x00, 0x14, 0x00, 0x7F });
    assertEquals("Transponding no reporter user name", "Transponder Find report: address 3(short) present at LR21 (BDL16x Board 2 RX4 zone C).\n", f.displayMessage(l));
    r.setUserName("AUserName");
    l = new LocoNetMessage(new int[] { 0xE5, 0x09, 0x00, 0x7D, 0x03, 0x00, 0x12, 0x00, 0x7F });
    assertEquals("Transponding in B, with reporter user name", "Transponder Find report: address 3(short) present at LR19 (AUserName) (BDL16x Board 2 RX4 zone B).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE5, 0x09, 0x01, 0x7D, 0x03, 0x00, 0x12, 0x00, 0x7F });
    assertEquals("Transponding Bad Message 1", "Unable to parse LocoNet message.\ncontents: E5 09 01 7D 03 00 12 00 7F\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE5, 0x09, 0x40, 0x00, 0x04, 0x00, 0x00, 0x00, 0x2D });
    assertEquals("find loco 4 (long)", "Transponding Find query for loco address 4.\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE5, 0x09, 0x00, 0x00, 0x04, 0x00, 0x16, 0x00, 0x7F });
    assertEquals(" in D", "Transponder Find report: address 4 present at LR23 (BDL16x Board 2 RX4 zone D).\n", f.displayMessage(l));
    assertNotNull("reporter Got Created", lnrm.getBySystemName("LR23"));
    assertNull("reporter is Not Yet Created", lnrm.getBySystemName("LR25"));
    l = new LocoNetMessage(new int[] { 0xE5, 0x09, 0x00, 0x00, 0x04, 0x00, 0x18, 0x00, 0x7F });
    assertEquals(" in D", "Transponder Find report: address 4 present at LR25 (BDL16x Board 2 RX4 zone E).\n", f.displayMessage(l));
    assertNotNull("reporter Created", lnrm.getBySystemName("LR25"));
    ((LnReporter) lnrm.getBySystemName("LR25")).setUserName("Friendly name E");
    assertEquals("check setting of username", lnrm.getBySystemName("LR25").getUserName(), "Friendly name E");
    ((LnReporter) lnrm.provideReporter("LR31")).setUserName("Friendly Name H");
    ((LnReporter) lnrm.provideReporter("LR29")).setUserName("Friendly Name G");
    ((LnReporter) lnrm.provideReporter("LR27")).setUserName("Friendly Name F");
    ((LnReporter) lnrm.provideReporter("LR23")).setUserName("Friendly Name D");
    ((LnReporter) lnrm.provideReporter("LR21")).setUserName("Friendly Name C");
    ((LnReporter) lnrm.provideReporter("LR19")).setUserName("Friendly Name B");
    ((LnReporter) lnrm.provideReporter("LR17")).setUserName("Friendly Name A");
    l = new LocoNetMessage(new int[] { 0xE5, 0x09, 0x00, 0x00, 0x04, 0x00, 0x18, 0x00, 0x7F });
    assertEquals(" in D", "Transponder Find report: address 4 present at LR25 (Friendly name E) (BDL16x Board 2 RX4 zone E).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE5, 0x09, 0x00, 0x00, 0x04, 0x00, 0x14, 0x00, 0x7F });
    assertEquals(" in D", "Transponder Find report: address 4 present at LR21 (Friendly Name C) (BDL16x Board 2 RX4 zone C).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE5, 0x09, 0x00, 0x00, 0x04, 0x00, 0x12, 0x00, 0x7F });
    assertEquals(" in D", "Transponder Find report: address 4 present at LR19 (Friendly Name B) (BDL16x Board 2 RX4 zone B).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE5, 0x09, 0x00, 0x00, 0x04, 0x00, 0x10, 0x00, 0x7F });
    assertEquals(" in D", "Transponder Find report: address 4 present at LR17 (Friendly Name A) (BDL16x Board 2 RX4 zone A).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE5, 0x09, 0x00, 0x00, 0x04, 0x00, 0x1A, 0x00, 0x7F });
    assertEquals(" in D", "Transponder Find report: address 4 present at LR27 (Friendly Name F) (BDL16x Board 2 RX4 zone F).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE5, 0x09, 0x00, 0x00, 0x04, 0x00, 0x1C, 0x00, 0x7F });
    assertEquals(" in D", "Transponder Find report: address 4 present at LR29 (Friendly Name G) (BDL16x Board 2 RX4 zone G).\n", f.displayMessage(l));
    l = new LocoNetMessage(new int[] { 0xE5, 0x09, 0x00, 0x00, 0x04, 0x00, 0x1E, 0x00, 0x7F });
    assertEquals(" in D", "Transponder Find report: address 4 present at LR31 (Friendly Name H) (BDL16x Board 2 RX4 zone H).\n", f.displayMessage(l));
}
Also used : LnReporter(jmri.jmrix.loconet.LnReporter) LocoNetMessage(jmri.jmrix.loconet.LocoNetMessage)

Aggregations

LnReporter (jmri.jmrix.loconet.LnReporter)1 LocoNetMessage (jmri.jmrix.loconet.LocoNetMessage)1