type ChargingSchedulePeriod,
type ChargingStationConfiguration,
type ChargingStationInfo,
+ type ChargingStationOptions,
type ChargingStationTemplate,
type ChargingStationWorkerMessageEvents,
ConnectorPhaseRotation,
const chargingStationInfo = {
chargePointModel: stationTemplate.chargePointModel,
chargePointVendor: stationTemplate.chargePointVendor,
- ...(stationTemplate.chargeBoxSerialNumberPrefix !== undefined && {
+ ...(stationTemplate.chargeBoxSerialNumberPrefix != null && {
chargeBoxSerialNumber: stationTemplate.chargeBoxSerialNumberPrefix
}),
- ...(stationTemplate.chargePointSerialNumberPrefix !== undefined && {
+ ...(stationTemplate.chargePointSerialNumberPrefix != null && {
chargePointSerialNumber: stationTemplate.chargePointSerialNumberPrefix
}),
- ...(stationTemplate.meterSerialNumberPrefix !== undefined && {
+ ...(stationTemplate.meterSerialNumberPrefix != null && {
meterSerialNumber: stationTemplate.meterSerialNumberPrefix
}),
- ...(stationTemplate.meterType !== undefined && {
+ ...(stationTemplate.meterType != null && {
meterType: stationTemplate.meterType
})
}
logger.error(`${logPrefix} ${errorMsg}`)
throw new BaseError(errorMsg)
}
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- if (isEmptyObject(stationTemplate.AutomaticTransactionGenerator!)) {
- stationTemplate.AutomaticTransactionGenerator = Constants.DEFAULT_ATG_CONFIGURATION
- logger.warn(
- `${logPrefix} Empty automatic transaction generator configuration from template file ${templateFile}, set to default: %j`,
- Constants.DEFAULT_ATG_CONFIGURATION
- )
- }
if (stationTemplate.idTagsFile == null || isEmptyString(stationTemplate.idTagsFile)) {
logger.warn(
`${logPrefix} Missing id tags file in template file ${templateFile}. That can lead to issues with the Automatic Transaction Generator`
return connectorsMap
}
+export const setChargingStationOptions = (
+ stationInfo: ChargingStationInfo,
+ options?: ChargingStationOptions
+): ChargingStationInfo => {
+ if (options?.supervisionUrls != null) {
+ stationInfo.supervisionUrls = options.supervisionUrls
+ }
+ if (options?.persistentConfiguration != null) {
+ stationInfo.stationInfoPersistentConfiguration = options.persistentConfiguration
+ stationInfo.ocppPersistentConfiguration = options.persistentConfiguration
+ stationInfo.automaticTransactionGeneratorPersistentConfiguration =
+ options.persistentConfiguration
+ }
+ if (options?.autoStart != null) {
+ stationInfo.autoStart = options.autoStart
+ }
+ if (options?.autoRegister != null) {
+ stationInfo.autoRegister = options.autoRegister
+ }
+ if (options?.enableStatistics != null) {
+ stationInfo.enableStatistics = options.enableStatistics
+ }
+ if (options?.ocppStrictCompliance != null) {
+ stationInfo.ocppStrictCompliance = options.ocppStrictCompliance
+ }
+ if (options?.stopTransactionsOnStopped != null) {
+ stationInfo.stopTransactionsOnStopped = options.stopTransactionsOnStopped
+ }
+ return stationInfo
+}
+
export const initializeConnectorsMapStatus = (
connectors: Map<number, ConnectorStatus>,
logPrefix: string
return {
chargePointModel: stationInfo.chargePointModel,
chargePointVendor: stationInfo.chargePointVendor,
- ...(stationInfo.chargeBoxSerialNumber !== undefined && {
+ ...(stationInfo.chargeBoxSerialNumber != null && {
chargeBoxSerialNumber: stationInfo.chargeBoxSerialNumber
}),
- ...(stationInfo.chargePointSerialNumber !== undefined && {
+ ...(stationInfo.chargePointSerialNumber != null && {
chargePointSerialNumber: stationInfo.chargePointSerialNumber
}),
- ...(stationInfo.firmwareVersion !== undefined && {
+ ...(stationInfo.firmwareVersion != null && {
firmwareVersion: stationInfo.firmwareVersion
}),
- ...(stationInfo.iccid !== undefined && { iccid: stationInfo.iccid }),
- ...(stationInfo.imsi !== undefined && { imsi: stationInfo.imsi }),
- ...(stationInfo.meterSerialNumber !== undefined && {
+ ...(stationInfo.iccid != null && { iccid: stationInfo.iccid }),
+ ...(stationInfo.imsi != null && { imsi: stationInfo.imsi }),
+ ...(stationInfo.meterSerialNumber != null && {
meterSerialNumber: stationInfo.meterSerialNumber
}),
- ...(stationInfo.meterType !== undefined && {
+ ...(stationInfo.meterType != null && {
meterType: stationInfo.meterType
})
} satisfies OCPP16BootNotificationRequest
chargingStation: {
model: stationInfo.chargePointModel,
vendorName: stationInfo.chargePointVendor,
- ...(stationInfo.firmwareVersion !== undefined && {
+ ...(stationInfo.firmwareVersion != null && {
firmwareVersion: stationInfo.firmwareVersion
}),
- ...(stationInfo.chargeBoxSerialNumber !== undefined && {
+ ...(stationInfo.chargeBoxSerialNumber != null && {
serialNumber: stationInfo.chargeBoxSerialNumber
}),
- ...((stationInfo.iccid !== undefined || stationInfo.imsi !== undefined) && {
+ ...((stationInfo.iccid != null || stationInfo.imsi != null) && {
modem: {
- ...(stationInfo.iccid !== undefined && { iccid: stationInfo.iccid }),
- ...(stationInfo.imsi !== undefined && { imsi: stationInfo.imsi })
+ ...(stationInfo.iccid != null && { iccid: stationInfo.iccid }),
+ ...(stationInfo.imsi != null && { imsi: stationInfo.imsi })
}
})
}
templateKey.deprecatedKey,
logPrefix,
templateFile,
- templateKey.key !== undefined ? `Use '${templateKey.key}' instead` : undefined
+ templateKey.key != null ? `Use '${templateKey.key}' instead` : undefined
)
convertDeprecatedTemplateKey(stationTemplate, templateKey.deprecatedKey, templateKey.key)
}
delete stationTemplate.Evses
delete stationTemplate.Configuration
delete stationTemplate.AutomaticTransactionGenerator
+ delete stationTemplate.numberOfConnectors
delete stationTemplate.chargeBoxSerialNumberPrefix
delete stationTemplate.chargePointSerialNumberPrefix
delete stationTemplate.meterSerialNumberPrefix
templateFile: string,
logMsgToAppend = ''
): void => {
- if (template[key as keyof ChargingStationTemplate] !== undefined) {
+ if (template[key as keyof ChargingStationTemplate] != null) {
const logMsg = `Deprecated template key '${key}' usage in file '${templateFile}'${
isNotEmptyString(logMsgToAppend) ? `. ${logMsgToAppend}` : ''
}`
deprecatedKey: string,
key?: string
): void => {
- if (template[deprecatedKey as keyof ChargingStationTemplate] !== undefined) {
- if (key !== undefined) {
+ if (template[deprecatedKey as keyof ChargingStationTemplate] != null) {
+ if (key != null) {
(template as unknown as Record<string, unknown>)[key] =
template[deprecatedKey as keyof ChargingStationTemplate]
}