From 4d20f040ab91f06c9399dbaf084358183cf75314 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 14 Jan 2023 19:36:34 +0100 Subject: [PATCH] Cleanup some helpers defaults values MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ChargingStationUtils.ts | 4 ++-- src/charging-station/ocpp/1.6/OCPP16RequestService.ts | 3 ++- src/charging-station/ocpp/2.0/OCPP20RequestService.ts | 3 ++- src/charging-station/ocpp/OCPPConstants.ts | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/charging-station/ChargingStationUtils.ts b/src/charging-station/ChargingStationUtils.ts index aa11822f..4cf1b386 100644 --- a/src/charging-station/ChargingStationUtils.ts +++ b/src/charging-station/ChargingStationUtils.ts @@ -244,7 +244,7 @@ export class ChargingStationUtils { public static createSerialNumber( stationTemplate: ChargingStationTemplate, - stationInfo: ChargingStationInfo = {} as ChargingStationInfo, + stationInfo: ChargingStationInfo, params: { randomSerialNumberUpperCase?: boolean; randomSerialNumber?: boolean; @@ -275,7 +275,7 @@ export class ChargingStationUtils { public static propagateSerialNumber( stationTemplate: ChargingStationTemplate, stationInfoSrc: ChargingStationInfo, - stationInfoDst: ChargingStationInfo = {} as ChargingStationInfo + stationInfoDst: ChargingStationInfo ) { if (!stationInfoSrc || !stationTemplate) { throw new BaseError( diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index 31772e89..9fa61243 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -30,6 +30,7 @@ import type { RequestParams } from '../../../types/ocpp/Requests'; import Constants from '../../../utils/Constants'; import Utils from '../../../utils/Utils'; import type ChargingStation from '../../ChargingStation'; +import OCPPConstants from '../OCPPConstants'; import OCPPRequestService from '../OCPPRequestService'; import type OCPPResponseService from '../OCPPResponseService'; @@ -180,7 +181,7 @@ export default class OCPP16RequestService extends OCPPRequestService { status: commandParams?.status, } as unknown as Request; case OCPP16RequestCommand.HEARTBEAT: - return {} as unknown as Request; + return OCPPConstants.OCPP_REQUEST_EMPTY as unknown as Request; case OCPP16RequestCommand.METER_VALUES: return { connectorId: commandParams?.connectorId, diff --git a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts index 18816f0e..c3f5d5d3 100644 --- a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts @@ -20,6 +20,7 @@ import { OCPPVersion } from '../../../types/ocpp/OCPPVersion'; import type { RequestParams } from '../../../types/ocpp/Requests'; import Utils from '../../../utils/Utils'; import type ChargingStation from '../../ChargingStation'; +import OCPPConstants from '../OCPPConstants'; import OCPPRequestService from '../OCPPRequestService'; import type OCPPResponseService from '../OCPPResponseService'; @@ -119,7 +120,7 @@ export default class OCPP20RequestService extends OCPPRequestService { }, } as unknown as Request; case OCPP20RequestCommand.HEARTBEAT: - return {} as unknown as Request; + return OCPPConstants.OCPP_RESPONSE_EMPTY as unknown as Request; case OCPP20RequestCommand.STATUS_NOTIFICATION: return { timestamp: commandParams?.timestamp ?? new Date(), diff --git a/src/charging-station/ocpp/OCPPConstants.ts b/src/charging-station/ocpp/OCPPConstants.ts index b9448447..a0b0d70a 100644 --- a/src/charging-station/ocpp/OCPPConstants.ts +++ b/src/charging-station/ocpp/OCPPConstants.ts @@ -10,6 +10,7 @@ import { } from '../../types/ocpp/Responses'; export default class OCPPConstants { + static readonly OCPP_REQUEST_EMPTY = Object.freeze({}); static readonly OCPP_RESPONSE_EMPTY = Object.freeze({}); static readonly OCPP_RESPONSE_ACCEPTED = Object.freeze({ status: GenericStatus.ACCEPTED }); static readonly OCPP_RESPONSE_REJECTED = Object.freeze({ status: GenericStatus.REJECTED }); -- 2.34.1