automaticTransactionGeneratorConfiguration: AutomaticTransactionGeneratorConfiguration,
chargingStation: ChargingStation
): AutomaticTransactionGenerator {
- if (!AutomaticTransactionGenerator.instances.has(chargingStation.hashId)) {
+ if (!AutomaticTransactionGenerator.instances.has(chargingStation.stationInfo.hashId)) {
AutomaticTransactionGenerator.instances.set(
- chargingStation.hashId,
+ chargingStation.stationInfo.hashId,
new AutomaticTransactionGenerator(
automaticTransactionGeneratorConfiguration,
chargingStation
)
);
}
- return AutomaticTransactionGenerator.instances.get(chargingStation.hashId);
+ return AutomaticTransactionGenerator.instances.get(chargingStation.stationInfo.hashId);
}
public start(): void {
}
private workerEventStarted(data: ChargingStationData) {
- this.uiServer?.chargingStations.set(data.hashId, data);
+ this.uiServer?.chargingStations.set(data.stationInfo.hashId, data);
++this.numberOfStartedChargingStations;
}
private workerEventStopped(data: ChargingStationData) {
- this.uiServer?.chargingStations.set(data.hashId, data);
+ this.uiServer?.chargingStations.set(data.stationInfo.hashId, data);
--this.numberOfStartedChargingStations;
}
private workerEventUpdated(data: ChargingStationData) {
- this.uiServer?.chargingStations.set(data.hashId, data);
+ this.uiServer?.chargingStations.set(data.stationInfo.hashId, data);
}
private workerEventPerformanceStatistics = (data: Statistics) => {
import SharedLRUCache from './SharedLRUCache';
export default class ChargingStation {
- public hashId!: string;
public readonly templateFile: string;
public authorizedTagsCache: AuthorizedTagsCache;
public stationInfo!: ChargingStationInfo;
);
const stationInfo: ChargingStationInfo =
ChargingStationUtils.stationTemplateToStationInfo(stationTemplate);
+ stationInfo.hashId = ChargingStationUtils.getHashId(this.index, stationTemplate);
stationInfo.chargingStationId = ChargingStationUtils.getChargingStationId(
this.index,
stationTemplate
}
private initialize(): void {
- this.hashId = ChargingStationUtils.getHashId(this.index, this.getTemplateFromFile());
- logger.info(`${this.logPrefix()} Charging station hashId '${this.hashId}'`);
+ this.stationInfo = this.getStationInfo();
+ this.saveStationInfo();
+ logger.info(`${this.logPrefix()} Charging station hashId '${this.stationInfo.hashId}'`);
this.configurationFile = path.join(
path.dirname(this.templateFile.replace('station-templates', 'configurations')),
- this.hashId + '.json'
+ this.stationInfo.hashId + '.json'
);
- this.stationInfo = this.getStationInfo();
- this.saveStationInfo();
// Avoid duplication of connectors related information in RAM
this.stationInfo?.Connectors && delete this.stationInfo.Connectors;
this.configuredSupervisionUrl = this.getConfiguredSupervisionUrl();
if (this.getEnableStatistics()) {
this.performanceStatistics = PerformanceStatistics.getInstance(
- this.hashId,
+ this.stationInfo.hashId,
this.stationInfo.chargingStationId,
this.configuredSupervisionUrl
);
delete stationTemplate.chargeBoxSerialNumberPrefix;
delete stationTemplate.chargePointSerialNumberPrefix;
delete stationTemplate.meterSerialNumberPrefix;
- return stationTemplate;
+ return stationTemplate as unknown as ChargingStationInfo;
}
public static createStationInfoHash(stationInfo: ChargingStationInfo): void {
if (
requestPayload?.hashId === undefined &&
- (requestPayload?.hashIds as string[])?.includes(this.chargingStation.hashId) === false
+ (requestPayload?.hashIds as string[])?.includes(this.chargingStation.stationInfo.hashId) ===
+ false
) {
return;
}
if (
requestPayload?.hashIds === undefined &&
- requestPayload?.hashId !== this.chargingStation.hashId
+ requestPayload?.hashId !== this.chargingStation.stationInfo.hashId
) {
return;
}
commandResponse = await this.commandHandler(command, requestPayload);
if (commandResponse === undefined) {
responsePayload = {
- hashId: this.chargingStation.hashId,
+ hashId: this.chargingStation.stationInfo.hashId,
status: ResponseStatus.SUCCESS,
};
} else {
responsePayload = {
- hashId: this.chargingStation.hashId,
+ hashId: this.chargingStation.stationInfo.hashId,
status: this.commandResponseToResponseStatus(commandResponse),
};
}
error
);
responsePayload = {
- hashId: this.chargingStation.hashId,
+ hashId: this.chargingStation.stationInfo.hashId,
status: ResponseStatus.FAILURE,
command,
requestPayload,
chargingStation: ChargingStation
): ChargingStationData {
return {
- hashId: chargingStation.hashId,
stationInfo: chargingStation.stationInfo,
stopped: chargingStation.stopped,
bootNotificationResponse: chargingStation.bootNotificationResponse,
| 'chargePointSerialNumberPrefix'
| 'meterSerialNumberPrefix'
> {
+ hashId: string;
infoHash?: string;
chargingStationId?: string;
chargeBoxSerialNumber?: string;
}
export interface ChargingStationData extends WorkerData {
- hashId: string;
stationInfo: ChargingStationInfo;
stopped: boolean;
bootNotificationResponse: BootNotificationResponse;
const props = defineProps<{
hashId: string;
connector: ConnectorStatus;
- transactionId?: number;
connectorId: number;
+ transactionId?: number;
idTag?: string;
}>();
// idTag: '',
// });
-function getHashId(): string {
- return props.chargingStation.hashId;
-}
function getConnectors(): ConnectorStatus[] {
return props.chargingStation.connectors?.slice(1);
}
function getInfo(): ChargingStationInfo {
return props.chargingStation.stationInfo;
}
+function getHashId(): string {
+ return getInfo().hashId;
+}
function getId(): string {
return Utils.ifUndefined<string>(getInfo().chargingStationId, 'Ø');
}
<tbody id="cs-table__body">
<CSData
v-for="chargingStation in chargingStations"
- :key="chargingStation.hashId"
+ :key="chargingStation.stationInfo.hashId"
:charging-station="chargingStation"
:idTag="props.idTag"
/>
import type { JsonObject } from './JsonType';
export type ChargingStationData = {
- hashId: string;
stationInfo: ChargingStationInfo;
stopped: boolean;
bootNotificationResponse: BootNotificationResponse;
};
export type ChargingStationInfo = {
+ hashId: string;
chargingStationId?: string;
chargePointModel: string;
chargePointVendor: string;
+import { threadId } from 'worker_threads';
+
import chalk from 'chalk';
export class WorkerUtils {
public static defaultExitHandler = (code: number): void => {
if (code !== 0) {
- console.error(chalk.red(`Worker stopped with exit code ${code}`));
+ console.error(chalk.red(`Worker ${threadId} stopped with exit code ${code}`));
}
};
}