public get stationInfo(): ChargingStationInfo {
return {
- ...this.internalStationInfo,
...{
enableStatistics: false,
remoteAuthorization: true,
reconnectExponentialDelay: false,
stopTransactionsOnStopped: true,
},
+ ...this.internalStationInfo,
};
}
public setSupervisionUrl(url: string): void {
if (
- this.stationInfo?.supervisionUrlOcppConfiguration &&
+ this.stationInfo?.supervisionUrlOcppConfiguration === true &&
isNotEmptyString(this.stationInfo?.supervisionUrlOcppKey)
) {
setConfigurationKeyValue(this, this.stationInfo.supervisionUrlOcppKey!, url);
this.wsConnection = new WebSocket(
this.wsConnectionUrl,
- `ocpp${this.stationInfo.ocppVersion}`,
+ `ocpp${this.stationInfo?.ocppVersion}`,
options,
);
? stationTemplate.power * 1000
: stationTemplate.power;
}
+ stationInfo.maximumAmperage = this.getMaximumAmperage(stationInfo);
stationInfo.firmwareVersionPattern =
stationTemplate?.firmwareVersionPattern ?? Constants.SEMVER_PATTERN;
if (
stationInfo.resetTime = !isNullOrUndefined(stationTemplate?.resetTime)
? secondsToMilliseconds(stationTemplate.resetTime!)
: Constants.CHARGING_STATION_DEFAULT_RESET_TIME;
- stationInfo.maximumAmperage = this.getMaximumAmperage(stationInfo);
return stationInfo;
}
}
}
- private handleUnsupportedVersion(version: OCPPVersion) {
+ private handleUnsupportedVersion(version: OCPPVersion | undefined) {
const errorMsg = `Unsupported protocol version '${version}' configured in template file ${this.templateFile}`;
logger.error(`${this.logPrefix()} ${errorMsg}`);
throw new BaseError(errorMsg);
this.ocppConfiguration = this.getOcppConfiguration();
this.initializeOcppConfiguration();
this.initializeOcppServices();
+ this.once(ChargingStationEvents.accepted, () => {
+ this.startMessageSequence().catch((error) => {
+ logger.error(`${this.logPrefix()} Error while starting the message sequence:`, error);
+ });
+ });
if (this.stationInfo?.autoRegister === true) {
this.bootNotificationResponse = {
currentTime: new Date(),
}
private initializeOcppServices(): void {
- const ocppVersion = this.stationInfo.ocppVersion;
+ const ocppVersion = this.stationInfo?.ocppVersion;
switch (ocppVersion) {
case OCPPVersion.VERSION_16:
this.ocppIncomingRequestService =
logger.info(
`${this.logPrefix()} Connection to OCPP server through ${this.wsConnectionUrl.toString()} succeeded`,
);
+ let registrationRetryCount = 0;
if (this.isRegistered() === false) {
// Send BootNotification
- let registrationRetryCount = 0;
do {
this.bootNotificationResponse = await this.ocppRequestService.requestHandler<
BootNotificationRequest,
} while (
this.isRegistered() === false &&
(registrationRetryCount <= this.stationInfo.registrationMaxRetries! ||
- this.stationInfo?.registrationMaxRetries) === -1
+ this.stationInfo?.registrationMaxRetries === -1)
);
}
if (this.isRegistered() === true) {
this.emit(ChargingStationEvents.registered);
if (this.inAcceptedState() === true) {
this.emit(ChargingStationEvents.accepted);
- await this.startMessageSequence();
}
} else {
logger.error(
- `${this.logPrefix()} Registration failure: max retries reached or retry disabled (${this
+ `${this.logPrefix()} Registration failure: maximum retries reached (${registrationRetryCount}) or retry disabled (${this
.stationInfo?.registrationMaxRetries})`,
);
}
private async handleIncomingMessage(request: IncomingRequest): Promise<void> {
const [messageType, messageId, commandName, commandPayload] = request;
- if (this.stationInfo.enableStatistics === true) {
+ if (this.stationInfo?.enableStatistics === true) {
this.performanceStatistics?.addRequestStatistic(commandName, messageType);
}
logger.debug(
private getPowerDivider(): number {
let powerDivider = this.hasEvses ? this.getNumberOfEvses() : this.getNumberOfConnectors();
- if (this.stationInfo?.powerSharedByConnectors) {
+ if (this.stationInfo?.powerSharedByConnectors === true) {
powerDivider = this.getNumberOfRunningTransactions();
}
return powerDivider;
}
private getCurrentOutType(stationInfo?: ChargingStationInfo): CurrentType {
- return (stationInfo ?? this.stationInfo).currentOutType!;
+ return (stationInfo ?? this.stationInfo).currentOutType ?? CurrentType.AC;
}
private getVoltageOut(stationInfo?: ChargingStationInfo): number {
this.stopWebSocketPing();
// Stop heartbeat
this.stopHeartbeat();
- // Stop ongoing transactions
- stopTransactions && (await this.stopRunningTransactions(reason));
// Stop the ATG
if (this.automaticTransactionGenerator?.started === true) {
this.stopAutomaticTransactionGenerator();
}
+ // Stop ongoing transactions
+ stopTransactions && (await this.stopRunningTransactions(reason));
if (this.hasEvses) {
for (const [evseId, evseStatus] of this.evses) {
if (evseId > 0) {