if (this.chargingStation.getEnableStatistics()) {
this.performanceObserver = new PerformanceObserver((list) => {
const entry = list.getEntries()[0];
- this.chargingStation.statistics.logPerformance(entry, Constants.ENTITY_AUTOMATIC_TRANSACTION_GENERATOR);
+ this.chargingStation.performanceStatistics.logPerformance(entry, Constants.ENTITY_AUTOMATIC_TRANSACTION_GENERATOR);
this.performanceObserver.disconnect();
});
}
startResponse = await this.startTransaction(connectorId, this);
}
if (startResponse?.idTagInfo?.status !== AuthorizationStatus.ACCEPTED) {
- logger.info(this.logPrefix(connectorId) + ' transaction rejected');
+ logger.warn(this.logPrefix(connectorId) + ' transaction rejected');
await Utils.sleep(Constants.CHARGING_STATION_ATG_WAIT_TIME);
} else {
// Wait until end of transaction
private logPrefix(connectorId: number = null): string {
if (connectorId) {
- return Utils.logPrefix(' ' + this.chargingStation.stationInfo.chargingStationId + ' ATG on connector #' + connectorId.toString() + ':');
+ return Utils.logPrefix(' ' + this.chargingStation.stationInfo.chargingStationId + ' | ATG on connector #' + connectorId.toString() + ':');
}
- return Utils.logPrefix(' ' + this.chargingStation.stationInfo.chargingStationId + ' ATG:');
+ return Utils.logPrefix(' ' + this.chargingStation.stationInfo.chargingStationId + ' | ATG:');
}
}
import OCPPIncomingRequestService from './ocpp/OCPPIncomingRequestService';
import OCPPRequestService from './ocpp/OCPPRequestService';
import { OCPPVersion } from '../types/ocpp/OCPPVersion';
+import PerformanceStatistics from '../utils/PerformanceStatistics';
import { StandardParametersKey } from '../types/ocpp/Configuration';
-import Statistics from '../utils/Statistics';
import { StopTransactionReason } from '../types/ocpp/Transaction';
import Utils from '../utils/Utils';
import { WebSocketCloseEventStatusCode } from '../types/WebSocket';
public wsConnection: WebSocket;
public requests: Requests;
public messageQueue: string[];
- public statistics: Statistics;
+ public performanceStatistics: PerformanceStatistics;
public heartbeatSetInterval: NodeJS.Timeout;
public ocppIncomingRequestService: OCPPIncomingRequestService;
public ocppRequestService: OCPPRequestService;
}
public logPrefix(): string {
- return Utils.logPrefix(` ${this.stationInfo.chargingStationId}:`);
+ return Utils.logPrefix(` ${this.stationInfo.chargingStationId} |`);
}
public getRandomTagId(): string {
}, this.getHeartbeatInterval());
logger.info(this.logPrefix() + ' Heartbeat started every ' + Utils.milliSecondsToHHMMSS(this.getHeartbeatInterval()));
} else if (this.heartbeatSetInterval) {
- logger.info(this.logPrefix() + ' Heartbeat every ' + Utils.milliSecondsToHHMMSS(this.getHeartbeatInterval()) + ' already started');
+ logger.info(this.logPrefix() + ' Heartbeat already started every ' + Utils.milliSecondsToHHMMSS(this.getHeartbeatInterval()));
} else {
logger.error(`${this.logPrefix()} Heartbeat interval set to ${this.getHeartbeatInterval() ? Utils.milliSecondsToHHMMSS(this.getHeartbeatInterval()) : this.getHeartbeatInterval()}, not starting the heartbeat`);
}
}
this.stationInfo.powerDivider = this.getPowerDivider();
if (this.getEnableStatistics()) {
- this.statistics = new Statistics(this.stationInfo.chargingStationId);
+ this.performanceStatistics = new PerformanceStatistics(this.stationInfo.chargingStationId);
this.performanceObserver = new PerformanceObserver((list) => {
const entry = list.getEntries()[0];
- this.statistics.logPerformance(entry, Constants.ENTITY_CHARGING_STATION);
+ this.performanceStatistics.logPerformance(entry, Constants.ENTITY_CHARGING_STATION);
this.performanceObserver.disconnect();
});
}
// Incoming Message
case MessageType.CALL_MESSAGE:
if (this.getEnableStatistics()) {
- this.statistics.addMessage(commandName, messageType);
+ this.performanceStatistics.addMessage(commandName, messageType);
}
// Process the call
await this.ocppIncomingRequestService.handleRequest(messageId, commandName, commandPayload);
}
}
if (this.getEnableStatistics()) {
- this.statistics.start();
+ this.performanceStatistics.start();
}
}
logger.debug(this.chargingStation.logPrefix() + ' Transaction remotely STARTED on ' + this.chargingStation.stationInfo.chargingStationId + '#' + transactionConnectorID.toString() + ' for idTag ' + commandPayload.idTag);
return Constants.OCPP_RESPONSE_ACCEPTED;
}
- logger.error(this.chargingStation.logPrefix() + ' Remote starting transaction REJECTED on connector Id ' + transactionConnectorID.toString() + ', idTag ' + commandPayload.idTag);
+ logger.warn(this.chargingStation.logPrefix() + ' Remote starting transaction REJECTED on connector Id ' + transactionConnectorID.toString() + ', idTag ' + commandPayload.idTag);
return Constants.OCPP_RESPONSE_REJECTED;
}
await this.chargingStation.ocppRequestService.sendStatusNotification(transactionConnectorID, OCPP16ChargePointStatus.PREPARING);
logger.debug(this.chargingStation.logPrefix() + ' Transaction remotely STARTED on ' + this.chargingStation.stationInfo.chargingStationId + '#' + transactionConnectorID.toString() + ' for idTag ' + commandPayload.idTag);
return Constants.OCPP_RESPONSE_ACCEPTED;
}
- logger.error(this.chargingStation.logPrefix() + ' Remote starting transaction REJECTED on unavailable connector Id ' + transactionConnectorID.toString() + ', idTag ' + commandPayload.idTag);
+ logger.warn(this.chargingStation.logPrefix() + ' Remote starting transaction REJECTED on unavailable connector Id ' + transactionConnectorID.toString() + ', idTag ' + commandPayload.idTag);
return Constants.OCPP_RESPONSE_REJECTED;
}
private handleResponseBootNotification(payload: OCPP16BootNotificationResponse, requestPayload: OCPP16BootNotificationRequest): void {
if (payload.status === OCPP16RegistrationStatus.ACCEPTED) {
- this.chargingStation.heartbeatSetInterval ? this.chargingStation.restartHeartbeat() : this.chargingStation.startHeartbeat();
this.chargingStation.addConfigurationKey(OCPP16StandardParametersKey.HeartBeatInterval, payload.interval.toString());
this.chargingStation.addConfigurationKey(OCPP16StandardParametersKey.HeartbeatInterval, payload.interval.toString(), false, false);
+ this.chargingStation.heartbeatSetInterval ? this.chargingStation.restartHeartbeat() : this.chargingStation.startHeartbeat();
} else if (payload.status === OCPP16RegistrationStatus.PENDING) {
logger.info(this.chargingStation.logPrefix() + ' Charging station in pending state on the central server');
} else {
- logger.info(this.chargingStation.logPrefix() + ' Charging station rejected by the central server');
+ logger.warn(this.chargingStation.logPrefix() + ' Charging station rejected by the central server');
}
}
const configuredMeterValueSampleInterval = this.chargingStation.getConfigurationKey(OCPP16StandardParametersKey.MeterValueSampleInterval);
this.chargingStation.startMeterValues(connectorId, configuredMeterValueSampleInterval ? Utils.convertToInt(configuredMeterValueSampleInterval.value) * 1000 : 60000);
} else {
- logger.error(this.chargingStation.logPrefix() + ' Starting transaction id ' + payload.transactionId.toString() + ' REJECTED with status ' + payload?.idTagInfo?.status + ', idTag ' + requestPayload.idTag);
+ logger.warn(this.chargingStation.logPrefix() + ' Starting transaction id ' + payload.transactionId.toString() + ' REJECTED with status ' + payload?.idTagInfo?.status + ', idTag ' + requestPayload.idTag);
this.chargingStation.resetTransactionOnConnector(connectorId);
await this.chargingStation.ocppRequestService.sendStatusNotification(connectorId, OCPP16ChargePointStatus.AVAILABLE);
this.chargingStation.getConnector(connectorId).status = OCPP16ChargePointStatus.AVAILABLE;
logger.info(this.chargingStation.logPrefix() + ' Transaction ' + requestPayload.transactionId.toString() + ' STOPPED on ' + this.chargingStation.stationInfo.chargingStationId + '#' + transactionConnectorId.toString());
this.chargingStation.resetTransactionOnConnector(transactionConnectorId);
} else {
- logger.error(this.chargingStation.logPrefix() + ' Stopping transaction id ' + requestPayload.transactionId.toString() + ' REJECTED with status ' + payload.idTagInfo?.status);
+ logger.warn(this.chargingStation.logPrefix() + ' Stopping transaction id ' + requestPayload.transactionId.toString() + ' REJECTED with status ' + payload.idTagInfo?.status);
}
}
// Check if wsConnection opened and charging station registered
if (this.chargingStation.isWebSocketOpen() && (this.chargingStation.isRegistered() || commandName === RequestCommand.BOOT_NOTIFICATION)) {
if (this.chargingStation.getEnableStatistics()) {
- this.chargingStation.statistics.addMessage(commandName, messageType);
+ this.chargingStation.performanceStatistics.addMessage(commandName, messageType);
}
// Yes: Send Message
this.chargingStation.wsConnection.send(messageToSend);
*/
async function responseCallback(payload: Record<string, unknown> | string, requestPayload: Record<string, unknown>): Promise<void> {
if (self.chargingStation.getEnableStatistics()) {
- self.chargingStation.statistics.addMessage(commandName, MessageType.CALL_RESULT_MESSAGE);
+ self.chargingStation.performanceStatistics.addMessage(commandName, MessageType.CALL_RESULT_MESSAGE);
}
// Send the response
await self.ocppResponseService.handleResponse(commandName as RequestCommand, payload, requestPayload);
*/
function rejectCallback(error: OCPPError): void {
if (self.chargingStation.getEnableStatistics()) {
- self.chargingStation.statistics.addMessage(commandName, MessageType.CALL_ERROR_MESSAGE);
+ self.chargingStation.performanceStatistics.addMessage(commandName, MessageType.CALL_ERROR_MESSAGE);
}
logger.debug(`${self.chargingStation.logPrefix()} Error: %j occurred when calling command %s with parameters: %j`, error, commandName, commandParams);
// Build Exception
import Utils from './Utils';
import logger from './Logger';
-export default class Statistics {
+export default class PerformanceStatistics {
private objId: string;
private commandsStatistics: CommandStatistics;
}
break;
default:
- logger.error(`${this.logPrefix()} Wrong message type ${messageType}`);
+ logger.error(`${this.logPrefix()} wrong message type ${messageType}`);
break;
}
}
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()} ${className} method(s) entry: %j`, perfEntry);
}
public start(): void {
}
private logPrefix(): string {
- return Utils.logPrefix(` ${this.objId} Statistics:`);
+ return Utils.logPrefix(` ${this.objId} | Performance statistics`);
}
}