Skip to content

Commit 9d0dc14

Browse files
committed
use new configuration keys in Ocpp16Controller
1 parent dcf4e28 commit 9d0dc14

3 files changed

Lines changed: 47 additions & 5 deletions

File tree

src/main/java/de/rwth/idsg/steve/web/controller/Ocpp12Controller.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class Ocpp12Controller {
4747
// -------------------------------------------------------------------------
4848

4949
private static final String CHANGE_AVAIL_PATH = "/ChangeAvailability";
50-
private static final String CHANGE_CONF_PATH = "/ChangeConfiguration";
50+
protected static final String CHANGE_CONF_PATH = "/ChangeConfiguration";
5151
private static final String CLEAR_CACHE_PATH = "/ClearCache";
5252
private static final String GET_DIAG_PATH = "/GetDiagnostics";
5353
private static final String REMOTE_START_TX_PATH = "/RemoteStartTransaction";

src/main/java/de/rwth/idsg/steve/web/controller/Ocpp15Controller.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class Ocpp15Controller extends Ocpp12Controller {
4040
private static final String RESERVE_PATH = "/ReserveNow";
4141
private static final String CANCEL_RESERV_PATH = "/CancelReservation";
4242
private static final String DATA_TRANSFER_PATH = "/DataTransfer";
43-
private static final String GET_CONF_PATH = "/GetConfiguration";
43+
protected static final String GET_CONF_PATH = "/GetConfiguration";
4444
private static final String GET_LIST_VERSION_PATH = "/GetLocalListVersion";
4545
private static final String SEND_LIST_PATH = "/SendLocalList";
4646

src/main/java/de/rwth/idsg/steve/web/controller/Ocpp16Controller.java

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33
import de.rwth.idsg.steve.service.ChargePointService12_Client;
44
import de.rwth.idsg.steve.service.ChargePointService15_Client;
55
import de.rwth.idsg.steve.service.ChargePointService16_Client;
6+
import de.rwth.idsg.steve.web.dto.ocpp.ChangeConfigurationParams;
67
import de.rwth.idsg.steve.web.dto.ocpp.ConfigurationKeyEnum;
8+
import de.rwth.idsg.steve.web.dto.ocpp.GetConfigurationParams;
79
import org.springframework.beans.factory.annotation.Autowired;
810
import org.springframework.beans.factory.annotation.Qualifier;
911
import org.springframework.stereotype.Controller;
1012
import org.springframework.ui.Model;
13+
import org.springframework.validation.BindingResult;
14+
import org.springframework.web.bind.annotation.ModelAttribute;
1115
import org.springframework.web.bind.annotation.RequestMapping;
1216
import org.springframework.web.bind.annotation.RequestMethod;
1317

18+
import javax.validation.Valid;
19+
import java.util.Collections;
1420
import java.util.Map;
1521

1622
/**
@@ -58,10 +64,15 @@ protected void setCommonAttributes(Model model) {
5864
model.addAttribute("opVersion", "v1.6");
5965
}
6066

67+
/**
68+
* Starting with OCPP 1.6 the configuration keys can be read-only or read-write. This method was returning all
69+
* read-write keys, which was the case with older OCPP versions. So, it does not meet the needs anymore and should
70+
* not be used.
71+
*/
72+
@Deprecated
6173
@Override
6274
protected Map<String, String> getConfigurationKeys() {
63-
// TODO: will fix/change this later.
64-
return ConfigurationKeyEnum.OCPP_15_MAP;
75+
return Collections.emptyMap();
6576
}
6677

6778
@Override
@@ -75,7 +86,38 @@ protected String getPrefix() {
7586
}
7687

7788
// -------------------------------------------------------------------------
78-
// Http methods (GET)
89+
// Old Http methods with changed logic
90+
// -------------------------------------------------------------------------
91+
92+
@RequestMapping(value = GET_CONF_PATH, method = RequestMethod.GET)
93+
public String getGetConf(Model model) {
94+
setCommonAttributes(model);
95+
model.addAttribute(PARAMS, new GetConfigurationParams());
96+
model.addAttribute("ocppConfKeys", ConfigurationKeyEnum.OCPP_16_MAP_R);
97+
return getPrefix() + GET_CONF_PATH;
98+
}
99+
100+
@RequestMapping(value = CHANGE_CONF_PATH, method = RequestMethod.GET)
101+
public String getChangeConf(Model model) {
102+
setCommonAttributes(model);
103+
model.addAttribute(PARAMS, new ChangeConfigurationParams());
104+
model.addAttribute("ocppConfKeys", ConfigurationKeyEnum.OCPP_16_MAP_RW);
105+
return getPrefix() + CHANGE_CONF_PATH;
106+
}
107+
108+
@RequestMapping(value = GET_CONF_PATH, method = RequestMethod.POST)
109+
public String postGetConf(@Valid @ModelAttribute(PARAMS) GetConfigurationParams params,
110+
BindingResult result, Model model) {
111+
if (result.hasErrors()) {
112+
setCommonAttributes(model);
113+
model.addAttribute("ocppConfKeys", ConfigurationKeyEnum.OCPP_16_MAP_R);
114+
return getPrefix() + GET_CONF_PATH;
115+
}
116+
return REDIRECT_TASKS_PATH + getClient15().getConfiguration(params);
117+
}
118+
119+
// -------------------------------------------------------------------------
120+
// New Http methods (GET)
79121
// -------------------------------------------------------------------------
80122

81123
@RequestMapping(value = GET_COMPOSITE_PATH, method = RequestMethod.GET)

0 commit comments

Comments
 (0)