- if (new.target?.name === moduleName) {
- throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
- }
- super();
- this.responseHandlers = new Map<OCPP20RequestCommand, ResponseHandler>();
- this.jsonSchemas = new Map<OCPP20RequestCommand, JSONSchemaType<JsonObject>>();
- this.validatePayload.bind(this);
+ // if (new.target?.name === moduleName) {
+ // throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
+ // }
+ super(OCPPVersion.VERSION_20);
+ this.responseHandlers = new Map<OCPP20RequestCommand, ResponseHandler>([
+ [
+ OCPP20RequestCommand.BOOT_NOTIFICATION,
+ this.handleResponseBootNotification.bind(this) as ResponseHandler,
+ ],
+ [OCPP20RequestCommand.HEARTBEAT, this.emptyResponseHandler.bind(this) as ResponseHandler],
+ [
+ OCPP20RequestCommand.STATUS_NOTIFICATION,
+ this.emptyResponseHandler.bind(this) as ResponseHandler,
+ ],
+ ]);
+ this.jsonSchemas = new Map<OCPP20RequestCommand, JSONSchemaType<JsonType>>([
+ [
+ OCPP20RequestCommand.BOOT_NOTIFICATION,
+ OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20BootNotificationResponse>(
+ 'assets/json-schemas/ocpp/2.0/BootNotificationResponse.json',
+ moduleName,
+ 'constructor',
+ ),
+ ],
+ [
+ OCPP20RequestCommand.HEARTBEAT,
+ OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20HeartbeatResponse>(
+ 'assets/json-schemas/ocpp/2.0/HeartbeatResponse.json',
+ moduleName,
+ 'constructor',
+ ),
+ ],
+ [
+ OCPP20RequestCommand.STATUS_NOTIFICATION,
+ OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20StatusNotificationResponse>(
+ 'assets/json-schemas/ocpp/2.0/StatusNotificationResponse.json',
+ moduleName,
+ 'constructor',
+ ),
+ ],
+ ]);
+ this.jsonIncomingRequestResponseSchemas = new Map([
+ [
+ OCPP20IncomingRequestCommand.CLEAR_CACHE,
+ OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20ClearCacheResponse>(
+ 'assets/json-schemas/ocpp/2.0/ClearCacheResponse.json',
+ moduleName,
+ 'constructor',
+ ),
+ ],
+ ]);
+ this.validatePayload = this.validatePayload.bind(this) as (
+ chargingStation: ChargingStation,
+ commandName: OCPP20RequestCommand,
+ payload: JsonType,
+ ) => boolean;