X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2F1.6%2FOCPP16ResponseService.ts;h=5d87f633e1f262004fb1232a157c5b5abd417976;hb=f6105f32e5f819ece6190c3958cd14582ce2ca33;hp=889b0235ed4536d9cd6b9925ff7d75f2ce419154;hpb=649287f8075bb01539ac9084bdccf027cfc50e89;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index 889b0235..5d87f633 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -4,11 +4,11 @@ import { parentPort } from 'node:worker_threads'; import type { JSONSchemaType } from 'ajv'; +import { OCPP16ServiceUtils } from './OCPP16ServiceUtils'; import { type ChargingStation, ChargingStationConfigurationUtils, ChargingStationUtils, - MessageChannelUtils, } from '../../../charging-station'; import { OCPPError } from '../../../exception'; import { @@ -35,6 +35,7 @@ import { type OCPP16MeterValuesRequest, type OCPP16MeterValuesResponse, OCPP16RequestCommand, + type OCPP16ReserveNowResponse, OCPP16StandardParametersKey, type OCPP16StartTransactionRequest, type OCPP16StartTransactionResponse, @@ -49,8 +50,8 @@ import { type SetChargingProfileResponse, type UnlockConnectorResponse, } from '../../../types'; -import { Constants, Utils, logger } from '../../../utils'; -import { OCPP16ServiceUtils, OCPPResponseService } from '../internal'; +import { Constants, Utils, buildUpdatedMessage, logger } from '../../../utils'; +import { OCPPResponseService } from '../OCPPResponseService'; const moduleName = 'OCPP16ResponseService'; @@ -84,7 +85,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16RequestCommand.BOOT_NOTIFICATION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/BootNotificationResponse.json', + 'assets/json-schemas/ocpp/1.6/BootNotificationResponse.json', moduleName, 'constructor' ), @@ -92,7 +93,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16RequestCommand.HEARTBEAT, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/HeartbeatResponse.json', + 'assets/json-schemas/ocpp/1.6/HeartbeatResponse.json', moduleName, 'constructor' ), @@ -100,7 +101,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16RequestCommand.AUTHORIZE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/AuthorizeResponse.json', + 'assets/json-schemas/ocpp/1.6/AuthorizeResponse.json', moduleName, 'constructor' ), @@ -108,7 +109,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16RequestCommand.START_TRANSACTION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/StartTransactionResponse.json', + 'assets/json-schemas/ocpp/1.6/StartTransactionResponse.json', moduleName, 'constructor' ), @@ -116,7 +117,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16RequestCommand.STOP_TRANSACTION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/StopTransactionResponse.json', + 'assets/json-schemas/ocpp/1.6/StopTransactionResponse.json', moduleName, 'constructor' ), @@ -124,7 +125,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16RequestCommand.STATUS_NOTIFICATION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/StatusNotificationResponse.json', + 'assets/json-schemas/ocpp/1.6/StatusNotificationResponse.json', moduleName, 'constructor' ), @@ -132,7 +133,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16RequestCommand.METER_VALUES, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/MeterValuesResponse.json', + 'assets/json-schemas/ocpp/1.6/MeterValuesResponse.json', moduleName, 'constructor' ), @@ -140,7 +141,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotificationResponse.json', + 'assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotificationResponse.json', moduleName, 'constructor' ), @@ -148,7 +149,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16RequestCommand.DATA_TRANSFER, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/DataTransferResponse.json', + 'assets/json-schemas/ocpp/1.6/DataTransferResponse.json', moduleName, 'constructor' ), @@ -156,7 +157,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/FirmwareStatusNotificationResponse.json', + 'assets/json-schemas/ocpp/1.6/FirmwareStatusNotificationResponse.json', moduleName, 'constructor' ), @@ -166,7 +167,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16IncomingRequestCommand.RESET, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/ResetResponse.json', + 'assets/json-schemas/ocpp/1.6/ResetResponse.json', moduleName, 'constructor' ), @@ -174,7 +175,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16IncomingRequestCommand.CLEAR_CACHE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/ClearCacheResponse.json', + 'assets/json-schemas/ocpp/1.6/ClearCacheResponse.json', moduleName, 'constructor' ), @@ -182,7 +183,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/ChangeAvailabilityResponse.json', + 'assets/json-schemas/ocpp/1.6/ChangeAvailabilityResponse.json', moduleName, 'constructor' ), @@ -190,7 +191,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/UnlockConnectorResponse.json', + 'assets/json-schemas/ocpp/1.6/UnlockConnectorResponse.json', moduleName, 'constructor' ), @@ -198,7 +199,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16IncomingRequestCommand.GET_CONFIGURATION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/GetConfigurationResponse.json', + 'assets/json-schemas/ocpp/1.6/GetConfigurationResponse.json', moduleName, 'constructor' ), @@ -206,7 +207,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/ChangeConfigurationResponse.json', + 'assets/json-schemas/ocpp/1.6/ChangeConfigurationResponse.json', moduleName, 'constructor' ), @@ -214,7 +215,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16IncomingRequestCommand.GET_COMPOSITE_SCHEDULE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/GetCompositeScheduleResponse.json', + 'assets/json-schemas/ocpp/1.6/GetCompositeScheduleResponse.json', moduleName, 'constructor' ), @@ -222,7 +223,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/SetChargingProfileResponse.json', + 'assets/json-schemas/ocpp/1.6/SetChargingProfileResponse.json', moduleName, 'constructor' ), @@ -230,7 +231,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/ClearChargingProfileResponse.json', + 'assets/json-schemas/ocpp/1.6/ClearChargingProfileResponse.json', moduleName, 'constructor' ), @@ -238,7 +239,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransactionResponse.json', + 'assets/json-schemas/ocpp/1.6/RemoteStartTransactionResponse.json', moduleName, 'constructor' ), @@ -246,7 +247,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransactionResponse.json', + 'assets/json-schemas/ocpp/1.6/RemoteStopTransactionResponse.json', moduleName, 'constructor' ), @@ -254,7 +255,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16IncomingRequestCommand.GET_DIAGNOSTICS, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/GetDiagnosticsResponse.json', + 'assets/json-schemas/ocpp/1.6/GetDiagnosticsResponse.json', moduleName, 'constructor' ), @@ -262,7 +263,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16IncomingRequestCommand.TRIGGER_MESSAGE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/TriggerMessageResponse.json', + 'assets/json-schemas/ocpp/1.6/TriggerMessageResponse.json', moduleName, 'constructor' ), @@ -270,7 +271,7 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16IncomingRequestCommand.DATA_TRANSFER, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/DataTransferResponse.json', + 'assets/json-schemas/ocpp/1.6/DataTransferResponse.json', moduleName, 'constructor' ), @@ -278,7 +279,23 @@ export class OCPP16ResponseService extends OCPPResponseService { [ OCPP16IncomingRequestCommand.UPDATE_FIRMWARE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/UpdateFirmwareResponse.json', + 'assets/json-schemas/ocpp/1.6/UpdateFirmwareResponse.json', + moduleName, + 'constructor' + ), + ], + [ + OCPP16IncomingRequestCommand.RESERVE_NOW, + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/ReserveNowResponse.json', + moduleName, + 'constructor' + ), + ], + [ + OCPP16IncomingRequestCommand.CANCEL_RESERVATION, + OCPP16ServiceUtils.parseJsonSchemaFile( + 'assets/json-schemas/ocpp/1.6/CancelReservationResponse.json', moduleName, 'constructor' ), @@ -612,7 +629,7 @@ export class OCPP16ResponseService extends OCPPResponseService { }#${transactionConnectorId.toString()} for idTag '${requestPayload.idTag}'` ); if (chargingStation.stationInfo.powerSharedByConnectors) { - chargingStation.powerDivider++; + ++chargingStation.powerDivider; } const configuredMeterValueSampleInterval = ChargingStationConfigurationUtils.getConfigurationKey( @@ -641,7 +658,7 @@ export class OCPP16ResponseService extends OCPPResponseService { ): Promise { ChargingStationUtils.resetConnectorStatus(chargingStation.getConnectorStatus(connectorId)); chargingStation.stopMeterValues(connectorId); - parentPort?.postMessage(MessageChannelUtils.buildUpdatedMessage(chargingStation)); + parentPort?.postMessage(buildUpdatedMessage(chargingStation)); if ( chargingStation.getConnectorStatus(connectorId)?.status !== OCPP16ChargePointStatus.Available ) { @@ -707,7 +724,7 @@ export class OCPP16ResponseService extends OCPPResponseService { chargingStation.getConnectorStatus(transactionConnectorId) ); chargingStation.stopMeterValues(transactionConnectorId); - parentPort?.postMessage(MessageChannelUtils.buildUpdatedMessage(chargingStation)); + parentPort?.postMessage(buildUpdatedMessage(chargingStation)); const logMsg = `${chargingStation.logPrefix()} Transaction with id ${requestPayload.transactionId.toString()} STOPPED on ${ chargingStation.stationInfo.chargingStationId }#${transactionConnectorId?.toString()} with status '${