- https://github.com/cloudfoundry/nodejs-buildpack
no-route: true
health-check-type: process
+ timeout: 30
command: node -r source-map-support/register dist/start.js
env:
OPTIMIZE_MEMORY: true
});
}
}
- logger.info(this.logPrefix() + ' started and will run for ' + Utils.milliSecondsToHHMMSS(this.stopDate.getTime() - this.startDate.getTime()));
+ logger.info(this.logPrefix() + ' started and will run for ' + Utils.formatDurationMilliSeconds(this.stopDate.getTime() - this.startDate.getTime()));
}
public async stop(reason: StopTransactionReason = StopTransactionReason.NONE): Promise<void> {
}
const wait = Utils.getRandomInt(this.chargingStation.stationInfo.AutomaticTransactionGenerator.maxDelayBetweenTwoTransactions,
this.chargingStation.stationInfo.AutomaticTransactionGenerator.minDelayBetweenTwoTransactions) * 1000;
- logger.info(this.logPrefix(connectorId) + ' waiting for ' + Utils.milliSecondsToHHMMSS(wait));
+ logger.info(this.logPrefix(connectorId) + ' waiting for ' + Utils.formatDurationMilliSeconds(wait));
await Utils.sleep(wait);
const start = Utils.secureRandom();
if (start < this.chargingStation.stationInfo.AutomaticTransactionGenerator.probabilityOfStart) {
// Wait until end of transaction
const waitTrxEnd = Utils.getRandomInt(this.chargingStation.stationInfo.AutomaticTransactionGenerator.maxDuration,
this.chargingStation.stationInfo.AutomaticTransactionGenerator.minDuration) * 1000;
- logger.info(this.logPrefix(connectorId) + ' transaction ' + this.chargingStation.getConnector(connectorId).transactionId.toString() + ' will stop in ' + Utils.milliSecondsToHHMMSS(waitTrxEnd));
+ logger.info(this.logPrefix(connectorId) + ' transaction ' + this.chargingStation.getConnector(connectorId).transactionId.toString() + ' will stop in ' + Utils.formatDurationMilliSeconds(waitTrxEnd));
await Utils.sleep(waitTrxEnd);
// Stop transaction
if (this.chargingStation.getConnector(connectorId)?.transactionStarted) {
this.heartbeatSetInterval = setInterval(async (): Promise<void> => {
await this.ocppRequestService.sendHeartbeat();
}, this.getHeartbeatInterval());
- logger.info(this.logPrefix() + ' Heartbeat started every ' + Utils.milliSecondsToHHMMSS(this.getHeartbeatInterval()));
+ logger.info(this.logPrefix() + ' Heartbeat started every ' + Utils.formatDurationMilliSeconds(this.getHeartbeatInterval()));
} else if (this.heartbeatSetInterval) {
- logger.info(this.logPrefix() + ' Heartbeat already started every ' + Utils.milliSecondsToHHMMSS(this.getHeartbeatInterval()));
+ logger.info(this.logPrefix() + ' Heartbeat already started every ' + Utils.formatDurationMilliSeconds(this.getHeartbeatInterval()));
} else {
- logger.error(`${this.logPrefix()} Heartbeat interval set to ${this.getHeartbeatInterval() ? Utils.milliSecondsToHHMMSS(this.getHeartbeatInterval()) : this.getHeartbeatInterval()}, not starting the heartbeat`);
+ logger.error(`${this.logPrefix()} Heartbeat interval set to ${this.getHeartbeatInterval() ? Utils.formatDurationMilliSeconds(this.getHeartbeatInterval()) : this.getHeartbeatInterval()}, not starting the heartbeat`);
}
}
await this.ocppRequestService.sendMeterValues(connectorId, this.getConnector(connectorId).transactionId, interval);
}, interval);
} else {
- logger.error(`${this.logPrefix()} Charging station ${StandardParametersKey.MeterValueSampleInterval} configuration set to ${interval ? Utils.milliSecondsToHHMMSS(interval) : interval}, not sending MeterValues`);
+ logger.error(`${this.logPrefix()} Charging station ${StandardParametersKey.MeterValueSampleInterval} configuration set to ${interval ? Utils.formatDurationMilliSeconds(interval) : interval}, not sending MeterValues`);
}
}
this.wsConnection.ping((): void => { /* This is intentional */ });
}
}, webSocketPingInterval * 1000);
- logger.info(this.logPrefix() + ' WebSocket ping started every ' + Utils.secondsToHHMMSS(webSocketPingInterval));
+ logger.info(this.logPrefix() + ' WebSocket ping started every ' + Utils.formatDurationSeconds(webSocketPingInterval));
} else if (this.webSocketPingSetInterval) {
- logger.info(this.logPrefix() + ' WebSocket ping every ' + Utils.secondsToHHMMSS(webSocketPingInterval) + ' already started');
+ logger.info(this.logPrefix() + ' WebSocket ping every ' + Utils.formatDurationSeconds(webSocketPingInterval) + ' already started');
} else {
- logger.error(`${this.logPrefix()} WebSocket ping interval set to ${webSocketPingInterval ? Utils.secondsToHHMMSS(webSocketPingInterval) : webSocketPingInterval}, not starting the WebSocket ping`);
+ logger.error(`${this.logPrefix()} WebSocket ping interval set to ${webSocketPingInterval ? Utils.formatDurationSeconds(webSocketPingInterval) : webSocketPingInterval}, not starting the WebSocket ping`);
}
}
await Utils.sleep(this.chargingStation.stationInfo.resetTime);
this.chargingStation.start();
});
- logger.info(`${this.chargingStation.logPrefix()} ${commandPayload.type} reset command received, simulating it. The station will be back online in ${Utils.milliSecondsToHHMMSS(this.chargingStation.stationInfo.resetTime)}`);
+ logger.info(`${this.chargingStation.logPrefix()} ${commandPayload.type} reset command received, simulating it. The station will be back online in ${Utils.formatDurationMilliSeconds(this.chargingStation.stationInfo.resetTime)}`);
return Constants.OCPP_RESPONSE_ACCEPTED;
}
this.displayInterval = setInterval(() => {
this.logStatistics();
}, Configuration.getLogStatisticsInterval() * 1000);
- logger.info(this.logPrefix() + ' logged every ' + Utils.secondsToHHMMSS(Configuration.getLogStatisticsInterval()));
+ logger.info(this.logPrefix() + ' logged every ' + Utils.formatDurationSeconds(Configuration.getLogStatisticsInterval()));
} else {
logger.info(this.logPrefix() + ' log interval is set to ' + Configuration.getLogStatisticsInterval().toString() + '. Not logging statistics');
}
return new Promise((resolve) => setTimeout(resolve, milliSeconds));
}
- public static secondsToHHMMSS(seconds: number): string {
- return Utils.milliSecondsToHHMMSS(seconds * 1000);
+ public static formatDurationMilliSeconds(duration: number): string {
+ duration = Utils.convertToInt(duration);
+ const hours = Math.floor(duration / (3600 * 1000));
+ const minutes = Math.floor((duration - (hours * (3600 * 1000))) / (60 * 1000));
+ const seconds = (duration - (hours * 3600 * 1000) - (minutes * 60 * 1000)) / 1000;
+ let hoursStr: string = hours.toString();
+ let minutesStr: string = minutes.toString();
+ let secondsStr: string = seconds.toString();
+
+ if (hours < 10) {
+ hoursStr = '0' + hours.toString();
+ }
+ if (minutes < 10) {
+ minutesStr = '0' + minutes.toString();
+ }
+ if (seconds < 10) {
+ secondsStr = '0' + seconds.toString();
+ }
+ return hoursStr + ':' + minutesStr + ':' + secondsStr;
}
- public static milliSecondsToHHMMSS(milliSeconds: number): string {
- return new Date(milliSeconds).toISOString().substr(11, 8);
+ public static formatDurationSeconds(duration: number): string {
+ return Utils.formatDurationMilliSeconds(duration * 1000);
}
public static removeExtraEmptyLines(tab: string[]): void {