type BootNotificationRequest,
type CachedRequest,
type ErrorCallback,
+ FirmwareStatus,
+ type FirmwareStatusNotificationRequest,
type HeartbeatRequest,
type IncomingRequest,
IncomingRequestCommand,
import {
type BootNotificationResponse,
type ErrorResponse,
+ type FirmwareStatusNotificationResponse,
type HeartbeatResponse,
type MeterValuesResponse,
- RegistrationStatus,
+ RegistrationStatusEnumType,
type Response,
type StatusNotificationResponse,
} from '../types/ocpp/Responses';
);
}
- public getEnableStatistics(): boolean | undefined {
- return !Utils.isUndefined(this.stationInfo.enableStatistics)
- ? this.stationInfo.enableStatistics
- : true;
+ public getEnableStatistics(): boolean {
+ return this.stationInfo.enableStatistics ?? false;
}
- public getMustAuthorizeAtRemoteStart(): boolean | undefined {
+ public getMustAuthorizeAtRemoteStart(): boolean {
return this.stationInfo.mustAuthorizeAtRemoteStart ?? true;
}
- public getPayloadSchemaValidation(): boolean | undefined {
+ public getPayloadSchemaValidation(): boolean {
return this.stationInfo.payloadSchemaValidation ?? true;
}
return this?.wsConnection?.readyState === WebSocket.OPEN;
}
- public getRegistrationStatus(): RegistrationStatus {
+ public getRegistrationStatus(): RegistrationStatusEnumType {
return this?.bootNotificationResponse?.status;
}
}
public isInPendingState(): boolean {
- return this?.bootNotificationResponse?.status === RegistrationStatus.PENDING;
+ return this?.bootNotificationResponse?.status === RegistrationStatusEnumType.PENDING;
}
public isInAcceptedState(): boolean {
- return this?.bootNotificationResponse?.status === RegistrationStatus.ACCEPTED;
+ return this?.bootNotificationResponse?.status === RegistrationStatusEnumType.ACCEPTED;
}
public isInRejectedState(): boolean {
- return this?.bootNotificationResponse?.status === RegistrationStatus.REJECTED;
+ return this?.bootNotificationResponse?.status === RegistrationStatusEnumType.REJECTED;
}
public isRegistered(): boolean {
if (this.started === false) {
if (this.starting === false) {
this.starting = true;
- if (this.getEnableStatistics()) {
+ if (this.getEnableStatistics() === true) {
this.performanceStatistics.start();
}
this.openWSConnection();
) {
this.startAutomaticTransactionGenerator();
}
- if (this.getEnableStatistics()) {
+ if (this.getEnableStatistics() === true) {
this.performanceStatistics.restart();
} else {
this.performanceStatistics.stop();
this.stopping = true;
await this.stopMessageSequence(reason);
this.closeWSConnection();
- if (this.getEnableStatistics()) {
+ if (this.getEnableStatistics() === true) {
this.performanceStatistics.stop();
}
this.sharedLRUCache.deleteChargingStationConfiguration(this.configurationFileHash);
'supervisionUrl',
'supervisionUrls'
);
- const firmwareVersionRegExp = stationTemplate.firmwareVersionPattern
- ? new RegExp(stationTemplate.firmwareVersionPattern)
- : Constants.SEMVER_REGEXP;
- if (
- stationTemplate.firmwareVersion &&
- firmwareVersionRegExp.test(stationTemplate.firmwareVersion) === false
- ) {
- logger.warn(
- `${this.logPrefix()} Firmware version '${
- stationTemplate.firmwareVersion
- }' in template file ${
- this.templateFile
- } does not match regular expression '${firmwareVersionRegExp.toString()}'`
- );
- }
const stationInfo: ChargingStationInfo =
ChargingStationUtils.stationTemplateToStationInfo(stationTemplate);
stationInfo.hashId = ChargingStationUtils.getHashId(this.index, stationTemplate);
? stationTemplate.power * 1000
: stationTemplate.power;
}
+ stationInfo.firmwareVersionPattern =
+ stationTemplate.firmwareVersionPattern ?? Constants.SEMVER_PATTERN;
+ if (
+ stationInfo.firmwareVersion &&
+ new RegExp(stationInfo.firmwareVersionPattern).test(stationInfo.firmwareVersion) === false
+ ) {
+ logger.warn(
+ `${this.logPrefix()} Firmware version '${stationInfo.firmwareVersion}' in template file ${
+ this.templateFile
+ } does not match firmware version pattern '${stationInfo.firmwareVersionPattern}'`
+ );
+ }
stationInfo.resetTime = stationTemplate.resetTime
? stationTemplate.resetTime * 1000
: Constants.CHARGING_STATION_DEFAULT_RESET_TIME;
// Avoid duplication of connectors related information in RAM
this.stationInfo?.Connectors && delete this.stationInfo.Connectors;
this.configuredSupervisionUrl = this.getConfiguredSupervisionUrl();
- if (this.getEnableStatistics()) {
+ if (this.getEnableStatistics() === true) {
this.performanceStatistics = PerformanceStatistics.getInstance(
this.stationInfo.hashId,
this.stationInfo.chargingStationId,
}
if (this.stationInfo?.autoRegister === true) {
this.bootNotificationResponse = {
- currentTime: new Date().toISOString(),
+ currentTime: new Date(),
interval: this.getHeartbeatInterval() / 1000,
- status: RegistrationStatus.ACCEPTED,
+ status: RegistrationStatusEnumType.ACCEPTED,
};
}
+ if (
+ this.stationInfo.firmwareStatus === FirmwareStatus.Installing &&
+ this.stationInfo.firmwareVersion &&
+ this.stationInfo.firmwareVersionPattern
+ ) {
+ const match = this.stationInfo.firmwareVersion
+ .match(new RegExp(this.stationInfo.firmwareVersionPattern))
+ .slice(1, this.stationInfo.firmwareVersion.split('.').length + 1);
+ const patchLevelIndex = match.length - 1;
+ match[patchLevelIndex] = (Utils.convertToInt(match[patchLevelIndex]) + 1).toString();
+ this.stationInfo.firmwareVersion = match.join('.');
+ }
}
private initializeOcppConfiguration(): void {
logger.error(
`${this.logPrefix()} Charging profile id ${
matchingChargingProfile.chargingProfileId
- } limit is greater than connector id ${connectorId} maximum, dump charging profiles' stack: %j`,
+ } limit ${limit} is greater than connector id ${connectorId} maximum ${connectorMaximumPower}, dump charging profiles' stack: %j`,
this.getConnectorStatus(connectorId).chargingProfiles
);
limit = connectorMaximumPower;
});
this.getConnectorStatus(connectorId).status = chargePointStatus;
}
+ if (this.stationInfo?.firmwareStatus === FirmwareStatus.Installing) {
+ await this.ocppRequestService.requestHandler<
+ FirmwareStatusNotificationRequest,
+ FirmwareStatusNotificationResponse
+ >(this, RequestCommand.FIRMWARE_STATUS_NOTIFICATION, {
+ status: FirmwareStatus.Installed,
+ });
+ this.stationInfo.firmwareStatus = FirmwareStatus.Installed;
+ }
+
// Start the ATG
if (this.getAutomaticTransactionGeneratorConfigurationFromTemplate()?.enable === true) {
this.startAutomaticTransactionGenerator();