sleep,
} from '../utils/index.js'
import type { ChargingStation } from './ChargingStation.js'
-import { checkChargingStation } from './Helpers.js'
+import { checkChargingStationState } from './Helpers.js'
import { IdTagsCache } from './IdTagsCache.js'
import { isIdTagAuthorized } from './ocpp/index.js'
}
public start (stopAbsoluteDuration?: boolean): void {
- if (!checkChargingStation(this.chargingStation, this.logPrefix())) {
+ if (!checkChargingStationState(this.chargingStation, this.logPrefix())) {
return
}
if (this.started) {
}
public startConnector (connectorId: number, stopAbsoluteDuration?: boolean): void {
- if (!checkChargingStation(this.chargingStation, this.logPrefix(connectorId))) {
+ if (!checkChargingStationState(this.chargingStation, this.logPrefix(connectorId))) {
return
}
if (!this.connectorsStatus.has(connectorId)) {
import {
buildConnectorsMap,
buildTemplateName,
- checkChargingStation,
+ checkChargingStationState,
checkConfiguration,
checkConnectorsConfiguration,
checkStationInfoConnectorStatus,
propagateSerialNumber,
setChargingStationOptions,
stationTemplateToStationInfo,
+ validateStationInfo,
warnTemplateKeysDeprecation,
} from './Helpers.js'
import { IdTagsCache } from './IdTagsCache.js'
...options,
}
params = { ...{ closeOpened: false, terminateOpened: false }, ...params }
- if (!checkChargingStation(this, this.logPrefix())) {
+ if (!checkChargingStationState(this, this.logPrefix())) {
return
}
if (this.stationInfo?.supervisionUser != null && this.stationInfo.supervisionPassword != null) {
this.initializeConnectorsOrEvsesFromTemplate(stationTemplate)
}
this.stationInfo = this.getStationInfo(options)
+ validateStationInfo(this)
if (
this.stationInfo.firmwareStatus === FirmwareStatus.Installing &&
isNotEmptyString(this.stationInfo.firmwareVersionPattern) &&
.digest('hex')
}
-export const checkChargingStation = (
+export const validateStationInfo = (chargingStation: ChargingStation): void => {
+ if (isEmpty(chargingStation.stationInfo)) {
+ throw new BaseError('Missing charging station information')
+ }
+ if (isEmpty(chargingStation.stationInfo?.hashId.trim())) {
+ throw new BaseError('Missing hashId in stationInfo properties')
+ }
+ if (isEmpty(chargingStation.stationInfo?.templateIndex)) {
+ throw new BaseError('Missing templateIndex in stationInfo properties')
+ }
+ if (isEmpty(chargingStation.stationInfo?.templateName.trim())) {
+ throw new BaseError('Missing templateName in stationInfo properties')
+ }
+ if (isEmpty(chargingStation.stationInfo?.chargingStationId?.trim())) {
+ throw new BaseError('Missing chargingStationId in stationInfo properties')
+ }
+ if (isEmpty(chargingStation.stationInfo?.maximumPower)) {
+ throw new BaseError('Missing maximumPower in stationInfo properties')
+ }
+ if (chargingStation.stationInfo?.maximumPower != null && chargingStation.stationInfo.maximumPower <= 0) {
+ throw new RangeError('Invalid maximumPower value in stationInfo properties')
+ }
+ if (isEmpty(chargingStation.stationInfo?.maximumAmperage)) {
+ throw new BaseError('Missing maximumAmperage in stationInfo properties')
+ }
+ if (chargingStation.stationInfo?.maximumAmperage != null && chargingStation.stationInfo.maximumAmperage <= 0) {
+ throw new RangeError('Invalid maximumAmperage value in stationInfo properties')
+ }
+ switch (chargingStation.stationInfo?.ocppVersion) {
+ case OCPPVersion.VERSION_20:
+ case OCPPVersion.VERSION_201:
+ if (chargingStation.evses.size === 0) {
+ throw new BaseError('OCPP 2.0 or superior requires at least one EVSE defined in the charging station template/configuration')
+ }
+ }
+}
+
+export const checkChargingStationState = (
chargingStation: ChargingStation,
logPrefix: string
): boolean => {
} from './ConfigurationKeyUtils.js'
export {
canProceedChargingProfile,
- checkChargingStation,
+ checkChargingStationState,
getConnectorChargingProfiles,
getIdTagsFile,
hasFeatureProfile,
import {
canProceedChargingProfile,
type ChargingStation,
- checkChargingStation,
+ checkChargingStationState,
getConfigurationKey,
getConnectorChargingProfiles,
prepareChargingProfileKind,
maxDelay = 30,
minDelay = 15
): Promise<void> {
- if (!checkChargingStation(chargingStation, chargingStation.logPrefix())) {
+ if (!checkChargingStationState(chargingStation, chargingStation.logPrefix())) {
return
}
if (chargingStation.hasEvses) {
}
} while (transactionsStarted)
!wasTransactionsStarted && (await sleep(secondsToMilliseconds(randomInt(minDelay, maxDelay))))
- if (!checkChargingStation(chargingStation, chargingStation.logPrefix())) {
+ if (!checkChargingStationState(chargingStation, chargingStation.logPrefix())) {
return
}
await chargingStation.ocppRequestService.requestHandler<