X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futils%2FStatistics.ts;h=d194451a031e5b2a3078f2107f8211ffa8f76de9;hb=0d7b35c4bb09627e56413d39ae6b2da56b6dcbd2;hp=966f1b57a6cc2b61de80485bc32c7cb57abbb5c2;hpb=418106c832022ba6f100f4bf81315300994bee87;p=e-mobility-charging-stations-simulator.git diff --git a/src/utils/Statistics.ts b/src/utils/Statistics.ts index 966f1b57..d194451a 100644 --- a/src/utils/Statistics.ts +++ b/src/utils/Statistics.ts @@ -1,5 +1,5 @@ import CommandStatistics, { CommandStatisticsData, PerfEntry } from '../types/CommandStatistics'; -import { IncomingRequestCommand, RequestCommand } from '../types/ocpp/1.6/Requests'; +import { IncomingRequestCommand, RequestCommand } from '../types/ocpp/Requests'; import CircularArray from './CircularArray'; import Configuration from './Configuration'; @@ -12,9 +12,9 @@ export default class Statistics { private objId: string; private commandsStatistics: CommandStatistics; - public constructor(objName: string) { - this.objId = objName; - this.commandsStatistics = { id: this.objId ? this.objId : ' Object id not specified', commandsStatisticsData: {} } as CommandStatistics; + public constructor(objId: string) { + this.objId = objId; + this.commandsStatistics = { id: this.objId ? this.objId : 'Object id not specified', commandsStatisticsData: {} }; } public addMessage(command: RequestCommand | IncomingRequestCommand, messageType: MessageType): void { @@ -52,7 +52,7 @@ export default class Statistics { } break; default: - logger.error(`${this._logPrefix()} Wrong message type ${messageType}`); + logger.error(`${this.logPrefix()} Wrong message type ${messageType}`); break; } } @@ -64,23 +64,23 @@ export default class Statistics { perfEntry.entryType = entry.entryType; perfEntry.startTime = entry.startTime; perfEntry.duration = entry.duration; - logger.info(`${this._logPrefix()} object ${className} method(s) performance entry: %j`, perfEntry); + logger.info(`${this.logPrefix()} object ${className} method(s) performance entry: %j`, perfEntry); } public start(): void { - this._displayInterval(); + this.displayInterval(); } - private _display(): void { - logger.info(this._logPrefix() + ' %j', this.commandsStatistics); + private display(): void { + logger.info(this.logPrefix() + ' %j', this.commandsStatistics); } - private _displayInterval(): void { + private displayInterval(): void { if (Configuration.getStatisticsDisplayInterval() > 0) { setInterval(() => { - this._display(); + this.display(); }, Configuration.getStatisticsDisplayInterval() * 1000); - logger.info(this._logPrefix() + ' displayed every ' + Utils.secondsToHHMMSS(Configuration.getStatisticsDisplayInterval())); + logger.info(this.logPrefix() + ' displayed every ' + Utils.secondsToHHMMSS(Configuration.getStatisticsDisplayInterval())); } } @@ -121,7 +121,7 @@ export default class Statistics { this.commandsStatistics.commandsStatisticsData[command].medTimeMeasurement = this.median(this.commandsStatistics.commandsStatisticsData[command].timeMeasurementSeries); } - private _logPrefix(): string { + private logPrefix(): string { return Utils.logPrefix(` ${this.objId} Statistics:`); } }