/** * 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; }
/** * 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; }
@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()); } }