/** * Returns a set of {@code io.motown.vas.viewmodel.persistence.entities.Evse}s based on * {@code io.motown.domain.api.chargingstation.Evse}s. The state of all EVSEs will be UNKNOWN. State will be updated * in the ComponentStatusNotificationReceivedEvent handler. * * @param eventEvses list of EVSEs. * @return set of VAS EVSEs. */ public Set<io.motown.vas.viewmodel.persistence.entities.Evse> getEvsesFromEventEvses(Set<Evse> eventEvses) { Set<io.motown.vas.viewmodel.persistence.entities.Evse> evses = new HashSet<>(); for (Evse evse : eventEvses) { evses.add(new io.motown.vas.viewmodel.persistence.entities.Evse(evse.getEvseId().getNumberedId(), ComponentStatus.UNKNOWN)); } return evses; }
/** * Generates a transaction identifier and starts a transaction by dispatching a StartTransactionCommand. * * @param chargingStationId identifier of the charging station. * @param evseId evse identifier on which the transaction is started. * @param idTag the identification which started the transaction. * @param futureEventCallback will be called once the authorize result event occurs. * @param addOnIdentity identity of the add on that calls this method. */ public void startTransaction(ChargingStationId chargingStationId, EvseId evseId, IdentifyingToken idTag, FutureEventCallback futureEventCallback, AddOnIdentity addOnIdentity) { ChargingStation chargingStation = this.checkChargingStationExistsAndIsRegisteredAndConfigured(chargingStationId); if (evseId.getNumberedId() > chargingStation.getNumberOfEvses()) { throw new IllegalStateException("Cannot start transaction on a unknown evse."); } // authorize the token, the future contains the call to start the transaction authorize(chargingStationId, idTag.getToken(), futureEventCallback, addOnIdentity); }
@Override public RequestResult unlockConnector(ChargingStationId id, EvseId evseId) { LOG.debug("Unlocking of connector {} on {}", evseId, id); ChargePointService chargePointService = this.createChargingStationService(id); UnlockConnectorRequest request = new UnlockConnectorRequest(); request.setConnectorId(evseId.getNumberedId()); UnlockConnectorResponse response = chargePointService.unlockConnector(request, id.getId()); if (UnlockStatus.ACCEPTED.equals(response.getStatus())) { LOG.info("Unlocking of connector {} on {} has been accepted", evseId, id); return RequestResult.SUCCESS; } else { LOG.warn("Unlocking of connector {} on {} has been rejected", evseId, id); return RequestResult.FAILURE; } }
@Override public RequestResult unlockConnector(ChargingStationId id, EvseId evseId) { LOG.debug("Unlocking of connector {} on {}", evseId, id); ChargePointService chargePointService = this.createChargingStationService(id); UnlockConnectorRequest request = new UnlockConnectorRequest(); request.setConnectorId(evseId.getNumberedId()); UnlockConnectorResponse response = chargePointService.unlockConnector(request, id.getId()); if (UnlockStatus.ACCEPTED.equals(response.getStatus())) { LOG.info("Unlocking of connector {} on {} has been accepted", evseId, id); return RequestResult.SUCCESS; } else { LOG.warn("Unlocking of connector {} on {} has been rejected", evseId, id); return RequestResult.FAILURE; } }
public void unlockEvse(ChargingStationId chargingStationId, EvseId evseId, CorrelationToken correlationToken) { Unlockconnector unlockConnectorRequest = new Unlockconnector(); unlockConnectorRequest.setConnectorId(evseId.getNumberedId()); responseHandlers.put(correlationToken.getToken(), new UnlockConnectorResponseHandler(evseId, correlationToken)); WampMessage wampMessage = new WampMessage(WampMessage.CALL, correlationToken.getToken(), MessageProcUri.UNLOCK_CONNECTOR, unlockConnectorRequest); sendWampMessage(wampMessage, chargingStationId); }
/** * {@inheritDoc} */ @Override public boolean startTransaction(ChargingStationId id, IdentifyingToken identifyingToken, EvseId evseId) { LOG.info("Requesting remote start transaction on {}", id); ChargePointService chargePointService = this.createChargingStationService(id); RemoteStartTransactionRequest request = new RemoteStartTransactionRequest(); request.setIdTag(identifyingToken.getToken()); request.setConnectorId(evseId.getNumberedId()); RemoteStartTransactionResponse response = chargePointService.remoteStartTransaction(request, id.getId()); boolean willTransactionStart; switch (response.getStatus()) { case ACCEPTED: LOG.info("Remote start transaction request on {} has been accepted", id); willTransactionStart = true; break; case REJECTED: LOG.info("Remote start transaction request on {} has been rejected", id); willTransactionStart = false; break; default: throw new AssertionError("Start transaction returned unknown response status " + response.getStatus()); } return willTransactionStart; }
public void changeAvailability(ChargingStationId chargingStationId, EvseId evseId, Changeavailability.Type availabilityType, CorrelationToken correlationToken) { Changeavailability changeAvailabilityRequest = new Changeavailability(); changeAvailabilityRequest.setConnectorId(evseId.getNumberedId()); changeAvailabilityRequest.setType(availabilityType); responseHandlers.put(correlationToken.getToken(), new ChangeAvailabilityResponseHandler(evseId, availabilityType, correlationToken)); WampMessage wampMessage = new WampMessage(WampMessage.CALL, correlationToken.getToken(), MessageProcUri.CHANGE_AVAILABILITY, changeAvailabilityRequest); sendWampMessage(wampMessage, chargingStationId); }
/** * {@inheritDoc} */ @Override public boolean startTransaction(ChargingStationId id, IdentifyingToken identifyingToken, EvseId evseId) { LOG.info("Requesting remote start transaction on {}", id); ChargePointService chargePointService = this.createChargingStationService(id); RemoteStartTransactionRequest request = new RemoteStartTransactionRequest(); request.setIdTag(identifyingToken.getToken()); request.setConnectorId(evseId.getNumberedId()); RemoteStartTransactionResponse response = chargePointService.remoteStartTransaction(request, id.getId()); boolean willTransactionStart; switch (response.getStatus()) { case ACCEPTED: LOG.info("Remote start transaction request on {} has been accepted", id); willTransactionStart = true; break; case REJECTED: LOG.info("Remote start transaction request on {} has been rejected", id); willTransactionStart = false; break; default: throw new AssertionError("Start transaction returned unknown response status " + response.getStatus()); } return willTransactionStart; }
/** * Handles the response when the change of availability has been accepted or scheduled, e.g. not rejected. * * @param chargingStationId The charging station identifier. * @param domainService The domain service. * @param addOnIdentity The AddOn identity. */ private void handleAcceptedOrScheduledChangeAvailabilityResponse(ChargingStationId chargingStationId, DomainService domainService, AddOnIdentity addOnIdentity) { if (Changeavailability.Type.INOPERATIVE.equals(availabilityType)) { if (evseId.getNumberedId() == 0) { domainService.changeChargingStationAvailabilityToInoperative(chargingStationId, getCorrelationToken(), addOnIdentity); } else { domainService.changeComponentAvailabilityToInoperative(chargingStationId, evseId, ChargingStationComponent.EVSE, getCorrelationToken(), addOnIdentity); } } else { if (evseId.getNumberedId() == 0) { domainService.changeChargingStationAvailabilityToOperative(chargingStationId, getCorrelationToken(), addOnIdentity); } else { domainService.changeComponentAvailabilityToOperative(chargingStationId, evseId, ChargingStationComponent.EVSE, getCorrelationToken(), addOnIdentity); } } } }
public void remoteStartTransaction(ChargingStationId chargingStationId, EvseId evseId, IdentifyingToken identifyingToken, CorrelationToken correlationToken) { Remotestarttransaction remoteStartTransactionRequest = new Remotestarttransaction(); remoteStartTransactionRequest.setConnectorId(evseId.getNumberedId()); remoteStartTransactionRequest.setIdTag(identifyingToken.getToken()); responseHandlers.put(correlationToken.getToken(), new RemoteStartTransactionResponseHandler(correlationToken)); WampMessage wampMessage = new WampMessage(WampMessage.CALL, correlationToken.getToken(), MessageProcUri.REMOTE_START_TRANSACTION, remoteStartTransactionRequest); sendWampMessage(wampMessage, chargingStationId); }
public void statusNotification(ChargingStationId chargingStationId, EvseId evseId, StatusNotification statusNotification, AddOnIdentity addOnIdentity) { this.checkChargingStationExistsAndIsRegisteredAndConfigured(chargingStationId); StatusNotificationCommand command; IdentityContext identityContext = new IdentityContext(addOnIdentity, new NullUserIdentity()); if (evseId.getNumberedId() == CHARGING_STATION_EVSE_ID) { command = new ChargingStationStatusNotificationCommand(chargingStationId, statusNotification, identityContext); } else { ChargingStationComponent component = ChargingStationComponent.EVSE; command = new ComponentStatusNotificationCommand(chargingStationId, component, evseId, statusNotification, identityContext); } commandGateway.send(command); }
@EventHandler public void handle(ComponentStatusNotificationReceivedEvent event) { LOG.info("ComponentStatusNotificationReceivedEvent for {} received", event.getChargingStationId()); ChargingStation chargingStation = getChargingStation(event.getChargingStationId()); if (chargingStation != null && event.getComponentId() instanceof EvseId) { io.motown.vas.viewmodel.persistence.entities.Evse evse = chargingStation.getEvse(((EvseId) event.getComponentId()).getNumberedId()); if (evse != null) { evse.setState(ComponentStatus.fromApiComponentStatus(event.getStatusNotification().getStatus())); chargingStationRepository.createOrUpdate(chargingStation); } else { LOG.error("Received ComponentStatusNotificationReceivedEvent for unknown component."); } subscriberService.updateSubscribers(chargingStation, event.getStatusNotification().getTimeStamp()); } }
request.setConnectorId(evseId.getNumberedId()); request.setExpiryDate(expiryDate); request.setIdTag(identifyingToken.getToken());
private RequestResult changeAvailability(ChargingStationId id, EvseId evseId, AvailabilityType type) { ChargePointService chargePointService = this.createChargingStationService(id); ChangeAvailabilityRequest request = new ChangeAvailabilityRequest(); request.setConnectorId(evseId.getNumberedId()); request.setType(type); ChangeAvailabilityResponse response = chargePointService.changeAvailability(request, id.getId()); if (AvailabilityStatus.ACCEPTED.equals(response.getStatus()) || AvailabilityStatus.SCHEDULED.equals(response.getStatus())) { return RequestResult.SUCCESS; } else { return RequestResult.FAILURE; } }
private RequestResult changeAvailability(ChargingStationId id, EvseId evseId, AvailabilityType type) { ChargePointService chargePointService = this.createChargingStationService(id); ChangeAvailabilityRequest request = new ChangeAvailabilityRequest(); request.setConnectorId(evseId.getNumberedId()); request.setType(type); ChangeAvailabilityResponse response = chargePointService.changeAvailability(request, id.getId()); if (AvailabilityStatus.ACCEPTED.equals(response.getStatus()) || AvailabilityStatus.SCHEDULED.equals(response.getStatus())) { return RequestResult.SUCCESS; } else { return RequestResult.FAILURE; } }
public void reserveNow(ChargingStationId chargingStationId, EvseId evseId, IdentifyingToken identifyingToken, IdentifyingToken parentIdentifyingToken, Date expiryDate, CorrelationToken correlationToken) { NumberedReservationId reservationId = domainService.generateReservationIdentifier(chargingStationId, PROTOCOL_IDENTIFIER); Reservenow reserveNowRequest = new Reservenow(); reserveNowRequest.setConnectorId(evseId.getNumberedId()); reserveNowRequest.setIdTag(identifyingToken.getToken()); if (parentIdentifyingToken != null) { reserveNowRequest.setParentIdTag(parentIdentifyingToken.getToken()); } reserveNowRequest.setExpiryDate(expiryDate); reserveNowRequest.setReservationId(reservationId.getNumber()); responseHandlers.put(correlationToken.getToken(), new ReserveNowResponseHandler(reservationId, evseId, expiryDate, correlationToken)); WampMessage wampMessage = new WampMessage(WampMessage.CALL, correlationToken.getToken(), MessageProcUri.RESERVE_NOW, reserveNowRequest); sendWampMessage(wampMessage, chargingStationId); }
/** * Handles a {@link StartTransactionCommand}. * * @param command the command which needs to be applied to the ChargingStation. */ @CommandHandler public void handle(StartTransactionCommand command, MetaData metaData) { if (command.getStartTransactionInfo().getEvseId().getNumberedId() > numberOfEvses) { apply(new EvseNotFoundEvent(id, command.getStartTransactionInfo().getEvseId(), command.getIdentityContext()), metaData); return; } apply(new TransactionStartedEvent(command.getChargingStationId(), command.getTransactionId(), command.getStartTransactionInfo(), command.getIdentityContext()), metaData); }
@CommandHandler public void handle(RequestUnlockEvseCommand command, MetaData metaData) { checkCommandAllowed(command.getIdentityContext(), command.getClass()); checkCommunicationAllowed(); if (command.getEvseId().getNumberedId() > numberOfEvses) { apply(new EvseNotFoundEvent(id, command.getEvseId(), command.getIdentityContext()), metaData); } else { if (command.getEvseId() == Evse.ALL) { for (int i = 1; i <= numberOfEvses; i++) { apply(new UnlockEvseRequestedEvent(id, protocol, new EvseId(i), command.getIdentityContext()), metaData); } } else { apply(new UnlockEvseRequestedEvent(id, protocol, command.getEvseId(), command.getIdentityContext()), metaData); } } }
if (command.getEvseId().getNumberedId() == 0) { checkAuthorization(csId, userIdentity, RequestChangeChargingStationAvailabilityToInoperativeCommand.class); commandGateway.send(new RequestChangeChargingStationAvailabilityToInoperativeCommand(new ChargingStationId(chargingStationId), identityContext), new CorrelationToken()); if (command.getEvseId().getNumberedId() == 0) { checkAuthorization(csId, userIdentity, RequestChangeChargingStationAvailabilityToOperativeCommand.class); commandGateway.send(new RequestChangeChargingStationAvailabilityToOperativeCommand(new ChargingStationId(chargingStationId), identityContext), new CorrelationToken());