Class AbstractTcpConnection

    • Method Detail

      • isServerConnection

        public boolean isServerConnection()
        Returns:
        the isServerConnection
      • connect

        public void connect()
                     throws CommConnectionException
        Description copied from class: ICommConnection
        This method opens a connection. Parameters are passed through the constructor
        Specified by:
        connect in class ICommConnection
        Throws:
        CommConnectionException - possible Errorcodes:
        • for TCP Connection:
          • ETHERNET_UNKNOWN_HOST
          • ETHERNET_TIMEOUT
          • WRONG_PARAMETER
        • for USB Connection:
          • DEVICE_IN_USE
          • NO_LIBRARY_FOUND
          • NO_DEVICES_FOUND
          • USB_SET_BAUDRATE
          • USB_SET_DATA_CHARACTERISTICS
          • USB_SET_FLOWCONTROL
          • USB_SET_TIMEOUTS
        • for RS232 Connection:
          • NO_LIBRARY_FOUND
          • SERIAL_PORT_NOT_EXIST
          • SERIAL_PARAMETER_NOT_SET
          • DEVICE_IN_USE
          • SERIAL_NO_ACCESS
          • SERIAL_NO_INITIALISE
      • setIPAddress

        public void setIPAddress​(java.lang.String ipaddress)
        sets the used IP address
        Parameters:
        ipaddress - IP address like "192.168.1.1"
      • getIPAddress

        public java.lang.String getIPAddress()
        Returns:
        the used IP address
      • setPort

        public void setPort​(int port)
        sets the used port
        Parameters:
        port - port
      • getPort

        public int getPort()
        Returns:
        the used port
      • isConnected

        public boolean isConnected()
        Specified by:
        isConnected in class ICommConnection
        Returns:
        true if connected else false
      • recv

        public int recv()
                 throws CommConnectionException
        Description copied from class: ICommConnection
        Receives a single byte.
        Specified by:
        recv in class ICommConnection
        Returns:
        byte or -1 if no Data available (timeout)
        Throws:
        CommConnectionException - possible Errorcodes:
        • for TCP Connection:
          • CONNECTION_LOST
          • UNHANDLED_ERROR
          • NOT_INITIALISE
        • for USB Connection:
          • CONNECTION_LOST
          • UNHANDLED_ERROR
          • NOT_INITIALISE
        • for RS232 Connection:
          • CONNECTION_LOST
          • UNHANDLED_ERROR
          • NOT_INITIALISE
      • setRecvTimeout

        public void setRecvTimeout​(int timeout)
                            throws CommConnectionException
        Description copied from class: ICommConnection
        set the receive timeout for read data, if the timeout expires an CommConnectionException is raised with errorcode RECV_TIMEOUT, the connection is still valid
        Specified by:
        setRecvTimeout in class ICommConnection
        Parameters:
        timeout - time in milliseconds
        Throws:
        CommConnectionException - possible Errorcodes:
        • for all connections
          • SET_CONFIGURATION
      • send

        public void send​(byte[] senddata)
                  throws CommConnectionException
        Description copied from class: ICommConnection
        Sends data to the connected device
        Specified by:
        send in class ICommConnection
        Parameters:
        senddata - data/command send to the connected device
        Throws:
        CommConnectionException - possible Errorcodes:
        • for TCP Connection:
          • WRONG_PARAMETER
          • UNHANDLED_ERROR
          • NOT_INITIALISE
        • for USB Connection:
          • WRONG_PARAMETER
          • UNHANDLED_ERROR
          • NOT_INITIALISE
        • for RS232 Connection:
          • WRONG_PARAMETER
          • CONNECTION_LOST
          • UNHANDLED_ERROR
          • NOT_INITIALISE
      • getInputStream

        public java.io.InputStream getInputStream()
        Specified by:
        getInputStream in class ICommConnection
        Returns:
        the InputStream of this connection
      • getOutputStream

        public java.io.OutputStream getOutputStream()
        Specified by:
        getOutputStream in class ICommConnection
        Returns:
        the OutputStream of this connection
      • getSocket

        public java.net.Socket getSocket()
        Returns:
        the Socket
      • getInfo

        public java.util.Hashtable<java.lang.String,​java.lang.Object> getInfo()
        Description copied from class: ICommConnection
        Gets Device Informations
        Specified by:
        getInfo in class ICommConnection
        Returns:
        Hashtable with the information
      • setSettings

        public void setSettings​(java.util.Hashtable<java.lang.String,​java.lang.String> settings)
                         throws java.lang.IllegalArgumentException
        Description copied from class: ICommConnection
        Sets connections settings
        Specified by:
        setSettings in class ICommConnection
        Parameters:
        settings - Hashtable with the special settings
        Throws:
        java.lang.IllegalArgumentException
      • isAlive

        public static boolean isAlive​(java.lang.String ipAdress,
                                      int time)
                               throws CommConnectionException
        Test if a Ethernet Device is reachable.
        Parameters:
        ipAdress - Device IP Address
        time - Timeout
        Returns:
        true if reachable, else false
        Throws:
        CommConnectionException - possible Errorcodes:
        • ETHERNET_UNKNOWN_HOST
        • UNHANDLED_ERROR
      • isAlive

        public boolean isAlive​(int time)
                        throws CommConnectionException
        Test if the Ethernet Device is reachable.
        Parameters:
        time - Timeout
        Returns:
        true if reachable, else false
        Throws:
        CommConnectionException - possible Errorcodes:
        • ETHERNET_UNKNOWN_HOST
        • UNHANDLED_ERROR
      • setConnectionTimeout

        public void setConnectionTimeout​(int time)
        Description copied from class: ICommConnection
        Sets the waiting time for the connection
        Specified by:
        setConnectionTimeout in class ICommConnection
        Parameters:
        time - connection timeout