}
}
- public start(): void {
+ public async start(): Promise<void> {
this.timeToStop = false;
if (this.chargingStation.stationInfo.AutomaticTransactionGenerator.stopAfterHours &&
this.chargingStation.stationInfo.AutomaticTransactionGenerator.stopAfterHours > 0) {
- setTimeout(() => {
- void this.stop();
+ setTimeout(async (): Promise<void> => {
+ await this.stop();
}, this.chargingStation.stationInfo.AutomaticTransactionGenerator.stopAfterHours * 3600 * 1000);
}
for (const connector in this.chargingStation.connectors) {
if (Utils.convertToInt(connector) > 0) {
- void this.startConnector(Utils.convertToInt(connector));
+ await this.startConnector(Utils.convertToInt(connector));
}
}
logger.info(this.logPrefix() + ' ATG started and will stop in ' + Utils.secondsToHHMMSS(this.chargingStation.stationInfo.AutomaticTransactionGenerator.stopAfterHours * 3600));
this.automaticTransactionGeneration = new AutomaticTransactionGenerator(this);
}
if (this.automaticTransactionGeneration.timeToStop) {
- this.automaticTransactionGeneration.start();
+ await this.automaticTransactionGeneration.start();
}
}
if (this.getEnableStatistics()) {
}
private startStationTemplateFileMonitoring(): void {
- fs.watch(this.stationTemplateFile).on('change', (e) => {
+ fs.watch(this.stationTemplateFile).on('change', async (e): Promise<void> => {
try {
logger.debug(this.logPrefix() + ' Template file ' + this.stationTemplateFile + ' have changed, reload');
// Initialize
// Stop the ATG
if (!this.stationInfo.AutomaticTransactionGenerator.enable &&
this.automaticTransactionGeneration) {
- this.automaticTransactionGeneration.stop().catch(() => { });
+ await this.automaticTransactionGeneration.stop();
}
// Start the ATG
if (this.stationInfo.AutomaticTransactionGenerator.enable) {
this.automaticTransactionGeneration = new AutomaticTransactionGenerator(this);
}
if (this.automaticTransactionGeneration.timeToStop) {
- this.automaticTransactionGeneration.start();
+ await this.automaticTransactionGeneration.start();
}
}
// FIXME?: restart heartbeat and WebSocket ping when their interval values have changed
return Constants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN;
}
- private handleRequestChangeAvailability(commandPayload: ChangeAvailabilityRequest): ChangeAvailabilityResponse {
+ private async handleRequestChangeAvailability(commandPayload: ChangeAvailabilityRequest): Promise<ChangeAvailabilityResponse> {
const connectorId: number = commandPayload.connectorId;
if (!this.chargingStation.getConnector(connectorId)) {
logger.error(`${this.chargingStation.logPrefix()} Trying to change the availability of a non existing connector Id ${connectorId.toString()}`);
}
this.chargingStation.getConnector(Utils.convertToInt(connector)).availability = commandPayload.type;
if (response === Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED) {
- void this.chargingStation.ocppRequestService.sendStatusNotification(Utils.convertToInt(connector), chargePointStatus);
+ await this.chargingStation.ocppRequestService.sendStatusNotification(Utils.convertToInt(connector), chargePointStatus);
this.chargingStation.getConnector(Utils.convertToInt(connector)).status = chargePointStatus;
}
}
return Constants.OCPP_AVAILABILITY_RESPONSE_SCHEDULED;
}
this.chargingStation.getConnector(connectorId).availability = commandPayload.type;
- void this.chargingStation.ocppRequestService.sendStatusNotification(connectorId, chargePointStatus);
+ await this.chargingStation.ocppRequestService.sendStatusNotification(connectorId, chargePointStatus);
this.chargingStation.getConnector(connectorId).status = chargePointStatus;
return Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED;
}
public abstract sendStopTransaction(transactionId: number, meterStop: number, idTag?: string, reason?: StopTransactionReason): Promise<StopTransactionResponse>;
public abstract sendMeterValues(connectorId: number, transactionId: number, interval: number, self: OCPPRequestService): Promise<void>;
public abstract sendError(messageId: string, error: OCPPError, commandName: RequestCommand | IncomingRequestCommand): Promise<unknown>;
-
}