bp

## Class Communicator

- java.lang.Object
- - bp.Communicator

- All Implemented Interfaces:
    jssc.SerialPortEventListener

      public class Communicator
      extends java.lang.Object
      implements jssc.SerialPortEventListener

  Class which allows to communicate with device via serial com port

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Communicator(MainGUI window)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `connect()` Connecting to the device via selected port and with sets parameters.
    `void` | `disconnect()` Disconnecting from device.
    `boolean` | `getConnected()` Gets the state of the connection, if the system is connected to the network device.
    `java.lang.String` | `getReceivedMsg()` Getting received msg
    `void` | `searchForPorts()` Searching available port for serial communication.
    `void` | `serialEvent(jssc.SerialPortEvent event)` If something changed on the opened serial connection between computer and the network device.
    `void` | `setConnected(boolean portConnected)` Setting bool if the port is connected.
    `void` | `setReceivedMsg(java.lang.String receivedMsg)` Setting the received msg
    `void` | `writeData(byte command)` Writing data to the serial link, opened port for the network device.
    `void` | `writeData(java.lang.String command)` Writing data to the serial link, opened port for the network device.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Communicator

          public Communicator(MainGUI window)

      Parameters:
        `window` - - main gui windows for user

  - ### Method Detail

    - #### searchForPorts

          public void searchForPorts()

      Searching available port for serial communication. All of them are inserted into cbox ports

    - #### connect

          public void connect()

      Connecting to the device via selected port and with sets parameters.

    - #### disconnect

          public void disconnect()

      Disconnecting from device. Serial port must be opened.

    - #### getConnected

          public final boolean getConnected()

      Gets the state of the connection, if the system is connected to the network device.
      Returns:
        - state of the connection

    - #### setConnected

          public void setConnected(boolean portConnected)

      Setting bool if the port is connected.
      Parameters:
        `portConnected` - - true if the port is connected.

    - #### getReceivedMsg

          public java.lang.String getReceivedMsg()

      Getting received msg
      Returns:
        - string as received msg via serial port

    - #### setReceivedMsg

          public void setReceivedMsg(java.lang.String receivedMsg)

      Setting the received msg
      Parameters:
        `receivedMsg` - - received msg

    - #### serialEvent

          public void serialEvent(jssc.SerialPortEvent event)

      If something changed on the opened serial connection between computer and the network device.
      Specified by:
        `serialEvent` in interface `jssc.SerialPortEventListener`
      Parameters:
        `event` - - when something happend on the serial communication port

    - #### writeData

          public void writeData(java.lang.String command)

      Writing data to the serial link, opened port for the network device.
      Parameters:
        `command` - - command as a string

    - #### writeData

          public void writeData(byte command)

      Writing data to the serial link, opened port for the network device.
      Parameters:
        `command` - - command as a byte