Skip to content

Commit b6b8840

Browse files
committed
prepare ocpp 1.6 client
1 parent 56a4a33 commit b6b8840

9 files changed

Lines changed: 315 additions & 0 deletions
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package de.rwth.idsg.steve.ocpp;
2+
3+
import de.rwth.idsg.steve.ocpp.task.ClearChargingProfileTask;
4+
import de.rwth.idsg.steve.ocpp.task.GetCompositeScheduleTask;
5+
import de.rwth.idsg.steve.ocpp.task.SetChargingProfileTask;
6+
import de.rwth.idsg.steve.ocpp.task.TriggerMessageTask;
7+
import de.rwth.idsg.steve.repository.dto.ChargePointSelect;
8+
9+
/**
10+
* @author Sevket Goekay <goekay@dbis.rwth-aachen.de>
11+
* @since 13.03.2018
12+
*/
13+
public interface ChargePointService16_Invoker extends ChargePointService15_Invoker {
14+
15+
void clearChargingProfile(ChargePointSelect cp, ClearChargingProfileTask task);
16+
17+
void setChargingProfile(ChargePointSelect cp, SetChargingProfileTask task);
18+
19+
void getCompositeSchedule(ChargePointSelect cp, GetCompositeScheduleTask task);
20+
21+
void triggerMessage(ChargePointSelect cp, TriggerMessageTask task);
22+
23+
}
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
package de.rwth.idsg.steve.ocpp;
2+
3+
import de.rwth.idsg.steve.ocpp.soap.ClientProvider;
4+
import de.rwth.idsg.steve.ocpp.task.CancelReservationTask;
5+
import de.rwth.idsg.steve.ocpp.task.ChangeAvailabilityTask;
6+
import de.rwth.idsg.steve.ocpp.task.ChangeConfigurationTask;
7+
import de.rwth.idsg.steve.ocpp.task.ClearCacheTask;
8+
import de.rwth.idsg.steve.ocpp.task.ClearChargingProfileTask;
9+
import de.rwth.idsg.steve.ocpp.task.DataTransferTask;
10+
import de.rwth.idsg.steve.ocpp.task.GetCompositeScheduleTask;
11+
import de.rwth.idsg.steve.ocpp.task.GetConfigurationTask;
12+
import de.rwth.idsg.steve.ocpp.task.GetDiagnosticsTask;
13+
import de.rwth.idsg.steve.ocpp.task.GetLocalListVersionTask;
14+
import de.rwth.idsg.steve.ocpp.task.RemoteStartTransactionTask;
15+
import de.rwth.idsg.steve.ocpp.task.RemoteStopTransactionTask;
16+
import de.rwth.idsg.steve.ocpp.task.ReserveNowTask;
17+
import de.rwth.idsg.steve.ocpp.task.ResetTask;
18+
import de.rwth.idsg.steve.ocpp.task.SendLocalListTask;
19+
import de.rwth.idsg.steve.ocpp.task.SetChargingProfileTask;
20+
import de.rwth.idsg.steve.ocpp.task.TriggerMessageTask;
21+
import de.rwth.idsg.steve.ocpp.task.UnlockConnectorTask;
22+
import de.rwth.idsg.steve.ocpp.task.UpdateFirmwareTask;
23+
import de.rwth.idsg.steve.ocpp.ws.AbstractChargePointServiceInvoker;
24+
import de.rwth.idsg.steve.ocpp.ws.ocpp16.Ocpp16TypeStore;
25+
import de.rwth.idsg.steve.ocpp.ws.ocpp16.Ocpp16WebSocketEndpoint;
26+
import de.rwth.idsg.steve.ocpp.ws.pipeline.OutgoingCallPipeline;
27+
import de.rwth.idsg.steve.repository.dto.ChargePointSelect;
28+
import ocpp.cp._2015._10.ChargePointService;
29+
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
30+
import org.springframework.stereotype.Service;
31+
32+
/**
33+
* @author Sevket Goekay <goekay@dbis.rwth-aachen.de>
34+
* @since 13.03.2018
35+
*/
36+
@Service
37+
public class ChargePointService16_InvokerImpl
38+
extends AbstractChargePointServiceInvoker
39+
implements ChargePointService16_Invoker {
40+
41+
public ChargePointService16_InvokerImpl(OutgoingCallPipeline pipeline, Ocpp16WebSocketEndpoint endpoint) {
42+
super(pipeline, endpoint, Ocpp16TypeStore.INSTANCE);
43+
}
44+
45+
@Override
46+
public void clearChargingProfile(ChargePointSelect cp, ClearChargingProfileTask task) {
47+
// TODO
48+
throw new RuntimeException("Not implemented");
49+
}
50+
51+
@Override
52+
public void setChargingProfile(ChargePointSelect cp, SetChargingProfileTask task) {
53+
// TODO
54+
throw new RuntimeException("Not implemented");
55+
}
56+
57+
@Override
58+
public void getCompositeSchedule(ChargePointSelect cp, GetCompositeScheduleTask task) {
59+
// TODO
60+
throw new RuntimeException("Not implemented");
61+
}
62+
63+
@Override
64+
public void triggerMessage(ChargePointSelect cp, TriggerMessageTask task) {
65+
throw new RuntimeException("Not implemented");
66+
}
67+
68+
@Override
69+
public void reset(ChargePointSelect cp, ResetTask task) {
70+
if (cp.isSoap()) {
71+
create(cp).resetAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId()));
72+
} else {
73+
runPipeline(cp, task);
74+
}
75+
}
76+
77+
@Override
78+
public void clearCache(ChargePointSelect cp, ClearCacheTask task) {
79+
if (cp.isSoap()) {
80+
create(cp).clearCacheAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId()));
81+
} else {
82+
runPipeline(cp, task);
83+
}
84+
}
85+
86+
@Override
87+
public void getDiagnostics(ChargePointSelect cp, GetDiagnosticsTask task) {
88+
if (cp.isSoap()) {
89+
create(cp).getDiagnosticsAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId()));
90+
} else {
91+
runPipeline(cp, task);
92+
}
93+
}
94+
95+
@Override
96+
public void updateFirmware(ChargePointSelect cp, UpdateFirmwareTask task) {
97+
if (cp.isSoap()) {
98+
create(cp).updateFirmwareAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId()));
99+
} else {
100+
runPipeline(cp, task);
101+
}
102+
}
103+
104+
@Override
105+
public void unlockConnector(ChargePointSelect cp, UnlockConnectorTask task) {
106+
if (cp.isSoap()) {
107+
create(cp).unlockConnectorAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId()));
108+
109+
} else {
110+
runPipeline(cp, task);
111+
}
112+
}
113+
114+
@Override
115+
public void changeAvailability(ChargePointSelect cp, ChangeAvailabilityTask task) {
116+
if (cp.isSoap()) {
117+
create(cp).changeAvailabilityAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId()));
118+
} else {
119+
runPipeline(cp, task);
120+
}
121+
}
122+
123+
@Override
124+
public void changeConfiguration(ChargePointSelect cp, ChangeConfigurationTask task) {
125+
if (cp.isSoap()) {
126+
create(cp).changeConfigurationAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId()));
127+
} else {
128+
runPipeline(cp, task);
129+
}
130+
}
131+
132+
@Override
133+
public void remoteStartTransaction(ChargePointSelect cp, RemoteStartTransactionTask task) {
134+
if (cp.isSoap()) {
135+
create(cp).remoteStartTransactionAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId()));
136+
} else {
137+
runPipeline(cp, task);
138+
}
139+
}
140+
141+
@Override
142+
public void remoteStopTransaction(ChargePointSelect cp, RemoteStopTransactionTask task) {
143+
if (cp.isSoap()) {
144+
create(cp).remoteStopTransactionAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId()));
145+
} else {
146+
runPipeline(cp, task);
147+
}
148+
}
149+
150+
@Override
151+
public void dataTransfer(ChargePointSelect cp, DataTransferTask task) {
152+
if (cp.isSoap()) {
153+
create(cp).dataTransferAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId()));
154+
} else {
155+
runPipeline(cp, task);
156+
}
157+
}
158+
159+
@Override
160+
public void getConfiguration(ChargePointSelect cp, GetConfigurationTask task) {
161+
if (cp.isSoap()) {
162+
create(cp).getConfigurationAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId()));
163+
} else {
164+
runPipeline(cp, task);
165+
}
166+
}
167+
168+
@Override
169+
public void getLocalListVersion(ChargePointSelect cp, GetLocalListVersionTask task) {
170+
if (cp.isSoap()) {
171+
create(cp).getLocalListVersionAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId()));
172+
} else {
173+
runPipeline(cp, task);
174+
}
175+
}
176+
177+
@Override
178+
public void sendLocalList(ChargePointSelect cp, SendLocalListTask task) {
179+
if (cp.isSoap()) {
180+
create(cp).sendLocalListAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId()));
181+
} else {
182+
runPipeline(cp, task);
183+
}
184+
}
185+
186+
@Override
187+
public void reserveNow(ChargePointSelect cp, ReserveNowTask task) {
188+
if (cp.isSoap()) {
189+
create(cp).reserveNowAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId()));
190+
} else {
191+
runPipeline(cp, task);
192+
}
193+
}
194+
195+
@Override
196+
public void cancelReservation(ChargePointSelect cp, CancelReservationTask task) {
197+
if (cp.isSoap()) {
198+
create(cp).cancelReservationAsync(task.getOcpp16Request(), cp.getChargeBoxId(), task.getOcpp16Handler(cp.getChargeBoxId()));
199+
} else {
200+
runPipeline(cp, task);
201+
}
202+
}
203+
204+
private static ChargePointService create(ChargePointSelect cp) {
205+
JaxWsProxyFactoryBean f = ClientProvider.getBean(cp.getEndpointAddress());
206+
f.setServiceClass(ChargePointService.class);
207+
return (ChargePointService) f.create();
208+
}
209+
}

