From: Jérôme Benoit Date: Wed, 11 Jan 2023 16:25:50 +0000 (+0100) Subject: Cleanup OCPP types namespace X-Git-Tag: v1.1.90~25 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=f03e10429357538c286b94a99c9ccc5dfe43b348;p=e-mobility-charging-stations-simulator.git Cleanup OCPP types namespace Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 997a8ebb..7e324b25 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -25,7 +25,6 @@ import { SupervisionUrlDistribution } from '../types/ConfigurationData'; import type { ConnectorStatus } from '../types/ConnectorStatus'; import { FileType } from '../types/FileType'; import type { JsonType } from '../types/JsonType'; -import { ChargePointErrorCode } from '../types/ocpp/ChargePointErrorCode'; import { ChargingProfile, ChargingRateUnitType } from '../types/ocpp/ChargingProfile'; import { ConnectorPhaseRotation, diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 36869b6d..3f1b2cfe 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -78,7 +78,7 @@ import type { OCPPConfigurationKey } from '../../../types/ocpp/Configuration'; import { ErrorType } from '../../../types/ocpp/ErrorType'; import { OCPPVersion } from '../../../types/ocpp/OCPPVersion'; import type { IncomingRequestHandler } from '../../../types/ocpp/Requests'; -import type { DefaultResponse } from '../../../types/ocpp/Responses'; +import type { GenericResponse } from '../../../types/ocpp/Responses'; import Constants from '../../../utils/Constants'; import logger from '../../../utils/Logger'; import Utils from '../../../utils/Utils'; @@ -329,7 +329,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer private handleRequestReset( chargingStation: ChargingStation, commandPayload: ResetRequest - ): DefaultResponse { + ): GenericResponse { this.asyncResource .runInAsyncScope( chargingStation.reset.bind(chargingStation) as ( @@ -694,7 +694,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer private async handleRequestRemoteStartTransaction( chargingStation: ChargingStation, commandPayload: RemoteStartTransactionRequest - ): Promise { + ): Promise { const transactionConnectorId = commandPayload.connectorId; if (chargingStation.connectors.has(transactionConnectorId) === true) { const remoteStartTransactionLogMsg = @@ -843,7 +843,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer chargingStation: ChargingStation, connectorId: number, idTag: string - ): Promise { + ): Promise { if ( chargingStation.getConnectorStatus(connectorId).status !== OCPP16ChargePointStatus.AVAILABLE ) { @@ -899,7 +899,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer private async handleRequestRemoteStopTransaction( chargingStation: ChargingStation, commandPayload: RemoteStopTransactionRequest - ): Promise { + ): Promise { const transactionId = commandPayload.transactionId; for (const connectorId of chargingStation.connectors.keys()) { if ( diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index 163ecbcf..61d1ffad 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -50,7 +50,7 @@ import { import { ErrorType } from '../../../types/ocpp/ErrorType'; import { OCPPVersion } from '../../../types/ocpp/OCPPVersion'; import { - type DefaultResponse, + type GenericResponse, RegistrationStatusEnumType, type ResponseHandler, } from '../../../types/ocpp/Responses'; @@ -155,13 +155,13 @@ export default class OCPP16ResponseService extends OCPPResponseService { this.jsonIncomingRequestResponseSchemas = new Map([ [ OCPP16IncomingRequestCommand.RESET, - this.parseJsonSchemaFile( + this.parseJsonSchemaFile( '../../../assets/json-schemas/ocpp/1.6/ResetResponse.json' ), ], [ OCPP16IncomingRequestCommand.CLEAR_CACHE, - this.parseJsonSchemaFile( + this.parseJsonSchemaFile( '../../../assets/json-schemas/ocpp/1.6/ClearCacheResponse.json' ), ], @@ -203,13 +203,13 @@ export default class OCPP16ResponseService extends OCPPResponseService { ], [ OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION, - this.parseJsonSchemaFile( + this.parseJsonSchemaFile( '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransactionResponse.json' ), ], [ OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION, - this.parseJsonSchemaFile( + this.parseJsonSchemaFile( '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransactionResponse.json' ), ], diff --git a/src/charging-station/ocpp/OCPPConstants.ts b/src/charging-station/ocpp/OCPPConstants.ts index f2f36cec..b9448447 100644 --- a/src/charging-station/ocpp/OCPPConstants.ts +++ b/src/charging-station/ocpp/OCPPConstants.ts @@ -4,15 +4,15 @@ import { ClearChargingProfileStatus, ConfigurationStatus, DataTransferStatus, - DefaultStatus, + GenericStatus, TriggerMessageStatus, UnlockStatus, } from '../../types/ocpp/Responses'; export default class OCPPConstants { static readonly OCPP_RESPONSE_EMPTY = Object.freeze({}); - static readonly OCPP_RESPONSE_ACCEPTED = Object.freeze({ status: DefaultStatus.ACCEPTED }); - static readonly OCPP_RESPONSE_REJECTED = Object.freeze({ status: DefaultStatus.REJECTED }); + static readonly OCPP_RESPONSE_ACCEPTED = Object.freeze({ status: GenericStatus.ACCEPTED }); + static readonly OCPP_RESPONSE_REJECTED = Object.freeze({ status: GenericStatus.REJECTED }); static readonly OCPP_CONFIGURATION_RESPONSE_ACCEPTED = Object.freeze({ status: ConfigurationStatus.ACCEPTED, diff --git a/src/types/ocpp/2.0/Responses.ts b/src/types/ocpp/2.0/Responses.ts index 53bbb173..04cd462b 100644 --- a/src/types/ocpp/2.0/Responses.ts +++ b/src/types/ocpp/2.0/Responses.ts @@ -1,6 +1,6 @@ import type { EmptyObject } from '../../EmptyObject'; import type { JsonObject } from '../../JsonType'; -import type { DefaultStatus, RegistrationStatusEnumType } from '../Responses'; +import type { GenericStatus, RegistrationStatusEnumType } from '../Responses'; export type StatusInfoType = { reasonCode: string; @@ -19,7 +19,7 @@ export type OCPP20HeartbeatResponse = { } & JsonObject; export type OCPP20ClearCacheResponse = { - status: DefaultStatus; + status: GenericStatus; statusInfo?: StatusInfoType; } & JsonObject; diff --git a/src/types/ocpp/Responses.ts b/src/types/ocpp/Responses.ts index 32367462..55c5c338 100644 --- a/src/types/ocpp/Responses.ts +++ b/src/types/ocpp/Responses.ts @@ -40,7 +40,7 @@ export type BootNotificationResponse = export type HeartbeatResponse = OCPP16HeartbeatResponse; -export type ClearCacheResponse = DefaultResponse | OCPP20ClearCacheResponse; +export type ClearCacheResponse = GenericResponse | OCPP20ClearCacheResponse; export type StatusNotificationResponse = | OCPP16StatusNotificationResponse @@ -54,13 +54,13 @@ export type DiagnosticsStatusNotificationResponse = OCPP16DiagnosticsStatusNotif export type FirmwareStatusNotificationResponse = OCPP16FirmwareStatusNotificationResponse; -export enum DefaultStatus { +export enum GenericStatus { ACCEPTED = 'Accepted', REJECTED = 'Rejected', } -export type DefaultResponse = { - status: DefaultStatus; +export type GenericResponse = { + status: GenericStatus; }; export enum RegistrationStatusEnumType {