@Override public String label(Vehicle vehicle) { return vehicle.getName(); }
/** * Finds the vehicle with the given name. * * @param name The name of the requested vehicle. * @return A single vehicle that has the given name. * @throws ObjectUnknownException If a vehicle with the given name does not exist. */ public VehicleState getVehicleStateByName(String name) throws ObjectUnknownException { requireNonNull(name, "name"); return orderService.fetchObjects(Vehicle.class, v -> v.getName().equals(name)) .stream() .map(v -> VehicleState.fromVehicle(v)) .findAny() .orElseThrow(() -> new ObjectUnknownException("Unknown vehicle: " + name)); }
writeEvent(StatisticsEvent.VEHICLE_STARTS_PROCESSING, vehicleNow.getName()); writeEvent(StatisticsEvent.VEHICLE_STOPS_PROCESSING, vehicleNow.getName()); writeEvent(StatisticsEvent.VEHICLE_STARTS_CHARGING, vehicleNow.getName()); writeEvent(StatisticsEvent.VEHICLE_STOPS_CHARGING, vehicleNow.getName()); && (vehicleOld.hasState(Vehicle.State.EXECUTING) || !vehicleOld.hasProcState(Vehicle.ProcState.PROCESSING_ORDER))) { writeEvent(StatisticsEvent.VEHICLE_STARTS_WAITING, vehicleNow.getName()); && vehicleNow.hasState(Vehicle.State.EXECUTING) && !vehicleOld.hasState(Vehicle.State.EXECUTING)) { writeEvent(StatisticsEvent.VEHICLE_STOPS_WAITING, vehicleNow.getName());
public static VehicleStatusMessage fromVehicle(Vehicle vehicle) { VehicleStatusMessage vehicleMessage = new VehicleStatusMessage(); vehicleMessage.setVehicleName(vehicle.getName()); vehicleMessage.setTransportOrderName( vehicle.getTransportOrder() == null ? null : vehicle.getTransportOrder().getName()); vehicleMessage.setPosition( vehicle.getCurrentPosition() == null ? null : vehicle.getCurrentPosition().getName()); vehicleMessage.setState(vehicle.getState()); vehicleMessage.setProcState(vehicle.getProcState()); Triple precisePos = vehicle.getPrecisePosition(); if (precisePos != null) { VehicleStatusMessage.PrecisePosition precisePosElement; precisePosElement = new VehicleStatusMessage.PrecisePosition( precisePos.getX(), precisePos.getY(), precisePos.getZ()); vehicleMessage.setPrecisePosition(precisePosElement); } return vehicleMessage; }
public static VehicleStatusMessage fromVehicle(Vehicle vehicle, long sequenceNumber, Instant creationTimeStamp) { VehicleStatusMessage vehicleMessage = new VehicleStatusMessage(); vehicleMessage.setSequenceNumber(sequenceNumber); vehicleMessage.setCreationTimeStamp(creationTimeStamp); vehicleMessage.setVehicleName(vehicle.getName()); vehicleMessage.setTransportOrderName( vehicle.getTransportOrder() == null ? null : vehicle.getTransportOrder().getName()); vehicleMessage.setPosition( vehicle.getCurrentPosition() == null ? null : vehicle.getCurrentPosition().getName()); vehicleMessage.setState(vehicle.getState()); vehicleMessage.setProcState(vehicle.getProcState()); Triple precisePos = vehicle.getPrecisePosition(); if (precisePos != null) { VehicleStatusMessage.PrecisePosition precisePosElement; precisePosElement = new VehicleStatusMessage.PrecisePosition( precisePos.getX(), precisePos.getY(), precisePos.getZ()); vehicleMessage.setPrecisePosition(precisePosElement); } return vehicleMessage; }
/** * Creates a <Code>VehicleState</Code> instance from a <Code>Vehicle</Code> instance. * * @param vehicle The vehicle whose properties will be used to create a <Code>VehicleState</Code> * instance. * @return A new <Code>VehicleState</Code> instance filled with data from the given vehicle. */ public static VehicleState fromVehicle(Vehicle vehicle) { if (vehicle == null) { return null; } VehicleState vehicleState = new VehicleState(); vehicleState.setName(vehicle.getName()); vehicleState.setProperties(vehicle.getProperties()); vehicleState.setLength(vehicle.getLength()); vehicleState.setEnergyLevelGood(vehicle.getEnergyLevelGood()); vehicleState.setEnergyLevelCritical(vehicle.getEnergyLevelCritical()); vehicleState.setEnergyLevel(vehicle.getEnergyLevel()); vehicleState.setIntegrationLevel(vehicle.getIntegrationLevel()); vehicleState.setProcState(vehicle.getProcState()); vehicleState.setTransportOrder(nameOfNullableReference(vehicle.getTransportOrder())); vehicleState.setCurrentPosition(nameOfNullableReference(vehicle.getCurrentPosition())); vehicleState.setState(vehicle.getState()); return vehicleState; }