use of org.opentcs.drivers.vehicle.management.ProcessModelEvent in project opentcs by openTCS.
the class AttachmentManager method updateAttachmentInformation.
private void updateAttachmentInformation(VehicleEntry entry) {
String vehicleName = entry.getVehicleName();
VehicleCommAdapterFactory factory = entry.getCommAdapterFactory();
AttachmentInformation newAttachment = attachmentPool.get(vehicleName).withAttachedCommAdapter(factory.getDescription());
attachmentPool.put(vehicleName, newAttachment);
eventHandler.onEvent(new AttachmentEvent(vehicleName, newAttachment));
if (entry.getCommAdapter() == null) {
// In case we are detached
eventHandler.onEvent(new ProcessModelEvent(vehicleName, new VehicleProcessModelTO()));
} else {
eventHandler.onEvent(new ProcessModelEvent(vehicleName, entry.getCommAdapter().createTransferableProcessModel()));
}
}
use of org.opentcs.drivers.vehicle.management.ProcessModelEvent in project opentcs by openTCS.
the class DefaultVehicleController method handleProcessModelEvent.
@SuppressWarnings("unchecked")
private void handleProcessModelEvent(PropertyChangeEvent evt) {
eventBus.onEvent(new ProcessModelEvent(evt.getPropertyName(), commAdapter.createTransferableProcessModel()));
if (Objects.equals(evt.getPropertyName(), VehicleProcessModel.Attribute.POSITION.name())) {
updateVehiclePosition((String) evt.getNewValue());
} else if (Objects.equals(evt.getPropertyName(), VehicleProcessModel.Attribute.PRECISE_POSITION.name())) {
updateVehiclePrecisePosition((Triple) evt.getNewValue());
} else if (Objects.equals(evt.getPropertyName(), VehicleProcessModel.Attribute.ORIENTATION_ANGLE.name())) {
vehicleService.updateVehicleOrientationAngle(vehicle.getReference(), (Double) evt.getNewValue());
} else if (Objects.equals(evt.getPropertyName(), VehicleProcessModel.Attribute.ENERGY_LEVEL.name())) {
vehicleService.updateVehicleEnergyLevel(vehicle.getReference(), (Integer) evt.getNewValue());
} else if (Objects.equals(evt.getPropertyName(), VehicleProcessModel.Attribute.LOAD_HANDLING_DEVICES.name())) {
vehicleService.updateVehicleLoadHandlingDevices(vehicle.getReference(), (List<LoadHandlingDevice>) evt.getNewValue());
} else if (Objects.equals(evt.getPropertyName(), VehicleProcessModel.Attribute.STATE.name())) {
updateVehicleState((Vehicle.State) evt.getNewValue());
} else if (Objects.equals(evt.getPropertyName(), VehicleProcessModel.Attribute.COMMAND_EXECUTED.name())) {
commandExecuted((MovementCommand) evt.getNewValue());
} else if (Objects.equals(evt.getPropertyName(), VehicleProcessModel.Attribute.COMMAND_FAILED.name())) {
dispatcherService.withdrawByVehicle(vehicle.getReference(), true);
} else if (Objects.equals(evt.getPropertyName(), VehicleProcessModel.Attribute.USER_NOTIFICATION.name())) {
notificationService.publishUserNotification((UserNotification) evt.getNewValue());
} else if (Objects.equals(evt.getPropertyName(), VehicleProcessModel.Attribute.COMM_ADAPTER_EVENT.name())) {
eventBus.onEvent((VehicleCommAdapterEvent) evt.getNewValue());
} else if (Objects.equals(evt.getPropertyName(), VehicleProcessModel.Attribute.VEHICLE_PROPERTY.name())) {
VehicleProcessModel.VehiclePropertyUpdate propUpdate = (VehicleProcessModel.VehiclePropertyUpdate) evt.getNewValue();
vehicleService.updateObjectProperty(vehicle.getReference(), propUpdate.getKey(), propUpdate.getValue());
} else if (Objects.equals(evt.getPropertyName(), VehicleProcessModel.Attribute.TRANSPORT_ORDER_PROPERTY.name())) {
VehicleProcessModel.TransportOrderPropertyUpdate propUpdate = (VehicleProcessModel.TransportOrderPropertyUpdate) evt.getNewValue();
if (currentDriveOrder != null) {
vehicleService.updateObjectProperty(currentDriveOrder.getTransportOrder(), propUpdate.getKey(), propUpdate.getValue());
}
}
}
use of org.opentcs.drivers.vehicle.management.ProcessModelEvent in project OpenTCS-4 by touchmii.
the class AttachmentManager method updateAttachmentInformation.
private void updateAttachmentInformation(VehicleEntry entry) {
String vehicleName = entry.getVehicleName();
VehicleCommAdapterFactory factory = entry.getCommAdapterFactory();
AttachmentInformation newAttachment = attachmentPool.get(vehicleName).withAttachedCommAdapter(factory.getDescription());
attachmentPool.put(vehicleName, newAttachment);
eventHandler.onEvent(new AttachmentEvent(vehicleName, newAttachment));
if (entry.getCommAdapter() == null) {
// In case we are detached
eventHandler.onEvent(new ProcessModelEvent(vehicleName, new VehicleProcessModelTO()));
} else {
eventHandler.onEvent(new ProcessModelEvent(vehicleName, entry.getCommAdapter().createTransferableProcessModel()));
}
}
use of org.opentcs.drivers.vehicle.management.ProcessModelEvent in project OpenTCS-4 by touchmii.
the class DetailPanel method onEvent.
@Override
public void onEvent(Object e) {
// Ignore events if no vehicle entry is associated with this panel.
if (vehicleEntry == null) {
return;
}
if (e instanceof AttachmentEvent) {
AttachmentEvent event = (AttachmentEvent) e;
if (Objects.equals(vehicleEntry.getVehicleName(), event.getVehicleName())) {
updateFromVehicleEntry(event);
}
}
if (e instanceof ProcessModelEvent) {
ProcessModelEvent event = (ProcessModelEvent) e;
if (Objects.equals(vehicleEntry.getVehicleName(), event.getUpdatedProcessModel().getVehicleName())) {
updateFromVehicleProcessModel(event);
// Forward event to the comm adapter panels
customPanelList.forEach(panel -> panel.processModelChange(event.getAttributeChanged(), event.getUpdatedProcessModel()));
}
}
}
use of org.opentcs.drivers.vehicle.management.ProcessModelEvent in project OpenTCS-4 by touchmii.
the class LocalVehicleEntryPool method onEvent.
@Override
public void onEvent(Object event) {
if (event instanceof ProcessModelEvent) {
ProcessModelEvent e = (ProcessModelEvent) event;
LocalVehicleEntry entry = getEntryFor(e.getUpdatedProcessModel().getVehicleName());
if (entry == null) {
return;
}
entry.setProcessModel(e.getUpdatedProcessModel());
} else if (event instanceof AttachmentEvent) {
AttachmentEvent e = (AttachmentEvent) event;
LocalVehicleEntry entry = getEntryFor(e.getVehicleName());
if (entry == null) {
return;
}
entry.setAttachmentInformation(e.getUpdatedAttachmentInformation());
}
}
Aggregations