1 // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
3 import { parentPort
} from
'node:worker_threads';
5 import type { JSONSchemaType
} from
'ajv';
6 import { secondsToMilliseconds
} from
'date-fns';
8 import { OCPP16ServiceUtils
} from
'./OCPP16ServiceUtils';
13 hasReservationExpired
,
15 } from
'../../../charging-station';
16 import { OCPPError
} from
'../../../exception';
18 type ChangeConfigurationResponse
,
19 type ClearChargingProfileResponse
,
22 type GetConfigurationResponse
,
23 type GetDiagnosticsResponse
,
26 OCPP16AuthorizationStatus
,
27 type OCPP16AuthorizeRequest
,
28 type OCPP16AuthorizeResponse
,
29 type OCPP16BootNotificationResponse
,
30 type OCPP16ChangeAvailabilityResponse
,
31 OCPP16ChargePointStatus
,
32 type OCPP16DataTransferResponse
,
33 type OCPP16DiagnosticsStatusNotificationResponse
,
34 type OCPP16FirmwareStatusNotificationResponse
,
35 type OCPP16GetCompositeScheduleResponse
,
36 type OCPP16HeartbeatResponse
,
37 OCPP16IncomingRequestCommand
,
38 type OCPP16MeterValuesRequest
,
39 type OCPP16MeterValuesResponse
,
41 type OCPP16ReserveNowResponse
,
42 OCPP16StandardParametersKey
,
43 type OCPP16StartTransactionRequest
,
44 type OCPP16StartTransactionResponse
,
45 type OCPP16StatusNotificationResponse
,
46 type OCPP16StopTransactionRequest
,
47 type OCPP16StopTransactionResponse
,
48 type OCPP16TriggerMessageResponse
,
49 type OCPP16UpdateFirmwareResponse
,
51 RegistrationStatusEnumType
,
52 ReservationTerminationReason
,
54 type SetChargingProfileResponse
,
55 type UnlockConnectorResponse
,
56 } from
'../../../types';
63 } from
'../../../utils';
64 import { OCPPResponseService
} from
'../OCPPResponseService';
66 const moduleName
= 'OCPP16ResponseService';
68 export class OCPP16ResponseService
extends OCPPResponseService
{
69 public jsonIncomingRequestResponseSchemas
: Map
<
70 OCPP16IncomingRequestCommand
,
71 JSONSchemaType
<JsonObject
>
74 private responseHandlers
: Map
<OCPP16RequestCommand
, ResponseHandler
>;
75 private jsonSchemas
: Map
<OCPP16RequestCommand
, JSONSchemaType
<JsonObject
>>;
77 public constructor() {
78 // if (new.target?.name === moduleName) {
79 // throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
81 super(OCPPVersion
.VERSION_16
);
82 this.responseHandlers
= new Map
<OCPP16RequestCommand
, ResponseHandler
>([
84 OCPP16RequestCommand
.BOOT_NOTIFICATION
,
85 this.handleResponseBootNotification
.bind(this) as ResponseHandler
,
87 [OCPP16RequestCommand
.HEARTBEAT
, this.emptyResponseHandler
.bind(this) as ResponseHandler
],
88 [OCPP16RequestCommand
.AUTHORIZE
, this.handleResponseAuthorize
.bind(this) as ResponseHandler
],
90 OCPP16RequestCommand
.START_TRANSACTION
,
91 this.handleResponseStartTransaction
.bind(this) as ResponseHandler
,
94 OCPP16RequestCommand
.STOP_TRANSACTION
,
95 this.handleResponseStopTransaction
.bind(this) as ResponseHandler
,
98 OCPP16RequestCommand
.STATUS_NOTIFICATION
,
99 this.emptyResponseHandler
.bind(this) as ResponseHandler
,
101 [OCPP16RequestCommand
.METER_VALUES
, this.emptyResponseHandler
.bind(this) as ResponseHandler
],
103 OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
,
104 this.emptyResponseHandler
.bind(this) as ResponseHandler
,
106 [OCPP16RequestCommand
.DATA_TRANSFER
, this.emptyResponseHandler
.bind(this) as ResponseHandler
],
108 OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
,
109 this.emptyResponseHandler
.bind(this) as ResponseHandler
,
112 this.jsonSchemas
= new Map
<OCPP16RequestCommand
, JSONSchemaType
<JsonObject
>>([
114 OCPP16RequestCommand
.BOOT_NOTIFICATION
,
115 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16BootNotificationResponse
>(
116 'assets/json-schemas/ocpp/1.6/BootNotificationResponse.json',
122 OCPP16RequestCommand
.HEARTBEAT
,
123 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16HeartbeatResponse
>(
124 'assets/json-schemas/ocpp/1.6/HeartbeatResponse.json',
130 OCPP16RequestCommand
.AUTHORIZE
,
131 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16AuthorizeResponse
>(
132 'assets/json-schemas/ocpp/1.6/AuthorizeResponse.json',
138 OCPP16RequestCommand
.START_TRANSACTION
,
139 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16StartTransactionResponse
>(
140 'assets/json-schemas/ocpp/1.6/StartTransactionResponse.json',
146 OCPP16RequestCommand
.STOP_TRANSACTION
,
147 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16StopTransactionResponse
>(
148 'assets/json-schemas/ocpp/1.6/StopTransactionResponse.json',
154 OCPP16RequestCommand
.STATUS_NOTIFICATION
,
155 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16StatusNotificationResponse
>(
156 'assets/json-schemas/ocpp/1.6/StatusNotificationResponse.json',
162 OCPP16RequestCommand
.METER_VALUES
,
163 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16MeterValuesResponse
>(
164 'assets/json-schemas/ocpp/1.6/MeterValuesResponse.json',
170 OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
,
171 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16DiagnosticsStatusNotificationResponse
>(
172 'assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotificationResponse.json',
178 OCPP16RequestCommand
.DATA_TRANSFER
,
179 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16DataTransferResponse
>(
180 'assets/json-schemas/ocpp/1.6/DataTransferResponse.json',
186 OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
,
187 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16FirmwareStatusNotificationResponse
>(
188 'assets/json-schemas/ocpp/1.6/FirmwareStatusNotificationResponse.json',
194 this.jsonIncomingRequestResponseSchemas
= new Map([
196 OCPP16IncomingRequestCommand
.RESET
,
197 OCPP16ServiceUtils
.parseJsonSchemaFile
<GenericResponse
>(
198 'assets/json-schemas/ocpp/1.6/ResetResponse.json',
204 OCPP16IncomingRequestCommand
.CLEAR_CACHE
,
205 OCPP16ServiceUtils
.parseJsonSchemaFile
<GenericResponse
>(
206 'assets/json-schemas/ocpp/1.6/ClearCacheResponse.json',
212 OCPP16IncomingRequestCommand
.CHANGE_AVAILABILITY
,
213 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16ChangeAvailabilityResponse
>(
214 'assets/json-schemas/ocpp/1.6/ChangeAvailabilityResponse.json',
220 OCPP16IncomingRequestCommand
.UNLOCK_CONNECTOR
,
221 OCPP16ServiceUtils
.parseJsonSchemaFile
<UnlockConnectorResponse
>(
222 'assets/json-schemas/ocpp/1.6/UnlockConnectorResponse.json',
228 OCPP16IncomingRequestCommand
.GET_CONFIGURATION
,
229 OCPP16ServiceUtils
.parseJsonSchemaFile
<GetConfigurationResponse
>(
230 'assets/json-schemas/ocpp/1.6/GetConfigurationResponse.json',
236 OCPP16IncomingRequestCommand
.CHANGE_CONFIGURATION
,
237 OCPP16ServiceUtils
.parseJsonSchemaFile
<ChangeConfigurationResponse
>(
238 'assets/json-schemas/ocpp/1.6/ChangeConfigurationResponse.json',
244 OCPP16IncomingRequestCommand
.GET_COMPOSITE_SCHEDULE
,
245 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16GetCompositeScheduleResponse
>(
246 'assets/json-schemas/ocpp/1.6/GetCompositeScheduleResponse.json',
252 OCPP16IncomingRequestCommand
.SET_CHARGING_PROFILE
,
253 OCPP16ServiceUtils
.parseJsonSchemaFile
<SetChargingProfileResponse
>(
254 'assets/json-schemas/ocpp/1.6/SetChargingProfileResponse.json',
260 OCPP16IncomingRequestCommand
.CLEAR_CHARGING_PROFILE
,
261 OCPP16ServiceUtils
.parseJsonSchemaFile
<ClearChargingProfileResponse
>(
262 'assets/json-schemas/ocpp/1.6/ClearChargingProfileResponse.json',
268 OCPP16IncomingRequestCommand
.REMOTE_START_TRANSACTION
,
269 OCPP16ServiceUtils
.parseJsonSchemaFile
<GenericResponse
>(
270 'assets/json-schemas/ocpp/1.6/RemoteStartTransactionResponse.json',
276 OCPP16IncomingRequestCommand
.REMOTE_STOP_TRANSACTION
,
277 OCPP16ServiceUtils
.parseJsonSchemaFile
<GenericResponse
>(
278 'assets/json-schemas/ocpp/1.6/RemoteStopTransactionResponse.json',
284 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
,
285 OCPP16ServiceUtils
.parseJsonSchemaFile
<GetDiagnosticsResponse
>(
286 'assets/json-schemas/ocpp/1.6/GetDiagnosticsResponse.json',
292 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
,
293 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16TriggerMessageResponse
>(
294 'assets/json-schemas/ocpp/1.6/TriggerMessageResponse.json',
300 OCPP16IncomingRequestCommand
.DATA_TRANSFER
,
301 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16DataTransferResponse
>(
302 'assets/json-schemas/ocpp/1.6/DataTransferResponse.json',
308 OCPP16IncomingRequestCommand
.UPDATE_FIRMWARE
,
309 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16UpdateFirmwareResponse
>(
310 'assets/json-schemas/ocpp/1.6/UpdateFirmwareResponse.json',
316 OCPP16IncomingRequestCommand
.RESERVE_NOW
,
317 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16ReserveNowResponse
>(
318 'assets/json-schemas/ocpp/1.6/ReserveNowResponse.json',
324 OCPP16IncomingRequestCommand
.CANCEL_RESERVATION
,
325 OCPP16ServiceUtils
.parseJsonSchemaFile
<GenericResponse
>(
326 'assets/json-schemas/ocpp/1.6/CancelReservationResponse.json',
332 this.validatePayload
= this.validatePayload
.bind(this) as (
333 chargingStation
: ChargingStation
,
334 commandName
: OCPP16RequestCommand
,
339 public async responseHandler
<ReqType
extends JsonType
, ResType
extends JsonType
>(
340 chargingStation
: ChargingStation
,
341 commandName
: OCPP16RequestCommand
,
343 requestPayload
: ReqType
,
346 chargingStation
.isRegistered() === true ||
347 commandName
=== OCPP16RequestCommand
.BOOT_NOTIFICATION
350 this.responseHandlers
.has(commandName
) === true &&
351 OCPP16ServiceUtils
.isRequestCommandSupported(chargingStation
, commandName
) === true
354 this.validatePayload(chargingStation
, commandName
, payload
);
355 await this.responseHandlers
.get(commandName
)!(chargingStation
, payload
, requestPayload
);
358 `${chargingStation.logPrefix()} ${moduleName}.responseHandler: Handle response error:`,
366 ErrorType
.NOT_IMPLEMENTED
,
367 `${commandName} is not implemented to handle response PDU ${JSON.stringify(
378 ErrorType
.SECURITY_ERROR
,
379 `${commandName} cannot be issued to handle response PDU ${JSON.stringify(
383 )} while the charging station is not registered on the central server.`,
390 private validatePayload(
391 chargingStation
: ChargingStation
,
392 commandName
: OCPP16RequestCommand
,
395 if (this.jsonSchemas
.has(commandName
) === true) {
396 return this.validateResponsePayload(
399 this.jsonSchemas
.get(commandName
)!,
404 `${chargingStation.logPrefix()} ${moduleName}.validatePayload: No JSON schema found for command '${commandName}' PDU validation`,
409 private handleResponseBootNotification(
410 chargingStation
: ChargingStation
,
411 payload
: OCPP16BootNotificationResponse
,
413 if (payload
.status === RegistrationStatusEnumType
.ACCEPTED
) {
416 OCPP16StandardParametersKey
.HeartbeatInterval
,
417 payload
.interval
.toString(),
419 { overwrite
: true, save
: true },
423 OCPP16StandardParametersKey
.HeartBeatInterval
,
424 payload
.interval
.toString(),
426 { overwrite
: true, save
: true },
428 OCPP16ServiceUtils
.startHeartbeatInterval(chargingStation
, payload
.interval
);
430 if (Object.values(RegistrationStatusEnumType
).includes(payload
.status)) {
431 const logMsg
= `${chargingStation.logPrefix()} Charging station in '${
433 }' state on the central server`;
434 payload
.status === RegistrationStatusEnumType
.REJECTED
435 ? logger
.warn(logMsg
)
436 : logger
.info(logMsg
);
439 `${chargingStation.logPrefix()} Charging station boot notification response received: %j with undefined registration status`,
445 private handleResponseAuthorize(
446 chargingStation
: ChargingStation
,
447 payload
: OCPP16AuthorizeResponse
,
448 requestPayload
: OCPP16AuthorizeRequest
,
450 let authorizeConnectorId
: number | undefined;
451 if (chargingStation
.hasEvses
) {
452 for (const [evseId
, evseStatus
] of chargingStation
.evses
) {
454 for (const [connectorId
, connectorStatus
] of evseStatus
.connectors
) {
455 if (connectorStatus
?.authorizeIdTag
=== requestPayload
.idTag
) {
456 authorizeConnectorId
= connectorId
;
463 for (const connectorId
of chargingStation
.connectors
.keys()) {
466 chargingStation
.getConnectorStatus(connectorId
)?.authorizeIdTag
=== requestPayload
.idTag
468 authorizeConnectorId
= connectorId
;
473 const authorizeConnectorStatus
= chargingStation
.getConnectorStatus(authorizeConnectorId
!);
474 const authorizeConnectorIdDefined
= !isNullOrUndefined(authorizeConnectorId
);
475 if (payload
.idTagInfo
.status === OCPP16AuthorizationStatus
.ACCEPTED
) {
476 if (authorizeConnectorIdDefined
) {
477 // authorizeConnectorStatus!.authorizeIdTag = requestPayload.idTag;
478 authorizeConnectorStatus
!.idTagAuthorized
= true;
481 `${chargingStation.logPrefix()} idTag '${requestPayload.idTag}' accepted${
482 authorizeConnectorIdDefined ? ` on connector id ${authorizeConnectorId}
` : ''
486 if (authorizeConnectorIdDefined
) {
487 authorizeConnectorStatus
!.idTagAuthorized
= false;
488 delete authorizeConnectorStatus
?.authorizeIdTag
;
491 `${chargingStation.logPrefix()} idTag '${requestPayload.idTag}' rejected with status '${
492 payload.idTagInfo.status
493 }'${authorizeConnectorIdDefined ? ` on connector id ${authorizeConnectorId}` : ''}`,
498 private async handleResponseStartTransaction(
499 chargingStation: ChargingStation,
500 payload: OCPP16StartTransactionResponse,
501 requestPayload: OCPP16StartTransactionRequest,
503 const { connectorId } = requestPayload;
504 if (connectorId === 0 || chargingStation.hasConnector(connectorId) === false) {
506 `${chargingStation.logPrefix()} Trying to start a transaction on a non existing connector id ${connectorId}
`,
510 const connectorStatus = chargingStation.getConnectorStatus(connectorId);
512 connectorStatus?.transactionRemoteStarted === true &&
513 chargingStation.getAuthorizeRemoteTxRequests() === true &&
514 chargingStation.getLocalAuthListEnabled() === true &&
515 chargingStation.hasIdTags() === true &&
516 connectorStatus?.idTagLocalAuthorized === false
519 `${chargingStation.logPrefix()} Trying to start a transaction
with a not local authorized idTag ${connectorStatus?.localAuthorizeIdTag} on connector id ${connectorId}
`,
521 await this.resetConnectorOnStartTransactionError(chargingStation, connectorId);
525 connectorStatus?.transactionRemoteStarted === true &&
526 chargingStation.getAuthorizeRemoteTxRequests() === true &&
527 chargingStation.getRemoteAuthorization() === true &&
528 connectorStatus?.idTagLocalAuthorized === false &&
529 connectorStatus?.idTagAuthorized === false
532 `${chargingStation.logPrefix()} Trying to start a transaction
with a not authorized idTag ${connectorStatus?.authorizeIdTag} on connector id ${connectorId}
`,
534 await this.resetConnectorOnStartTransactionError(chargingStation, connectorId);
538 connectorStatus?.idTagAuthorized &&
539 connectorStatus?.authorizeIdTag !== requestPayload.idTag
542 `${chargingStation.logPrefix()} Trying to start a transaction
with an idTag $
{
544 } different from the authorize request one ${connectorStatus?.authorizeIdTag} on connector id ${connectorId}
`,
546 await this.resetConnectorOnStartTransactionError(chargingStation, connectorId);
550 connectorStatus?.idTagLocalAuthorized &&
551 connectorStatus?.localAuthorizeIdTag !== requestPayload.idTag
554 `${chargingStation.logPrefix()} Trying to start a transaction
with an idTag $
{
556 } different from the local authorized one ${connectorStatus?.localAuthorizeIdTag} on connector id ${connectorId}
`,
558 await this.resetConnectorOnStartTransactionError(chargingStation, connectorId);
561 if (connectorStatus?.transactionStarted === true) {
563 `${chargingStation.logPrefix()} Trying to start a transaction on an already used connector id ${connectorId}
:`,
568 if (chargingStation.hasEvses) {
569 for (const [evseId, evseStatus] of chargingStation.evses) {
570 if (evseStatus.connectors.size > 1) {
571 for (const [id, status] of evseStatus.connectors) {
572 if (id !== connectorId && status?.transactionStarted === true) {
574 `${chargingStation.logPrefix()} Trying to start a transaction on an already used evse id ${evseId}
:`,
577 await this.resetConnectorOnStartTransactionError(chargingStation, connectorId);
585 connectorStatus?.status !== OCPP16ChargePointStatus.Available &&
586 connectorStatus?.status !== OCPP16ChargePointStatus.Preparing
589 `${chargingStation.logPrefix()} Trying to start a transaction on connector id ${connectorId}
with status ${connectorStatus?.status}
`,
593 if (!Number.isSafeInteger(payload.transactionId)) {
595 `${chargingStation.logPrefix()} Trying to start a transaction on connector id ${connectorId}
with a non integer transaction id $
{
596 payload
.transactionId
597 }, converting to integer
`,
599 payload.transactionId = convertToInt(payload.transactionId);
602 if (payload.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED) {
603 connectorStatus.transactionStarted = true;
604 connectorStatus.transactionStart = requestPayload.timestamp;
605 connectorStatus.transactionId = payload.transactionId;
606 connectorStatus.transactionIdTag = requestPayload.idTag;
607 connectorStatus.transactionEnergyActiveImportRegisterValue = 0;
608 connectorStatus.transactionBeginMeterValue =
609 OCPP16ServiceUtils.buildTransactionBeginMeterValue(
612 requestPayload.meterStart,
614 if (requestPayload.reservationId) {
615 const reservation = chargingStation.getReservationBy(
617 requestPayload.reservationId,
619 if (reservation.idTag !== requestPayload.idTag) {
621 `${chargingStation.logPrefix()} Reserved transaction $
{
622 payload
.transactionId
623 } started
with a different idTag ${requestPayload.idTag} than the reservation one $
{
628 if (hasReservationExpired(reservation)) {
630 `${chargingStation.logPrefix()} Reserved transaction $
{
631 payload
.transactionId
632 } started
with expired reservation $
{
633 requestPayload
.reservationId
634 } (expiry date
: ${reservation.expiryDate.toISOString()}
))`,
637 await chargingStation.removeReservation(
639 ReservationTerminationReason.TRANSACTION_STARTED,
642 chargingStation.getBeginEndMeterValues() &&
643 (await chargingStation.ocppRequestService.requestHandler<
644 OCPP16MeterValuesRequest,
645 OCPP16MeterValuesResponse
646 >(chargingStation, OCPP16RequestCommand.METER_VALUES, {
648 transactionId: payload.transactionId,
649 meterValue: [connectorStatus.transactionBeginMeterValue],
650 } as OCPP16MeterValuesRequest));
651 await OCPP16ServiceUtils.sendAndSetConnectorStatus(
654 OCPP16ChargePointStatus.Charging,
657 `${chargingStation.logPrefix()} Transaction
with id ${payload.transactionId} STARTED on $
{
658 chargingStation
.stationInfo
.chargingStationId
659 }#${connectorId}
for idTag
'${requestPayload.idTag}'`,
661 if (chargingStation.stationInfo.powerSharedByConnectors) {
662 ++chargingStation.powerDivider;
664 const configuredMeterValueSampleInterval = getConfigurationKey(
666 OCPP16StandardParametersKey.MeterValueSampleInterval,
668 chargingStation.startMeterValues(
670 configuredMeterValueSampleInterval
671 ? secondsToMilliseconds(convertToInt(configuredMeterValueSampleInterval.value))
672 : Constants.DEFAULT_METER_VALUES_INTERVAL,
676 `${chargingStation.logPrefix()} Starting transaction
with id $
{
677 payload
.transactionId
679 chargingStation
.stationInfo
.chargingStationId
680 }#${connectorId}
with status '${payload.idTagInfo?.status}', idTag
'${
683 OCPP16ServiceUtils
.hasReservation(chargingStation
, connectorId
, requestPayload
.idTag
)
684 ? `, reservationId '${requestPayload.reservationId}'`
688 await this.resetConnectorOnStartTransactionError(chargingStation, connectorId);
692 private async resetConnectorOnStartTransactionError(
693 chargingStation: ChargingStation,
696 const connectorStatus = chargingStation.getConnectorStatus(connectorId);
697 resetConnectorStatus(connectorStatus!);
698 chargingStation.stopMeterValues(connectorId);
699 if (connectorStatus?.status !== OCPP16ChargePointStatus.Available) {
700 await OCPP16ServiceUtils.sendAndSetConnectorStatus(
703 OCPP16ChargePointStatus.Available,
706 parentPort?.postMessage(buildUpdatedMessage(chargingStation));
709 private async handleResponseStopTransaction(
710 chargingStation: ChargingStation,
711 payload: OCPP16StopTransactionResponse,
712 requestPayload: OCPP16StopTransactionRequest,
714 const transactionConnectorId = chargingStation.getConnectorIdByTransactionId(
715 requestPayload.transactionId,
717 if (isNullOrUndefined(transactionConnectorId)) {
719 `${chargingStation.logPrefix()} Trying to stop a non existing transaction
with id $
{
720 requestPayload
.transactionId
725 chargingStation.getBeginEndMeterValues() === true &&
726 chargingStation.getOcppStrictCompliance() === false &&
727 chargingStation.getOutOfOrderEndMeterValues() === true &&
728 (await chargingStation.ocppRequestService.requestHandler<
729 OCPP16MeterValuesRequest,
730 OCPP16MeterValuesResponse
731 >(chargingStation, OCPP16RequestCommand.METER_VALUES, {
732 connectorId: transactionConnectorId,
733 transactionId: requestPayload.transactionId,
735 OCPP16ServiceUtils.buildTransactionEndMeterValue(
737 transactionConnectorId!,
738 requestPayload.meterStop,
743 chargingStation.isChargingStationAvailable() === false ||
744 chargingStation.isConnectorAvailable(transactionConnectorId!) === false
746 await OCPP16ServiceUtils.sendAndSetConnectorStatus(
748 transactionConnectorId!,
749 OCPP16ChargePointStatus.Unavailable,
752 await OCPP16ServiceUtils.sendAndSetConnectorStatus(
754 transactionConnectorId!,
755 OCPP16ChargePointStatus.Available,
758 if (chargingStation.stationInfo.powerSharedByConnectors) {
759 chargingStation.powerDivider--;
761 resetConnectorStatus(chargingStation.getConnectorStatus(transactionConnectorId!)!);
762 chargingStation.stopMeterValues(transactionConnectorId!);
763 parentPort?.postMessage(buildUpdatedMessage(chargingStation));
764 const logMsg = `${chargingStation.logPrefix()} Transaction
with id $
{
765 requestPayload
.transactionId
767 chargingStation
.stationInfo
.chargingStationId
768 }#${transactionConnectorId}
with status '${payload.idTagInfo?.status ?? 'undefined'}'`;
770 isNullOrUndefined(payload.idTagInfo) ||
771 payload.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED