#!/usr/bin/env sh
-node -r source-map-support/register dist/start.cjs &
+node -r source-map-support/register dist/start.mjs &
node webui/start.js
routes:
- route: e-mobility-charging-stations-simulator.cfapps.sap.hana.ondemand.com
health-check-type: process
- command: node -r source-map-support/register dist/start.cjs
+ command: node -r source-map-support/register dist/start.mjs
env:
# OPTIMIZE_MEMORY: true
NODE_OPTIONS: --stack-trace-limit=1024 --max-old-space-size=768
"scripts": {
"prepare": "node prepare.js",
"build-requirements": "node build-requirements.js",
- "start": "npm run build && cross-env NODE_ENV=production node -r source-map-support/register dist/start.cjs",
- "start:esm": "npm run build && cross-env NODE_ENV=production node -r source-map-support/register dist/start.mjs",
- "start:dev": "npm run build:dev && cross-env NODE_ENV=development node -r source-map-support/register dist/start.cjs",
- "start:dev:debug": "npm run build:dev && cross-env NODE_ENV=development node -r source-map-support/register --inspect dist/start.cjs",
- "start:dev:esm": "npm run build:dev && cross-env NODE_ENV=development node -r source-map-support/register dist/start.mjs",
- "start:dev:esm:debug": "npm run build:dev && cross-env NODE_ENV=development node -r source-map-support/register --inspect dist/start.mjs",
+ "start": "npm run build && cross-env NODE_ENV=production node -r source-map-support/register dist/start.mjs",
+ "start:cjs": "npm run build && cross-env NODE_ENV=production node -r source-map-support/register dist/start.cjs",
+ "start:dev": "npm run build:dev && cross-env NODE_ENV=development node -r source-map-support/register dist/start.mjs",
+ "start:dev:debug": "npm run build:dev && cross-env NODE_ENV=development node -r source-map-support/register --inspect dist/start.mjs",
+ "start:dev:cjs": "npm run build:dev && cross-env NODE_ENV=development node -r source-map-support/register dist/start.cjs",
+ "start:dev:cjs:debug": "npm run build:dev && cross-env NODE_ENV=development node -r source-map-support/register --inspect dist/start.cjs",
"start:prof": "cross-env NODE_ENV=production node -r source-map-support/register --prof dist/start.cjs",
- "start:doctorprof": "cross-env NODE_ENV=production clinic doctor -- node -r source-map-support/register dist/start.cjs",
- "start:flameprof": "cross-env NODE_ENV=production clinic flame -- node -r source-map-support/register dist/start.cjs",
- "start:bubbleprof": "cross-env NODE_ENV=production clinic bubbleprof -- node -r source-map-support/register dist/start.cjs",
- "start:heapprofiler": "cross-env NODE_ENV=production clinic heapprofiler -- node -r source-map-support/register dist/start.cjs",
+ "start:doctorprof": "cross-env NODE_ENV=production clinic doctor -- node -r source-map-support/register dist/start.mjs",
+ "start:flameprof": "cross-env NODE_ENV=production clinic flame -- node -r source-map-support/register dist/start.mjs",
+ "start:bubbleprof": "cross-env NODE_ENV=production clinic bubbleprof -- node -r source-map-support/register dist/start.mjs",
+ "start:heapprofiler": "cross-env NODE_ENV=production clinic heapprofiler -- node -r source-map-support/register dist/start.mjs",
"rollup": "npm run build-requirements && rollup --config",
"build": "npm run rollup",
"build:dev": "npm run rollup -- --environment BUILD:development",
RegistrationStatusEnumType,
RequestCommand,
type Response,
- type ResponseCallback,
StandardParametersKey,
type StatusNotificationRequest,
type StatusNotificationResponse,
}
public openWSConnection(
- options: WsOptions = this.stationInfo?.wsOptions ?? Constants.EMPTY_OBJECT,
+ options: WsOptions = this.stationInfo?.wsOptions ?? {},
params: { closeOpened?: boolean; terminateOpened?: boolean } = {
closeOpened: false,
terminateOpened: false,
},
reset: true,
},
- stationTemplate?.firmwareUpgrade ?? Constants.EMPTY_OBJECT
+ stationTemplate?.firmwareUpgrade ?? {}
);
stationInfo.resetTime = !Utils.isNullOrUndefined(stationTemplate?.resetTime)
? stationTemplate.resetTime * 1000
fs.mkdirSync(path.dirname(this.configurationFile), { recursive: true });
}
const configurationData: ChargingStationConfiguration =
- Utils.cloneObject(this.getConfigurationFromFile()) ?? Constants.EMPTY_OBJECT;
+ Utils.cloneObject(this.getConfigurationFromFile()) ?? {};
this.ocppConfiguration?.configurationKey &&
(configurationData.configurationKey = this.ocppConfiguration.configurationKey);
this.stationInfo && (configurationData.stationInfo = this.stationInfo);
);
this.openWSConnection(
{
- ...(this.stationInfo?.wsOptions ?? Constants.EMPTY_OBJECT),
+ ...(this.stationInfo?.wsOptions ?? {}),
handshakeTimeout: reconnectTimeout,
},
{ closeOpened: true }
},
params: AddConfigurationKeyParams = { overwrite: false, save: false }
): void {
- options = options ?? (Constants.EMPTY_OBJECT as ConfigurationKeyOptions);
+ options = options ?? ({} as ConfigurationKeyOptions);
options.readonly = options?.readonly ?? false;
options.visible = options?.visible ?? true;
options.reboot = options?.reboot ?? false;
randomSerialNumber: true,
}
): void {
- params = params ?? Constants.EMPTY_OBJECT;
+ params = params ?? {};
params.randomSerialNumberUpperCase = params?.randomSerialNumberUpperCase ?? true;
params.randomSerialNumber = params?.randomSerialNumber ?? true;
const serialNumberSuffix = params?.randomSerialNumber
chargingStation,
OCPP16StandardParametersKey.HeartbeatInterval,
payload.interval.toString(),
- Constants.EMPTY_OBJECT,
+ {},
{ overwrite: true, save: true }
);
ChargingStationConfigurationUtils.addConfigurationKey(
connectorId,
OCPP16MeterValueMeasurand.POWER_ACTIVE_IMPORT
);
- let powerPerPhaseSampledValueTemplates: MeasurandPerPhaseSampledValueTemplates =
- Constants.EMPTY_OBJECT;
+ let powerPerPhaseSampledValueTemplates: MeasurandPerPhaseSampledValueTemplates = {};
if (chargingStation.getNumberOfPhases() === 3) {
powerPerPhaseSampledValueTemplates = {
L1: OCPP16ServiceUtils.getSampledValueTemplate(
powerSampledValueTemplate.measurand ??
OCPP16MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
} measurand value`;
- const powerMeasurandValues = Constants.EMPTY_OBJECT as MeasurandValues;
+ const powerMeasurandValues = {} as MeasurandValues;
const unitDivider = powerSampledValueTemplate?.unit === MeterValueUnit.KILO_WATT ? 1000 : 1;
const connectorMaximumAvailablePower =
chargingStation.getConnectorMaximumAvailablePower(connectorId);
connectorId,
OCPP16MeterValueMeasurand.CURRENT_IMPORT
);
- let currentPerPhaseSampledValueTemplates: MeasurandPerPhaseSampledValueTemplates =
- Constants.EMPTY_OBJECT;
+ let currentPerPhaseSampledValueTemplates: MeasurandPerPhaseSampledValueTemplates = {};
if (chargingStation.getNumberOfPhases() === 3) {
currentPerPhaseSampledValueTemplates = {
L1: OCPP16ServiceUtils.getSampledValueTemplate(
currentSampledValueTemplate.measurand ??
OCPP16MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
} measurand value`;
- const currentMeasurandValues: MeasurandValues = Constants.EMPTY_OBJECT as MeasurandValues;
+ const currentMeasurandValues: MeasurandValues = {} as MeasurandValues;
const connectorMaximumAvailablePower =
chargingStation.getConnectorMaximumAvailablePower(connectorId);
let connectorMaximumAmperage: number;
chargingStation,
OCPP20OptionalVariableName.HeartbeatInterval,
payload.interval.toString(),
- Constants.EMPTY_OBJECT,
+ {},
{ overwrite: true, save: true }
);
chargingStation.heartbeatSetInterval
const entryName = entry.name;
// Initialize command statistics
if (!this.statistics.statisticsData.has(entryName)) {
- this.statistics.statisticsData.set(entryName, Constants.EMPTY_OBJECT);
+ this.statistics.statisticsData.set(entryName, {});
}
// Update current statistics
this.statistics.updatedAt = new Date();
static readonly MAX_RANDOM_INTEGER = 281474976710654;
- static EMPTY_OBJECT = {};
static readonly EMPTY_FREEZED_OBJECT = Object.freeze({});
static readonly EMPTY_FUNCTION = Object.freeze(() => {
/* This is intentional */
poolMinSize: WorkerConstants.DEFAULT_POOL_MIN_SIZE,
poolMaxSize: WorkerConstants.DEFAULT_POOL_MAX_SIZE,
elementsPerWorker: WorkerConstants.DEFAULT_ELEMENTS_PER_WORKER,
- poolOptions: WorkerConstants.EMPTY_OBJECT,
+ poolOptions: {},
messageHandler: WorkerConstants.EMPTY_FUNCTION,
}
) {
export class WorkerConstants {
- public static EMPTY_OBJECT = {};
public static readonly EMPTY_FUNCTION = Object.freeze(() => {
/* This is intentional */
});
if (!isMainThread) {
throw new Error('Cannot get a worker implementation outside the main thread');
}
- workerOptions = workerOptions ?? (WorkerConstants.EMPTY_OBJECT as WorkerOptions);
+ workerOptions = workerOptions ?? ({} as WorkerOptions);
workerOptions.workerStartDelay =
workerOptions?.workerStartDelay ?? WorkerConstants.DEFAULT_WORKER_START_DELAY;
workerOptions.elementStartDelay =
workerOptions?.elementStartDelay ?? WorkerConstants.DEFAULT_ELEMENT_START_DELAY;
- workerOptions.poolOptions =
- workerOptions?.poolOptions ?? (WorkerConstants.EMPTY_OBJECT as PoolOptions<Worker>);
+ workerOptions.poolOptions = workerOptions?.poolOptions ?? ({} as PoolOptions<Worker>);
workerOptions?.messageHandler &&
(workerOptions.poolOptions.messageHandler = workerOptions.messageHandler);
let workerImplementation: WorkerAbstract<T> | null = null;