From: Jérôme Benoit Date: Sat, 14 Jan 2023 18:36:34 +0000 (+0100) Subject: Cleanup some helpers defaults values X-Git-Tag: v1.1.90~12 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=4d20f040ab91f06c9399dbaf084358183cf75314;p=e-mobility-charging-stations-simulator.git Cleanup some helpers defaults values Signed-off-by: Jérôme Benoit --- 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 });