src/main/java/de/rwth/idsg/steve/ocpp/CommunicationTask.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public RequestType getRequest() {
132132
switch (ocppVersion) {
133133
case V_12: return getOcpp12Request();
134134
case V_15: return getOcpp15Request();
135+
case V_16: return getOcpp16Request();
135136
default: throw new RuntimeException("Request type not found");
136137
}
137138
}
@@ -140,6 +141,7 @@ public <T extends ResponseType> AsyncHandler<T> getHandler(String chargeBoxId) {
140141
switch (ocppVersion) {
141142
case V_12: return getOcpp12Handler(chargeBoxId);
142143
case V_15: return getOcpp15Handler(chargeBoxId);
144+
case V_16: return getOcpp16Handler(chargeBoxId);
143145
default: throw new RuntimeException("ResponseType handler not found");
144146
}
145147
}
@@ -150,10 +152,14 @@ public <T extends ResponseType> AsyncHandler<T> getHandler(String chargeBoxId) {
150152

151153
public abstract <T extends RequestType> T getOcpp15Request();
152154

155+
public abstract <T extends RequestType> T getOcpp16Request();
156+
153157
public abstract <T extends ResponseType> AsyncHandler<T> getOcpp12Handler(String chargeBoxId);
154158

155159
public abstract <T extends ResponseType> AsyncHandler<T> getOcpp15Handler(String chargeBoxId);
156160

161+
public abstract <T extends ResponseType> AsyncHandler<T> getOcpp16Handler(String chargeBoxId);
162+
157163
// -------------------------------------------------------------------------
158164
// Classes
159165
// -------------------------------------------------------------------------
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package de.rwth.idsg.steve.ocpp.task;
2+
3+
/**
4+
* @author Sevket Goekay <goekay@dbis.rwth-aachen.de>
5+
* @since 13.03.2018
6+
*/
7+
public class ClearChargingProfileTask {
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package de.rwth.idsg.steve.ocpp.task;
2+
3+
/**
4+
* @author Sevket Goekay <goekay@dbis.rwth-aachen.de>
5+
* @since 13.03.2018
6+
*/
7+
public class GetChargingProfileTask {
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package de.rwth.idsg.steve.ocpp.task;
2+
3+
/**
4+
* @author Sevket Goekay <goekay@dbis.rwth-aachen.de>
5+
* @since 13.03.2018
6+
*/
7+
public class GetCompositeScheduleTask {
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package de.rwth.idsg.steve.ocpp.task;
2+
3+
/**
4+
* @author Sevket Goekay <goekay@dbis.rwth-aachen.de>
5+
* @since 13.03.2018
6+
*/
7+
public class SetChargingProfileTask {
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package de.rwth.idsg.steve.ocpp.task;
2+
3+
/**
4+
* @author Sevket Goekay <goekay@dbis.rwth-aachen.de>
5+
* @since 13.03.2018
6+
*/
7+
public class TriggerMessageTask {
8+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package de.rwth.idsg.steve.service;
2+
3+
import de.rwth.idsg.steve.ocpp.ChargePointService12_Invoker;
4+
import de.rwth.idsg.steve.ocpp.ChargePointService15_Invoker;
5+
import de.rwth.idsg.steve.ocpp.ChargePointService16_InvokerImpl;
6+
import de.rwth.idsg.steve.ocpp.OcppVersion;
7+
import lombok.extern.slf4j.Slf4j;
8+
import org.springframework.beans.factory.annotation.Autowired;
9+
import org.springframework.beans.factory.annotation.Qualifier;
10+
import org.springframework.stereotype.Service;
11+
12+
/**
13+
* @author Sevket Goekay <goekay@dbis.rwth-aachen.de>
14+
* @since 13.03.2018
15+
*/
16+
@Slf4j
17+
@Service
18+
@Qualifier("ChargePointService16_Client")
19+
public class ChargePointService16_Client extends ChargePointService15_Client {
20+
21+
@Autowired private ChargePointService16_InvokerImpl invoker16;
22+
23+
@Override
24+
protected OcppVersion getVersion() {
25+
return OcppVersion.V_16;
26+
}
27+
28+
@Override
29+
protected ChargePointService12_Invoker getOcpp12Invoker() {
30+
return invoker16;
31+
}
32+
33+
protected ChargePointService15_Invoker getOcpp15Invoker() {
34+
return invoker16;
35+
}
36+
37+
}

0 commit comments

Comments
 (0)