X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2F2.0%2FOCPP20ResponseService.ts;h=f9d8fde9feb7d39d944bb1f5d38cf27b1f474f42;hb=32e1ad3b16c388b9c6aea81b649fef40dc2d21e1;hp=15b355a5b0862e1de4e851e84d36070c376663d4;hpb=81533a206ec56709897f27edf1298e7c86d74c31;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts b/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts index 15b355a5..f9d8fde9 100644 --- a/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts @@ -16,6 +16,7 @@ import type { OCPP20BootNotificationResponse, OCPP20ClearCacheResponse, OCPP20HeartbeatResponse, + OCPP20StatusNotificationResponse, } from '../../../types/ocpp/2.0/Responses'; import { ErrorType } from '../../../types/ocpp/ErrorType'; import { OCPPVersion } from '../../../types/ocpp/OCPPVersion'; @@ -44,45 +45,34 @@ export default class OCPP20ResponseService extends OCPPResponseService { this.responseHandlers = new Map([ [OCPP20RequestCommand.BOOT_NOTIFICATION, this.handleResponseBootNotification.bind(this)], [OCPP20RequestCommand.HEARTBEAT, this.emptyResponseHandler.bind(this)], + [OCPP20RequestCommand.STATUS_NOTIFICATION, this.emptyResponseHandler.bind(this)], ]); this.jsonSchemas = new Map>([ [ OCPP20RequestCommand.BOOT_NOTIFICATION, - JSON.parse( - fs.readFileSync( - path.resolve( - path.dirname(fileURLToPath(import.meta.url)), - '../../../assets/json-schemas/ocpp/2.0/BootNotificationResponse.json' - ), - 'utf8' - ) - ) as JSONSchemaType, + this.parseJsonSchemaFile( + '../../../assets/json-schemas/ocpp/2.0/BootNotificationResponse.json' + ), ], [ OCPP20RequestCommand.HEARTBEAT, - JSON.parse( - fs.readFileSync( - path.resolve( - path.dirname(fileURLToPath(import.meta.url)), - '../../../assets/json-schemas/ocpp/2.0/HeartbeatResponse.json' - ), - 'utf8' - ) - ) as JSONSchemaType, + this.parseJsonSchemaFile( + '../../../assets/json-schemas/ocpp/2.0/HeartbeatResponse.json' + ), + ], + [ + OCPP20RequestCommand.STATUS_NOTIFICATION, + this.parseJsonSchemaFile( + '../../../assets/json-schemas/ocpp/2.0/StatusNotificationResponse.json' + ), ], ]); this.jsonIncomingRequestResponseSchemas = new Map([ [ OCPP20IncomingRequestCommand.CLEAR_CACHE, - JSON.parse( - fs.readFileSync( - path.resolve( - path.dirname(fileURLToPath(import.meta.url)), - '../../../assets/json-schemas/ocpp/2.0/ClearCacheResponse.json' - ), - 'utf8' - ) - ) as JSONSchemaType, + this.parseJsonSchemaFile( + '../../../assets/json-schemas/ocpp/2.0/ClearCacheResponse.json' + ), ], ]); this.validatePayload.bind(this); @@ -196,4 +186,13 @@ export default class OCPP20ResponseService extends OCPPResponseService { ); } } + + private parseJsonSchemaFile(relativePath: string): JSONSchemaType { + return JSON.parse( + fs.readFileSync( + path.resolve(path.dirname(fileURLToPath(import.meta.url)), relativePath), + 'utf8' + ) + ) as JSONSchemaType; + } }