Search in sources :

Example 1 with AttachmentEvent

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()));
    }
}
Also used : VehicleCommAdapterFactory(org.opentcs.drivers.vehicle.VehicleCommAdapterFactory) ProcessModelEvent(org.opentcs.drivers.vehicle.management.ProcessModelEvent) AttachmentInformation(org.opentcs.drivers.vehicle.management.AttachmentInformation) VehicleProcessModelTO(org.opentcs.drivers.vehicle.management.VehicleProcessModelTO) AttachmentEvent(org.opentcs.drivers.vehicle.management.AttachmentEvent)

Example 2 with AttachmentEvent

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()));
    }
}
Also used : VehicleCommAdapterFactory(org.opentcs.drivers.vehicle.VehicleCommAdapterFactory) ProcessModelEvent(org.opentcs.drivers.vehicle.management.ProcessModelEvent) AttachmentInformation(org.opentcs.drivers.vehicle.management.AttachmentInformation) VehicleProcessModelTO(org.opentcs.drivers.vehicle.management.VehicleProcessModelTO) AttachmentEvent(org.opentcs.drivers.vehicle.management.AttachmentEvent)

Example 3 with AttachmentEvent

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()));
        }
    }
}
Also used : ProcessModelEvent(org.opentcs.drivers.vehicle.management.ProcessModelEvent) AttachmentEvent(org.opentcs.drivers.vehicle.management.AttachmentEvent)

Example 4 with AttachmentEvent

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());
    }
}
Also used : ProcessModelEvent(org.opentcs.drivers.vehicle.management.ProcessModelEvent) AttachmentEvent(org.opentcs.drivers.vehicle.management.AttachmentEvent)

Example 5 with AttachmentEvent

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()));
        }
    }
}
Also used : ProcessModelEvent(org.opentcs.drivers.vehicle.management.ProcessModelEvent) AttachmentEvent(org.opentcs.drivers.vehicle.management.AttachmentEvent)

Aggregations

AttachmentEvent (org.opentcs.drivers.vehicle.management.AttachmentEvent)6 ProcessModelEvent (org.opentcs.drivers.vehicle.management.ProcessModelEvent)6 VehicleCommAdapterFactory (org.opentcs.drivers.vehicle.VehicleCommAdapterFactory)2 AttachmentInformation (org.opentcs.drivers.vehicle.management.AttachmentInformation)2 VehicleProcessModelTO (org.opentcs.drivers.vehicle.management.VehicleProcessModelTO)2