use of org.opentcs.drivers.vehicle.management.AttachmentEvent 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.AttachmentEvent 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.AttachmentEvent 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.AttachmentEvent 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());
}
}
use of org.opentcs.drivers.vehicle.management.AttachmentEvent in project opentcs by openTCS.
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()));
}
}
}
Aggregations