X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2F1.6%2FOCPP16ResponseService.ts;h=7f1217fa45d1791b1337cc673440188dbc190b47;hb=909dcf2dda1acb9556a5ec21c252bcca2992ec1c;hp=23751c33d4365477ec0d1bb0bdf92e8bbf0e5de5;hpb=672fed6e70e94e37ba8db689d8517f42ae0f4477;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index 23751c33..7f1217fa 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -4,9 +4,8 @@ import { AuthorizeRequest, OCPP16AuthorizationStatus, OCPP16AuthorizeResponse, O import { HeartbeatRequest, OCPP16RequestCommand, StatusNotificationRequest } from '../../../types/ocpp/1.6/Requests'; import { HeartbeatResponse, OCPP16BootNotificationResponse, OCPP16RegistrationStatus, StatusNotificationResponse } from '../../../types/ocpp/1.6/Responses'; import { MeterValuesRequest, MeterValuesResponse } from '../../../types/ocpp/1.6/MeterValues'; -import { RegistrationStatus, ResponseHandler } from '../../../types/ocpp/Responses'; -import ChargingStation from '../../ChargingStation'; +import type ChargingStation from '../../ChargingStation'; import { ErrorType } from '../../../types/ocpp/ErrorType'; import { JsonType } from '../../../types/JsonType'; import { OCPP16ChargePointStatus } from '../../../types/ocpp/1.6/ChargePointStatus'; @@ -14,13 +13,19 @@ import { OCPP16ServiceUtils } from './OCPP16ServiceUtils'; import { OCPP16StandardParametersKey } from '../../../types/ocpp/1.6/Configuration'; import OCPPError from '../../../exception/OCPPError'; import OCPPResponseService from '../OCPPResponseService'; +import { ResponseHandler } from '../../../types/ocpp/Responses'; import Utils from '../../../utils/Utils'; import logger from '../../../utils/Logger'; +const moduleName = 'OCPP16ResponseService'; + export default class OCPP16ResponseService extends OCPPResponseService { private responseHandlers: Map; - constructor(chargingStation: ChargingStation) { + public constructor(chargingStation: ChargingStation) { + if (new.target?.name === moduleName) { + throw new TypeError(`Cannot construct ${new.target?.name} instances directly`); + } super(chargingStation); this.responseHandlers = new Map([ [OCPP16RequestCommand.BOOT_NOTIFICATION, this.handleResponseBootNotification.bind(this)], @@ -57,7 +62,7 @@ export default class OCPP16ResponseService extends OCPPResponseService { this.chargingStation.addConfigurationKey(OCPP16StandardParametersKey.HeartbeatInterval, payload.interval.toString(), { visible: false }); this.chargingStation.heartbeatSetInterval ? this.chargingStation.restartHeartbeat() : this.chargingStation.startHeartbeat(); } - if (Object.values(RegistrationStatus).includes(payload.status)) { + if (Object.values(OCPP16RegistrationStatus).includes(payload.status)) { const logMsg = `${this.chargingStation.logPrefix()} Charging station in '${payload.status}' state on the central server`; payload.status === OCPP16RegistrationStatus.REJECTED ? logger.warn(logMsg) : logger.info(logMsg); } else {