{
"key": "SupportedFeatureProfiles",
"readonly": true,
- "value": "Core,FirmwareManagement,LocalAuthListManagement,SmartCharging,RemoteTrigger"
+ "value": "Core,FirmwareManagement,LocalAuthListManagement,SmartCharging,RemoteTrigger,Reservation"
},
{
"key": "LocalAuthListEnabled",
// 2,
// )}`,
// );
+ if (isNullOrUndefined(msg?.event)) {
+ return;
+ }
try {
- switch (msg.id) {
+ switch (msg.event) {
case ChargingStationWorkerMessageEvents.started:
this.workerEventStarted(msg.data as ChargingStationData);
this.emit(ChargingStationWorkerMessageEvents.started, msg.data as ChargingStationData);
break;
default:
throw new BaseError(
- `Unknown event type: '${msg.id}' for data: ${JSON.stringify(msg.data, null, 2)}`,
+ `Unknown event type: '${msg.event}' for data: ${JSON.stringify(msg.data, null, 2)}`,
);
}
} catch (error) {
logger.error(
`${this.logPrefix()} ${moduleName}.messageHandler: Error occurred while handling '${
- msg.id
+ msg.event
}' event:`,
error,
);
if (this.hasEvses) {
for (const evseStatus of this.evses.values()) {
for (const connectorStatus of evseStatus.connectors.values()) {
- if (connectorStatus.reservation!.expiryDate < now) {
+ if (connectorStatus.reservation && connectorStatus.reservation.expiryDate < now) {
await this.removeReservation(
- connectorStatus.reservation!,
+ connectorStatus.reservation,
ReservationTerminationReason.EXPIRED,
);
}
}
} else {
for (const connectorStatus of this.connectors.values()) {
- if (connectorStatus.reservation!.expiryDate < now) {
+ if (connectorStatus.reservation && connectorStatus.reservation.expiryDate < now) {
await this.removeReservation(
- connectorStatus.reservation!,
+ connectorStatus.reservation,
ReservationTerminationReason.EXPIRED,
);
}
super(moduleName);
// Add message listener to create and start charging station from the main thread
parentPort?.on('message', (message: WorkerMessage<ChargingStationWorkerData>) => {
- if (message.id === WorkerMessageEvents.startWorkerElement) {
+ if (message.event === WorkerMessageEvents.startWorkerElement) {
this.runInAsyncScope(
startChargingStation.bind(this) as (data?: ChargingStationWorkerData) => void,
this,
export type ChargingStationWorkerMessage<T extends ChargingStationWorkerMessageData> = Omit<
WorkerMessage<T>,
- 'id'
+ 'event'
> & {
- id: ChargingStationWorkerMessageEvents;
+ event: ChargingStationWorkerMessageEvents;
};
chargingStation: ChargingStation,
): ChargingStationWorkerMessage<ChargingStationData> => {
return {
- id: ChargingStationWorkerMessageEvents.started,
+ event: ChargingStationWorkerMessageEvents.started,
data: buildChargingStationDataPayload(chargingStation),
};
};
chargingStation: ChargingStation,
): ChargingStationWorkerMessage<ChargingStationData> => {
return {
- id: ChargingStationWorkerMessageEvents.stopped,
+ event: ChargingStationWorkerMessageEvents.stopped,
data: buildChargingStationDataPayload(chargingStation),
};
};
chargingStation: ChargingStation,
): ChargingStationWorkerMessage<ChargingStationData> => {
return {
- id: ChargingStationWorkerMessageEvents.updated,
+ event: ChargingStationWorkerMessageEvents.updated,
data: buildChargingStationDataPayload(chargingStation),
};
};
statistics: Statistics,
): ChargingStationWorkerMessage<Statistics> => {
return {
- id: ChargingStationWorkerMessageEvents.performanceStatistics,
+ event: ChargingStationWorkerMessageEvents.performanceStatistics,
data: statistics,
};
};
}
export interface WorkerMessage<T extends WorkerData> {
- id: WorkerMessageEvents;
+ event: WorkerMessageEvents;
data: T;
}