Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
Convert sendDiagnosticsStatusNotification to OCPP message sending han…
Browse files Browse the repository at this point in the history
…dler

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
  • Loading branch information
Jérôme Benoit committed Mar 8, 2022
1 parent 3a33b6a commit bad85ee
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 27 deletions.
28 changes: 20 additions & 8 deletions src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -829,17 +829,23 @@ 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(
path.join(path.resolve(__dirname, '../../../../'), diagnosticsArchive),
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();
Expand All @@ -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();
Expand All @@ -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;
}
Expand Down
15 changes: 1 addition & 14 deletions src/charging-station/ocpp/1.6/OCPP16RequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -57,19 +57,6 @@ export default class OCPP16RequestService extends OCPPRequestService {
);
}

public async sendDiagnosticsStatusNotification(
diagnosticsStatus: OCPP16DiagnosticsStatus
): Promise<void> {
const payload: DiagnosticsStatusNotificationRequest = {
status: diagnosticsStatus,
};
await this.sendMessage(
Utils.generateUUID(),
payload,
OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION
);
}

private buildCommandPayload(
commandName: OCPP16RequestCommand,
commandParams?: JsonType
Expand Down
5 changes: 0 additions & 5 deletions src/charging-station/ocpp/OCPPRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -323,8 +322,4 @@ export default abstract class OCPPRequestService {
commandParams?: JsonType,
params?: SendParams
): Promise<ResponseType>;

public abstract sendDiagnosticsStatusNotification(
diagnosticsStatus: DiagnosticsStatus
): Promise<void>;
}

0 comments on commit bad85ee

Please sign in to comment.