// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
-import * as url from 'url';
-
import { ChangeAvailabilityRequest, ChangeConfigurationRequest, ClearChargingProfileRequest, GetConfigurationRequest, GetDiagnosticsRequest, MessageTrigger, OCPP16AvailabilityType, OCPP16IncomingRequestCommand, OCPP16TriggerMessageRequest, RemoteStartTransactionRequest, RemoteStopTransactionRequest, ResetRequest, SetChargingProfileRequest, UnlockConnectorRequest } from '../../../types/ocpp/1.6/Requests';
import { ChangeAvailabilityResponse, ChangeConfigurationResponse, ClearChargingProfileResponse, GetConfigurationResponse, GetDiagnosticsResponse, OCPP16TriggerMessageResponse, SetChargingProfileResponse, UnlockConnectorResponse } from '../../../types/ocpp/1.6/Responses';
import { ChargingProfilePurposeType, OCPP16ChargingProfile } from '../../../types/ocpp/1.6/ChargingProfile';
import { OCPPConfigurationKey } from '../../../types/ocpp/Configuration';
import OCPPError from '../OCPPError';
import OCPPIncomingRequestService from '../OCPPIncomingRequestService';
+import { URL } from 'url';
import Utils from '../../../utils/Utils';
import fs from 'fs';
import logger from '../../../utils/Logger';
private async handleRequestGetDiagnostics(commandPayload: GetDiagnosticsRequest): Promise<GetDiagnosticsResponse> {
logger.debug(this.chargingStation.logPrefix() + ' ' + IncomingRequestCommand.GET_DIAGNOSTICS + ' request received: %j', commandPayload);
- const uri = new url.URL(commandPayload.location);
+ const uri = new URL(commandPayload.location);
if (uri.protocol.startsWith('ftp:')) {
let ftpClient: Client;
try {
// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
import { AuthorizeRequest, OCPP16AuthorizationStatus, OCPP16AuthorizeResponse, OCPP16StartTransactionResponse, OCPP16StopTransactionResponse, StartTransactionRequest, StopTransactionRequest } from '../../../types/ocpp/1.6/Transaction';
-import { HeartbeatRequest, OCPP16BootNotificationRequest, OCPP16RequestCommand, StatusNotificationRequest } from '../../../types/ocpp/1.6/Requests';
+import { HeartbeatRequest, OCPP16RequestCommand, StatusNotificationRequest } from '../../../types/ocpp/1.6/Requests';
import { HeartbeatResponse, OCPP16BootNotificationResponse, OCPP16RegistrationStatus, StatusNotificationResponse } from '../../../types/ocpp/1.6/Responses';
import { MeterValuesRequest, MeterValuesResponse } from '../../../types/ocpp/1.6/MeterValues';
const hours = Math.floor(duration / (3600 * 1000));
const minutes = Math.floor((duration / 1000 - (hours * 3600)) / 60);
const seconds = duration / 1000 - (hours * 3600) - (minutes * 60);
- let hoursStr: string = hours.toString();
- let minutesStr: string = minutes.toString();
- let secondsStr: string = seconds.toString();
+ let hoursStr = hours.toString();
+ let minutesStr = minutes.toString();
+ let secondsStr = seconds.toString();
if (hours < 10) {
hoursStr = '0' + hours.toString();
}
public static getRandomInt(max: number, min = 0): number {
+ if (max < 0) {
+ throw new RangeError('Invalid interval');
+ }
max = Math.floor(max);
if (min) {
+ if (max < min || min < 0) {
+ throw new RangeError('Invalid interval');
+ }
min = Math.ceil(min);
return Math.floor(Utils.secureRandom() * (max - min + 1)) + min;
}