repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix: ensure message sequence is fired at boot notification response
[e-mobility-charging-stations-simulator.git]
/
src
/
charging-station
/
ocpp
/
1.6
/
OCPP16ServiceUtils.ts
diff --git
a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts
b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts
index 570708b74be0ba7f30b9f243bc613ccbe25dd584..d9144064003fb5bf07e0443720e17ac2af084501 100644
(file)
--- a/
src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts
+++ b/
src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts
@@
-1,17
+1,16
@@
-// Partial Copyright Jerome Benoit. 2021-202
3
. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-202
4
. All Rights Reserved.
import type { JSONSchemaType } from 'ajv'
import {
import type { JSONSchemaType } from 'ajv'
import {
- type Interval,
addSeconds,
areIntervalsOverlapping,
differenceInSeconds,
addSeconds,
areIntervalsOverlapping,
differenceInSeconds,
+ type Interval,
isAfter,
isBefore,
isWithinInterval
} from 'date-fns'
isAfter,
isBefore,
isWithinInterval
} from 'date-fns'
-import { OCPP16Constants } from './OCPP16Constants.js'
import {
type ChargingStation,
hasFeatureProfile,
import {
type ChargingStation,
hasFeatureProfile,
@@
-38,8
+37,9
@@
import {
type OCPP16SupportedFeatureProfiles,
OCPPVersion
} from '../../../types/index.js'
type OCPP16SupportedFeatureProfiles,
OCPPVersion
} from '../../../types/index.js'
-import { isNotEmptyArray, logger, roundTo } from '../../../utils/index.js'
+import {
convertToDate,
isNotEmptyArray, logger, roundTo } from '../../../utils/index.js'
import { OCPPServiceUtils } from '../OCPPServiceUtils.js'
import { OCPPServiceUtils } from '../OCPPServiceUtils.js'
+import { OCPP16Constants } from './OCPP16Constants.js'
export class OCPP16ServiceUtils extends OCPPServiceUtils {
public static checkFeatureProfile (
export class OCPP16ServiceUtils extends OCPPServiceUtils {
public static checkFeatureProfile (
@@
-164,6
+164,9
@@
export class OCPP16ServiceUtils extends OCPPServiceUtils {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
chargingStation.getConnectorStatus(connectorId)!.chargingProfiles = []
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
chargingStation.getConnectorStatus(connectorId)!.chargingProfiles = []
}
+ 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
let cpReplaced = false
if (isNotEmptyArray(chargingStation.getConnectorStatus(connectorId)?.chargingProfiles)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@
-192,7
+195,7
@@
export class OCPP16ServiceUtils extends OCPPServiceUtils {
const { id, chargingProfilePurpose, stackLevel } = commandPayload
let clearedCP = false
if (isNotEmptyArray(chargingProfiles)) {
const { id, chargingProfilePurpose, stackLevel } = commandPayload
let clearedCP = false
if (isNotEmptyArray(chargingProfiles)) {
- chargingProfiles
?
.forEach((chargingProfile: OCPP16ChargingProfile, index: number) => {
+ chargingProfiles.forEach((chargingProfile: OCPP16ChargingProfile, index: number) => {
let clearCurrentCP = false
if (chargingProfile.chargingProfileId === id) {
clearCurrentCP = true
let clearCurrentCP = false
if (chargingProfile.chargingProfileId === id) {
clearCurrentCP = true
@@
-293,7
+296,7
@@
export class OCPP16ServiceUtils extends OCPPServiceUtils {
),
chargingSchedulePeriod: [
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
),
chargingSchedulePeriod: [
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ...compositeChargingScheduleHigher!.chargingSchedulePeriod.map(
(schedulePeriod)
=> {
+ ...compositeChargingScheduleHigher!.chargingSchedulePeriod.map(
schedulePeriod
=> {
return {
...schedulePeriod,
startPeriod: higherFirst
return {
...schedulePeriod,
startPeriod: higherFirst
@@
-306,7
+309,7
@@
export class OCPP16ServiceUtils extends OCPPServiceUtils {
}
}),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
}
}),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ...compositeChargingScheduleLower!.chargingSchedulePeriod.map(
(schedulePeriod)
=> {
+ ...compositeChargingScheduleLower!.chargingSchedulePeriod.map(
schedulePeriod
=> {
return {
...schedulePeriod,
startPeriod: higherFirst
return {
...schedulePeriod,
startPeriod: higherFirst
@@
-339,7
+342,7
@@
export class OCPP16ServiceUtils extends OCPPServiceUtils {
),
chargingSchedulePeriod: [
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
),
chargingSchedulePeriod: [
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ...compositeChargingScheduleHigher!.chargingSchedulePeriod.map(
(schedulePeriod)
=> {
+ ...compositeChargingScheduleHigher!.chargingSchedulePeriod.map(
schedulePeriod
=> {
return {
...schedulePeriod,
startPeriod: higherFirst
return {
...schedulePeriod,
startPeriod: higherFirst
@@
-504,8
+507,7
@@
export class OCPP16ServiceUtils extends OCPPServiceUtils {
.filter((schedulePeriod, index) => {
if (
isWithinInterval(
.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
)
) {
compositeInterval
)
) {
@@
-544,10
+546,9
@@
export class OCPP16ServiceUtils extends OCPPServiceUtils {
compositeInterval.end as Date,
chargingScheduleInterval.start
),
compositeInterval.end as Date,
chargingScheduleInterval.start
),
- chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod.filter(
(schedulePeriod)
=>
+ chargingSchedulePeriod: chargingSchedule.chargingSchedulePeriod.filter(
schedulePeriod
=>
isWithinInterval(
isWithinInterval(
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod)!,
+ addSeconds(chargingScheduleInterval.start, schedulePeriod.startPeriod),
compositeInterval
)
)
compositeInterval
)
)