X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStation.ts;h=689fe2d98099f844a42b1d15195def868f55746b;hb=edd134392e237a3242dc2093341df70244c51472;hp=6e35d864741abb3ed0e09431d79f3a7cb9be6895;hpb=e0b0ee2176a4dc5a8914a3fb094ec16b4966a740;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 6e35d864..689fe2d9 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1,4 +1,4 @@ -// Partial Copyright Jerome Benoit. 2021. All Rights Reserved. +// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved. import crypto from 'crypto'; import fs from 'fs'; @@ -82,6 +82,9 @@ import OCPP16IncomingRequestService from './ocpp/1.6/OCPP16IncomingRequestServic import OCPP16RequestService from './ocpp/1.6/OCPP16RequestService'; import OCPP16ResponseService from './ocpp/1.6/OCPP16ResponseService'; import { OCPP16ServiceUtils } from './ocpp/1.6/OCPP16ServiceUtils'; +import OCPP20IncomingRequestService from './ocpp/2.0/OCPP20IncomingRequestService'; +import OCPP20RequestService from './ocpp/2.0/OCPP20RequestService'; +import OCPP20ResponseService from './ocpp/2.0/OCPP20ResponseService'; import type OCPPIncomingRequestService from './ocpp/OCPPIncomingRequestService'; import type OCPPRequestService from './ocpp/OCPPRequestService'; import SharedLRUCache from './SharedLRUCache'; @@ -626,13 +629,16 @@ export default class ChargingStation { if (params?.terminateOpened) { this.terminateWSConnection(); } + const ocppVersion = this.getOcppVersion(); let protocol: string; - switch (this.getOcppVersion()) { + switch (ocppVersion) { case OCPPVersion.VERSION_16: - protocol = 'ocpp' + OCPPVersion.VERSION_16; + case OCPPVersion.VERSION_20: + case OCPPVersion.VERSION_201: + protocol = 'ocpp' + ocppVersion; break; default: - this.handleUnsupportedVersion(this.getOcppVersion()); + this.handleUnsupportedVersion(ocppVersion); break; } @@ -974,6 +980,14 @@ export default class ChargingStation { OCPP16ResponseService.getInstance() ); break; + case OCPPVersion.VERSION_20: + case OCPPVersion.VERSION_201: + this.ocppIncomingRequestService = + OCPP20IncomingRequestService.getInstance(); + this.ocppRequestService = OCPP20RequestService.getInstance( + OCPP20ResponseService.getInstance() + ); + break; default: this.handleUnsupportedVersion(this.getOcppVersion()); break;