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; }
if (vehicleNow.getTransportOrder() != null && vehicleOld.getTransportOrder() == null) { writeEvent(StatisticsEvent.VEHICLE_STARTS_PROCESSING, vehicleNow.getName()); if (vehicleNow.getTransportOrder() == null && vehicleOld.getTransportOrder() != null) { writeEvent(StatisticsEvent.VEHICLE_STOPS_PROCESSING, vehicleNow.getName());
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; }