- public deleteConfigurationKey(
- key: string | StandardParametersKey,
- params: { save?: boolean; caseInsensitive?: boolean } = { save: true, caseInsensitive: false }
- ): ConfigurationKey[] {
- const keyFound = this.getConfigurationKey(key, params?.caseInsensitive);
- if (keyFound) {
- const deletedConfigurationKey = this.ocppConfiguration.configurationKey.splice(
- this.ocppConfiguration.configurationKey.indexOf(keyFound),
- 1
- );
- params?.save && this.saveOcppConfiguration();
- return deletedConfigurationKey;
- }
- }
-
- public getChargingProfilePowerLimit(connectorId: number): number | undefined {
- const timestamp = new Date().getTime();
- let matchingChargingProfile: ChargingProfile;
- let chargingSchedulePeriods: ChargingSchedulePeriod[] = [];
- if (!Utils.isEmptyArray(this.getConnectorStatus(connectorId)?.chargingProfiles)) {
- const chargingProfiles: ChargingProfile[] = this.getConnectorStatus(
- connectorId
- ).chargingProfiles.filter(
- (chargingProfile) =>
- timestamp >= chargingProfile.chargingSchedule?.startSchedule.getTime() &&
- timestamp <
- chargingProfile.chargingSchedule?.startSchedule.getTime() +
- chargingProfile.chargingSchedule.duration * 1000 &&
- chargingProfile?.stackLevel === Math.max(...chargingProfiles.map((cp) => cp?.stackLevel))
- );
- if (!Utils.isEmptyArray(chargingProfiles)) {
- for (const chargingProfile of chargingProfiles) {
- if (!Utils.isEmptyArray(chargingProfile.chargingSchedule.chargingSchedulePeriod)) {
- chargingSchedulePeriods =
- chargingProfile.chargingSchedule.chargingSchedulePeriod.filter(
- (chargingSchedulePeriod, index) => {
- timestamp >=
- chargingProfile.chargingSchedule.startSchedule.getTime() +
- chargingSchedulePeriod.startPeriod * 1000 &&
- ((chargingProfile.chargingSchedule.chargingSchedulePeriod[index + 1] &&
- timestamp <
- chargingProfile.chargingSchedule.startSchedule.getTime() +
- chargingProfile.chargingSchedule.chargingSchedulePeriod[index + 1]
- ?.startPeriod *
- 1000) ||
- !chargingProfile.chargingSchedule.chargingSchedulePeriod[index + 1]);
- }
- );
- if (!Utils.isEmptyArray(chargingSchedulePeriods)) {
- matchingChargingProfile = chargingProfile;
- break;
- }
- }
- }
- }
- }
- let limit: number;
- if (!Utils.isEmptyArray(chargingSchedulePeriods)) {
- switch (this.getCurrentOutType()) {
- case CurrentType.AC:
- limit =
- matchingChargingProfile.chargingSchedule.chargingRateUnit === ChargingRateUnitType.WATT
- ? chargingSchedulePeriods[0].limit
- : ACElectricUtils.powerTotal(
- this.getNumberOfPhases(),
- this.getVoltageOut(),
- chargingSchedulePeriods[0].limit
- );
- break;
- case CurrentType.DC:
- limit =
- matchingChargingProfile.chargingSchedule.chargingRateUnit === ChargingRateUnitType.WATT
- ? chargingSchedulePeriods[0].limit
- : DCElectricUtils.power(this.getVoltageOut(), chargingSchedulePeriods[0].limit);
- }
- }
- const connectorMaximumPower = this.getMaximumPower() / this.stationInfo.powerDivider;
- if (limit > connectorMaximumPower) {
- logger.error(
- `${this.logPrefix()} Charging profile id ${
- matchingChargingProfile.chargingProfileId
- } limit is greater than connector id ${connectorId} maximum, dump charging profiles' stack: %j`,
- this.getConnectorStatus(connectorId).chargingProfiles
+ public async stopTransactionOnConnector(
+ connectorId: number,
+ reason = StopTransactionReason.NONE
+ ): Promise<StopTransactionResponse> {
+ const transactionId = this.getConnectorStatus(connectorId)?.transactionId;
+ if (
+ this.getBeginEndMeterValues() === true &&
+ this.getOcppStrictCompliance() === true &&
+ this.getOutOfOrderEndMeterValues() === false
+ ) {
+ // FIXME: Implement OCPP version agnostic helpers
+ const transactionEndMeterValue = OCPP16ServiceUtils.buildTransactionEndMeterValue(
+ this,
+ connectorId,
+ this.getEnergyActiveImportRegisterByTransactionId(transactionId)