Search in sources :

Example 1 with SetIdleTimeoutCommand

use of com.example.commadapter.vehicle.exchange.commands.SetIdleTimeoutCommand in project opentcs-integration-example by openTCS.

the class ControlPanel method enableAdapterCheckBoxActionPerformed.

// GEN-LAST:event_sendOrderButtonActionPerformed
private void enableAdapterCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_enableAdapterCheckBoxActionPerformed
    if (enableAdapterCheckBox.isSelected()) {
        String host = hostTextField.getText();
        if (Strings.isNullOrEmpty(host)) {
            enableAdapterCheckBox.setSelected(false);
            JOptionPane.showMessageDialog(this, "IP address can not be empty.");
            return;
        }
        String portString = portTextField.getText();
        int port;
        if (!Strings.isNullOrEmpty(portString)) {
            port = Integer.valueOf(portString);
        } else {
            enableAdapterCheckBox.setSelected(false);
            JOptionPane.showMessageDialog(this, "TCP port can not be empty.");
            return;
        }
        String timeoutString = aliveTimeoutTextField.getText();
        int timeout;
        if (!Strings.isNullOrEmpty(timeoutString)) {
            timeout = Integer.valueOf(aliveTimeoutTextField.getText());
        } else {
            enableAdapterCheckBox.setSelected(false);
            JOptionPane.showMessageDialog(this, "Inactive after (ms) can not be empty.");
            return;
        }
        sendAdapterCommand(new SetVehicleHostCommand(host));
        sendAdapterCommand(new SetVehiclePortCommand(port));
        sendAdapterCommand(new SetIdleTimeoutCommand(timeout));
    }
    enableCommAdapter(enableAdapterCheckBox.isSelected());
}
Also used : SetVehicleHostCommand(com.example.commadapter.vehicle.exchange.commands.SetVehicleHostCommand) SetIdleTimeoutCommand(com.example.commadapter.vehicle.exchange.commands.SetIdleTimeoutCommand) Point(org.opentcs.data.model.Point) SetVehiclePortCommand(com.example.commadapter.vehicle.exchange.commands.SetVehiclePortCommand)

Aggregations

SetIdleTimeoutCommand (com.example.commadapter.vehicle.exchange.commands.SetIdleTimeoutCommand)1 SetVehicleHostCommand (com.example.commadapter.vehicle.exchange.commands.SetVehicleHostCommand)1 SetVehiclePortCommand (com.example.commadapter.vehicle.exchange.commands.SetVehiclePortCommand)1 Point (org.opentcs.data.model.Point)1