From: Jérôme Benoit Date: Tue, 8 Mar 2022 11:37:53 +0000 (+0100) Subject: Convert sendDiagnosticsStatusNotification to OCPP message sending handler X-Git-Tag: v1.1.52~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=bad85ee42a1c6a12be50560e535331dadff453b4;p=e-mobility-charging-stations-simulator.git Convert sendDiagnosticsStatusNotification to OCPP message sending handler Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index a86e995e..bd998504 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -829,8 +829,11 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer info.bytes / 1024 } bytes transferred from diagnostics archive ${info.name}` ); - await this.chargingStation.ocppRequestService.sendDiagnosticsStatusNotification( - OCPP16DiagnosticsStatus.Uploading + await this.chargingStation.ocppRequestService.sendMessageHandler( + OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, + { + status: OCPP16DiagnosticsStatus.Uploading, + } ); }); uploadResponse = await ftpClient.uploadFrom( @@ -838,8 +841,11 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer uri.pathname + diagnosticsArchive ); if (uploadResponse.code === 226) { - await this.chargingStation.ocppRequestService.sendDiagnosticsStatusNotification( - OCPP16DiagnosticsStatus.Uploaded + await this.chargingStation.ocppRequestService.sendMessageHandler( + OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, + { + status: OCPP16DiagnosticsStatus.Uploaded, + } ); if (ftpClient) { ftpClient.close(); @@ -862,8 +868,11 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer OCPP16IncomingRequestCommand.GET_DIAGNOSTICS ); } catch (error) { - await this.chargingStation.ocppRequestService.sendDiagnosticsStatusNotification( - OCPP16DiagnosticsStatus.UploadFailed + await this.chargingStation.ocppRequestService.sendMessageHandler( + OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, + { + status: OCPP16DiagnosticsStatus.UploadFailed, + } ); if (ftpClient) { ftpClient.close(); @@ -880,8 +889,11 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer uri.protocol } to transfer the diagnostic logs archive` ); - await this.chargingStation.ocppRequestService.sendDiagnosticsStatusNotification( - OCPP16DiagnosticsStatus.UploadFailed + await this.chargingStation.ocppRequestService.sendMessageHandler( + OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, + { + status: OCPP16DiagnosticsStatus.UploadFailed, + } ); return Constants.OCPP_RESPONSE_EMPTY; } diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index 8ba3c086..f184c7ab 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -12,13 +12,13 @@ import { OCPP16RequestCommand, StatusNotificationRequest, } from '../../../types/ocpp/1.6/Requests'; -import { MeterValuesRequest, OCPP16MeterValue } from '../../../types/ocpp/1.6/MeterValues'; import { ResponseType, SendParams } from '../../../types/ocpp/Requests'; import type ChargingStation from '../../ChargingStation'; import Constants from '../../../utils/Constants'; import { ErrorType } from '../../../types/ocpp/ErrorType'; import { JsonType } from '../../../types/JsonType'; +import { MeterValuesRequest } from '../../../types/ocpp/1.6/MeterValues'; import { OCPP16DiagnosticsStatus } from '../../../types/ocpp/1.6/DiagnosticsStatus'; import { OCPP16ServiceUtils } from './OCPP16ServiceUtils'; import OCPPError from '../../../exception/OCPPError'; @@ -57,19 +57,6 @@ export default class OCPP16RequestService extends OCPPRequestService { ); } - public async sendDiagnosticsStatusNotification( - diagnosticsStatus: OCPP16DiagnosticsStatus - ): Promise { - const payload: DiagnosticsStatusNotificationRequest = { - status: diagnosticsStatus, - }; - await this.sendMessage( - Utils.generateUUID(), - payload, - OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION - ); - } - private buildCommandPayload( commandName: OCPP16RequestCommand, commandParams?: JsonType diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 1430de07..e5047d33 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -13,7 +13,6 @@ import { ErrorType } from '../../types/ocpp/ErrorType'; import { HandleErrorParams } from '../../types/Error'; import { JsonType } from '../../types/JsonType'; import { MessageType } from '../../types/ocpp/MessageType'; -import { MeterValue } from '../../types/ocpp/MeterValues'; import OCPPError from '../../exception/OCPPError'; import type OCPPResponseService from './OCPPResponseService'; import PerformanceStatistics from '../../performance/PerformanceStatistics'; @@ -323,8 +322,4 @@ export default abstract class OCPPRequestService { commandParams?: JsonType, params?: SendParams ): Promise; - - public abstract sendDiagnosticsStatusNotification( - diagnosticsStatus: DiagnosticsStatus - ): Promise; }