handleFileException,
isNotEmptyArray,
isNotEmptyString,
- isNullOrUndefined,
isUndefined,
logPrefix,
logger,
}
public inUnknownState (): boolean {
- return isNullOrUndefined(this?.bootNotificationResponse?.status)
+ return this?.bootNotificationResponse?.status == null
}
public inPendingState (): boolean {
public getConnectorMaximumAvailablePower (connectorId: number): number {
let connectorAmperageLimitationPowerLimit: number | undefined
if (
- !isNullOrUndefined(this.getAmperageLimitation()) &&
+ this.getAmperageLimitation() != null &&
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.getAmperageLimitation()! < this.stationInfo.maximumAmperage!
) {
return
} else if (
this.getConnectorStatus(connectorId)?.transactionStarted === true &&
- isNullOrUndefined(this.getConnectorStatus(connectorId)?.transactionId)
+ this.getConnectorStatus(connectorId)?.transactionId == null
) {
logger.error(
`${this.logPrefix()} Trying to start MeterValues on connector id ${connectorId} with no transaction id`
if (!checkChargingStation(this, this.logPrefix())) {
return
}
- if (
- !isNullOrUndefined(this.stationInfo.supervisionUser) &&
- !isNullOrUndefined(this.stationInfo.supervisionPassword)
- ) {
+ if (this.stationInfo.supervisionUser != null && this.stationInfo.supervisionPassword != null) {
options.auth = `${this.stationInfo.supervisionUser}:${this.stationInfo.supervisionPassword}`
}
if (params?.closeOpened === true) {
}
public getAutomaticTransactionGeneratorConfiguration (): AutomaticTransactionGeneratorConfiguration {
- if (isNullOrUndefined(this.automaticTransactionGeneratorConfiguration)) {
+ if (this.automaticTransactionGeneratorConfiguration == null) {
let automaticTransactionGeneratorConfiguration:
| AutomaticTransactionGeneratorConfiguration
| undefined
...automaticTransactionGeneratorConfiguration
}
}
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- return this.automaticTransactionGeneratorConfiguration!
+ return this.automaticTransactionGeneratorConfiguration
}
public getAutomaticTransactionGeneratorStatuses (): Status[] | undefined {
transactionId,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
meterStop: this.getEnergyActiveImportRegisterByTransactionId(transactionId!, true),
- ...(isNullOrUndefined(reason) && { reason })
+ ...(reason != null && { reason })
})
}
this.wsConnection?.send(message, (error?: Error) => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
isRequest && PerformanceStatistics.endMeasure(commandName!, beginId!)
- if (isNullOrUndefined(error)) {
+ if (error == null) {
logger.debug(
`${this.logPrefix()} >> Buffered ${getMessageTypeString(
messageType
},
stationTemplate?.firmwareUpgrade ?? {}
)
- stationInfo.resetTime = !isNullOrUndefined(stationTemplate?.resetTime)
- ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- secondsToMilliseconds(stationTemplate.resetTime!)
- : Constants.CHARGING_STATION_DEFAULT_RESET_TIME
+ stationInfo.resetTime =
+ stationTemplate?.resetTime != null
+ ? secondsToMilliseconds(stationTemplate.resetTime)
+ : Constants.CHARGING_STATION_DEFAULT_RESET_TIME
return stationInfo
}
.exec(this.stationInfo.firmwareVersion!)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
?.slice(1, patternGroup! + 1)
- if (!isNullOrUndefined(match)) {
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- const patchLevelIndex = match!.length - 1
- // prettier-ignore
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- match![patchLevelIndex] = (convertToInt(match![patchLevelIndex]) +
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.stationInfo.firmwareUpgrade!.versionUpgrade!.step!).toString()
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.stationInfo.firmwareVersion = match!.join('.')
+ if (match != null) {
+ const patchLevelIndex = match.length - 1
+ match[patchLevelIndex] = (
+ convertToInt(match[patchLevelIndex]) +
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ this.stationInfo.firmwareUpgrade!.versionUpgrade!.step!
+ ).toString()
+ this.stationInfo.firmwareVersion = match.join('.')
}
}
this.saveStationInfo()
}
private initializeOcppConfiguration (): void {
- if (isNullOrUndefined(getConfigurationKey(this, StandardParametersKey.HeartbeatInterval))) {
+ if (getConfigurationKey(this, StandardParametersKey.HeartbeatInterval) == null) {
addConfigurationKey(this, StandardParametersKey.HeartbeatInterval, '0')
}
- if (isNullOrUndefined(getConfigurationKey(this, StandardParametersKey.HeartBeatInterval))) {
+ if (getConfigurationKey(this, StandardParametersKey.HeartBeatInterval) == null) {
addConfigurationKey(this, StandardParametersKey.HeartBeatInterval, '0', { visible: false })
}
if (
this.stationInfo?.supervisionUrlOcppConfiguration === true &&
isNotEmptyString(this.stationInfo?.supervisionUrlOcppKey) &&
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- isNullOrUndefined(getConfigurationKey(this, this.stationInfo.supervisionUrlOcppKey!))
+ getConfigurationKey(this, this.stationInfo.supervisionUrlOcppKey!) == null
) {
addConfigurationKey(
this,
this.stationInfo?.supervisionUrlOcppConfiguration === false &&
isNotEmptyString(this.stationInfo?.supervisionUrlOcppKey) &&
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- !isNullOrUndefined(getConfigurationKey(this, this.stationInfo.supervisionUrlOcppKey!))
+ getConfigurationKey(this, this.stationInfo.supervisionUrlOcppKey!) != null
) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
deleteConfigurationKey(this, this.stationInfo.supervisionUrlOcppKey!, { save: false })
if (
isNotEmptyString(this.stationInfo?.amperageLimitationOcppKey) &&
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- isNullOrUndefined(getConfigurationKey(this, this.stationInfo.amperageLimitationOcppKey!))
+ getConfigurationKey(this, this.stationInfo.amperageLimitationOcppKey!) == null
) {
addConfigurationKey(
this,
(this.stationInfo.maximumAmperage! * getAmperageLimitationUnitDivider(this.stationInfo)).toString()
)
}
- if (
- isNullOrUndefined(getConfigurationKey(this, StandardParametersKey.SupportedFeatureProfiles))
- ) {
+ if (getConfigurationKey(this, StandardParametersKey.SupportedFeatureProfiles) == null) {
addConfigurationKey(
this,
StandardParametersKey.SupportedFeatureProfiles,
{ readonly: true },
{ overwrite: true }
)
- if (
- isNullOrUndefined(getConfigurationKey(this, StandardParametersKey.MeterValuesSampledData))
- ) {
+ if (getConfigurationKey(this, StandardParametersKey.MeterValuesSampledData) == null) {
addConfigurationKey(
this,
StandardParametersKey.MeterValuesSampledData,
MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
)
}
- if (
- isNullOrUndefined(getConfigurationKey(this, StandardParametersKey.ConnectorPhaseRotation))
- ) {
+ if (getConfigurationKey(this, StandardParametersKey.ConnectorPhaseRotation) == null) {
const connectorsPhaseRotation: string[] = []
if (this.hasEvses) {
for (const evseStatus of this.evses.values()) {
connectorsPhaseRotation.toString()
)
}
- if (
- isNullOrUndefined(getConfigurationKey(this, StandardParametersKey.AuthorizeRemoteTxRequests))
- ) {
+ if (getConfigurationKey(this, StandardParametersKey.AuthorizeRemoteTxRequests) == null) {
addConfigurationKey(this, StandardParametersKey.AuthorizeRemoteTxRequests, 'true')
}
if (
- isNullOrUndefined(getConfigurationKey(this, StandardParametersKey.LocalAuthListEnabled)) &&
+ getConfigurationKey(this, StandardParametersKey.LocalAuthListEnabled) == null &&
hasFeatureProfile(this, SupportedFeatureProfiles.LocalAuthListManagement) === true
) {
addConfigurationKey(this, StandardParametersKey.LocalAuthListEnabled, 'false')
}
- if (isNullOrUndefined(getConfigurationKey(this, StandardParametersKey.ConnectionTimeOut))) {
+ if (getConfigurationKey(this, StandardParametersKey.ConnectionTimeOut) == null) {
addConfigurationKey(
this,
StandardParametersKey.ConnectionTimeOut,
type ResponsePayload,
ResponseStatus
} from '../../types/index.js'
-import { isNullOrUndefined, logger } from '../../utils/index.js'
+import { logger } from '../../utils/index.js'
import type { AbstractUIService } from '../ui-server/ui-services/AbstractUIService.js'
const moduleName = 'UIServiceWorkerBroadcastChannel'
}
return undefined
})
- .filter((hashId) => !isNullOrUndefined(hashId)) as string[],
+ .filter((hashId) => hashId != null) as string[],
...(responsesStatus === ResponseStatus.FAILURE && {
hashIdsFailed: this.responses
.get(uuid)
}
return undefined
})
- .filter((hashId) => !isNullOrUndefined(hashId)) as string[]
+ .filter((hashId) => hashId != null) as string[]
}),
...(responsesStatus === ResponseStatus.FAILURE && {
responsesFailed: this.responses
}
return undefined
})
- .filter((response) => !isNullOrUndefined(response)) as BroadcastChannelResponsePayload[]
+ .filter((response) => response != null) as BroadcastChannelResponsePayload[]
})
}
}
type SetChargingProfileResponse,
type UnlockConnectorResponse
} from '../../../types/index.js'
-import { Constants, convertToInt, isNullOrUndefined, logger } from '../../../utils/index.js'
+import { Constants, convertToInt, logger } from '../../../utils/index.js'
import { OCPPResponseService } from '../OCPPResponseService.js'
const moduleName = 'OCPP16ResponseService'
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const authorizeConnectorStatus = chargingStation.getConnectorStatus(authorizeConnectorId!)
- const authorizeConnectorIdDefined = !isNullOrUndefined(authorizeConnectorId)
+ const authorizeConnectorIdDefined = authorizeConnectorId != null
if (payload.idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED) {
if (authorizeConnectorIdDefined) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const transactionConnectorId = chargingStation.getConnectorIdByTransactionId(
requestPayload.transactionId
)
- if (isNullOrUndefined(transactionConnectorId)) {
+ if (transactionConnectorId == null) {
logger.error(
`${chargingStation.logPrefix()} Trying to stop a non existing transaction with id ${
requestPayload.transactionId
meterValue: [
OCPP16ServiceUtils.buildTransactionEndMeterValue(
chargingStation,
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- transactionConnectorId!,
+ transactionConnectorId,
requestPayload.meterStop
)
]
}))
if (
!chargingStation.isChargingStationAvailable() ||
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- !chargingStation.isConnectorAvailable(transactionConnectorId!)
+ !chargingStation.isConnectorAvailable(transactionConnectorId)
) {
await OCPP16ServiceUtils.sendAndSetConnectorStatus(
chargingStation,
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- transactionConnectorId!,
+ transactionConnectorId,
OCPP16ChargePointStatus.Unavailable
)
} else {
await OCPP16ServiceUtils.sendAndSetConnectorStatus(
chargingStation,
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- transactionConnectorId!,
+ transactionConnectorId,
OCPP16ChargePointStatus.Available
)
}
chargingStation.powerDivider--
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- resetConnectorStatus(chargingStation.getConnectorStatus(transactionConnectorId!)!)
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- chargingStation.stopMeterValues(transactionConnectorId!)
+ resetConnectorStatus(chargingStation.getConnectorStatus(transactionConnectorId)!)
+ chargingStation.stopMeterValues(transactionConnectorId)
const logMsg = `${chargingStation.logPrefix()} Transaction with id ${
requestPayload.transactionId
} STOPPED on ${
chargingStation.stationInfo.chargingStationId
}#${transactionConnectorId} with status '${payload.idTagInfo?.status}'`
if (
- isNullOrUndefined(payload.idTagInfo) ||
+ payload.idTagInfo == null ||
payload.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED
) {
logger.info(logMsg)
type OCPP16SupportedFeatureProfiles,
OCPPVersion
} from '../../../types/index.js'
-import { isNotEmptyArray, isNullOrUndefined, logger, roundTo } from '../../../utils/index.js'
+import { isNotEmptyArray, logger, roundTo } from '../../../utils/index.js'
import { OCPPServiceUtils } from '../OCPPServiceUtils.js'
export class OCPP16ServiceUtils extends OCPPServiceUtils {
connectorId: number,
cp: OCPP16ChargingProfile
): void {
- if (isNullOrUndefined(chargingStation.getConnectorStatus(connectorId)?.chargingProfiles)) {
+ if (chargingStation.getConnectorStatus(connectorId)?.chargingProfiles == null) {
logger.error(
`${chargingStation.logPrefix()} Trying to set a charging profile on connector id ${connectorId} with an uninitialized charging profiles array attribute, applying deferred initialization`
)
cloneObject,
formatDurationMilliSeconds,
handleSendMessageError,
- isNullOrUndefined,
logger
} from '../../utils/index.js'
type Ajv = _Ajv.default
chargingStation.wsConnection?.send(messageToSend, (error?: Error) => {
PerformanceStatistics.endMeasure(commandName, beginId)
clearTimeout(sendTimeout)
- if (isNullOrUndefined(error)) {
+ if (error == null) {
logger.debug(
`${chargingStation.logPrefix()} >> Command '${commandName}' sent ${OCPPServiceUtils.getMessageTypeString(
messageType
type ResponsePayload,
ResponseStatus
} from '../../../types/index.js'
-import { isNotEmptyArray, isNullOrUndefined, logger } from '../../../utils/index.js'
+import { isNotEmptyArray, logger } from '../../../utils/index.js'
import { Bootstrap } from '../../Bootstrap.js'
import { UIServiceWorkerBroadcastChannel } from '../../broadcast-channel/UIServiceWorkerBroadcastChannel.js'
import type { AbstractUIServer } from '../AbstractUIServer.js'
errorDetails: (error as OCPPError).details
}
}
- if (!isNullOrUndefined(responsePayload)) {
+ if (responsePayload != null) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- return this.uiServer.buildProtocolResponse(messageId!, responsePayload!)
+ return this.uiServer.buildProtocolResponse(messageId!, responsePayload)
}
}
)
return undefined
})
- ?.filter((hashId) => !isNullOrUndefined(hashId)) as string[]
+ ?.filter((hashId) => hashId != null) as string[]
} else {
delete payload.hashIds
}
-import { isNullOrUndefined } from './Utils.js'
import type { ChargingStation } from '../charging-station/index.js'
import type {
ChargingStationAutomaticTransactionGeneratorConfiguration,
): ChargingStationAutomaticTransactionGeneratorConfiguration => {
return {
automaticTransactionGenerator: chargingStation.getAutomaticTransactionGeneratorConfiguration(),
- ...(!isNullOrUndefined(chargingStation.automaticTransactionGenerator?.connectorsStatus) && {
+ ...(chargingStation.automaticTransactionGenerator?.connectorsStatus != null && {
automaticTransactionGeneratorStatuses: [
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ...chargingStation.automaticTransactionGenerator!.connectorsStatus.values()
+ ...chargingStation.automaticTransactionGenerator.connectorsStatus.values()
]
})
}
-import { isEmptyArray, isNullOrUndefined } from './Utils.js'
+import { isEmptyArray } from './Utils.js'
/**
* Computes the average of the given data set.
}
const percentileIndexBase = (percentile / 100) * (sortedDataSet.length - 1)
const percentileIndexInteger = Math.floor(percentileIndexBase)
- if (!isNullOrUndefined(sortedDataSet[percentileIndexInteger + 1])) {
+ if (sortedDataSet[percentileIndexInteger + 1] != null) {
return (
sortedDataSet[percentileIndexInteger] +
(percentileIndexBase - percentileIndexInteger) *
}
export const isObject = (item: unknown): boolean => {
- return !isNullOrUndefined(item) && typeof item === 'object' && !Array.isArray(item)
+ return item != null && typeof item === 'object' && !Array.isArray(item)
}
type CloneableData =
}
export const isCFEnvironment = (): boolean => {
- return !isNullOrUndefined(env.VCAP_APPLICATION)
+ return env.VCAP_APPLICATION != null
}
export const isIterable = <T>(obj: T): boolean => {
- return !isNullOrUndefined(obj) ? typeof obj[Symbol.iterator as keyof T] === 'function' : false
+ return obj != null ? typeof obj[Symbol.iterator as keyof T] === 'function' : false
}
const isString = (value: unknown): boolean => {
}
export const isEmptyString = (value: unknown): boolean => {
- return isNullOrUndefined(value) || (isString(value) && (value as string).trim().length === 0)
+ return value == null || (isString(value) && (value as string).trim().length === 0)
}
export const isNotEmptyString = (value: unknown): boolean => {