ui

## Class InitialWindowController

- java.lang.Object
- - ui.InitialWindowController

- All Implemented Interfaces:
    javafx.fxml.Initializable

      public class InitialWindowController
      extends java.lang.Object
      implements javafx.fxml.Initializable

  Layer 1 controller
  Author:
    David Hudec (dwdization@gmail.com)

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `InitialWindowController.GUIPeriodicTelegram` PeriodicTelegram extension, provide description text and status icon.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private javafx.scene.control.Button` | `btnConnect`
    `private javafx.scene.control.Button` | `btnScan`
    `private javafx.scene.control.TableColumn` | `colEnabled`
    `private javafx.scene.control.TableColumn` | `colFluctuation`
    `private javafx.scene.control.TableColumn` | `colFrame`
    `private javafx.scene.control.TableColumn` | `colInterval`
    `private javafx.scene.control.TableColumn` | `colStatus`
    `private javafx.scene.control.ToggleGroup` | `connectionGroup`
    `private static FrameDialogController` | `fdc`
    `private static java.util.logging.Logger` | `LOG`
    `private javafx.util.Callback` | `onColumnEnabledEditCommit` Handles changes on the "Enabled" column.
    `private javafx.util.Callback` | `onColumnFluctuateEditCommit` Handles changes on the "Fluctuate" column.
    `private javafx.event.EventHandler<javafx.stage.WindowEvent>` | `onFrameDialogClose` Custom EventHandler to take care of Layer 2 windows.
    `private javafx.collections.ObservableList<InitialWindowController.GUIPeriodicTelegram>` | `periodicTelegrams`
    `private javafx.scene.control.RadioButton` | `rbtnSerialSending`
    `private javafx.scene.control.RadioButton` | `rbtnUdpSending`
    `private Sender` | `sender`
    `private javafx.scene.layout.StackPane` | `stackConnection`
    `private javafx.scene.control.TableView` | `tblFrames`
    `private javafx.scene.control.TextField` | `txtDstIP`
    `private javafx.scene.control.TextField` | `txtDstPort`
    `private javafx.scene.control.TextField` | `txtSerialPortName`
    `private javafx.scene.control.TextField` | `txtSrcIP`
    `private javafx.scene.control.TextField` | `txtSrcPort`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `InitialWindowController()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `private void` | `btnAddFrameClicked()` New Layer 2 window is opened and set to default by passing an empty frame.
    `private void` | `btnConnectDisconnectClicked()` Initiates disconnecting from the output channel (represented by a Sender).
    `private void` | `btnEditFrameClicked()` If one and just one frame is selected, a Layer 2 window, set by the selected frame, is opened.
    `private void` | `btnRemoveFrameClicked()` Raises a confirmation dialog to remove selected frames.
    `private void` | `btnScanClicked()` Initiates a serial port scan.
    `private void` | `cancelAllTelegrams()` Disables the sending of all defined telegrams.
    `private void` | `disablePortScanning(boolean disabled)` Disables/enables controls to start port scanning.
    `private void` | `disableSenderProperties(boolean disabled)` Disables/enables controls to change connection properties.
    `private void` | `disableSenderSwitching(boolean disabled)` Disables/enables controls to change connection switching.
    `Sender` | `getSender()`
    `void` | `initialize(java.net.URL url, java.util.ResourceBundle rb)`
    `private void` | `initSender(java.lang.Class<? extends Sender> senderClass)` Initiates a Sender of the given class.
    `private void` | `onColumnIntervalEdit(javafx.scene.control.TableColumn.CellEditEvent<InitialWindowController.GUIPeriodicTelegram,Sender.SendingInterval> event)` Updates one row entity upon its interval change.
    `private void` | `openNewFrameDialog(Frame frame)` Opens a new Layer 2 window and sets the GUI controls by given frame.
    `private void` | `refreshFrameItems()`
    `private void` | `swapConnectionPane()` Cycles the connection panes in the stack pane like a card deck.

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

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

