+ handleRequestSetChargingProfile(commandPayload: SetChargingProfileRequest): SetChargingProfileResponse {
+ if (!this.getConnector(commandPayload.connectorId)) {
+ logger.error(`${this._logPrefix()} Trying to set a charging profile to a non existing connector Id ${commandPayload.connectorId}`);
+ return Constants.OCPP_CHARGING_PROFILE_RESPONSE_REJECTED;
+ }
+ if (commandPayload.csChargingProfiles.chargingProfilePurpose === ChargingProfilePurposeType.TX_PROFILE && !this.getConnector(commandPayload.connectorId)?.transactionStarted) {
+ return Constants.OCPP_CHARGING_PROFILE_RESPONSE_REJECTED;
+ }
+ this.getConnector(commandPayload.connectorId).chargingProfiles.forEach((chargingProfile: ChargingProfile, index: number) => {
+ if (chargingProfile.chargingProfileId === commandPayload.csChargingProfiles.chargingProfileId
+ || (chargingProfile.stackLevel === commandPayload.csChargingProfiles.stackLevel && chargingProfile.chargingProfilePurpose === commandPayload.csChargingProfiles.chargingProfilePurpose)) {
+ this.getConnector(commandPayload.connectorId).chargingProfiles[index] = chargingProfile;
+ return Constants.OCPP_CHARGING_PROFILE_RESPONSE_ACCEPTED;
+ }
+ });
+ this.getConnector(commandPayload.connectorId).chargingProfiles.push(commandPayload.csChargingProfiles);
+ return Constants.OCPP_CHARGING_PROFILE_RESPONSE_ACCEPTED;
+ }
+
+ async handleRequestRemoteStartTransaction(commandPayload: RemoteStartTransactionRequest): Promise<DefaultResponse> {