use of com.example.commadapter.vehicle.exchange.commands.SendRequestCommand in project opentcs-integration-example by openTCS.
the class ControlPanel method sendOrderButtonActionPerformed.
// GEN-LAST:event_repeatLastOrderButtonActionPerformed
private void sendOrderButtonActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_sendOrderButtonActionPerformed
// Parse and check destination
Object selectedItem = destinationComboBox.getSelectedItem();
String destinationIdString = selectedItem instanceof Point ? ((Point) selectedItem).getName() : selectedItem.toString();
int destinationId = 0;
try {
destinationId = Integer.parseInt(destinationIdString);
if (destinationId < 0 || destinationId > 65535) {
throw new NumberFormatException("destinationId out of bounds");
}
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(this, "Destination ID must be in [0..65535].");
return;
}
// Parse and check action
OrderRequest.OrderAction action = (OrderRequest.OrderAction) actionComboBox.getSelectedItem();
// Parse and check order ID.
int orderId;
try {
orderId = Integer.parseUnsignedInt(orderIdTextField.getText());
if (orderId < 0 || orderId > 65535) {
throw new NumberFormatException("orderId out of bounds");
}
} catch (NumberFormatException exc) {
JOptionPane.showMessageDialog(this, "Order ID must be in [0..65535].");
return;
}
OrderRequest telegram = new OrderRequest(0, orderId, destinationId, action);
// Send this telegram to vehicle.
sendAdapterCommand(new SendRequestCommand(telegram));
// Increment the order ID in case the user wants to send another one.
orderId = (orderId + 1) % 65535;
if (orderId == 0) {
orderId = 1;
}
orderIdTextField.setText(Integer.toString(orderId));
}
use of com.example.commadapter.vehicle.exchange.commands.SendRequestCommand in project opentcs-integration-example by openTCS.
the class StatusPanel method buttonGetStateActionPerformed.
// GEN-LAST:event_chkBoxEnablePeriodicGetStateActionPerformed
private void buttonGetStateActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_buttonGetStateActionPerformed
SendRequestCommand command = new SendRequestCommand(new StateRequest(0));
sendAdapterCommand(command);
}
Aggregations