Пример #1
0
 public void testSetUserAddress() {
   // test the code to set the User address
   SerialNode node = new SerialNode();
   byte uad[] = {(byte) 0x6D, (byte) 0x97};
   node.setUserAddress(uad);
   Assert.assertEquals("Node user address high byte", uad[0], node.getUserAddress()[0]);
   Assert.assertEquals("Node user address low byte", uad[1], node.getUserAddress()[1]);
 }
Пример #2
0
 /**
  * Set the current state of this Light This routine requests the hardware to change. If this is
  * really a change in state of this bit (tested in SerialNode), a Transmit packet will be sent
  * before this Node is next polled.
  */
 protected void doNewState(int oldState, int newState) {
   SerialNode mNode = SerialAddress.getNodeFromSystemName(getSystemName());
   if (mNode != null) {
     if (newState == ON) {
       mNode.setOutputBit(mBit, false);
     } else if (newState == OFF) {
       mNode.setOutputBit(mBit, true);
     } else {
       log.warn("illegal state requested for Light: " + getSystemName());
     }
   }
 }
Пример #3
0
 /**
  * Public method to set a SECSI Output bit Note: systemName is of format CNnnnBxxxx where "nnn" is
  * the serial node number (0 - 127) "xxxx' is the bit number within that node (1 thru number of
  * defined bits) state is 'true' for 0, 'false' for 1 The bit is transmitted to the hardware
  * immediately before the next poll packet is sent.
  */
 public void setSerialOutput(String systemName, boolean state) {
   // get the node and bit numbers
   SerialNode node = SerialAddress.getNodeFromSystemName(systemName);
   if (node == null) {
     log.error("bad SerialNode specification in SerialOutput system name:" + systemName);
     return;
   }
   int bit = SerialAddress.getBitFromSystemName(systemName);
   if (bit == 0) {
     log.error("bad output bit specification in SerialOutput system name:" + systemName);
     return;
   }
   // set the bit
   node.setOutputBit(bit, state);
 }
Пример #4
0
 public void testSetGlobalAddress() {
   // test the code to set the User address
   SerialNode node = new SerialNode();
   byte gad[] = {
     (byte) 0x00,
     (byte) 0x13,
     (byte) 0xA2,
     (byte) 0x00,
     (byte) 0x40,
     (byte) 0xA0,
     (byte) 0x4D,
     (byte) 0x2D
   };
   node.setGlobalAddress(gad);
   for (int i = 0; i < gad.length; i++) {
     Assert.assertEquals("Node global address byte " + i, gad[i], node.getGlobalAddress()[i]);
   }
 }
 public void testSerialOutput() {
   SerialTrafficController c = new SerialTrafficController();
   SerialNode a = new SerialNode();
   Assert.assertNotNull("exists", a);
   SerialNode g = new SerialNode(5, SerialNode.DAUGHTER);
   Assert.assertTrue("must Send", g.mustSend());
   g.resetMustSend();
   Assert.assertTrue("must Send off", !(g.mustSend()));
   c.setSerialOutput("VL5B2", false);
   c.setSerialOutput("VL5B1", false);
   c.setSerialOutput("VL5B23", false);
   c.setSerialOutput("VL5B22", false);
   c.setSerialOutput("VL5B21", false);
   c.setSerialOutput("VL5B2", true);
   c.setSerialOutput("VL5B19", false);
   c.setSerialOutput("VL5B5", false);
   c.setSerialOutput("VL5B20", false);
   c.setSerialOutput("VL5B17", true);
   Assert.assertTrue("must Send on", g.mustSend());
   AbstractMRMessage m = g.createOutPacket();
   Assert.assertEquals("packet size", 9, m.getNumDataElements());
   Assert.assertEquals("node address", 5, m.getElement(0));
   Assert.assertEquals("byte 1 lo nibble", 0x02, m.getElement(1));
   Assert.assertEquals("byte 1 hi nibble", 0x10, m.getElement(2));
   Assert.assertEquals("byte 2 lo nibble", 0x20, m.getElement(3));
   Assert.assertEquals("byte 2 hi nibble", 0x30, m.getElement(4));
   Assert.assertEquals("byte 3 lo nibble", 0x41, m.getElement(5));
   Assert.assertEquals("byte 3 hi nibble", 0x50, m.getElement(6));
   Assert.assertEquals("byte 4 lo nibble", 0x60, m.getElement(7));
   Assert.assertEquals("byte 4 hi nibble", 0x70, m.getElement(8));
 }
  public void testSensorCreationAndRegistration() {
    // replace the SerialTrafficController to get clean reset
    SerialTrafficController t =
        new SerialTrafficController() {
          SerialTrafficController test() {
            setInstance();
            return this;
          }
        }.test();
    Assert.assertNotNull("exists", t);

    // construct nodes
    SerialNode n1 = new SerialNode(1, SerialNode.NODE2002V6);
    SerialNode n2 = new SerialNode(2, SerialNode.NODE2002V6);
    SerialNode n3 = new SerialNode(3, SerialNode.NODE2002V1);

    SerialSensorManager s = new SerialSensorManager();
    Assert.assertTrue("none expected A1", !(n1.getSensorsActive()));
    Assert.assertTrue("none expected A2", !(n2.getSensorsActive()));
    Assert.assertTrue("none expected A3", !(n3.getSensorsActive()));
    s.provideSensor("1003");
    Assert.assertTrue("UA 1", n1.getSensorsActive());
    Assert.assertTrue("2nd none expected A2", !(n2.getSensorsActive()));
    Assert.assertTrue("2nd none expected A3", !(n3.getSensorsActive()));
    s.provideSensor("1011");
    s.provideSensor("1008");
    s.provideSensor("1009");
    s.provideSensor("1011");
    s.provideSensor("GS2006");
    Assert.assertTrue("2nd UA 1", n1.getSensorsActive());
    Assert.assertTrue("2nd UA 2", n2.getSensorsActive());
    Assert.assertTrue("2nd none expected UA 3", !(n3.getSensorsActive()));
    s.provideSensor("1010");
    s.provideSensor("3001");
    Assert.assertTrue("3rd UA 1", n1.getSensorsActive());
    Assert.assertTrue("3rd UA 2", n2.getSensorsActive());
    Assert.assertTrue("3nd UA 3", n3.getSensorsActive());
    s.provideSensor("1007");
    s.provideSensor("2007");
    s.provideSensor("3007");
    Assert.assertTrue("4th UA 1", n1.getSensorsActive());
    Assert.assertTrue("4th UA 2", n2.getSensorsActive());
    Assert.assertTrue("4th UA 3", n3.getSensorsActive());

    // some equality tests
    Assert.assertTrue("GS1p7 == GS1007", s.getSensor("GS1p7") == s.getSensor("GS1007"));
    Assert.assertTrue("GS1B7 == GS1007", s.getSensor("GS1B7") == s.getSensor("GS1007"));
  }