// );
try {
switch (msg.id) {
- case ChargingStationWorkerMessageEvents.STARTED:
+ case ChargingStationWorkerMessageEvents.started:
this.workerEventStarted(msg.data as ChargingStationData);
break;
- case ChargingStationWorkerMessageEvents.STOPPED:
+ case ChargingStationWorkerMessageEvents.stopped:
this.workerEventStopped(msg.data as ChargingStationData);
break;
- case ChargingStationWorkerMessageEvents.UPDATED:
+ case ChargingStationWorkerMessageEvents.updated:
this.workerEventUpdated(msg.data as ChargingStationData);
break;
- case ChargingStationWorkerMessageEvents.PERFORMANCE_STATISTICS:
+ case ChargingStationWorkerMessageEvents.performanceStatistics:
this.workerEventPerformanceStatistics(msg.data as Statistics);
break;
default:
(this.isChargingStationAvailable() === false ||
this.isConnectorAvailable(connectorId) === false)
) {
- connectorStatus = ConnectorStatusEnum.UNAVAILABLE;
+ connectorStatus = ConnectorStatusEnum.Unavailable;
} else if (
!this.getConnectorStatus(connectorId)?.status &&
this.getConnectorStatus(connectorId)?.bootStatus
connectorStatus = this.getConnectorStatus(connectorId)?.status;
} else {
// Set default status
- connectorStatus = ConnectorStatusEnum.AVAILABLE;
+ connectorStatus = ConnectorStatusEnum.Available;
}
await this.ocppRequestService.requestHandler<
StatusNotificationRequest,
OCPPServiceUtils.buildStatusNotificationRequest(
this,
connectorId,
- ConnectorStatusEnum.UNAVAILABLE
+ ConnectorStatusEnum.Unavailable
)
);
this.getConnectorStatus(connectorId).status = undefined;
}
public static workerPoolInUse(): boolean {
- return [WorkerProcessType.DYNAMIC_POOL, WorkerProcessType.STATIC_POOL].includes(
+ return [WorkerProcessType.dynamicPool, WorkerProcessType.staticPool].includes(
Configuration.getWorker().processType
);
}
public static workerDynamicPoolInUse(): boolean {
- return Configuration.getWorker().processType === WorkerProcessType.DYNAMIC_POOL;
+ return Configuration.getWorker().processType === WorkerProcessType.dynamicPool;
}
public static warnDeprecatedTemplateKey(
*/
function addMessageListener(): void {
parentPort?.on('message', (message: WorkerMessage<ChargingStationWorkerData>) => {
- if (message.id === WorkerMessageEvents.START_WORKER_ELEMENT) {
+ if (message.id === WorkerMessageEvents.startWorkerElement) {
startChargingStation(message.data);
}
});
chargingStation: ChargingStation
): ChargingStationWorkerMessage<ChargingStationData> {
return {
- id: ChargingStationWorkerMessageEvents.STARTED,
+ id: ChargingStationWorkerMessageEvents.started,
data: MessageChannelUtils.buildChargingStationDataPayload(chargingStation),
};
}
chargingStation: ChargingStation
): ChargingStationWorkerMessage<ChargingStationData> {
return {
- id: ChargingStationWorkerMessageEvents.STOPPED,
+ id: ChargingStationWorkerMessageEvents.stopped,
data: MessageChannelUtils.buildChargingStationDataPayload(chargingStation),
};
}
chargingStation: ChargingStation
): ChargingStationWorkerMessage<ChargingStationData> {
return {
- id: ChargingStationWorkerMessageEvents.UPDATED,
+ id: ChargingStationWorkerMessageEvents.updated,
data: MessageChannelUtils.buildChargingStationDataPayload(chargingStation),
};
}
statistics: Statistics
): ChargingStationWorkerMessage<Statistics> {
return {
- id: ChargingStationWorkerMessageEvents.PERFORMANCE_STATISTICS,
+ id: ChargingStationWorkerMessageEvents.performanceStatistics,
data: statistics,
};
}
OCPP16StatusNotificationResponse
>(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, {
connectorId,
- status: OCPP16ChargePointStatus.AVAILABLE,
+ status: OCPP16ChargePointStatus.Available,
errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
});
- chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.AVAILABLE;
+ chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.Available;
return OCPPConstants.OCPP_RESPONSE_UNLOCKED;
}
}
const chargePointStatus: OCPP16ChargePointStatus =
commandPayload.type === OCPP16AvailabilityType.OPERATIVE
- ? OCPP16ChargePointStatus.AVAILABLE
- : OCPP16ChargePointStatus.UNAVAILABLE;
+ ? OCPP16ChargePointStatus.Available
+ : OCPP16ChargePointStatus.Unavailable;
if (connectorId === 0) {
let response: ChangeAvailabilityResponse = OCPPConstants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED;
for (const id of chargingStation.connectors.keys()) {
OCPP16StatusNotificationResponse
>(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, {
connectorId: transactionConnectorId,
- status: OCPP16ChargePointStatus.PREPARING,
+ status: OCPP16ChargePointStatus.Preparing,
errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
});
const connectorStatus = chargingStation.getConnectorStatus(transactionConnectorId);
- connectorStatus.status = OCPP16ChargePointStatus.PREPARING;
+ connectorStatus.status = OCPP16ChargePointStatus.Preparing;
if (chargingStation.isChargingStationAvailable() === true) {
// Check if authorized
if (chargingStation.getAuthorizeRemoteTxRequests() === true) {
idTag: string
): Promise<GenericResponse> {
if (
- chargingStation.getConnectorStatus(connectorId)?.status !== OCPP16ChargePointStatus.AVAILABLE
+ chargingStation.getConnectorStatus(connectorId)?.status !== OCPP16ChargePointStatus.Available
) {
await chargingStation.ocppRequestService.requestHandler<
OCPP16StatusNotificationRequest,
OCPP16StatusNotificationResponse
>(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, {
connectorId,
- status: OCPP16ChargePointStatus.AVAILABLE,
+ status: OCPP16ChargePointStatus.Available,
errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
});
- chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.AVAILABLE;
+ chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.Available;
}
logger.warn(
`${chargingStation.logPrefix()} Remote starting transaction REJECTED on connector Id ${connectorId.toString()}, idTag '${idTag}', availability '${
OCPP16StatusNotificationResponse
>(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, {
connectorId,
- status: OCPP16ChargePointStatus.FINISHING,
+ status: OCPP16ChargePointStatus.Finishing,
errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
});
- chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.FINISHING;
+ chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.Finishing;
const stopResponse = await chargingStation.stopTransactionOnConnector(
connectorId,
OCPP16StopTransactionReason.REMOTE
OCPP16StatusNotificationResponse
>(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, {
connectorId,
- status: OCPP16ChargePointStatus.UNAVAILABLE,
+ status: OCPP16ChargePointStatus.Unavailable,
errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
});
chargingStation.getConnectorStatus(connectorId).status =
- OCPP16ChargePointStatus.UNAVAILABLE;
+ OCPP16ChargePointStatus.Unavailable;
}
}
if (
}
if (
chargingStation.getConnectorStatus(connectorId)?.status !==
- OCPP16ChargePointStatus.AVAILABLE &&
- chargingStation.getConnectorStatus(connectorId)?.status !== OCPP16ChargePointStatus.PREPARING
+ OCPP16ChargePointStatus.Available &&
+ chargingStation.getConnectorStatus(connectorId)?.status !== OCPP16ChargePointStatus.Preparing
) {
logger.error(
`${chargingStation.logPrefix()} Trying to start a transaction on connector ${connectorId.toString()} with status ${
OCPP16StatusNotificationResponse
>(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, {
connectorId,
- status: OCPP16ChargePointStatus.CHARGING,
+ status: OCPP16ChargePointStatus.Charging,
errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
});
- chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.CHARGING;
+ chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.Charging;
logger.info(
`${chargingStation.logPrefix()} Transaction ${payload.transactionId.toString()} STARTED on ${
chargingStation.stationInfo.chargingStationId
): Promise<void> {
chargingStation.resetConnectorStatus(connectorId);
if (
- chargingStation.getConnectorStatus(connectorId)?.status !== OCPP16ChargePointStatus.AVAILABLE
+ chargingStation.getConnectorStatus(connectorId)?.status !== OCPP16ChargePointStatus.Available
) {
await chargingStation.ocppRequestService.requestHandler<
OCPP16StatusNotificationRequest,
OCPP16StatusNotificationResponse
>(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, {
connectorId,
- status: OCPP16ChargePointStatus.AVAILABLE,
+ status: OCPP16ChargePointStatus.Available,
errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
});
- chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.AVAILABLE;
+ chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.Available;
}
}
OCPP16StatusNotificationResponse
>(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, {
connectorId: transactionConnectorId,
- status: OCPP16ChargePointStatus.UNAVAILABLE,
+ status: OCPP16ChargePointStatus.Unavailable,
errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
});
chargingStation.getConnectorStatus(transactionConnectorId).status =
- OCPP16ChargePointStatus.UNAVAILABLE;
+ OCPP16ChargePointStatus.Unavailable;
} else {
await chargingStation.ocppRequestService.requestHandler<
OCPP16BootNotificationRequest,
OCPP16BootNotificationResponse
>(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, {
connectorId: transactionConnectorId,
- status: OCPP16ChargePointStatus.AVAILABLE,
+ status: OCPP16ChargePointStatus.Available,
errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
});
chargingStation.getConnectorStatus(transactionConnectorId).status =
- OCPP16ChargePointStatus.AVAILABLE;
+ OCPP16ChargePointStatus.Available;
}
if (chargingStation.stationInfo.powerSharedByConnectors) {
chargingStation.powerDivider--;
}
enum ChargingStationMessageEvents {
- STARTED = 'started',
- STOPPED = 'stopped',
- UPDATED = 'updated',
- PERFORMANCE_STATISTICS = 'performanceStatistics',
+ started = 'started',
+ stopped = 'stopped',
+ updated = 'updated',
+ performanceStatistics = 'performanceStatistics',
}
export const ChargingStationWorkerMessageEvents = {
export enum OCPP16ChargePointStatus {
- AVAILABLE = 'Available',
- PREPARING = 'Preparing',
- CHARGING = 'Charging',
- OCCUPIED = 'Occupied',
- SUSPENDED_EVSE = 'SuspendedEVSE',
- SUSPENDED_EV = 'SuspendedEV',
- FINISHING = 'Finishing',
- RESERVED = 'Reserved',
- UNAVAILABLE = 'Unavailable',
- FAULTED = 'Faulted',
+ Available = 'Available',
+ Preparing = 'Preparing',
+ Charging = 'Charging',
+ Occupied = 'Occupied',
+ SuspendedEVSE = 'SuspendedEVSE',
+ SuspendedEV = 'SuspendedEV',
+ Finishing = 'Finishing',
+ Reserved = 'Reserved',
+ Unavailable = 'Unavailable',
+ Faulted = 'Faulted',
}
}
export enum OCPP20ConnectorStatusEnumType {
- AVAILABLE = 'Available',
- OCCUPIED = 'Occupied',
- RESERVED = 'Reserved',
- UNAVAILABLE = 'Unavailable',
- FAULTED = 'Faulted',
+ Available = 'Available',
+ Occupied = 'Occupied',
+ Reserved = 'Reserved',
+ Unavailable = 'Unavailable',
+ Faulted = 'Faulted',
}
export type GenericStatusEnumType = GenericStatus;
let workerConfiguration: WorkerConfiguration = {
processType: Utils.hasOwnProp(Configuration.getConfig(), 'workerProcess')
? Configuration.getConfig()?.workerProcess
- : WorkerProcessType.WORKER_SET,
+ : WorkerProcessType.workerSet,
startDelay: Utils.hasOwnProp(Configuration.getConfig(), 'workerStartDelay')
? Configuration.getConfig()?.workerStartDelay
: WorkerConstants.DEFAULT_WORKER_START_DELAY,
(workerOptions.poolOptions.messageHandler = workerOptions.messageHandler);
let workerImplementation: WorkerAbstract<T> | null = null;
switch (workerProcessType) {
- case WorkerProcessType.WORKER_SET:
+ case WorkerProcessType.workerSet:
workerOptions.elementsPerWorker =
workerOptions?.elementsPerWorker ?? WorkerConstants.DEFAULT_ELEMENTS_PER_WORKER;
workerImplementation = new WorkerSet(workerScript, workerOptions);
break;
- case WorkerProcessType.STATIC_POOL:
+ case WorkerProcessType.staticPool:
workerOptions.poolMaxSize =
workerOptions?.poolMaxSize ?? WorkerConstants.DEFAULT_POOL_MAX_SIZE;
workerImplementation = new WorkerStaticPool(workerScript, workerOptions);
break;
- case WorkerProcessType.DYNAMIC_POOL:
+ case WorkerProcessType.dynamicPool:
workerOptions.poolMinSize =
workerOptions?.poolMinSize ?? WorkerConstants.DEFAULT_POOL_MIN_SIZE;
workerOptions.poolMaxSize =
await this.startWorker();
}
this.getLastWorker().postMessage({
- id: WorkerMessageEvents.START_WORKER_ELEMENT,
+ id: WorkerMessageEvents.startWorkerElement,
data: elementData,
});
this.getLastWorkerSetElement().numberOfWorkerElements++;
import type { PoolOptions } from 'poolifier';
export enum WorkerProcessType {
- WORKER_SET = 'workerSet',
- DYNAMIC_POOL = 'dynamicPool',
- STATIC_POOL = 'staticPool',
+ workerSet = 'workerSet',
+ dynamicPool = 'dynamicPool',
+ staticPool = 'staticPool',
}
export type MessageHandler<T> = (this: T, message: unknown) => void;
};
export enum WorkerMessageEvents {
- START_WORKER_ELEMENT = 'startWorkerElement',
+ startWorkerElement = 'startWorkerElement',
}