import BaseError from '../exception/BaseError';
import OCPPError from '../exception/OCPPError';
import PerformanceStatistics from '../performance/PerformanceStatistics';
-import { AutomaticTransactionGeneratorConfiguration } from '../types/AutomaticTransactionGenerator';
-import ChargingStationConfiguration from '../types/ChargingStationConfiguration';
-import ChargingStationInfo from '../types/ChargingStationInfo';
-import ChargingStationOcppConfiguration from '../types/ChargingStationOcppConfiguration';
+import type { AutomaticTransactionGeneratorConfiguration } from '../types/AutomaticTransactionGenerator';
+import type ChargingStationConfiguration from '../types/ChargingStationConfiguration';
+import type ChargingStationInfo from '../types/ChargingStationInfo';
+import type ChargingStationOcppConfiguration from '../types/ChargingStationOcppConfiguration';
import ChargingStationTemplate, {
CurrentType,
PowerUnits,
WsOptions,
} from '../types/ChargingStationTemplate';
import { SupervisionUrlDistribution } from '../types/ConfigurationData';
-import { ConnectorStatus } from '../types/ConnectorStatus';
+import type { ConnectorStatus } from '../types/ConnectorStatus';
import { FileType } from '../types/FileType';
-import { JsonType } from '../types/JsonType';
+import type { JsonType } from '../types/JsonType';
import { ChargePointErrorCode } from '../types/ocpp/ChargePointErrorCode';
import { ChargePointStatus } from '../types/ocpp/ChargePointStatus';
import { ChargingProfile, ChargingRateUnitType } from '../types/ocpp/ChargingProfile';
import OCPP16RequestService from './ocpp/1.6/OCPP16RequestService';
import OCPP16ResponseService from './ocpp/1.6/OCPP16ResponseService';
import { OCPP16ServiceUtils } from './ocpp/1.6/OCPP16ServiceUtils';
-import OCPPIncomingRequestService from './ocpp/OCPPIncomingRequestService';
-import OCPPRequestService from './ocpp/OCPPRequestService';
+import type OCPPIncomingRequestService from './ocpp/OCPPIncomingRequestService';
+import type OCPPRequestService from './ocpp/OCPPRequestService';
import SharedLRUCache from './SharedLRUCache';
export default class ChargingStation {
: true;
}
- public getMayAuthorizeAtRemoteStart(): boolean | undefined {
- return this.stationInfo.mayAuthorizeAtRemoteStart ?? true;
+ public getMustAuthorizeAtRemoteStart(): boolean | undefined {
+ return this.stationInfo.mustAuthorizeAtRemoteStart ?? true;
}
public getPayloadSchemaValidation(): boolean | undefined {
this.templateFileWatcher.close();
this.sharedLRUCache.deleteChargingStationTemplate(this.stationInfo?.templateHash);
this.bootNotificationResponse = null;
- parentPort.postMessage(MessageChannelUtils.buildStoppedMessage(this));
this.stopped = true;
+ parentPort.postMessage(MessageChannelUtils.buildStoppedMessage(this));
}
public async reset(reason?: StopTransactionReason): Promise<void> {
if (!Utils.isEmptyArray(chargingProfiles)) {
const result = ChargingStationUtils.getLimitFromChargingProfiles(
chargingProfiles,
- Utils.logPrefix()
+ this.logPrefix()
);
if (!Utils.isNullOrUndefined(result)) {
limit = result.limit;
ChargingStationUtils.checkConfiguredMaxConnectors(
configuredMaxConnectors,
this.templateFile,
- Utils.logPrefix()
+ this.logPrefix()
);
const templateMaxConnectors =
ChargingStationUtils.getTemplateMaxNumberOfConnectors(stationTemplate);
ChargingStationUtils.checkTemplateMaxConnectors(
templateMaxConnectors,
this.templateFile,
- Utils.logPrefix()
+ this.logPrefix()
);
if (
configuredMaxConnectors >
}
private handleUnsupportedVersion(version: OCPPVersion) {
- const errMsg = `${this.logPrefix()} Unsupported protocol version '${version}' configured in template file ${
- this.templateFile
- }`;
- logger.error(errMsg);
+ const errMsg = `Unsupported protocol version '${version}' configured in template file ${this.templateFile}`;
+ logger.error(`${this.logPrefix()} ${errMsg}`);
throw new BaseError(errMsg);
}
templateMaxConnectors: number
): void {
if (!stationInfo?.Connectors && this.connectors.size === 0) {
- const logMsg = `${this.logPrefix()} No already defined connectors and charging station information from template ${
- this.templateFile
- } with no connectors configuration defined`;
- logger.error(logMsg);
+ const logMsg = `No already defined connectors and charging station information from template ${this.templateFile} with no connectors configuration defined`;
+ logger.error(`${this.logPrefix()} ${logMsg}`);
throw new BaseError(logMsg);
}
if (!stationInfo?.Connectors[0]) {
// Error
default:
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
- errMsg = `${this.logPrefix()} Wrong message type ${messageType}`;
- logger.error(errMsg);
+ errMsg = `Wrong message type ${messageType}`;
+ logger.error(`${this.logPrefix()} ${errMsg}`);
throw new OCPPError(ErrorType.PROTOCOL_ERROR, errMsg);
}
parentPort.postMessage(MessageChannelUtils.buildUpdatedMessage(this));
} catch (error) {
// Log
logger.error(
- "%s Incoming OCPP '%s' message '%j' matching cached request '%j' processing error:",
- this.logPrefix(),
- commandName ?? requestCommandName ?? null,
- data.toString(),
- this.requests.get(messageId),
+ `${this.logPrefix()} Incoming OCPP command '${
+ commandName ?? requestCommandName ?? null
+ }' message '${data.toString()}' matching cached request '${JSON.stringify(
+ this.requests.get(messageId)
+ )}' processing error:`,
error
);
if (!(error instanceof OCPPError)) {
logger.warn(
- "%s Error thrown at incoming OCPP '%s' message '%j' handling is not an OCPPError:",
- this.logPrefix(),
- commandName ?? requestCommandName ?? null,
- data.toString(),
+ `${this.logPrefix()} Error thrown at incoming OCPP command '${
+ commandName ?? requestCommandName ?? null
+ }' message '${data.toString()}' handling is not an OCPPError:`,
error
);
}