import { AsyncResource } from 'async_hooks';
+import type ChargingStation from './ChargingStation';
+import { ChargingStationUtils } from './ChargingStationUtils';
import BaseError from '../exception/BaseError';
import PerformanceStatistics from '../performance/PerformanceStatistics';
import {
import Constants from '../utils/Constants';
import logger from '../utils/Logger';
import Utils from '../utils/Utils';
-import type ChargingStation from './ChargingStation';
-import { ChargingStationUtils } from './ChargingStationUtils';
const moduleName = 'AutomaticTransactionGenerator';
import chalk from 'chalk';
+import { ChargingStationUtils } from './ChargingStationUtils';
+import type { AbstractUIServer } from './ui-server/AbstractUIServer';
+import UIServerFactory from './ui-server/UIServerFactory';
import { version } from '../../package.json';
import BaseError from '../exception/BaseError';
import type { Storage } from '../performance/storage/Storage';
import Utils from '../utils/Utils';
import type WorkerAbstract from '../worker/WorkerAbstract';
import WorkerFactory from '../worker/WorkerFactory';
-import { ChargingStationUtils } from './ChargingStationUtils';
-import type { AbstractUIServer } from './ui-server/AbstractUIServer';
-import UIServerFactory from './ui-server/UIServerFactory';
const moduleName = 'Bootstrap';
import merge from 'just-merge';
import WebSocket, { type RawData } from 'ws';
+import AuthorizedTagsCache from './AuthorizedTagsCache';
+import AutomaticTransactionGenerator from './AutomaticTransactionGenerator';
+import { ChargingStationConfigurationUtils } from './ChargingStationConfigurationUtils';
+import { ChargingStationUtils } from './ChargingStationUtils';
+import ChargingStationWorkerBroadcastChannel from './ChargingStationWorkerBroadcastChannel';
+import { MessageChannelUtils } from './MessageChannelUtils';
+import OCPP16IncomingRequestService from './ocpp/1.6/OCPP16IncomingRequestService';
+import OCPP16RequestService from './ocpp/1.6/OCPP16RequestService';
+import OCPP16ResponseService from './ocpp/1.6/OCPP16ResponseService';
+import { OCPP16ServiceUtils } from './ocpp/1.6/OCPP16ServiceUtils';
+import OCPP20IncomingRequestService from './ocpp/2.0/OCPP20IncomingRequestService';
+import OCPP20RequestService from './ocpp/2.0/OCPP20RequestService';
+import OCPP20ResponseService from './ocpp/2.0/OCPP20ResponseService';
+import type OCPPIncomingRequestService from './ocpp/OCPPIncomingRequestService';
+import type OCPPRequestService from './ocpp/OCPPRequestService';
+import { OCPPServiceUtils } from './ocpp/OCPPServiceUtils';
+import SharedLRUCache from './SharedLRUCache';
import BaseError from '../exception/BaseError';
import OCPPError from '../exception/OCPPError';
import PerformanceStatistics from '../performance/PerformanceStatistics';
import FileUtils from '../utils/FileUtils';
import logger from '../utils/Logger';
import Utils from '../utils/Utils';
-import AuthorizedTagsCache from './AuthorizedTagsCache';
-import AutomaticTransactionGenerator from './AutomaticTransactionGenerator';
-import { ChargingStationConfigurationUtils } from './ChargingStationConfigurationUtils';
-import { ChargingStationUtils } from './ChargingStationUtils';
-import ChargingStationWorkerBroadcastChannel from './ChargingStationWorkerBroadcastChannel';
-import { MessageChannelUtils } from './MessageChannelUtils';
-import OCPP16IncomingRequestService from './ocpp/1.6/OCPP16IncomingRequestService';
-import OCPP16RequestService from './ocpp/1.6/OCPP16RequestService';
-import OCPP16ResponseService from './ocpp/1.6/OCPP16ResponseService';
-import { OCPP16ServiceUtils } from './ocpp/1.6/OCPP16ServiceUtils';
-import OCPP20IncomingRequestService from './ocpp/2.0/OCPP20IncomingRequestService';
-import OCPP20RequestService from './ocpp/2.0/OCPP20RequestService';
-import OCPP20ResponseService from './ocpp/2.0/OCPP20ResponseService';
-import type OCPPIncomingRequestService from './ocpp/OCPPIncomingRequestService';
-import type OCPPRequestService from './ocpp/OCPPRequestService';
-import { OCPPServiceUtils } from './ocpp/OCPPServiceUtils';
-import SharedLRUCache from './SharedLRUCache';
export default class ChargingStation {
public readonly index: number;
+import type ChargingStation from './ChargingStation';
import type { ConfigurationKey } from '../types/ChargingStationOcppConfiguration';
import type { StandardParametersKey } from '../types/ocpp/Configuration';
import logger from '../utils/Logger';
-import type ChargingStation from './ChargingStation';
type ConfigurationKeyOptions = { readonly?: boolean; visible?: boolean; reboot?: boolean };
type DeleteConfigurationKeyParams = { save?: boolean; caseInsensitive?: boolean };
import { ThreadWorker } from 'poolifier';
+import ChargingStation from './ChargingStation';
+import { ChargingStationUtils } from './ChargingStationUtils';
import type { ChargingStationWorkerData } from '../types/ChargingStationWorker';
import { type WorkerMessage, WorkerMessageEvents } from '../types/Worker';
import Utils from '../utils/Utils';
import WorkerConstants from '../worker/WorkerConstants';
-import ChargingStation from './ChargingStation';
-import { ChargingStationUtils } from './ChargingStationUtils';
// Conditionally export ThreadWorker instance for pool usage
export let threadWorker: ThreadWorker;
+import type ChargingStation from './ChargingStation';
+import { ChargingStationConfigurationUtils } from './ChargingStationConfigurationUtils';
+import { OCPP16ServiceUtils } from './ocpp/1.6/OCPP16ServiceUtils';
+import WorkerBroadcastChannel from './WorkerBroadcastChannel';
import BaseError from '../exception/BaseError';
import type OCPPError from '../exception/OCPPError';
import { StandardParametersKey } from '../types/ocpp/Configuration';
import Constants from '../utils/Constants';
import logger from '../utils/Logger';
import Utils from '../utils/Utils';
-import type ChargingStation from './ChargingStation';
-import { ChargingStationConfigurationUtils } from './ChargingStationConfigurationUtils';
-import { OCPP16ServiceUtils } from './ocpp/1.6/OCPP16ServiceUtils';
-import WorkerBroadcastChannel from './WorkerBroadcastChannel';
const moduleName = 'ChargingStationWorkerBroadcastChannel';
+import type ChargingStation from './ChargingStation';
import {
type ChargingStationData,
type ChargingStationWorkerMessage,
ChargingStationWorkerMessageEvents,
} from '../types/ChargingStationWorker';
import type { Statistics } from '../types/Statistics';
-import type ChargingStation from './ChargingStation';
export class MessageChannelUtils {
private constructor() {
+import type AbstractUIService from './ui-server/ui-services/AbstractUIService';
+import WorkerBroadcastChannel from './WorkerBroadcastChannel';
import { type ResponsePayload, ResponseStatus } from '../types/UIProtocol';
import type {
BroadcastChannelResponse,
MessageEvent,
} from '../types/WorkerBroadcastChannel';
import logger from '../utils/Logger';
-import type AbstractUIService from './ui-server/ui-services/AbstractUIService';
-import WorkerBroadcastChannel from './WorkerBroadcastChannel';
const moduleName = 'UIServiceWorkerBroadcastChannel';
import { Client, type FTPResponse } from 'basic-ftp';
import tar from 'tar';
+import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
import OCPPError from '../../../exception/OCPPError';
import type { JsonObject, JsonType } from '../../../types/JsonType';
import { OCPP16ChargePointErrorCode } from '../../../types/ocpp/1.6/ChargePointErrorCode';
import { ChargingStationUtils } from '../../ChargingStationUtils';
import OCPPConstants from '../OCPPConstants';
import OCPPIncomingRequestService from '../OCPPIncomingRequestService';
-import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
const moduleName = 'OCPP16IncomingRequestService';
import type { JSONSchemaType } from 'ajv';
+import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
import OCPPError from '../../../exception/OCPPError';
import type { JsonObject, JsonType } from '../../../types/JsonType';
import type { OCPP16MeterValuesRequest } from '../../../types/ocpp/1.6/MeterValues';
import type ChargingStation from '../../ChargingStation';
import OCPPRequestService from '../OCPPRequestService';
import type OCPPResponseService from '../OCPPResponseService';
-import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
const moduleName = 'OCPP16RequestService';
import type { JSONSchemaType } from 'ajv';
+import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
import OCPPError from '../../../exception/OCPPError';
import type { JsonObject, JsonType } from '../../../types/JsonType';
import { OCPP16ChargePointErrorCode } from '../../../types/ocpp/1.6/ChargePointErrorCode';
import type ChargingStation from '../../ChargingStation';
import { ChargingStationConfigurationUtils } from '../../ChargingStationConfigurationUtils';
import OCPPResponseService from '../OCPPResponseService';
-import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
const moduleName = 'OCPP16ResponseService';
import type { JSONSchemaType } from 'ajv';
+import { OCPP20ServiceUtils } from './OCPP20ServiceUtils';
import OCPPError from '../../../exception/OCPPError';
import type { JsonObject, JsonType } from '../../../types/JsonType';
import {
import logger from '../../../utils/Logger';
import type ChargingStation from '../../ChargingStation';
import OCPPIncomingRequestService from '../OCPPIncomingRequestService';
-import { OCPP20ServiceUtils } from './OCPP20ServiceUtils';
const moduleName = 'OCPP20IncomingRequestService';
import type { JSONSchemaType } from 'ajv';
+import { OCPP20ServiceUtils } from './OCPP20ServiceUtils';
import OCPPError from '../../../exception/OCPPError';
import type { JsonObject, JsonType } from '../../../types/JsonType';
import {
import type ChargingStation from '../../ChargingStation';
import OCPPRequestService from '../OCPPRequestService';
import type OCPPResponseService from '../OCPPResponseService';
-import { OCPP20ServiceUtils } from './OCPP20ServiceUtils';
const moduleName = 'OCPP20RequestService';
import type { JSONSchemaType } from 'ajv';
+import { OCPP20ServiceUtils } from './OCPP20ServiceUtils';
import OCPPError from '../../../exception/OCPPError';
import type { JsonObject, JsonType } from '../../../types/JsonType';
import {
import logger from '../../../utils/Logger';
import type ChargingStation from '../../ChargingStation';
import OCPPResponseService from '../OCPPResponseService';
-import { OCPP20ServiceUtils } from './OCPP20ServiceUtils';
const moduleName = 'OCPP20ResponseService';
import Ajv, { type JSONSchemaType } from 'ajv';
import ajvFormats from 'ajv-formats';
+import OCPPConstants from './OCPPConstants';
+import { OCPPServiceUtils } from './OCPPServiceUtils';
import OCPPError from '../../exception/OCPPError';
import type { HandleErrorParams } from '../../types/Error';
import type { JsonObject, JsonType } from '../../types/JsonType';
import logger from '../../utils/Logger';
import type ChargingStation from '../ChargingStation';
import { ChargingStationUtils } from '../ChargingStationUtils';
-import OCPPConstants from './OCPPConstants';
-import { OCPPServiceUtils } from './OCPPServiceUtils';
const moduleName = 'OCPPIncomingRequestService';
import Ajv, { type JSONSchemaType } from 'ajv';
import ajvFormats from 'ajv-formats';
+import type OCPPResponseService from './OCPPResponseService';
+import { OCPPServiceUtils } from './OCPPServiceUtils';
import OCPPError from '../../exception/OCPPError';
import PerformanceStatistics from '../../performance/PerformanceStatistics';
import type { EmptyObject } from '../../types/EmptyObject';
import logger from '../../utils/Logger';
import Utils from '../../utils/Utils';
import type ChargingStation from '../ChargingStation';
-import type OCPPResponseService from './OCPPResponseService';
-import { OCPPServiceUtils } from './OCPPServiceUtils';
const moduleName = 'OCPPRequestService';
import Ajv, { type JSONSchemaType } from 'ajv';
import ajvFormats from 'ajv-formats';
+import { OCPPServiceUtils } from './OCPPServiceUtils';
import OCPPError from '../../exception/OCPPError';
import type { JsonObject, JsonType } from '../../types/JsonType';
import type { OCPPVersion } from '../../types/ocpp/OCPPVersion';
import type { IncomingRequestCommand, RequestCommand } from '../../types/ocpp/Requests';
import logger from '../../utils/Logger';
import type ChargingStation from '../ChargingStation';
-import { OCPPServiceUtils } from './OCPPServiceUtils';
const moduleName = 'OCPPResponseService';
import type { WebSocket } from 'ws';
+import type AbstractUIService from './ui-services/AbstractUIService';
+import UIServiceFactory from './ui-services/UIServiceFactory';
import type { ChargingStationData } from '../../types/ChargingStationWorker';
import type { UIServerConfiguration } from '../../types/ConfigurationData';
import {
type RequestPayload,
type ResponsePayload,
} from '../../types/UIProtocol';
-import type AbstractUIService from './ui-services/AbstractUIService';
-import UIServiceFactory from './ui-services/UIServiceFactory';
export abstract class AbstractUIServer {
public readonly chargingStations: Map<string, ChargingStationData>;
import { StatusCodes } from 'http-status-codes';
+import { AbstractUIServer } from './AbstractUIServer';
+import { UIServerUtils } from './UIServerUtils';
import BaseError from '../../exception/BaseError';
import type { UIServerConfiguration } from '../../types/ConfigurationData';
import {
} from '../../types/UIProtocol';
import logger from '../../utils/Logger';
import Utils from '../../utils/Utils';
-import { AbstractUIServer } from './AbstractUIServer';
-import { UIServerUtils } from './UIServerUtils';
const moduleName = 'UIHttpServer';
import chalk from 'chalk';
-import type { UIServerConfiguration } from '../../types/ConfigurationData';
-import { ApplicationProtocol } from '../../types/UIProtocol';
-import Configuration from '../../utils/Configuration';
import type { AbstractUIServer } from './AbstractUIServer';
import UIHttpServer from './UIHttpServer';
import { UIServerUtils } from './UIServerUtils';
import UIWebSocketServer from './UIWebSocketServer';
+import type { UIServerConfiguration } from '../../types/ConfigurationData';
+import { ApplicationProtocol } from '../../types/UIProtocol';
+import Configuration from '../../utils/Configuration';
export default class UIServerFactory {
private constructor() {
import { StatusCodes } from 'http-status-codes';
import WebSocket, { type RawData, WebSocketServer } from 'ws';
+import { AbstractUIServer } from './AbstractUIServer';
+import { UIServerUtils } from './UIServerUtils';
import type { UIServerConfiguration } from '../../types/ConfigurationData';
import type { ProtocolRequest, ProtocolResponse } from '../../types/UIProtocol';
import { WebSocketCloseEventStatusCode } from '../../types/WebSocket';
import logger from '../../utils/Logger';
import Utils from '../../utils/Utils';
-import { AbstractUIServer } from './AbstractUIServer';
-import { UIServerUtils } from './UIServerUtils';
const moduleName = 'UIWebSocketServer';
+import AbstractUIService from './AbstractUIService';
import {
ProcedureName,
type ProtocolRequestHandler,
ProtocolVersion,
} from '../../../types/UIProtocol';
import type { AbstractUIServer } from '../AbstractUIServer';
-import AbstractUIService from './AbstractUIService';
export default class UIService001 extends AbstractUIService {
constructor(uiServer: AbstractUIServer) {
-import { ProtocolVersion } from '../../../types/UIProtocol';
-import type { AbstractUIServer } from '../AbstractUIServer';
import type AbstractUIService from './AbstractUIService';
import UIService001 from './UIService001';
+import { ProtocolVersion } from '../../../types/UIProtocol';
+import type { AbstractUIServer } from '../AbstractUIServer';
export default class UIServiceFactory {
private constructor() {
// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
+import BaseError from './BaseError';
import type { JsonType } from '../types/JsonType';
import { ErrorType } from '../types/ocpp/ErrorType';
import type { IncomingRequestCommand, RequestCommand } from '../types/ocpp/Requests';
-import BaseError from './BaseError';
export default class OCPPError extends BaseError {
code: ErrorType;
import lockfile from 'proper-lockfile';
+import { Storage } from './Storage';
import { FileType } from '../../types/FileType';
import type { Statistics } from '../../types/Statistics';
import FileUtils from '../../utils/FileUtils';
import Utils from '../../utils/Utils';
-import { Storage } from './Storage';
export class JsonFileStorage extends Storage {
private fd: number | null = null;
import { Configuration, Connection, IDatabaseDriver, MikroORM, Options } from '@mikro-orm/core';
import { TsMorphMetadataProvider } from '@mikro-orm/reflection';
+import { Storage } from './Storage';
import { PerformanceData } from '../../types/orm/entities/PerformanceData';
import { PerformanceRecord } from '../../types/orm/entities/PerformanceRecord';
import type { Statistics } from '../../types/Statistics';
import { MikroORMDBType, StorageType } from '../../types/Storage';
import Constants from '../../utils/Constants';
-import { Storage } from './Storage';
export class MikroOrmStorage extends Storage {
private storageType: StorageType;
import { MongoClient } from 'mongodb';
+import { Storage } from './Storage';
import type { Statistics } from '../../types/Statistics';
import { StorageType } from '../../types/Storage';
import Constants from '../../utils/Constants';
-import { Storage } from './Storage';
export class MongoDBStorage extends Storage {
private readonly client: MongoClient | null;
// Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
-import { StorageType } from '../../types/Storage';
import { JsonFileStorage } from './JsonFileStorage';
import { MikroOrmStorage } from './MikroOrmStorage';
import { MongoDBStorage } from './MongoDBStorage';
import type { Storage } from './Storage';
+import { StorageType } from '../../types/Storage';
export class StorageFactory {
private constructor() {
-import type { CircularArray } from '../utils/CircularArray';
import type { IncomingRequestCommand, RequestCommand } from './ocpp/Requests';
import type { WorkerData } from './Worker';
+import type { CircularArray } from '../utils/CircularArray';
export type TimeSeries = {
timestamp: number;
-import type { EmptyObject } from '../../EmptyObject';
-import type { JsonObject } from '../../JsonType';
import type { OCPP16ChargePointErrorCode } from './ChargePointErrorCode';
import type { OCPP16ChargePointStatus } from './ChargePointStatus';
import type { ChargingProfilePurposeType, OCPP16ChargingProfile } from './ChargingProfile';
import type { OCPP16StandardParametersKey } from './Configuration';
import type { OCPP16DiagnosticsStatus } from './DiagnosticsStatus';
+import type { EmptyObject } from '../../EmptyObject';
+import type { JsonObject } from '../../JsonType';
export enum OCPP16RequestCommand {
BOOT_NOTIFICATION = 'BootNotification',
-import type { JsonObject } from '../../JsonType';
import type { OCPP16MeterValue } from './MeterValues';
+import type { JsonObject } from '../../JsonType';
export enum OCPP16StopTransactionReason {
NONE = '',
-import type { JsonObject } from '../JsonType';
import {
OCPP16StandardParametersKey,
OCPP16SupportedFeatureProfiles,
OCPP16VendorDefaultParametersKey,
} from './1.6/Configuration';
+import type { JsonObject } from '../JsonType';
export const StandardParametersKey = {
...OCPP16StandardParametersKey,
-import type ChargingStation from '../../charging-station/ChargingStation';
-import type OCPPError from '../../exception/OCPPError';
-import type { JsonType } from '../JsonType';
import { OCPP16DiagnosticsStatus } from './1.6/DiagnosticsStatus';
import type { OCPP16MeterValuesRequest } from './1.6/MeterValues';
import {
type OCPP20StatusNotificationRequest,
} from './2.0/Requests';
import type { MessageType } from './MessageType';
+import type ChargingStation from '../../charging-station/ChargingStation';
+import type OCPPError from '../../exception/OCPPError';
+import type { JsonType } from '../JsonType';
export const RequestCommand = {
...OCPP16RequestCommand,
-import type ChargingStation from '../../charging-station/ChargingStation';
-import type { JsonType } from '../JsonType';
import type { OCPP16MeterValuesResponse } from './1.6/MeterValues';
import {
OCPP16AvailabilityStatus,
} from './2.0/Responses';
import type { ErrorType } from './ErrorType';
import type { MessageType } from './MessageType';
+import type ChargingStation from '../../charging-station/ChargingStation';
+import type { JsonType } from '../JsonType';
export type Response = [MessageType.CALL_RESULT_MESSAGE, string, JsonType];
import merge from 'just-merge';
import { WorkerChoiceStrategies } from 'poolifier';
+import Constants from './Constants';
import {
type ConfigurationData,
type StationTemplateUrl,
import { ApplicationProtocol } from '../types/UIProtocol';
import { WorkerProcessType } from '../types/Worker';
import WorkerConstants from '../worker/WorkerConstants';
-import Constants from './Constants';
export default class Configuration {
private static configurationFile = path.join(
import chalk from 'chalk';
+import logger from './Logger';
+import Utils from './Utils';
import type { EmptyObject } from '../types/EmptyObject';
import type { HandleErrorParams } from '../types/Error';
import type { FileType } from '../types/FileType';
import type { JsonType } from '../types/JsonType';
-import logger from './Logger';
-import Utils from './Utils';
export default class FileUtils {
private constructor() {
import type { Format } from 'logform';
import { Logger, createLogger, format, transport } from 'winston';
-import DailyRotateFile from 'winston-daily-rotate-file';
import TransportType from 'winston/lib/winston/transports';
+import DailyRotateFile from 'winston-daily-rotate-file';
import Configuration from './Configuration';
import Utils from './Utils';
import fs from 'fs';
-import type { WorkerData, WorkerOptions } from '../types/Worker';
import WorkerConstants from './WorkerConstants';
+import type { WorkerData, WorkerOptions } from '../types/Worker';
export default abstract class WorkerAbstract<T extends WorkerData> {
protected readonly workerScript: string;
import { DynamicThreadPool, type ErrorHandler, type ExitHandler } from 'poolifier';
-import type { WorkerData, WorkerOptions } from '../types/Worker';
-import Utils from '../utils/Utils';
import WorkerAbstract from './WorkerAbstract';
import { WorkerUtils } from './WorkerUtils';
+import type { WorkerData, WorkerOptions } from '../types/Worker';
+import Utils from '../utils/Utils';
export default class WorkerDynamicPool extends WorkerAbstract<WorkerData> {
private readonly pool: DynamicThreadPool<WorkerData>;
import type { PoolOptions } from 'poolifier';
-import { type WorkerData, type WorkerOptions, WorkerProcessType } from '../types/Worker';
import type WorkerAbstract from './WorkerAbstract';
import WorkerConstants from './WorkerConstants';
import WorkerDynamicPool from './WorkerDynamicPool';
import WorkerSet from './WorkerSet';
import WorkerStaticPool from './WorkerStaticPool';
+import { type WorkerData, type WorkerOptions, WorkerProcessType } from '../types/Worker';
export default class WorkerFactory {
private constructor() {
import { Worker } from 'worker_threads';
+import WorkerAbstract from './WorkerAbstract';
+import { WorkerUtils } from './WorkerUtils';
import {
type MessageHandler,
type WorkerData,
type WorkerSetElement,
} from '../types/Worker';
import Utils from '../utils/Utils';
-import WorkerAbstract from './WorkerAbstract';
-import { WorkerUtils } from './WorkerUtils';
export default class WorkerSet extends WorkerAbstract<WorkerData> {
private readonly workerSet: Set<WorkerSetElement>;
import { type ErrorHandler, type ExitHandler, FixedThreadPool } from 'poolifier';
-import type { WorkerData, WorkerOptions } from '../types/Worker';
-import Utils from '../utils/Utils';
import WorkerAbstract from './WorkerAbstract';
import { WorkerUtils } from './WorkerUtils';
+import type { WorkerData, WorkerOptions } from '../types/Worker';
+import Utils from '../utils/Utils';
export default class WorkerStaticPool extends WorkerAbstract<WorkerData> {
private readonly pool: FixedThreadPool<WorkerData>;