Clean up Charging Station's connector when Available Status Notification is sent with no Stop Transaction
MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -549,7 +549,7 @@ export default class OCPPService {
const { user, alternateUser } = await this.checkAuthorizeStopTransactionAndGetUsers(
tenant, chargingStation, transaction, tagID, isStoppedByCentralSystem);
// Free the connector
- OCPPUtils.clearChargingStationConnector(chargingStation, transaction.connectorId);
+ OCPPUtils.clearChargingStationConnectorRuntimeData(chargingStation, transaction.connectorId);
// Save Charging Station
await ChargingStationStorage.saveChargingStation(tenant, chargingStation);
// Soft Stop
@@ -912,6 +912,7 @@ export default class OCPPService {
message: `${Utils.buildConnectorInfo(lastTransaction.connectorId, lastTransaction.id)} Received Status Notification '${statusNotification.status}' on Connector ID ${lastTransaction.connectorId ?? 'unknown'} while a transaction is ongoing, expect inconsistencies in the inactivity time computation. Ask charging station vendor to fix the firmware`,
detailedMessages: { statusNotification }
});
+ OCPPUtils.clearChargingStationConnectorRuntimeData(chargingStation, lastTransaction.connectorId);
}
}
}
@@ -1206,7 +1207,7 @@ export default class OCPPService {
});
// Cleanup connector transaction data
} else if (foundConnector) {
- OCPPUtils.clearChargingStationConnector(chargingStation, foundConnector.connectorId);
+ OCPPUtils.clearChargingStationConnectorRuntimeData(chargingStation, foundConnector.connectorId);
}
}
@@ -1447,7 +1448,7 @@ export default class OCPPService {
// Delete
await TransactionStorage.deleteTransaction(tenant, activeTransaction.id);
// Clear connector
- OCPPUtils.clearChargingStationConnector(chargingStation, activeTransaction.connectorId);
+ OCPPUtils.clearChargingStationConnectorRuntimeData(chargingStation, activeTransaction.connectorId);
} else {
// Simulate a Stop Transaction
const result = await this.handleStopTransaction({

MODIFY
src/server/ocpp/utils/OCPPUtils.ts
src/server/ocpp/utils/OCPPUtils.ts
@@ -1799,7 +1799,7 @@ export default class OCPPUtils {
return result;
}
- public static clearChargingStationConnector(chargingStation: ChargingStation, connectorID: number): void {
+ public static clearChargingStationConnectorRuntimeData(chargingStation: ChargingStation, connectorID: number): void {
// Cleanup connector transaction data
const foundConnector = Utils.getConnectorFromID(chargingStation, connectorID);
if (foundConnector) {

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -832,7 +832,7 @@ export default class ChargingStationService {
user: req.user
});
} else {
- OCPPUtils.clearChargingStationConnector(chargingStation, connector.connectorId);
+ OCPPUtils.clearChargingStationConnectorRuntimeData(chargingStation, connector.connectorId);
}
}
}

MODIFY
src/server/rest/v1/service/TransactionService.ts
src/server/rest/v1/service/TransactionService.ts
@@ -481,7 +481,7 @@ export default class TransactionService {
// Check if already stopped
if (transaction.stop) {
// Clear Connector
- OCPPUtils.clearChargingStationConnector(chargingStation, transaction.connectorId);
+ OCPPUtils.clearChargingStationConnectorRuntimeData(chargingStation, transaction.connectorId);
// Save Connectors
await ChargingStationStorage.saveChargingStationConnectors(req.tenant, chargingStation.id, chargingStation.connectors);
await Logging.logSecurityInfo({
@@ -1050,7 +1050,7 @@ export default class TransactionService {
// Check connector
const foundConnector = Utils.getConnectorFromID(transaction.chargeBox, transaction.connectorId);
if (foundConnector && transaction.id === foundConnector.currentTransactionID) {
- OCPPUtils.clearChargingStationConnector(transaction.chargeBox, transaction.connectorId);
+ OCPPUtils.clearChargingStationConnectorRuntimeData(transaction.chargeBox, transaction.connectorId);
await ChargingStationStorage.saveChargingStationConnectors(await TenantStorage.getTenant(loggedUser.tenantID),
transaction.chargeBox.id, transaction.chargeBox.connectors);
}

MODIFY
src/server/rest/v1/service/UtilsService.ts
src/server/rest/v1/service/UtilsService.ts
@@ -933,13 +933,13 @@ export default class UtilsService {
res.end();
}
- public static async exportToPDF(req: Request, res: Response, attachementName: string,
+ public static async exportToPDF(req: Request, res: Response, attachmentName: string,
handleGetData: (req: Request) => Promise<DataResult<any>>,
handleConvertToPDF: (req: Request, pdfDocument: PDFKit.PDFDocument, data: any[]) => Promise<string>): Promise<void> {
// Override
req.query.Limit = Constants.EXPORT_PDF_PAGE_SIZE.toString();
// Set the attachment name
- res.attachment(attachementName);
+ res.attachment(attachmentName);
// Get the total number of Logs
req.query.OnlyRecordCount = 'true';
let data = await handleGetData(req);

Clean up Charging Station's connector when Available Status Notification is sent with no Stop Transaction