- - ### Field Detail

    - #### btnConnect

          private javafx.scene.control.Button btnConnect

    - #### btnScan

          private javafx.scene.control.Button btnScan

    - #### colEnabled

          private javafx.scene.control.TableColumn colEnabled

    - #### colFluctuation

          private javafx.scene.control.TableColumn colFluctuation

    - #### colFrame

          private javafx.scene.control.TableColumn colFrame

    - #### colInterval

          private javafx.scene.control.TableColumn colInterval

    - #### colStatus

          private javafx.scene.control.TableColumn colStatus

    - #### connectionGroup

          private final javafx.scene.control.ToggleGroup connectionGroup

    - #### fdc

          private static FrameDialogController fdc

    - #### LOG

          private static final java.util.logging.Logger LOG

    - #### onColumnEnabledEditCommit

          private javafx.util.Callback onColumnEnabledEditCommit

      Handles changes on the "Enabled" column. Results are written to the respective PeriodicTelegram, which is then started / canceled.

    - #### onColumnFluctuateEditCommit

          private javafx.util.Callback onColumnFluctuateEditCommit

      Handles changes on the "Fluctuate" column. Results are written to the respective PeriodicTelegram, which then will / will not be fluctuated every time before it is sent.

    - #### onFrameDialogClose

          private javafx.event.EventHandler<javafx.stage.WindowEvent> onFrameDialogClose

      Custom EventHandler to take care of Layer 2 windows. If a Layer 2 window was confirmed (OK), the defined frame is stored and this window updated.

    - #### periodicTelegrams

          private javafx.collections.ObservableList<InitialWindowController.GUIPeriodicTelegram> periodicTelegrams

    - #### rbtnSerialSending

          private javafx.scene.control.RadioButton rbtnSerialSending

    - #### rbtnUdpSending

          private javafx.scene.control.RadioButton rbtnUdpSending

    - #### sender

          private Sender sender

    - #### stackConnection

          private javafx.scene.layout.StackPane stackConnection

    - #### tblFrames

          private javafx.scene.control.TableView tblFrames

    - #### txtDstIP

          private javafx.scene.control.TextField txtDstIP

    - #### txtDstPort

          private javafx.scene.control.TextField txtDstPort

    - #### txtSerialPortName

          private javafx.scene.control.TextField txtSerialPortName

    - #### txtSrcIP

          private javafx.scene.control.TextField txtSrcIP

    - #### txtSrcPort

          private javafx.scene.control.TextField txtSrcPort

  - ### Constructor Detail

    - #### InitialWindowController

          public InitialWindowController()

  - ### Method Detail

    - #### btnAddFrameClicked

          private void btnAddFrameClicked()

      New Layer 2 window is opened and set to default by passing an empty frame.

    - #### btnConnectDisconnectClicked

          private void btnConnectDisconnectClicked()

      Initiates disconnecting from the output channel (represented by a Sender). Connection switching elements are unlocked once this succeeds.

    - #### btnEditFrameClicked

          private void btnEditFrameClicked()

      If one and just one frame is selected, a Layer 2 window, set by the selected frame, is opened. An alert is raised otherwise.

    - #### btnRemoveFrameClicked

          private void btnRemoveFrameClicked()

      Raises a confirmation dialog to remove selected frames. If confirmed, these are deleted. Raises an alert if none is selected.

    - #### btnScanClicked

          private void btnScanClicked()

      Initiates a serial port scan. Results are presented in a dialog. If available ports are found, the name of the first one is placed into the port name input field.

    - #### cancelAllTelegrams

          private void cancelAllTelegrams()

      Disables the sending of all defined telegrams.

    - #### disablePortScanning

          private void disablePortScanning(boolean disabled)

      Disables/enables controls to start port scanning.
      Parameters:
        `disabled` - put true to disable, false to enable

    - #### disableSenderProperties

          private void disableSenderProperties(boolean disabled)

      Disables/enables controls to change connection properties.
      Parameters:
        `disabled` - put true to disable, false to enable

    - #### disableSenderSwitching

          private void disableSenderSwitching(boolean disabled)

      Disables/enables controls to change connection switching.
      Parameters:
        `disabled` - put true to disable, false to enable

    - #### getSender

          public Sender getSender()

    - #### initialize

          public void initialize(java.net.URL url,
                                 java.util.ResourceBundle rb)

      Specified by:
        `initialize` in interface `javafx.fxml.Initializable`

    - #### initSender

          private void initSender(java.lang.Class<? extends Sender> senderClass)
                           throws java.lang.NumberFormatException,
                                  jssc.SerialPortException

      Initiates a Sender of the given class. CommSender is default. Connection switching controls are disabled once this succeeds.
      Parameters:
        `senderClass` - class of the sender to instantiate
      Throws:
        `java.lang.NumberFormatException` - in case of conversion error
        `jssc.SerialPortException` - in case of read/write error

    - #### onColumnIntervalEdit

          private void onColumnIntervalEdit(javafx.scene.control.TableColumn.CellEditEvent<InitialWindowController.GUIPeriodicTelegram,Sender.SendingInterval> event)

      Updates one row entity upon its interval change.

    - #### openNewFrameDialog

          private void openNewFrameDialog(Frame frame)

      Opens a new Layer 2 window and sets the GUI controls by given frame.
      Parameters:
        `frame` - Frame to set the window by

    - #### refreshFrameItems

          private void refreshFrameItems()

    - #### swapConnectionPane

          private void swapConnectionPane()

      Cycles the connection panes in the stack pane like a card deck. The one at the top is put to the bottom, the one which was second appears on top.