Class OpenConnector

  • Direct Known Subclasses:
    BUSConnector, USBConnector

    public abstract class OpenConnector
    extends Object
    Abstract connector for communicating with an OpenWebNet gateway using command command (CMD) and monitoring (MON) connections
    Author:
    M. Valla - Initial contribution
    • Constructor Detail

      • OpenConnector

        public OpenConnector()
    • Method Detail

      • openCmdConn

        public abstract void openCmdConn()
                                  throws OWNException
        Opens command (CMD) connection
        Throws:
        OWNException - in case of error
      • openMonConn

        public abstract void openMonConn()
                                  throws OWNException
        Opens monitor (MON) connection
        Throws:
        OWNException - in case of error
      • isCmdConnected

        public boolean isCmdConnected()
        Check if CMD is connected
        Returns:
        boolean true if connected
      • getLastCmdFrameSentTs

        public long getLastCmdFrameSentTs()
        Get timestamp of last CMD frame sent successfully
        Returns:
        long timestamp
      • isMonConnected

        public boolean isMonConnected()
        Check if MON is connected
        Returns:
        boolean true if connected
      • setListener

        public void setListener​(ConnectorListener listener)
        Sets the ConnectorListener for MONITOR events for this OpenConnector
        Parameters:
        listener - the ConnectorListener to set
      • sendCommandSynch

        public Response sendCommandSynch​(String frame)
                                  throws OWNException
        Send a command frame String on the connection, waits for a AckOpenMessage (ACN/NACK) or timeout and returns the received messages in a Response object
        Parameters:
        frame - the frame String to send
        Returns:
        Response object with messages received as response
        Throws:
        OWNException - in case of error while sending command frame or reading response
      • processFrame

        protected abstract void processFrame​(String newFrame)
        Process a frame string received
        Parameters:
        newFrame - the new frame received
      • notifyListener

        protected void notifyListener​(OpenMessage msg)
        Notify new message on MON connection to OpenListener using notifierExecutor
        Parameters:
        msg - the OpenMessage to be notified
      • handleMonDisconnect

        protected void handleMonDisconnect​(OWNException e)
        Called when MON connection is disconnected
        Parameters:
        e - the {link OWNException} received when disconnected
      • disconnect

        public void disconnect()
        Disconnects both MON and CMD connections and stops MON receive thread
      • disconnectMonChannel

        protected void disconnectMonChannel()
      • disconnectCmdChannel

        protected void disconnectCmdChannel()