/** * Returns a set of {@code io.motown.vas.viewmodel.model.ChargingCapability}s based on the EVSEs. * * @param evses list of EVSEs. * @return set of ChargingCapability. */ public Set<ChargingCapability> getChargingCapabilitiesFromEvses(Set<Evse> evses) { Set<ChargingCapability> chargingCapabilities = new HashSet<>(); for (Evse evse : evses) { for (Connector connector : evse.getConnectors()) { chargingCapabilities.add(ChargingCapability.fromConnector(connector)); } } return chargingCapabilities; }
/** * 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; }
@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)); }
/** * 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; }
/** * Determines the charge mode based on the first connector, because VAS does not support multiple protocols for a * single charging station. If no charge mode can be determined UNSPECIFIED will be returned. * * @param evses list of EVSEs. * @return charge mode or UNSPECIFIED if no specific charge mode can be determined. */ public ChargeMode getChargeModeFromEvses(Set<Evse> evses) { ChargeMode chargeMode = ChargeMode.UNSPECIFIED; for (Evse evse : evses) { if (!evse.getConnectors().isEmpty()) { chargeMode = ChargeMode.fromChargingProtocol(evse.getConnectors().get(0).getChargingProtocol()); break; } } return chargeMode; }
/** * Creates a set of {@code ConnectorType} based on the EVSEs. Duplicates will be filtered. * * @param evses list of EVSEs * @return set of connector types */ public Set<ConnectorType> getConnectorTypesFromEvses(Set<Evse> evses) { Set<ConnectorType> connectorTypes = new HashSet<>(); for (Evse evse : evses) { for (Connector connector : evse.getConnectors()) { connectorTypes.add(ConnectorType.fromConnectorType(connector.getConnectorType())); } } return connectorTypes; }