Class SerialNode


  • public class SerialNode
    extends AbstractNode
    Models a serial node.

    Nodes are numbered ala their address, from 0 to 255. Node number 1 carries sensors 1 to 999, node 2 1001 to 1999 etc.

    The array of sensor states is used to update sensor known state only when there's a change on the serial bus. This allows for the sensor state to be updated within the program, keeping this updated state until the next change on the serial bus. E.g. you can manually change a state via an icon, and not have it change back the next time that node is polled.

    • Constructor Detail

      • SerialNode

        public SerialNode​(SerialTrafficController tc)
        Assumes a node address of 1, and a node type of 0 (NODE2002V6). If this constructor is used, actual node address must be set using 'setNodeAddress()', and actual node type using 'setNodeType()'
        Parameters:
        tc - system connection traffic controller.
      • SerialNode

        public SerialNode​(int address,
                          int type,
                          SerialTrafficController tc)
        Create a new SerialNode and initialize default instance variables.
        Parameters:
        address - the address of node on serial bus (1-127)
        type - a type constant from the class
        tc - the TrafficController for this connection
    • Method Detail

      • getBoardNames

        public static java.lang.String[] getBoardNames()
      • setOutputBit

        public void setOutputBit​(int bitNumber,
                                 boolean state)
        Set an output bit on this node.
        Parameters:
        bitNumber - the bit index. Bits are numbered from 1 (not 0)
        state - 'true' for 0, 'false' for 1.
      • getNodeType

        public int getNodeType()
        Get node type.
        Returns:
        node type, e.g. NODE2002V1 or NODE2002V6.
      • setNodeType

        public void setNodeType​(int type)
        Set node type.
        Parameters:
        type - node type, e.g. NODE2002V1 or NODE2002V6.
      • checkNodeAddress

        protected boolean checkNodeAddress​(int address)
        Check for valid node address.
        Specified by:
        checkNodeAddress in class AbstractNode
        Parameters:
        address - node number to check.
        Returns:
        true if valid
      • createInitPacket

        public AbstractMRMessage createInitPacket()
        Create Initialization packets (SerialMessage) for this node. Initialization consists of multiple parts:
        • Turn on the ASD input 0x71 to bank 0
        • After a wait, another ASD message 0x73 to bank 0
        (Eventually, it should also request input values, once we know what message does that)

        As an Ugly Hack to keep these separate, only the first is put in the reply from this. The other(s) are sent via the usual output methods.

        Specified by:
        createInitPacket in class AbstractNode
        Returns:
        the packet, or 'null' if not needed
      • warn

        void warn​(java.lang.String s)
      • markChanges

        public void markChanges​(SerialReply l)
        Use the contents of a reply from the Grapevine to mark changes in the sensors on the layout.
        Parameters:
        l - Reply to a poll operation
      • markBit

        void markBit​(boolean input,
                     int sensorNum)
        Mark and act on a single input bit.
        Parameters:
        input - true if sensor says active
        sensorNum - from 1 to lastUsedSensor+1 on this node
      • registerSensor

        public void registerSensor​(Sensor s,
                                   int i)
        Register a sensor on a node.

        The numbers here are 0 to MAXSENSORS, not 1 to MAXSENSORS. E.g. the integer argument is one less than the name of the sensor object.

        Parameters:
        s - Sensor object
        i - bit number corresponding, a 1-based value corresponding to the low digits of the system name