hasFeatureProfile,
hasReservationExpired,
initializeConnectorsMapStatus,
+ prepareDatesInConnectorStatus,
propagateSerialNumber,
setChargingStationOptions,
stationTemplateToStationInfo,
private initializeConnectorsOrEvsesFromFile (configuration: ChargingStationConfiguration): void {
if (configuration.connectorsStatus != null && configuration.evsesStatus == null) {
for (const [connectorId, connectorStatus] of configuration.connectorsStatus.entries()) {
- this.connectors.set(connectorId, clone<ConnectorStatus>(connectorStatus))
+ this.connectors.set(
+ connectorId,
+ prepareDatesInConnectorStatus(clone<ConnectorStatus>(connectorStatus))
+ )
}
} else if (configuration.evsesStatus != null && configuration.connectorsStatus == null) {
for (const [evseId, evseStatusConfiguration] of configuration.evsesStatus.entries()) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
evseStatusConfiguration.connectorsStatus!.map((connectorStatus, connectorId) => [
connectorId,
- connectorStatus
+ prepareDatesInConnectorStatus(connectorStatus)
])
)
})
}
}
-export const buildConnectorsMap = (
- connectors: Record<string, ConnectorStatus>,
- logPrefix: string,
- templateFile: string
-): Map<number, ConnectorStatus> => {
- const connectorsMap = new Map<number, ConnectorStatus>()
- if (getMaxNumberOfConnectors(connectors) > 0) {
- for (const connector in connectors) {
- const connectorStatus = connectors[connector]
- const connectorId = convertToInt(connector)
- checkStationInfoConnectorStatus(connectorId, connectorStatus, logPrefix, templateFile)
- connectorsMap.set(connectorId, clone<ConnectorStatus>(connectorStatus))
- }
- } else {
- logger.warn(
- `${logPrefix} Charging station information from template ${templateFile} with no connectors, cannot build connectors map`
- )
- }
- return connectorsMap
-}
-
export const setChargingStationOptions = (
stationInfo: ChargingStationInfo,
options?: ChargingStationOptions
return stationInfo
}
+export const buildConnectorsMap = (
+ connectors: Record<string, ConnectorStatus>,
+ logPrefix: string,
+ templateFile: string
+): Map<number, ConnectorStatus> => {
+ const connectorsMap = new Map<number, ConnectorStatus>()
+ if (getMaxNumberOfConnectors(connectors) > 0) {
+ for (const connector in connectors) {
+ const connectorStatus = connectors[connector]
+ const connectorId = convertToInt(connector)
+ checkStationInfoConnectorStatus(connectorId, connectorStatus, logPrefix, templateFile)
+ connectorsMap.set(connectorId, clone<ConnectorStatus>(connectorStatus))
+ }
+ } else {
+ logger.warn(
+ `${logPrefix} Charging station information from template ${templateFile} with no connectors, cannot build connectors map`
+ )
+ }
+ return connectorsMap
+}
+
export const initializeConnectorsMapStatus = (
connectors: Map<number, ConnectorStatus>,
logPrefix: string
delete connectorStatus.transactionBeginMeterValue
}
+export const prepareDatesInConnectorStatus = (
+ connectorStatus: ConnectorStatus
+): ConnectorStatus => {
+ if (connectorStatus.reservation != null) {
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ connectorStatus.reservation.expiryDate = convertToDate(connectorStatus.reservation.expiryDate)!
+ }
+ if (isNotEmptyArray(connectorStatus.chargingProfiles)) {
+ connectorStatus.chargingProfiles = connectorStatus.chargingProfiles.map(chargingProfile => {
+ chargingProfile.chargingSchedule.startSchedule = convertToDate(
+ chargingProfile.chargingSchedule.startSchedule
+ )
+ chargingProfile.validFrom = convertToDate(chargingProfile.validFrom)
+ chargingProfile.validTo = convertToDate(chargingProfile.validTo)
+ return chargingProfile
+ })
+ }
+ return connectorStatus
+}
+
export const createBootNotificationRequest = (
stationInfo: ChargingStationInfo,
bootReason: BootReasonEnumType = BootReasonEnumType.PowerUp