RegistrationStatus,
StatusNotificationResponse,
} from '../types/ocpp/Responses';
+import {
+ ChargingProfile,
+ ChargingRateUnitType,
+ ChargingSchedulePeriod,
+} from '../types/ocpp/ChargingProfile';
import ChargingStationConfiguration, { Section } from '../types/ChargingStationConfiguration';
import ChargingStationOcppConfiguration, {
ConfigurationKey,
import AutomaticTransactionGenerator from './AutomaticTransactionGenerator';
import { ChargePointErrorCode } from '../types/ocpp/ChargePointErrorCode';
import { ChargePointStatus } from '../types/ocpp/ChargePointStatus';
-import { ChargingProfile } from '../types/ocpp/ChargingProfile';
import ChargingStationInfo from '../types/ChargingStationInfo';
import { ChargingStationWorkerMessageEvents } from '../types/ChargingStationWorker';
import Configuration from '../utils/Configuration';
}
}
+ public getChargingProfileLimit(
+ connectorId: number
+ ): { limit: number; unit: ChargingRateUnitType } | 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 &&
+ 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 &&
+ chargingProfile.chargingSchedule.chargingSchedulePeriod[index + 1] &&
+ timestamp <
+ chargingProfile.chargingSchedule.startSchedule.getTime() +
+ chargingProfile.chargingSchedule.chargingSchedulePeriod[index + 1]
+ ?.startPeriod;
+ }
+ );
+ if (!Utils.isEmptyArray(chargingSchedulePeriods)) {
+ matchingChargingProfile = chargingProfile;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return (
+ !Utils.isEmptyArray(chargingSchedulePeriods) && {
+ limit: chargingSchedulePeriods[0].limit,
+ unit: matchingChargingProfile.chargingSchedule.chargingRateUnit,
+ }
+ );
+ }
+
public setChargingProfile(connectorId: number, cp: ChargingProfile): void {
let cpReplaced = false;
if (!Utils.isEmptyArray(this.getConnectorStatus(connectorId).chargingProfiles)) {
export interface ChargingSchedule extends JsonType {
duration?: number;
startSchedule?: Date;
- chargingRateUnit: ChargingRateUnitType;
- chargingSchedulePeriod: ChargingSchedulePeriod[];
+ chargingRateUnit: OCPP16ChargingRateUnitType;
+ chargingSchedulePeriod: OCPP16ChargingSchedulePeriod[];
minChargeRate?: number;
}
-export interface ChargingSchedulePeriod extends JsonType {
+export interface OCPP16ChargingSchedulePeriod extends JsonType {
startPeriod: number;
limit: number;
numberPhases?: number;
}
-export enum ChargingRateUnitType {
+export enum OCPP16ChargingRateUnitType {
WATT = 'W',
AMPERE = 'A',
}
export enum RecurrencyKindType {
DAILY = 'Daily',
WEEKLY = 'Weekly',
+ MONTHLY = 'Monthly',
}
-import { OCPP16ChargingProfile } from './1.6/ChargingProfile';
+import {
+ OCPP16ChargingProfile,
+ OCPP16ChargingRateUnitType,
+ OCPP16ChargingSchedulePeriod,
+} from './1.6/ChargingProfile';
export type ChargingProfile = OCPP16ChargingProfile;
+
+export type ChargingSchedulePeriod = OCPP16ChargingSchedulePeriod;
+
+export type ChargingRateUnitType = OCPP16ChargingRateUnitType;
+
+export const ChargingRateUnitType = {
+ ...OCPP16ChargingRateUnitType,
+};