public timeToStop: boolean;
private startDate!: Date;
private stopDate!: Date;
+ private runningDuration!: number;
private chargingStation: ChargingStation;
constructor(chargingStation: ChargingStation) {
public start(): void {
this.startDate = new Date();
- this.stopDate = new Date(this.startDate.getTime() + (this.chargingStation.stationInfo?.AutomaticTransactionGenerator?.stopAfterHours ?? Constants.CHARGING_STATION_ATG_DEFAULT_STOP_AFTER_HOURS) * 3600 * 1000);
+ this.stopDate = new Date(this.startDate.getTime()
+ + (this.chargingStation.stationInfo?.AutomaticTransactionGenerator?.stopAfterHours ?? Constants.CHARGING_STATION_ATG_DEFAULT_STOP_AFTER_HOURS) * 3600 * 1000
+ - (this.runningDuration ?? 0));
this.timeToStop = false;
for (const connector in this.chargingStation.connectors) {
if (Utils.convertToInt(connector) > 0) {
}
public async stop(reason: StopTransactionReason = StopTransactionReason.NONE): Promise<void> {
- logger.info(this.logPrefix() + ' over. Stopping all transactions');
+ logger.info(`${this.logPrefix()} over and lasted for ${Utils.formatDurationMilliSeconds(this.runningDuration ?? 0)}. Stopping all transactions`);
for (const connector in this.chargingStation.connectors) {
const transactionId = this.chargingStation.getConnector(Utils.convertToInt(connector)).transactionId;
if (this.chargingStation.getConnector(Utils.convertToInt(connector)).transactionStarted) {
totalTransactionSkip++;
logger.info(this.logPrefix(connectorId) + ' skipped transaction ' + transactionSkip.toString() + '/' + totalTransactionSkip.toString());
}
+ this.runningDuration = (new Date()).getTime() - this.startDate.getTime();
}
logger.info(this.logPrefix(connectorId) + ' stopped on connector');
}
import Connectors, { Connector, SampledValueTemplate } from '../types/Connectors';
import { MeterValueMeasurand, MeterValuePhase } from '../types/ocpp/MeterValues';
import { WSError, WebSocketCloseEventStatusCode } from '../types/WebSocket';
-import WebSocket, { ClientOptions, Data } from 'ws';
+import WebSocket, { ClientOptions, Data, OPEN } from 'ws';
import AutomaticTransactionGenerator from './AutomaticTransactionGenerator';
import { ChargePointStatus } from '../types/ocpp/ChargePointStatus';
}
public isWebSocketConnectionOpened(): boolean {
- return this.wsConnection?.readyState === WebSocket.OPEN;
+ return this.wsConnection?.readyState === OPEN;
}
public isRegistered(): boolean {