@Override public void handle(ChangeComponentAvailabilityToOperativeRequestedEvent event, CorrelationToken correlationToken) { LOG.info("OCPP 1.2 ChangeComponentAvailabilityToOperativeRequestedEvent"); RequestResult requestResult = chargingStationOcpp12Client.changeAvailabilityToOperative(event.getChargingStationId(), (EvseId) event.getComponentId()); switch (requestResult) { case SUCCESS: domainService.changeComponentAvailabilityToOperative(event.getChargingStationId(), event.getComponentId(), ChargingStationComponent.EVSE, correlationToken, addOnIdentity); break; case FAILURE: LOG.info("Failed to set availability of evse {} on chargingstation {} to operative", event.getComponentId().getId(), event.getChargingStationId().getId()); break; default: throw new AssertionError(String.format("Unknown status for change component availability to operative: '%s'", requestResult)); } }
@Override public void handle(ChangeComponentAvailabilityToOperativeRequestedEvent event, CorrelationToken correlationToken) { LOG.info("OCPP 1.5 ChangeComponentAvailabilityToOperativeRequestedEvent"); RequestResult requestResult = chargingStationOcpp15Client.changeAvailabilityToOperative(event.getChargingStationId(), (EvseId) event.getComponentId()); switch (requestResult) { case SUCCESS: domainService.changeComponentAvailabilityToOperative(event.getChargingStationId(), event.getComponentId(), ChargingStationComponent.EVSE, correlationToken, addOnIdentity); break; case FAILURE: LOG.info("Failed to set availability of evse {} on chargingstation {} to operative", event.getComponentId().getId(), event.getChargingStationId().getId()); break; default: throw new AssertionError(String.format("Unkown status for change component availability to operative: '%s'", requestResult)); } }
@Override public void handle(ChangeComponentAvailabilityToInoperativeRequestedEvent event, @MetaData(CorrelationToken.KEY) CorrelationToken correlationToken) { LOG.info("OCPP 1.5 ChangeComponentAvailabilityToInoperativeRequestedEvent"); RequestResult requestResult = chargingStationOcpp15Client.changeAvailabilityToInoperative(event.getChargingStationId(), (EvseId) event.getComponentId()); switch (requestResult) { case SUCCESS: domainService.changeComponentAvailabilityToInoperative(event.getChargingStationId(), event.getComponentId(), ChargingStationComponent.EVSE, correlationToken, addOnIdentity); break; case FAILURE: LOG.info("Failed to set availability of evse {} on chargingstation {} to inoperative", event.getComponentId().getId(), event.getChargingStationId().getId()); break; default: throw new AssertionError(String.format("Unkown status for change component availability to inoperative: '%s'", requestResult)); } }
@Override public void handle(ChangeComponentAvailabilityToInoperativeRequestedEvent event, @MetaData(CorrelationToken.KEY) CorrelationToken correlationToken) { LOG.info("OCPP 1.2 ChangeComponentAvailabilityToInoperativeRequestedEvent"); RequestResult requestResult = chargingStationOcpp12Client.changeAvailabilityToInoperative(event.getChargingStationId(), (EvseId) event.getComponentId()); switch (requestResult) { case SUCCESS: domainService.changeComponentAvailabilityToInoperative(event.getChargingStationId(), event.getComponentId(), ChargingStationComponent.EVSE, correlationToken, addOnIdentity); break; case FAILURE: LOG.info("Failed to set availability of evse {} on chargingstation {} to inoperative", event.getComponentId().getId(), event.getChargingStationId().getId()); break; default: throw new AssertionError(String.format("Unknown status for change component availability to inoperative: '%s'", requestResult)); } }
/** * Updates a charging station's component availability. * * @param chargingStationId the charging station's id. * @param componentId the component's id. * @param component the component type. * @param availability the the charging station's new availability. */ private void updateComponentAvailability(ChargingStationId chargingStationId, ComponentId componentId, ChargingStationComponent component, Availability availability) { if (!component.equals(ChargingStationComponent.EVSE) || !(componentId instanceof EvseId)) { return; } ChargingStation chargingStation = repository.findOne(chargingStationId.getId()); if (chargingStation != null) { for (Evse evse : chargingStation.getEvses()) { if (evse.getEvseId().equals(componentId.getId())) { evse.setAvailability(availability); break; } } repository.createOrUpdate(chargingStation); } }
/** * Handles the {@link ComponentStatusNotificationReceivedEvent}. * * @param event the event to handle. */ @EventHandler public void handle(ComponentStatusNotificationReceivedEvent event) { if (event.getComponent() == ChargingStationComponent.EVSE) { ChargingStation chargingStation = repository.findOne(event.getChargingStationId().getId()); if (chargingStation != null) { updateEvseStatus(chargingStation, event.getComponentId().getId(), event.getStatusNotification().getStatus()); repository.createOrUpdate(chargingStation); } } }