Skip to content

Commit

Permalink
Update to latest common OCPP web.
Browse files Browse the repository at this point in the history
  • Loading branch information
msqr committed Jul 4, 2024
1 parent bf71cfa commit 797b477
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 90 deletions.
4 changes: 2 additions & 2 deletions solarnet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ subprojects {
jsonSchemaValidatorVersion = '1.3.2'
myBatisStarterVersion = '3.0.3'
saxonVersion = '12.4'
snCommonVersion = '3.11.0'
snCommonVersion = '3.14.0'
snCommonMqttVersion = '5.0.0'
snCommonMqttNettyVersion = '4.0.1'
snCommonOcppVersion = '4.3.0'
snCommonOcpp16JakartaVersion = '4.0.2'
snCommonOcpp201Version = '1.2.3'
snCommonOcppWebJakartaVersion = '3.0.3'
snCommonOcppWebJakartaVersion = '3.1.0'
snCommonPkiBcVersion = '3.1.0'
snCommonWebJakartaVersion = '2.0.1'
snExternalOcpp16JakartaVersion = '1.0.0'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@
import net.solarnetwork.ocpp.service.ActionMessageQueue;
import net.solarnetwork.ocpp.service.ErrorCodeResolver;
import net.solarnetwork.ocpp.web.jakarta.json.OcppWebSocketHandler;
import net.solarnetwork.service.PingTest;
import net.solarnetwork.service.PingTestResult;
import net.solarnetwork.service.ServiceLifecycleObserver;
import net.solarnetwork.util.StatTracker;

Expand All @@ -72,7 +70,7 @@
*/
public class CentralOcppWebSocketHandler<C extends Enum<C> & Action, S extends Enum<S> & Action>
extends OcppWebSocketHandler<C, S>
implements ServiceLifecycleObserver, CentralOcppUserEvents, PingTest, SmartLifecycle {
implements ServiceLifecycleObserver, CentralOcppUserEvents, SmartLifecycle {

/** The {@code shutdownTaskMaxWait} property default value (1 minute). */
public static final Duration DEFAULT_SHUTDOWN_TASK_MAX_WAIT = Duration.ofMinutes(1);
Expand All @@ -84,9 +82,6 @@ public class CentralOcppWebSocketHandler<C extends Enum<C> & Action, S extends E
public static final int DEFAULT_STAT_LOG_UPDATE_COUNT = 500;

private final Clock clock;
private final StatTracker stats;
private final String pingTestId;
private final String pingTestName;
private CentralChargePointDao chargePointDao;
private NodeInstructionDao instructionDao;
private UserEventAppenderBiz userEventAppenderBiz;
Expand Down Expand Up @@ -136,8 +131,9 @@ public CentralOcppWebSocketHandler(Class<C> chargePointActionClass,
ActionPayloadDecoder centralServiceActionPayloadDecoder,
ActionPayloadDecoder chargePointActionPayloadDecoder, String... subProtocols) {
this(Clock.systemUTC(),
new StatTracker(
"CentralOcppWebSocketHandler-" + arrayToCommaDelimitedString(subProtocols), null,
new StatTracker("OCPP WebSocket Handler " + arrayToCommaDelimitedString(subProtocols),
CentralOcppWebSocketHandler.class.getName() + "-"
+ arrayToCommaDelimitedString(subProtocols),
LoggerFactory.getLogger(CentralOcppWebSocketHandler.class),
DEFAULT_STAT_LOG_UPDATE_COUNT),
chargePointActionClass, centralSystemActionClass, errorCodeResolver, executor, mapper,
Expand Down Expand Up @@ -179,14 +175,10 @@ public CentralOcppWebSocketHandler(Clock clock, StatTracker stats, Class<C> char
AsyncTaskExecutor executor, ObjectMapper mapper, ActionMessageQueue pendingMessageQueue,
ActionPayloadDecoder centralServiceActionPayloadDecoder,
ActionPayloadDecoder chargePointActionPayloadDecoder, String... subProtocols) {
super(chargePointActionClass, centralSystemActionClass, errorCodeResolver, executor, mapper,
pendingMessageQueue, centralServiceActionPayloadDecoder, chargePointActionPayloadDecoder,
subProtocols);
super(stats, chargePointActionClass, centralSystemActionClass, errorCodeResolver, executor,
mapper, pendingMessageQueue, centralServiceActionPayloadDecoder,
chargePointActionPayloadDecoder, subProtocols);
this.clock = requireNonNullArgument(clock, "clock");
this.stats = requireNonNullArgument(stats, "stats");
this.pingTestId = CentralOcppWebSocketHandler.class.getName() + "-"
+ arrayToCommaDelimitedString(subProtocols);
this.pingTestName = "OCPP WebSocket Handler " + arrayToCommaDelimitedString(subProtocols);
}

@Override
Expand Down Expand Up @@ -256,7 +248,6 @@ protected void disconnectClients() {
@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
super.afterConnectionEstablished(session);
stats.increment(CentralOcppStatusCount.ChargePointsConnected);
ChargePointIdentity clientId = clientId(session);
if ( clientId != null ) {
if ( clientId.getUserIdentifier() instanceof Long userId ) {
Expand Down Expand Up @@ -285,7 +276,6 @@ public void afterConnectionEstablished(WebSocketSession session) throws Exceptio

@Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
stats.increment(CentralOcppStatusCount.ChargePointsDisconnected);
ChargePointIdentity clientId = clientId(session);
if ( clientId != null ) {
final var eventPublisher = getEventPublisher();
Expand Down Expand Up @@ -434,30 +424,6 @@ private void generateUserEvent(Long userId, String[] tags, String message, Objec
});
}

@Override
public String getPingTestId() {
return pingTestId;
}

@Override
public String getPingTestName() {
return pingTestName;
}

@Override
public long getPingTestMaximumExecutionMilliseconds() {
return 1000;
}

@Override
public Result performPingTest() throws Exception {
Map<String, Long> statMap = stats.allCounts();
statMap.put(CentralOcppStatusCount.ChargePointActiveConnections.name(),
(long) availableChargePointsIds().size());
return new PingTestResult(true, "WebSocket processor " + (isStarted() ? "started" : "stopped."),
statMap);
}

/**
* Get the charge point DAO.
*
Expand Down

0 comments on commit 797b477

Please sign in to comment.