public start(): void {
if (this.started === true) {
- logger.warn(`${this.logPrefix()} trying to start while already started`);
+ logger.warn(`${this.logPrefix()} is already started`);
return;
}
this.startConnectors();
public stop(): void {
if (this.started === false) {
- logger.warn(`${this.logPrefix()} trying to stop while not started`);
+ logger.warn(`${this.logPrefix()} is already stopped`);
return;
}
this.stopConnectors();
public startConnector(connectorId: number): void {
if (this.chargingStation.connectors.has(connectorId) === false) {
- logger.warn(`${this.logPrefix(connectorId)} trying to start on non existing connector`);
+ logger.warn(`${this.logPrefix(connectorId)} starting on non existing connector`);
return;
}
if (this.connectorsStatus.get(connectorId)?.start === false) {
});
});
} else if (this.connectorsStatus.get(connectorId)?.start === true) {
- logger.warn(`${this.logPrefix(connectorId)} already started on connector`);
+ logger.warn(`${this.logPrefix(connectorId)} is already started on connector`);
}
}
public stopConnector(connectorId: number): void {
- this.connectorsStatus.set(connectorId, {
- ...this.connectorsStatus.get(connectorId),
- start: false,
- });
+ if (this.chargingStation.connectors.has(connectorId) === false) {
+ logger.warn(`${this.logPrefix(connectorId)} stopping on non existing connector`);
+ return;
+ }
+ if (this.connectorsStatus.get(connectorId)?.start === true) {
+ this.connectorsStatus.set(connectorId, {
+ ...this.connectorsStatus.get(connectorId),
+ start: false,
+ });
+ } else if (this.connectorsStatus.get(connectorId)?.start === false) {
+ logger.warn(`${this.logPrefix(connectorId)} is already stopped on connector`);
+ }
}
private startConnectors(): void {
const idTag = this.chargingStation.getRandomIdTag();
const startTransactionLogMsg = `${this.logPrefix(
connectorId
- )} start transaction for idTag '${idTag}'`;
+ )} start transaction with an idTag '${idTag}'`;
if (this.getRequireAuthorize()) {
this.chargingStation.getConnectorStatus(connectorId).authorizeIdTag = idTag;
// Authorize idTag
} else {
const transactionId = this.chargingStation.getConnectorStatus(connectorId).transactionId;
logger.warn(
- `${this.logPrefix(connectorId)} trying to stop a not started transaction${
+ `${this.logPrefix(connectorId)} stopping a not started transaction${
transactionId ? ' ' + transactionId.toString() : ''
}`
);
// Outcome Message
case MessageType.CALL_RESULT_MESSAGE:
[, , commandPayload] = request as Response;
- if (!this.requests.has(messageId)) {
+ if (this.requests.has(messageId) === false) {
// Error
throw new OCPPError(
ErrorType.INTERNAL_ERROR,
// Error Message
case MessageType.CALL_ERROR_MESSAGE:
[, , errorType, errorMessage, errorDetails] = request as ErrorResponse;
- if (!this.requests.has(messageId)) {
+ if (this.requests.has(messageId) === false) {
// Error
throw new OCPPError(
ErrorType.INTERNAL_ERROR,
parentPort.postMessage(MessageChannelUtils.buildUpdatedMessage(this));
} else {
throw new OCPPError(ErrorType.PROTOCOL_ERROR, 'Incoming message is not an array', null, {
- payload: request,
+ request,
});
}
} catch (error) {
)}' processing error:`,
error
);
- if (!(error instanceof OCPPError)) {
+ if (error instanceof OCPPError === false) {
logger.warn(
`${this.logPrefix()} Error thrown at incoming OCPP command '${
commandName ?? requestCommandName ?? null
error
);
}
- // Send error
- messageType === MessageType.CALL_MESSAGE &&
- (await this.ocppRequestService.sendError(
+ if (messageType === MessageType.CALL_MESSAGE) {
+ // Send error
+ await this.ocppRequestService.sendError(
this,
messageId,
error as OCPPError,
commandName ?? requestCommandName ?? null
- ));
+ );
+ }
}
}