// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
import {
- AuthorizeRequest,
OCPP16AuthorizationStatus,
+ OCPP16AuthorizeRequest,
OCPP16AuthorizeResponse,
+ OCPP16StartTransactionRequest,
OCPP16StartTransactionResponse,
+ OCPP16StopTransactionRequest,
OCPP16StopTransactionResponse,
- StartTransactionRequest,
- StopTransactionRequest,
} from '../../../types/ocpp/1.6/Transaction';
import {
- HeartbeatRequest,
+ OCPP16BootNotificationRequest,
OCPP16RequestCommand,
- StatusNotificationRequest,
+ OCPP16StatusNotificationRequest,
} from '../../../types/ocpp/1.6/Requests';
-import { MeterValuesRequest, OCPP16MeterValuesResponse } from '../../../types/ocpp/1.6/MeterValues';
import {
OCPP16BootNotificationResponse,
- OCPP16HeartbeatResponse,
OCPP16RegistrationStatus,
OCPP16StatusNotificationResponse,
} from '../../../types/ocpp/1.6/Responses';
+import {
+ OCPP16MeterValuesRequest,
+ OCPP16MeterValuesResponse,
+} from '../../../types/ocpp/1.6/MeterValues';
import type ChargingStation from '../../ChargingStation';
import { ErrorType } from '../../../types/ocpp/ErrorType';
]);
}
- public async handleResponse(
+ public async responseHandler(
commandName: OCPP16RequestCommand,
- payload: JsonType | string,
+ payload: JsonType,
requestPayload: JsonType
): Promise<void> {
if (
}
}
- private handleResponseHeartbeat(
- payload: OCPP16HeartbeatResponse,
- requestPayload: HeartbeatRequest
- ): void {
- logger.debug(
- this.chargingStation.logPrefix() +
- ' Heartbeat response received: %j to Heartbeat request: %j',
- payload,
- requestPayload
- );
- }
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
+ private handleResponseHeartbeat(): void {}
private handleResponseAuthorize(
payload: OCPP16AuthorizeResponse,
- requestPayload: AuthorizeRequest
+ requestPayload: OCPP16AuthorizeRequest
): void {
let authorizeConnectorId: number;
for (const connectorId of this.chargingStation.connectors.keys()) {
private async handleResponseStartTransaction(
payload: OCPP16StartTransactionResponse,
- requestPayload: StartTransactionRequest
+ requestPayload: OCPP16StartTransactionRequest
): Promise<void> {
const connectorId = requestPayload.connectorId;
requestPayload.meterStart
);
this.chargingStation.getBeginEndMeterValues() &&
- (await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16MeterValuesResponse>(
- OCPP16RequestCommand.METER_VALUES,
- {
- connectorId,
- transactionId: payload.transactionId,
- meterValue:
- this.chargingStation.getConnectorStatus(connectorId).transactionBeginMeterValue,
- }
- ));
- await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16StatusNotificationResponse>(
- OCPP16RequestCommand.STATUS_NOTIFICATION,
- {
+ (await this.chargingStation.ocppRequestService.requestHandler<
+ OCPP16MeterValuesRequest,
+ OCPP16MeterValuesResponse
+ >(OCPP16RequestCommand.METER_VALUES, {
connectorId,
- status: OCPP16ChargePointStatus.CHARGING,
- errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
- }
- );
+ transactionId: payload.transactionId,
+ meterValue:
+ this.chargingStation.getConnectorStatus(connectorId).transactionBeginMeterValue,
+ }));
+ await this.chargingStation.ocppRequestService.requestHandler<
+ OCPP16StatusNotificationRequest,
+ OCPP16StatusNotificationResponse
+ >(OCPP16RequestCommand.STATUS_NOTIFICATION, {
+ connectorId,
+ status: OCPP16ChargePointStatus.CHARGING,
+ errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
+ });
this.chargingStation.getConnectorStatus(connectorId).status =
OCPP16ChargePointStatus.CHARGING;
logger.info(
this.chargingStation.getConnectorStatus(connectorId).status !==
OCPP16ChargePointStatus.AVAILABLE
) {
- await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16StatusNotificationResponse>(
- OCPP16RequestCommand.STATUS_NOTIFICATION,
- {
- connectorId,
- status: OCPP16ChargePointStatus.AVAILABLE,
- errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
- }
- );
+ await this.chargingStation.ocppRequestService.requestHandler<
+ OCPP16StatusNotificationRequest,
+ OCPP16StatusNotificationResponse
+ >(OCPP16RequestCommand.STATUS_NOTIFICATION, {
+ connectorId,
+ status: OCPP16ChargePointStatus.AVAILABLE,
+ errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
+ });
this.chargingStation.getConnectorStatus(connectorId).status =
OCPP16ChargePointStatus.AVAILABLE;
}
private async handleResponseStopTransaction(
payload: OCPP16StopTransactionResponse,
- requestPayload: StopTransactionRequest
+ requestPayload: OCPP16StopTransactionRequest
): Promise<void> {
const transactionConnectorId = this.chargingStation.getConnectorIdByTransactionId(
requestPayload.transactionId
this.chargingStation.getBeginEndMeterValues() &&
!this.chargingStation.getOcppStrictCompliance() &&
this.chargingStation.getOutOfOrderEndMeterValues() &&
- (await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16MeterValuesResponse>(
- OCPP16RequestCommand.METER_VALUES,
- {
- connectorId: transactionConnectorId,
- transactionId: requestPayload.transactionId,
- meterValue: OCPP16ServiceUtils.buildTransactionEndMeterValue(
- this.chargingStation,
- transactionConnectorId,
- requestPayload.meterStop
- ),
- }
- ));
+ (await this.chargingStation.ocppRequestService.requestHandler<
+ OCPP16MeterValuesRequest,
+ OCPP16MeterValuesResponse
+ >(OCPP16RequestCommand.METER_VALUES, {
+ connectorId: transactionConnectorId,
+ transactionId: requestPayload.transactionId,
+ meterValue: OCPP16ServiceUtils.buildTransactionEndMeterValue(
+ this.chargingStation,
+ transactionConnectorId,
+ requestPayload.meterStop
+ ),
+ }));
if (
!this.chargingStation.isChargingStationAvailable() ||
!this.chargingStation.isConnectorAvailable(transactionConnectorId)
) {
- await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16StatusNotificationResponse>(
- OCPP16RequestCommand.STATUS_NOTIFICATION,
- {
- connectorId: transactionConnectorId,
- status: OCPP16ChargePointStatus.UNAVAILABLE,
- errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
- }
- );
+ await this.chargingStation.ocppRequestService.requestHandler<
+ OCPP16StatusNotificationRequest,
+ OCPP16StatusNotificationResponse
+ >(OCPP16RequestCommand.STATUS_NOTIFICATION, {
+ connectorId: transactionConnectorId,
+ status: OCPP16ChargePointStatus.UNAVAILABLE,
+ errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
+ });
this.chargingStation.getConnectorStatus(transactionConnectorId).status =
OCPP16ChargePointStatus.UNAVAILABLE;
} else {
- await this.chargingStation.ocppRequestService.sendMessageHandler<OCPP16BootNotificationResponse>(
- OCPP16RequestCommand.STATUS_NOTIFICATION,
- {
- connectorId: transactionConnectorId,
- status: OCPP16ChargePointStatus.AVAILABLE,
- errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
- }
- );
+ await this.chargingStation.ocppRequestService.requestHandler<
+ OCPP16BootNotificationRequest,
+ OCPP16BootNotificationResponse
+ >(OCPP16RequestCommand.STATUS_NOTIFICATION, {
+ connectorId: transactionConnectorId,
+ status: OCPP16ChargePointStatus.AVAILABLE,
+ errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
+ });
this.chargingStation.getConnectorStatus(transactionConnectorId).status =
OCPP16ChargePointStatus.AVAILABLE;
}
}
}
- private handleResponseStatusNotification(
- payload: StatusNotificationRequest,
- requestPayload: OCPP16StatusNotificationResponse
- ): void {
- logger.debug(
- this.chargingStation.logPrefix() +
- ' Status notification response received: %j to StatusNotification request: %j',
- payload,
- requestPayload
- );
- }
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
+ private handleResponseStatusNotification(): void {}
- private handleResponseMeterValues(
- payload: MeterValuesRequest,
- requestPayload: OCPP16MeterValuesResponse
- ): void {
- logger.debug(
- this.chargingStation.logPrefix() +
- ' MeterValues response received: %j to MeterValues request: %j',
- payload,
- requestPayload
- );
- }
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
+ private handleResponseMeterValues(): void {}
}