senders

## Class Sender

- java.lang.Object
- - senders.Sender

- Direct Known Subclasses:
    CommSender, UdpSender

      public abstract class Sender
      extends java.lang.Object

  Author:
    David Hudec (dwdization@gmail.com)

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Sender.SendingInterval` Supported sending intervals.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `connected`
    `protected java.util.concurrent.ScheduledExecutorService` | `scheduler`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Sender()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.concurrent.ScheduledFuture<?>` | `add(PeriodicTelegramBase pt)` Schedules given PeriodicTelegram for periodic sending.
    `java.util.concurrent.ScheduledFuture<?>` | `add(PeriodicTelegramBase pt, int delay)` Schedules given PeriodicTelegram for periodic sending with initial delay.
    `void` | `cancel(java.util.concurrent.ScheduledFuture<?> index)` Removes given scheduler ID from the periodic sending process.
    `void` | `connect()` Initiates connection with the output channel.
    `protected abstract java.lang.Runnable` | `getRunnable(PeriodicTelegramBase f)` Gets the Runnable that performs the sending process, which is that periodically executed.
    `boolean` | `isConnected()`
    `java.util.concurrent.ScheduledFuture<?>` | `reschedule(PeriodicTelegramBase pt)` Reschedules given PeriodicTelegram.
    `void` | `shutdown()` Terminates the sending process and, if applicable, connected devices and channels.

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

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

- - ### Field Detail

    - #### connected

          protected boolean connected

    - #### scheduler

          protected final java.util.concurrent.ScheduledExecutorService scheduler

  - ### Constructor Detail

    - #### Sender

          public Sender()

  - ### Method Detail

    - #### add

          public java.util.concurrent.ScheduledFuture<?> add(PeriodicTelegramBase pt)

      Schedules given PeriodicTelegram for periodic sending.
      Parameters:
        `pt` - PeriodicTelegram to send
      Returns:
        Scheduler ID of the operation

    - #### add

          public java.util.concurrent.ScheduledFuture<?> add(PeriodicTelegramBase pt,
                                                             int delay)

      Schedules given PeriodicTelegram for periodic sending with initial delay.
      Parameters:
        `pt` - PeriodicTelegram to send
        `delay` - firt transmission delay in seconds
      Returns:
        Scheduler ID of the operation

    - #### cancel

          public void cancel(java.util.concurrent.ScheduledFuture<?> index)

      Removes given scheduler ID from the periodic sending process.
      Parameters:
        `index` - scheduler ID of the PeriodicTelegram to cancel

    - #### connect

          public void connect()
                       throws jssc.SerialPortException

      Initiates connection with the output channel.
      Throws:
        `jssc.SerialPortException` - in case of read/write error

    - #### getRunnable

          protected abstract java.lang.Runnable getRunnable(PeriodicTelegramBase f)
                                                     throws java.lang.NumberFormatException

      Gets the Runnable that performs the sending process, which is that periodically executed.
      Parameters:
        `f` - PeriodicTelegram to send
      Returns:
        Runnable of this process
      Throws:
        `java.lang.NumberFormatException` - in case of conversion error

    - #### isConnected

          public boolean isConnected()

    - #### reschedule

          public java.util.concurrent.ScheduledFuture<?> reschedule(PeriodicTelegramBase pt)

      Reschedules given PeriodicTelegram. If the given telegram is found in the periodic sending process, its interval is update to this one's.
      Parameters:
        `pt` - PeriodicTelegram to send
      Returns:
        Scheduler ID of the operation

    - #### shutdown

          public void shutdown()

      Terminates the sending process and, if applicable, connected devices and channels.