- this.bootNotificationResponseJsonSchema = JSON.parse(
- fs.readFileSync(
- path.resolve(
- path.dirname(fileURLToPath(import.meta.url)),
- '../../../assets/json-schemas/ocpp/1.6/BootNotificationResponse.json'
- ),
- 'utf8'
- )
- ) as JSONSchemaType<OCPP16BootNotificationResponse>;
- this.heartbeatResponseJsonSchema = JSON.parse(
- fs.readFileSync(
- path.resolve(
- path.dirname(fileURLToPath(import.meta.url)),
- '../../../assets/json-schemas/ocpp/1.6/HeartbeatResponse.json'
- ),
- 'utf8'
- )
- ) as JSONSchemaType<OCPP16HeartbeatResponse>;
- this.authorizeResponseJsonSchema = JSON.parse(
- fs.readFileSync(
- path.resolve(
- path.dirname(fileURLToPath(import.meta.url)),
- '../../../assets/json-schemas/ocpp/1.6/AuthorizeResponse.json'
- ),
- 'utf8'
- )
- ) as JSONSchemaType<OCPP16AuthorizeResponse>;
- this.startTransactionResponseJsonSchema = JSON.parse(
- fs.readFileSync(
- path.resolve(
- path.dirname(fileURLToPath(import.meta.url)),
- '../../../assets/json-schemas/ocpp/1.6/StartTransactionResponse.json'
- ),
- 'utf8'
- )
- ) as JSONSchemaType<OCPP16StartTransactionResponse>;
- this.stopTransactionResponseJsonSchema = JSON.parse(
- fs.readFileSync(
- path.resolve(
- path.dirname(fileURLToPath(import.meta.url)),
- '../../../assets/json-schemas/ocpp/1.6/StopTransactionResponse.json'
- ),
- 'utf8'
- )
- ) as JSONSchemaType<OCPP16StopTransactionResponse>;
- this.statusNotificationResponseJsonSchema = JSON.parse(
- fs.readFileSync(
- path.resolve(
- path.dirname(fileURLToPath(import.meta.url)),
- '../../../assets/json-schemas/ocpp/1.6/StatusNotificationResponse.json'
- ),
- 'utf8'
- )
- ) as JSONSchemaType<OCPP16StatusNotificationResponse>;
- this.meterValuesResponseJsonSchema = JSON.parse(
- fs.readFileSync(
- path.resolve(
- path.dirname(fileURLToPath(import.meta.url)),
- '../../../assets/json-schemas/ocpp/1.6/MeterValuesResponse.json'
- ),
- 'utf8'
- )
- ) as JSONSchemaType<OCPP16MeterValuesResponse>;
+ this.jsonSchemas = new Map<OCPP16RequestCommand, JSONSchemaType<JsonObject>>([
+ [
+ OCPP16RequestCommand.BOOT_NOTIFICATION,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/1.6/BootNotificationResponse.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<OCPP16BootNotificationResponse>,
+ ],
+ [
+ OCPP16RequestCommand.HEARTBEAT,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/1.6/HeartbeatResponse.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<OCPP16HeartbeatResponse>,
+ ],
+ [
+ OCPP16RequestCommand.AUTHORIZE,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/1.6/AuthorizeResponse.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<OCPP16AuthorizeResponse>,
+ ],
+ [
+ OCPP16RequestCommand.START_TRANSACTION,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/1.6/StartTransactionResponse.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<OCPP16StartTransactionResponse>,
+ ],
+ [
+ OCPP16RequestCommand.STOP_TRANSACTION,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/1.6/StopTransactionResponse.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<OCPP16StopTransactionResponse>,
+ ],
+ [
+ OCPP16RequestCommand.STATUS_NOTIFICATION,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/1.6/StatusNotificationResponse.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<OCPP16StatusNotificationResponse>,
+ ],
+ [
+ OCPP16RequestCommand.METER_VALUES,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/1.6/MeterValuesResponse.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<OCPP16MeterValuesResponse>,
+ ],
+ [
+ OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotificationResponse.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<DiagnosticsStatusNotificationResponse>,
+ ],
+ ]);
+ this.validatePayload.bind(this);