Search in sources :

Example 1 with CommunicationContext

use of de.rwth.idsg.steve.ocpp.ws.data.CommunicationContext in project steve by RWTH-i5-IDSG.

the class AbstractChargePointServiceInvoker method run.

/**
 * Actual processing
 */
private void run(String chargeBoxId, CommunicationTask task) {
    RequestType request = task.getRequest();
    String messageId = UUID.randomUUID().toString();
    ActionResponsePair pair = typeStore.findActionResponse(request);
    if (pair == null) {
        throw new SteveException("Action name is not found");
    }
    OcppJsonCall call = new OcppJsonCall();
    call.setMessageId(messageId);
    call.setPayload(request);
    call.setAction(pair.getAction());
    FutureResponseContext frc = new FutureResponseContext(task, pair.getResponseClass());
    CommunicationContext context = new CommunicationContext(endpoint.getSession(chargeBoxId), chargeBoxId);
    context.setOutgoingMessage(call);
    context.setFutureResponseContext(frc);
    outgoingCallPipeline.accept(context);
}
Also used : CommunicationContext(de.rwth.idsg.steve.ocpp.ws.data.CommunicationContext) ActionResponsePair(de.rwth.idsg.steve.ocpp.ws.data.ActionResponsePair) OcppJsonCall(de.rwth.idsg.steve.ocpp.ws.data.OcppJsonCall) FutureResponseContext(de.rwth.idsg.steve.ocpp.ws.data.FutureResponseContext) RequestType(de.rwth.idsg.steve.ocpp.RequestType) SteveException(de.rwth.idsg.steve.SteveException)

Example 2 with CommunicationContext

use of de.rwth.idsg.steve.ocpp.ws.data.CommunicationContext in project steve by RWTH-i5-IDSG.

the class OcppJsonChargePoint method prepare.

public <T extends ResponseType> void prepare(RequestType request, Class<T> responseClass, Consumer<T> responseHandler, Consumer<OcppJsonError> errorHandler) {
    String messageId = UUID.randomUUID().toString();
    OcppJsonCall call = new OcppJsonCall();
    call.setMessageId(messageId);
    call.setPayload(request);
    call.setAction(getOperationName(request));
    // session is null, because we do not need org.springframework.web.socket.WebSocketSession
    CommunicationContext ctx = new CommunicationContext(null, chargeBoxId);
    ctx.setOutgoingMessage(call);
    Serializer.INSTANCE.accept(ctx);
    ResponseContext resCtx = new ResponseContext(ctx.getOutgoingString(), responseClass, responseHandler, errorHandler);
    responseContextMap.put(messageId, resCtx);
}
Also used : CommunicationContext(de.rwth.idsg.steve.ocpp.ws.data.CommunicationContext) OcppJsonCall(de.rwth.idsg.steve.ocpp.ws.data.OcppJsonCall)

Example 3 with CommunicationContext

use of de.rwth.idsg.steve.ocpp.ws.data.CommunicationContext in project steve by RWTH-i5-IDSG.

the class AbstractWebSocketEndpoint method handleTextMessage.

private void handleTextMessage(WebSocketSession session, TextMessage webSocketMessage) throws Exception {
    String incomingString = webSocketMessage.getPayload();
    String chargeBoxId = getChargeBoxId(session);
    log.info("[chargeBoxId={}, sessionId={}] Received message: {}", chargeBoxId, session.getId(), incomingString);
    CommunicationContext context = new CommunicationContext(session, chargeBoxId);
    context.setIncomingString(incomingString);
    pipeline.accept(context);
}
Also used : CommunicationContext(de.rwth.idsg.steve.ocpp.ws.data.CommunicationContext)

Aggregations

CommunicationContext (de.rwth.idsg.steve.ocpp.ws.data.CommunicationContext)3 OcppJsonCall (de.rwth.idsg.steve.ocpp.ws.data.OcppJsonCall)2 SteveException (de.rwth.idsg.steve.SteveException)1 RequestType (de.rwth.idsg.steve.ocpp.RequestType)1 ActionResponsePair (de.rwth.idsg.steve.ocpp.ws.data.ActionResponsePair)1 FutureResponseContext (de.rwth.idsg.steve.ocpp.ws.data.FutureResponseContext)1