|
| 1 | +package de.rwth.idsg.steve.web.dto.common; |
| 2 | + |
| 3 | +import de.rwth.idsg.steve.ocpp.OcppVersion; |
| 4 | + |
| 5 | +import java.util.LinkedHashMap; |
| 6 | +import java.util.Map; |
| 7 | +import java.util.Set; |
| 8 | + |
| 9 | +import static com.google.common.collect.Sets.newHashSet; |
| 10 | +import static de.rwth.idsg.steve.ocpp.OcppVersion.V_12; |
| 11 | +import static de.rwth.idsg.steve.ocpp.OcppVersion.V_15; |
| 12 | + |
| 13 | +/** |
| 14 | + * @author Sevket Goekay <goekay@dbis.rwth-aachen.de> |
| 15 | + * @since 02.01.2015 |
| 16 | + */ |
| 17 | +public enum ConfigurationKeyEnum { |
| 18 | + // From Ocpp 1.2 |
| 19 | + HeartBeatInterval("HeartBeatInterval", "in seconds", newHashSet(V_12, V_15)), |
| 20 | + ConnectionTimeOut("ConnectionTimeOut", "in seconds", newHashSet(V_12, V_15)), |
| 21 | + ProximityContactRetries("ProximityContactRetries", "in times", newHashSet(V_12, V_15)), |
| 22 | + ProximityLockRetries("ProximityLockRetries", "in times", newHashSet(V_12, V_15)), |
| 23 | + ResetRetries("ResetRetries", "in times", newHashSet(V_12, V_15)), |
| 24 | + BlinkRepeat("BlinkRepeat", "in times", newHashSet(V_12, V_15)), |
| 25 | + LightIntensity("LightIntensity", "in %", newHashSet(V_12, V_15)), |
| 26 | + ChargePointId("ChargePointId", "string", newHashSet(V_12, V_15)), |
| 27 | + MeterValueSampleInterval("MeterValueSampleInterval", "in seconds", newHashSet(V_12, V_15)), |
| 28 | + |
| 29 | + // New in Ocpp 1.5 |
| 30 | + ClockAlignedDataInterval("ClockAlignedDataInterval", "in seconds", newHashSet(V_15)), |
| 31 | + MeterValuesSampledData("MeterValuesSampledData", "comma seperated list", newHashSet(V_15)), |
| 32 | + MeterValuesAlignedData("MeterValuesAlignedData", "comma seperated list", newHashSet(V_15)), |
| 33 | + StopTxnSampledData("StopTxnSampledData", "comma seperated list", newHashSet(V_15)), |
| 34 | + StopTxnAlignedData("StopTxnAlignedData", "comma seperated list", newHashSet(V_15)); |
| 35 | + |
| 36 | + private final String value; |
| 37 | + private final String text; |
| 38 | + private final Set<OcppVersion> versions; |
| 39 | + |
| 40 | + public static final Map<String, String> OCPP_12_MAP = asMap(OcppVersion.V_12); |
| 41 | + public static final Map<String, String> OCPP_15_MAP = asMap(OcppVersion.V_15); |
| 42 | + |
| 43 | + ConfigurationKeyEnum(String value, String comment, Set<OcppVersion> versions) { |
| 44 | + this.value = value; |
| 45 | + this.text = String.format("%s (%s)", value, comment); |
| 46 | + this.versions = versions; |
| 47 | + } |
| 48 | + |
| 49 | + public String value() { |
| 50 | + return value; |
| 51 | + } |
| 52 | + |
| 53 | + public static ConfigurationKeyEnum fromValue(String v) { |
| 54 | + for (ConfigurationKeyEnum c : ConfigurationKeyEnum.values()) { |
| 55 | + if (c.value.equals(v)) { |
| 56 | + return c; |
| 57 | + } |
| 58 | + } |
| 59 | + throw new IllegalArgumentException(v); |
| 60 | + } |
| 61 | + |
| 62 | + private static Map<String, String> asMap(OcppVersion version) { |
| 63 | + Map<String, String> map = new LinkedHashMap<>(); |
| 64 | + for (ConfigurationKeyEnum c : ConfigurationKeyEnum.values()) { |
| 65 | + if (c.versions.contains(version)) { |
| 66 | + map.put(c.value, c.text); |
| 67 | + } |
| 68 | + } |
| 69 | + return map; |
| 70 | + } |
| 71 | +} |
0 commit comments