public EvseId getEvseId() { return new EvseId(Integer.valueOf(evseId)); }
/** * 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; }
public void setEvseId(EvseId evseId) { this.evseId = evseId.getId(); }
@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); } } }
@Override public EvseId deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { if (!json.isJsonPrimitive()) { throw new JsonParseException("EvseId must be a JSON primitive"); } int evseId; try { evseId = json.getAsInt(); } catch (ClassCastException | IllegalStateException | NumberFormatException e) { throw new JsonParseException("EvseId must be a JSON integer", e); } return new EvseId(evseId); }
/** * 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); }
@EventHandler public void handle(ChargingStationConfiguredEvent event) { LOG.debug("ChargingStationConfiguredEvent for [{}] received!", event.getChargingStationId()); ChargingStation chargingStation = repository.findOne(event.getChargingStationId().getId()); if (chargingStation != null) { for (io.motown.domain.api.chargingstation.Evse coreEvse : event.getEvses()) { Evse evse = new Evse(coreEvse.getEvseId().getId()); for (Connector coreConnector : coreEvse.getConnectors()) { io.motown.operatorapi.viewmodel.persistence.entities.Connector connector = new io.motown.operatorapi.viewmodel.persistence.entities.Connector( coreConnector.getMaxAmp(), coreConnector.getPhase(), coreConnector.getVoltage(), coreConnector.getChargingProtocol(), coreConnector.getCurrent(), coreConnector.getConnectorType() ); evse.getConnectors().add(connector); } chargingStation.getEvses().add(evse); } chargingStation.setConfigured(true); repository.createOrUpdate(chargingStation); } else { LOG.error("operator api repo COULD NOT FIND CHARGEPOINT {} and configure it", event.getChargingStationId()); } }
/** * Gets a default EVSE with the given identifier. * * @param identifier the identifier for the EVSE. * @return a default EVSE with the given identifier. */ public static Evse getEvse(int identifier) { return new Evse(new EvseId(identifier), getConnectors(NUMBER_OF_CONNECTORS)); }
@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 void handle(ChangeChargingStationAvailabilityToInoperativeRequestedEvent event, CorrelationToken correlationToken) { ocppJsonService.changeAvailability(event.getChargingStationId(), new EvseId(0), Changeavailability.Type.INOPERATIVE, correlationToken); }
@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; } }
/** * Retrieves a set of {@code io.motown.domain.api.chargingstation.Evse}s based on the vendor and model. * * @param vendor vendor code. * @param model model code. * @return set of Evses if they can be found, otherwise an empty set. */ public Set<io.motown.domain.api.chargingstation.Evse> getEvses(String vendor, String model) { List<ChargingStationType> items = chargingStationTypeRepository.findByCodeAndManufacturerCode(model, vendor); Set<io.motown.domain.api.chargingstation.Evse> result = new HashSet<>(); int resultSize = items.size(); if (resultSize > 0) { ChargingStationType chargingStationType = items.get(0); for (Evse evse : chargingStationType.getEvses()) { result.add(new io.motown.domain.api.chargingstation.Evse(new EvseId(evse.getIdentifier()), convertViewModelConnectorsToDomain(evse.getConnectors()))); } } return result; }
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); }
@Override public void handle(ChangeChargingStationAvailabilityToInoperativeRequestedEvent event, CorrelationToken correlationToken) { LOG.info("OCPP 1.2 ChangeChargingStationAvailabilityToInoperativeRequestedEvent"); EvseId chargingStationEvseId = new EvseId(0); RequestResult requestResult = chargingStationOcpp12Client.changeAvailabilityToInoperative(event.getChargingStationId(), chargingStationEvseId); switch (requestResult) { case SUCCESS: domainService.changeChargingStationAvailabilityToInoperative(event.getChargingStationId(), correlationToken, addOnIdentity); break; case FAILURE: LOG.info("Failed to set availability of chargingstation {} to inoperative", event.getChargingStationId().getId()); break; default: throw new AssertionError(String.format("Unknown status for change availability to inoperative: '%s'", requestResult)); } }
/** * {@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; }
@Override public void handle(ChangeChargingStationAvailabilityToInoperativeRequestedEvent event, CorrelationToken correlationToken) { LOG.info("OCPP 1.5 ChangeChargingStationAvailabilityToInoperativeRequestedEvent"); EvseId chargingStationEvseId = new EvseId(0); RequestResult requestResult = chargingStationOcpp15Client.changeAvailabilityToInoperative(event.getChargingStationId(), chargingStationEvseId); switch (requestResult) { case SUCCESS: domainService.changeChargingStationAvailabilityToInoperative(event.getChargingStationId(), correlationToken, addOnIdentity); break; case FAILURE: LOG.info("Failed to set availability of chargingstation {} to inoperative", event.getChargingStationId().getId()); break; default: throw new AssertionError(String.format("Unkown status for change availability to inoperative: '%s'", requestResult)); } }
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); }
@Override public void handle(ChangeChargingStationAvailabilityToOperativeRequestedEvent event, @MetaData(CorrelationToken.KEY) CorrelationToken correlationToken) { ocppJsonService.changeAvailability(event.getChargingStationId(), new EvseId(0), Changeavailability.Type.OPERATIVE, correlationToken); }
/** * {@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; }
@Override public MeterValuesResponse meterValues(MeterValuesRequest request, String chargeBoxIdentity) { ChargingStationId chargingStationId = new ChargingStationId(chargeBoxIdentity); //OCPP 1.2 does not contain transactionId references in it's metervalue communication TransactionId transactionId = null; List<MeterValue> meterValues = new ArrayList<>(); for (io.motown.ocpp.v12.soap.centralsystem.schema.MeterValue mv : request.getValues()) { meterValues.add(new MeterValue(mv.getTimestamp(), Integer.toString(mv.getValue()))); } domainService.meterValues(chargingStationId, transactionId, new EvseId(request.getConnectorId()), meterValues, addOnIdentity); return new MeterValuesResponse(); }