import type { JSONSchemaType } from 'ajv'
import {
- type Interval,
addSeconds,
areIntervalsOverlapping,
differenceInSeconds,
+ type Interval,
isAfter,
isBefore,
isWithinInterval
} from 'date-fns'
-import { OCPP16Constants } from './OCPP16Constants.js'
import {
type ChargingStation,
hasFeatureProfile,
} from '../../../types/index.js'
import { convertToDate, isNotEmptyArray, logger, roundTo } from '../../../utils/index.js'
import { OCPPServiceUtils } from '../OCPPServiceUtils.js'
+import { OCPP16Constants } from './OCPP16Constants.js'
export class OCPP16ServiceUtils extends OCPPServiceUtils {
public static checkFeatureProfile (
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
chargingStation.getConnectorStatus(connectorId)!.chargingProfiles = []
}
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- cp.chargingSchedule.startSchedule = convertToDate(cp.chargingSchedule.startSchedule)!
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- cp.validFrom = convertToDate(cp.validFrom)!
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- cp.validTo = convertToDate(cp.validTo)!
+ cp.chargingSchedule.startSchedule = convertToDate(cp.chargingSchedule.startSchedule)
+ cp.validFrom = convertToDate(cp.validFrom)
+ cp.validTo = convertToDate(cp.validTo)
let cpReplaced = false
if (isNotEmptyArray(chargingStation.getConnectorStatus(connectorId)?.chargingProfiles)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
.filter((schedulePeriod, index) => {
if (
isWithinInterval(
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod)!,
+ addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod),
compositeInterval
)
) {
),
chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod.filter(schedulePeriod =>
isWithinInterval(
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod)!,
+ addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod),
compositeInterval
)
)