X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2F1.6%2FOCPP16IncomingRequestService.ts;h=e2d5886bc799001d36837bef11bff647a2850297;hb=721646e902fa12d165d4a1da06fb963fb30dc9f2;hp=b735967728bb5ffc5bc4de1f24444639549391a3;hpb=60a743910478b70e39dcefa5e1b752ec8a93880e;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index b7359677..e2d5886b 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -19,7 +19,6 @@ import { type ChangeAvailabilityResponse, type ChangeConfigurationRequest, type ChangeConfigurationResponse, - ChargingProfilePurposeType, type ClearChargingProfileRequest, type ClearChargingProfileResponse, ErrorType, @@ -40,6 +39,7 @@ import { OCPP16ChargePointErrorCode, OCPP16ChargePointStatus, type OCPP16ChargingProfile, + OCPP16ChargingProfilePurposeType, type OCPP16ClearCacheRequest, type OCPP16DataTransferRequest, type OCPP16DataTransferResponse, @@ -358,9 +358,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { ) => Promise, chargingStation, `${commandPayload.type}Reset` as OCPP16StopTransactionReason - ).catch(() => { - /* This is intentional */ - }); + ).catch(Constants.EMPTY_FUNCTION); logger.info( `${chargingStation.logPrefix()} ${ commandPayload.type @@ -403,10 +401,10 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { OCPP16StatusNotificationResponse >(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, { connectorId, - status: OCPP16ChargePointStatus.AVAILABLE, + status: OCPP16ChargePointStatus.Available, errorCode: OCPP16ChargePointErrorCode.NO_ERROR, }); - chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.AVAILABLE; + chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.Available; return OCPPConstants.OCPP_RESPONSE_UNLOCKED; } @@ -537,14 +535,14 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { } if ( commandPayload.csChargingProfiles.chargingProfilePurpose === - ChargingProfilePurposeType.CHARGE_POINT_MAX_PROFILE && + OCPP16ChargingProfilePurposeType.CHARGE_POINT_MAX_PROFILE && commandPayload.connectorId !== 0 ) { return OCPPConstants.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED; } if ( commandPayload.csChargingProfiles.chargingProfilePurpose === - ChargingProfilePurposeType.TX_PROFILE && + OCPP16ChargingProfilePurposeType.TX_PROFILE && (commandPayload.connectorId === 0 || chargingStation.getConnectorStatus(commandPayload.connectorId)?.transactionStarted === false) @@ -666,8 +664,8 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { } const chargePointStatus: OCPP16ChargePointStatus = commandPayload.type === OCPP16AvailabilityType.OPERATIVE - ? OCPP16ChargePointStatus.AVAILABLE - : OCPP16ChargePointStatus.UNAVAILABLE; + ? OCPP16ChargePointStatus.Available + : OCPP16ChargePointStatus.Unavailable; if (connectorId === 0) { let response: ChangeAvailabilityResponse = OCPPConstants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED; for (const id of chargingStation.connectors.keys()) { @@ -727,11 +725,11 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { OCPP16StatusNotificationResponse >(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, { connectorId: transactionConnectorId, - status: OCPP16ChargePointStatus.PREPARING, + status: OCPP16ChargePointStatus.Preparing, errorCode: OCPP16ChargePointErrorCode.NO_ERROR, }); const connectorStatus = chargingStation.getConnectorStatus(transactionConnectorId); - connectorStatus.status = OCPP16ChargePointStatus.PREPARING; + connectorStatus.status = OCPP16ChargePointStatus.Preparing; if (chargingStation.isChargingStationAvailable() === true) { // Check if authorized if (chargingStation.getAuthorizeRemoteTxRequests() === true) { @@ -863,17 +861,17 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { idTag: string ): Promise { if ( - chargingStation.getConnectorStatus(connectorId)?.status !== OCPP16ChargePointStatus.AVAILABLE + chargingStation.getConnectorStatus(connectorId)?.status !== OCPP16ChargePointStatus.Available ) { await chargingStation.ocppRequestService.requestHandler< OCPP16StatusNotificationRequest, OCPP16StatusNotificationResponse >(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, { connectorId, - status: OCPP16ChargePointStatus.AVAILABLE, + status: OCPP16ChargePointStatus.Available, errorCode: OCPP16ChargePointErrorCode.NO_ERROR, }); - chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.AVAILABLE; + chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.Available; } logger.warn( `${chargingStation.logPrefix()} Remote starting transaction REJECTED on connector Id ${connectorId.toString()}, idTag '${idTag}', availability '${ @@ -888,14 +886,14 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { connectorId: number, cp: OCPP16ChargingProfile ): boolean { - if (cp && cp.chargingProfilePurpose === ChargingProfilePurposeType.TX_PROFILE) { + if (cp && cp.chargingProfilePurpose === OCPP16ChargingProfilePurposeType.TX_PROFILE) { OCPP16ServiceUtils.setChargingProfile(chargingStation, connectorId, cp); logger.debug( `${chargingStation.logPrefix()} Charging profile(s) set at remote start transaction on connector id ${connectorId}: %j`, cp ); return true; - } else if (cp && cp.chargingProfilePurpose !== ChargingProfilePurposeType.TX_PROFILE) { + } else if (cp && cp.chargingProfilePurpose !== OCPP16ChargingProfilePurposeType.TX_PROFILE) { logger.warn( `${chargingStation.logPrefix()} Not allowed to set ${ cp.chargingProfilePurpose @@ -922,10 +920,10 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { OCPP16StatusNotificationResponse >(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, { connectorId, - status: OCPP16ChargePointStatus.FINISHING, + status: OCPP16ChargePointStatus.Finishing, errorCode: OCPP16ChargePointErrorCode.NO_ERROR, }); - chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.FINISHING; + chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.Finishing; const stopResponse = await chargingStation.stopTransactionOnConnector( connectorId, OCPP16StopTransactionReason.REMOTE @@ -977,14 +975,10 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { ) => Promise, this, chargingStation - ).catch(() => { - /* This is intentional */ - }); + ).catch(Constants.EMPTY_FUNCTION); } else { setTimeout(() => { - this.updateFirmware(chargingStation).catch(() => { - /* Intentional */ - }); + this.updateFirmware(chargingStation).catch(Constants.EMPTY_FUNCTION); }, retrieveDate?.getTime() - now); } return OCPPConstants.OCPP_RESPONSE_EMPTY; @@ -1006,11 +1000,11 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { OCPP16StatusNotificationResponse >(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, { connectorId, - status: OCPP16ChargePointStatus.UNAVAILABLE, + status: OCPP16ChargePointStatus.Unavailable, errorCode: OCPP16ChargePointErrorCode.NO_ERROR, }); chargingStation.getConnectorStatus(connectorId).status = - OCPP16ChargePointStatus.UNAVAILABLE; + OCPP16ChargePointStatus.Unavailable; } } if ( @@ -1218,9 +1212,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { .then((response) => { chargingStation.bootNotificationResponse = response; }) - .catch(() => { - /* This is intentional */ - }); + .catch(Constants.EMPTY_FUNCTION); }, Constants.OCPP_TRIGGER_MESSAGE_DELAY); return OCPPConstants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED; case OCPP16MessageTrigger.Heartbeat: @@ -1234,9 +1226,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { triggerMessage: true, } ) - .catch(() => { - /* This is intentional */ - }); + .catch(Constants.EMPTY_FUNCTION); }, Constants.OCPP_TRIGGER_MESSAGE_DELAY); return OCPPConstants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED; case OCPP16MessageTrigger.StatusNotification: @@ -1255,9 +1245,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { triggerMessage: true, } ) - .catch(() => { - /* This is intentional */ - }); + .catch(Constants.EMPTY_FUNCTION); } else { for (const connectorId of chargingStation.connectors.keys()) { chargingStation.ocppRequestService @@ -1276,9 +1264,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { triggerMessage: true, } ) - .catch(() => { - /* This is intentional */ - }); + .catch(Constants.EMPTY_FUNCTION); } } }, Constants.OCPP_TRIGGER_MESSAGE_DELAY);