export default abstract class OCPPRequestService {
private static instance: OCPPRequestService | null = null;
- private ajv: Ajv;
+ private readonly ajv: Ajv;
private readonly ocppResponseService: OCPPResponseService;
this.ajv = new Ajv();
ajvFormats(this.ajv);
this.requestHandler.bind(this);
+ this.sendMessage.bind(this);
this.sendResponse.bind(this);
this.sendError.bind(this);
this.internalSendMessage.bind(this);
);
} catch (error) {
this.handleSendMessageError(chargingStation, commandName, error as Error, {
- throwError: false,
+ throwError: true,
});
}
}
params
);
} catch (error) {
- this.handleSendMessageError(chargingStation, commandName, error as Error, {
- throwError: false,
- });
+ this.handleSendMessageError(chargingStation, commandName, error as Error);
}
}
}
): Promise<ResponseType> {
if (
- (chargingStation.isInUnknownState() && commandName === RequestCommand.BOOT_NOTIFICATION) ||
- (!chargingStation.getOcppStrictCompliance() && chargingStation.isInUnknownState()) ||
- chargingStation.isInAcceptedState() ||
- (chargingStation.isInPendingState() &&
- (params.triggerMessage || messageType === MessageType.CALL_RESULT_MESSAGE))
+ (chargingStation.isInUnknownState() === true &&
+ commandName === RequestCommand.BOOT_NOTIFICATION) ||
+ (chargingStation.getOcppStrictCompliance() === false &&
+ chargingStation.isInUnknownState() === true) ||
+ chargingStation.isInAcceptedState() === true ||
+ (chargingStation.isInPendingState() === true &&
+ (params.triggerMessage === true || messageType === MessageType.CALL_RESULT_MESSAGE))
) {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this;
chargingStation: ChargingStation,
commandName: RequestCommand | IncomingRequestCommand,
error: Error,
- params: HandleErrorParams<EmptyObject> = { throwError: true }
+ params: HandleErrorParams<EmptyObject> = { throwError: false }
): void {
logger.error(`${chargingStation.logPrefix()} Request command '${commandName}' error:`, error);
- if (params?.throwError) {
+ if (params?.throwError === true) {
throw error;
}
}