1 // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
3 import { parentPort
} from
'node:worker_threads';
5 import type { JSONSchemaType
} from
'ajv';
7 import { OCPP16ServiceUtils
} from
'./OCPP16ServiceUtils';
10 ChargingStationConfigurationUtils
,
13 } from
'../../../charging-station';
14 import { OCPPError
} from
'../../../exception';
16 type ChangeAvailabilityResponse
,
17 type ChangeConfigurationResponse
,
18 type ClearChargingProfileResponse
,
21 type GetConfigurationResponse
,
22 type GetDiagnosticsResponse
,
25 OCPP16AuthorizationStatus
,
26 type OCPP16AuthorizeRequest
,
27 type OCPP16AuthorizeResponse
,
28 type OCPP16BootNotificationResponse
,
29 OCPP16ChargePointStatus
,
30 type OCPP16DataTransferResponse
,
31 type OCPP16DiagnosticsStatusNotificationResponse
,
32 type OCPP16FirmwareStatusNotificationResponse
,
33 type OCPP16GetCompositeScheduleResponse
,
34 type OCPP16HeartbeatResponse
,
35 OCPP16IncomingRequestCommand
,
36 type OCPP16MeterValuesRequest
,
37 type OCPP16MeterValuesResponse
,
39 OCPP16StandardParametersKey
,
40 type OCPP16StartTransactionRequest
,
41 type OCPP16StartTransactionResponse
,
42 type OCPP16StatusNotificationResponse
,
43 type OCPP16StopTransactionRequest
,
44 type OCPP16StopTransactionResponse
,
45 type OCPP16TriggerMessageResponse
,
46 type OCPP16UpdateFirmwareResponse
,
48 RegistrationStatusEnumType
,
50 type SetChargingProfileResponse
,
51 type UnlockConnectorResponse
,
52 } from
'../../../types';
53 import { Constants
, Utils
, logger
} from
'../../../utils';
54 import { OCPPResponseService
} from
'../OCPPResponseService';
56 const moduleName
= 'OCPP16ResponseService';
58 export class OCPP16ResponseService
extends OCPPResponseService
{
59 public jsonIncomingRequestResponseSchemas
: Map
<
60 OCPP16IncomingRequestCommand
,
61 JSONSchemaType
<JsonObject
>
64 private responseHandlers
: Map
<OCPP16RequestCommand
, ResponseHandler
>;
65 private jsonSchemas
: Map
<OCPP16RequestCommand
, JSONSchemaType
<JsonObject
>>;
67 public constructor() {
68 // if (new.target?.name === moduleName) {
69 // throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
71 super(OCPPVersion
.VERSION_16
);
72 this.responseHandlers
= new Map
<OCPP16RequestCommand
, ResponseHandler
>([
73 [OCPP16RequestCommand
.BOOT_NOTIFICATION
, this.handleResponseBootNotification
.bind(this)],
74 [OCPP16RequestCommand
.HEARTBEAT
, this.emptyResponseHandler
.bind(this)],
75 [OCPP16RequestCommand
.AUTHORIZE
, this.handleResponseAuthorize
.bind(this)],
76 [OCPP16RequestCommand
.START_TRANSACTION
, this.handleResponseStartTransaction
.bind(this)],
77 [OCPP16RequestCommand
.STOP_TRANSACTION
, this.handleResponseStopTransaction
.bind(this)],
78 [OCPP16RequestCommand
.STATUS_NOTIFICATION
, this.emptyResponseHandler
.bind(this)],
79 [OCPP16RequestCommand
.METER_VALUES
, this.emptyResponseHandler
.bind(this)],
80 [OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, this.emptyResponseHandler
.bind(this)],
81 [OCPP16RequestCommand
.DATA_TRANSFER
, this.emptyResponseHandler
.bind(this)],
82 [OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, this.emptyResponseHandler
.bind(this)],
84 this.jsonSchemas
= new Map
<OCPP16RequestCommand
, JSONSchemaType
<JsonObject
>>([
86 OCPP16RequestCommand
.BOOT_NOTIFICATION
,
87 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16BootNotificationResponse
>(
88 'assets/json-schemas/ocpp/1.6/BootNotificationResponse.json',
94 OCPP16RequestCommand
.HEARTBEAT
,
95 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16HeartbeatResponse
>(
96 'assets/json-schemas/ocpp/1.6/HeartbeatResponse.json',
102 OCPP16RequestCommand
.AUTHORIZE
,
103 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16AuthorizeResponse
>(
104 'assets/json-schemas/ocpp/1.6/AuthorizeResponse.json',
110 OCPP16RequestCommand
.START_TRANSACTION
,
111 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16StartTransactionResponse
>(
112 'assets/json-schemas/ocpp/1.6/StartTransactionResponse.json',
118 OCPP16RequestCommand
.STOP_TRANSACTION
,
119 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16StopTransactionResponse
>(
120 'assets/json-schemas/ocpp/1.6/StopTransactionResponse.json',
126 OCPP16RequestCommand
.STATUS_NOTIFICATION
,
127 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16StatusNotificationResponse
>(
128 'assets/json-schemas/ocpp/1.6/StatusNotificationResponse.json',
134 OCPP16RequestCommand
.METER_VALUES
,
135 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16MeterValuesResponse
>(
136 'assets/json-schemas/ocpp/1.6/MeterValuesResponse.json',
142 OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
,
143 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16DiagnosticsStatusNotificationResponse
>(
144 'assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotificationResponse.json',
150 OCPP16RequestCommand
.DATA_TRANSFER
,
151 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16DataTransferResponse
>(
152 'assets/json-schemas/ocpp/1.6/DataTransferResponse.json',
158 OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
,
159 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16FirmwareStatusNotificationResponse
>(
160 'assets/json-schemas/ocpp/1.6/FirmwareStatusNotificationResponse.json',
166 this.jsonIncomingRequestResponseSchemas
= new Map([
168 OCPP16IncomingRequestCommand
.RESET
,
169 OCPP16ServiceUtils
.parseJsonSchemaFile
<GenericResponse
>(
170 'assets/json-schemas/ocpp/1.6/ResetResponse.json',
176 OCPP16IncomingRequestCommand
.CLEAR_CACHE
,
177 OCPP16ServiceUtils
.parseJsonSchemaFile
<GenericResponse
>(
178 'assets/json-schemas/ocpp/1.6/ClearCacheResponse.json',
184 OCPP16IncomingRequestCommand
.CHANGE_AVAILABILITY
,
185 OCPP16ServiceUtils
.parseJsonSchemaFile
<ChangeAvailabilityResponse
>(
186 'assets/json-schemas/ocpp/1.6/ChangeAvailabilityResponse.json',
192 OCPP16IncomingRequestCommand
.UNLOCK_CONNECTOR
,
193 OCPP16ServiceUtils
.parseJsonSchemaFile
<UnlockConnectorResponse
>(
194 'assets/json-schemas/ocpp/1.6/UnlockConnectorResponse.json',
200 OCPP16IncomingRequestCommand
.GET_CONFIGURATION
,
201 OCPP16ServiceUtils
.parseJsonSchemaFile
<GetConfigurationResponse
>(
202 'assets/json-schemas/ocpp/1.6/GetConfigurationResponse.json',
208 OCPP16IncomingRequestCommand
.CHANGE_CONFIGURATION
,
209 OCPP16ServiceUtils
.parseJsonSchemaFile
<ChangeConfigurationResponse
>(
210 'assets/json-schemas/ocpp/1.6/ChangeConfigurationResponse.json',
216 OCPP16IncomingRequestCommand
.GET_COMPOSITE_SCHEDULE
,
217 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16GetCompositeScheduleResponse
>(
218 'assets/json-schemas/ocpp/1.6/GetCompositeScheduleResponse.json',
224 OCPP16IncomingRequestCommand
.SET_CHARGING_PROFILE
,
225 OCPP16ServiceUtils
.parseJsonSchemaFile
<SetChargingProfileResponse
>(
226 'assets/json-schemas/ocpp/1.6/SetChargingProfileResponse.json',
232 OCPP16IncomingRequestCommand
.CLEAR_CHARGING_PROFILE
,
233 OCPP16ServiceUtils
.parseJsonSchemaFile
<ClearChargingProfileResponse
>(
234 'assets/json-schemas/ocpp/1.6/ClearChargingProfileResponse.json',
240 OCPP16IncomingRequestCommand
.REMOTE_START_TRANSACTION
,
241 OCPP16ServiceUtils
.parseJsonSchemaFile
<GenericResponse
>(
242 'assets/json-schemas/ocpp/1.6/RemoteStartTransactionResponse.json',
248 OCPP16IncomingRequestCommand
.REMOTE_STOP_TRANSACTION
,
249 OCPP16ServiceUtils
.parseJsonSchemaFile
<GenericResponse
>(
250 'assets/json-schemas/ocpp/1.6/RemoteStopTransactionResponse.json',
256 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
,
257 OCPP16ServiceUtils
.parseJsonSchemaFile
<GetDiagnosticsResponse
>(
258 'assets/json-schemas/ocpp/1.6/GetDiagnosticsResponse.json',
264 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
,
265 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16TriggerMessageResponse
>(
266 'assets/json-schemas/ocpp/1.6/TriggerMessageResponse.json',
272 OCPP16IncomingRequestCommand
.DATA_TRANSFER
,
273 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16DataTransferResponse
>(
274 'assets/json-schemas/ocpp/1.6/DataTransferResponse.json',
280 OCPP16IncomingRequestCommand
.UPDATE_FIRMWARE
,
281 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16UpdateFirmwareResponse
>(
282 'assets/json-schemas/ocpp/1.6/UpdateFirmwareResponse.json',
288 this.validatePayload
= this.validatePayload
.bind(this) as (
289 chargingStation
: ChargingStation
,
290 commandName
: OCPP16RequestCommand
,
295 public async responseHandler(
296 chargingStation
: ChargingStation
,
297 commandName
: OCPP16RequestCommand
,
299 requestPayload
: JsonType
302 chargingStation
.isRegistered() === true ||
303 commandName
=== OCPP16RequestCommand
.BOOT_NOTIFICATION
306 this.responseHandlers
.has(commandName
) === true &&
307 OCPP16ServiceUtils
.isRequestCommandSupported(chargingStation
, commandName
) === true
310 this.validatePayload(chargingStation
, commandName
, payload
);
311 await this.responseHandlers
.get(commandName
)(chargingStation
, payload
, requestPayload
);
314 `${chargingStation.logPrefix()} ${moduleName}.responseHandler: Handle response error:`,
322 ErrorType
.NOT_IMPLEMENTED
,
323 `${commandName} is not implemented to handle response PDU ${JSON.stringify(
334 ErrorType
.SECURITY_ERROR
,
335 `${commandName} cannot be issued to handle response PDU ${JSON.stringify(
339 )} while the charging station is not registered on the central server.`,
346 private validatePayload(
347 chargingStation
: ChargingStation
,
348 commandName
: OCPP16RequestCommand
,
351 if (this.jsonSchemas
.has(commandName
) === true) {
352 return this.validateResponsePayload(
355 this.jsonSchemas
.get(commandName
),
360 `${chargingStation.logPrefix()} ${moduleName}.validatePayload: No JSON schema found for command '${commandName}' PDU validation`
365 private handleResponseBootNotification(
366 chargingStation
: ChargingStation
,
367 payload
: OCPP16BootNotificationResponse
369 if (payload
.status === RegistrationStatusEnumType
.ACCEPTED
) {
370 ChargingStationConfigurationUtils
.addConfigurationKey(
372 OCPP16StandardParametersKey
.HeartbeatInterval
,
373 payload
.interval
.toString(),
375 { overwrite
: true, save
: true }
377 ChargingStationConfigurationUtils
.addConfigurationKey(
379 OCPP16StandardParametersKey
.HeartBeatInterval
,
380 payload
.interval
.toString(),
382 { overwrite
: true, save
: true }
384 OCPP16ServiceUtils
.startHeartbeatInterval(chargingStation
, payload
.interval
);
386 if (Object.values(RegistrationStatusEnumType
).includes(payload
.status)) {
387 const logMsg
= `${chargingStation.logPrefix()} Charging station in '${
389 }' state on the central server`;
390 payload
.status === RegistrationStatusEnumType
.REJECTED
391 ? logger
.warn(logMsg
)
392 : logger
.info(logMsg
);
395 `${chargingStation.logPrefix()} Charging station boot notification response received: %j with undefined registration status`,
401 private handleResponseAuthorize(
402 chargingStation
: ChargingStation
,
403 payload
: OCPP16AuthorizeResponse
,
404 requestPayload
: OCPP16AuthorizeRequest
406 let authorizeConnectorId
: number;
407 if (chargingStation
.hasEvses
) {
408 for (const [evseId
, evseStatus
] of chargingStation
.evses
) {
410 for (const [connectorId
, connectorStatus
] of evseStatus
.connectors
) {
411 if (connectorStatus
?.authorizeIdTag
=== requestPayload
.idTag
) {
412 authorizeConnectorId
= connectorId
;
419 for (const connectorId
of chargingStation
.connectors
.keys()) {
422 chargingStation
.getConnectorStatus(connectorId
)?.authorizeIdTag
=== requestPayload
.idTag
424 authorizeConnectorId
= connectorId
;
429 const authorizeConnectorIdDefined
= !Utils
.isNullOrUndefined(authorizeConnectorId
);
430 if (payload
.idTagInfo
.status === OCPP16AuthorizationStatus
.ACCEPTED
) {
431 authorizeConnectorIdDefined
&&
432 (chargingStation
.getConnectorStatus(authorizeConnectorId
).idTagAuthorized
= true);
434 `${chargingStation.logPrefix()} idTag '${requestPayload.idTag}' accepted${
435 authorizeConnectorIdDefined ? ` on connector id ${authorizeConnectorId}
` : ''
439 if (authorizeConnectorIdDefined
) {
440 chargingStation
.getConnectorStatus(authorizeConnectorId
).idTagAuthorized
= false;
441 delete chargingStation
.getConnectorStatus(authorizeConnectorId
)?.authorizeIdTag
;
444 `${chargingStation.logPrefix()} idTag '${requestPayload.idTag}' rejected with status '${
445 payload.idTagInfo.status
446 }'${authorizeConnectorIdDefined ? ` on connector id ${authorizeConnectorId}` : ''}`
451 private async handleResponseStartTransaction(
452 chargingStation: ChargingStation,
453 payload: OCPP16StartTransactionResponse,
454 requestPayload: OCPP16StartTransactionRequest
456 const transactionConnectorId = requestPayload.connectorId;
458 transactionConnectorId === 0 ||
459 chargingStation.hasConnector(transactionConnectorId) === false
462 `${chargingStation.logPrefix()} Trying to start a transaction on a non existing connector id ${transactionConnectorId.toString()}
`
467 chargingStation.getConnectorStatus(transactionConnectorId)?.transactionRemoteStarted ===
469 chargingStation.getAuthorizeRemoteTxRequests() === true &&
470 chargingStation.getLocalAuthListEnabled() === true &&
471 chargingStation.hasIdTags() &&
472 chargingStation.getConnectorStatus(transactionConnectorId)?.idTagLocalAuthorized === false
475 `${chargingStation.logPrefix()} Trying to start a transaction
with a not local authorized idTag $
{
476 chargingStation
.getConnectorStatus(transactionConnectorId
)?.localAuthorizeIdTag
477 } on connector id ${transactionConnectorId.toString()}
`
479 await this.resetConnectorOnStartTransactionError(chargingStation, transactionConnectorId);
483 chargingStation.getConnectorStatus(transactionConnectorId)?.transactionRemoteStarted ===
485 chargingStation.getAuthorizeRemoteTxRequests() === true &&
486 chargingStation.getMustAuthorizeAtRemoteStart() === true &&
487 chargingStation.getConnectorStatus(transactionConnectorId)?.idTagLocalAuthorized === false &&
488 chargingStation.getConnectorStatus(transactionConnectorId)?.idTagAuthorized === false
491 `${chargingStation.logPrefix()} Trying to start a transaction
with a not authorized idTag $
{
492 chargingStation
.getConnectorStatus(transactionConnectorId
)?.authorizeIdTag
493 } on connector id ${transactionConnectorId.toString()}
`
495 await this.resetConnectorOnStartTransactionError(chargingStation, transactionConnectorId);
499 chargingStation.getConnectorStatus(transactionConnectorId)?.idTagAuthorized &&
500 chargingStation.getConnectorStatus(transactionConnectorId)?.authorizeIdTag !==
504 `${chargingStation.logPrefix()} Trying to start a transaction
with an idTag $
{
506 } different from the authorize request one $
{
507 chargingStation
.getConnectorStatus(transactionConnectorId
)?.authorizeIdTag
508 } on connector id ${transactionConnectorId.toString()}
`
510 await this.resetConnectorOnStartTransactionError(chargingStation, transactionConnectorId);
514 chargingStation.getConnectorStatus(transactionConnectorId)?.idTagLocalAuthorized &&
515 chargingStation.getConnectorStatus(transactionConnectorId)?.localAuthorizeIdTag !==
519 `${chargingStation.logPrefix()} Trying to start a transaction
with an idTag $
{
521 } different from the local authorized one $
{
522 chargingStation
.getConnectorStatus(transactionConnectorId
)?.localAuthorizeIdTag
523 } on connector id ${transactionConnectorId.toString()}
`
525 await this.resetConnectorOnStartTransactionError(chargingStation, transactionConnectorId);
528 if (chargingStation.getConnectorStatus(transactionConnectorId)?.transactionStarted === true) {
530 `${chargingStation.logPrefix()} Trying to start a transaction on an already used connector id ${transactionConnectorId.toString()}
:`,
531 chargingStation.getConnectorStatus(transactionConnectorId)
535 if (chargingStation.hasEvses) {
536 for (const [evseId, evseStatus] of chargingStation.evses) {
537 if (evseStatus.connectors.size > 1) {
538 for (const [connectorId, connectorStatus] of evseStatus.connectors) {
540 transactionConnectorId !== connectorId &&
541 connectorStatus?.transactionStarted === true
544 `${chargingStation.logPrefix()} Trying to start a transaction on an already used evse id ${evseId.toString()}
:`,
547 await this.resetConnectorOnStartTransactionError(
549 transactionConnectorId
558 chargingStation.getConnectorStatus(transactionConnectorId)?.status !==
559 OCPP16ChargePointStatus.Available &&
560 chargingStation.getConnectorStatus(transactionConnectorId)?.status !==
561 OCPP16ChargePointStatus.Preparing
564 `${chargingStation.logPrefix()} Trying to start a transaction on connector id ${transactionConnectorId.toString()}
with status $
{
565 chargingStation
.getConnectorStatus(transactionConnectorId
)?.status
570 if (!Number.isInteger(payload.transactionId)) {
572 `${chargingStation.logPrefix()} Trying to start a transaction on connector id ${transactionConnectorId.toString()}
with a non integer transaction id $
{
573 payload
.transactionId
574 }, converting to integer
`
576 payload.transactionId = Utils.convertToInt(payload.transactionId);
579 if (payload.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED) {
580 chargingStation.getConnectorStatus(transactionConnectorId).transactionStarted = true;
581 chargingStation.getConnectorStatus(transactionConnectorId).transactionId =
582 payload.transactionId;
583 chargingStation.getConnectorStatus(transactionConnectorId).transactionIdTag =
584 requestPayload.idTag;
585 chargingStation.getConnectorStatus(
586 transactionConnectorId
587 ).transactionEnergyActiveImportRegisterValue = 0;
588 chargingStation.getConnectorStatus(transactionConnectorId).transactionBeginMeterValue =
589 OCPP16ServiceUtils.buildTransactionBeginMeterValue(
591 transactionConnectorId,
592 requestPayload.meterStart
594 chargingStation.getBeginEndMeterValues() &&
595 (await chargingStation.ocppRequestService.requestHandler<
596 OCPP16MeterValuesRequest,
597 OCPP16MeterValuesResponse
598 >(chargingStation, OCPP16RequestCommand.METER_VALUES, {
599 connectorId: transactionConnectorId,
600 transactionId: payload.transactionId,
602 chargingStation.getConnectorStatus(transactionConnectorId).transactionBeginMeterValue,
605 await OCPP16ServiceUtils.sendAndSetConnectorStatus(
607 transactionConnectorId,
608 OCPP16ChargePointStatus.Charging
611 `${chargingStation.logPrefix()} Transaction
with id ${payload.transactionId.toString()} STARTED on $
{
612 chargingStation
.stationInfo
.chargingStationId
613 }#${transactionConnectorId.toString()}
for idTag
'${requestPayload.idTag}'`
615 if (chargingStation.stationInfo.powerSharedByConnectors) {
616 chargingStation.powerDivider++;
618 const configuredMeterValueSampleInterval =
619 ChargingStationConfigurationUtils.getConfigurationKey(
621 OCPP16StandardParametersKey.MeterValueSampleInterval
623 chargingStation.startMeterValues(
624 transactionConnectorId,
625 configuredMeterValueSampleInterval
626 ? Utils.convertToInt(configuredMeterValueSampleInterval.value) * 1000
627 : Constants.DEFAULT_METER_VALUES_INTERVAL
631 `${chargingStation.logPrefix()} Starting transaction
with id ${payload.transactionId.toString()} REJECTED
with status '${
632 payload.idTagInfo?.status
633 }', idTag
'${requestPayload.idTag}'`
635 await this.resetConnectorOnStartTransactionError(chargingStation, transactionConnectorId);
639 private async resetConnectorOnStartTransactionError(
640 chargingStation: ChargingStation,
643 ChargingStationUtils.resetConnectorStatus(chargingStation.getConnectorStatus(connectorId));
644 chargingStation.stopMeterValues(connectorId);
645 parentPort?.postMessage(MessageChannelUtils.buildUpdatedMessage(chargingStation));
647 chargingStation.getConnectorStatus(connectorId)?.status !== OCPP16ChargePointStatus.Available
649 await OCPP16ServiceUtils.sendAndSetConnectorStatus(
652 OCPP16ChargePointStatus.Available
657 private async handleResponseStopTransaction(
658 chargingStation: ChargingStation,
659 payload: OCPP16StopTransactionResponse,
660 requestPayload: OCPP16StopTransactionRequest
662 const transactionConnectorId = chargingStation.getConnectorIdByTransactionId(
663 requestPayload.transactionId
665 if (Utils.isNullOrUndefined(transactionConnectorId)) {
667 `${chargingStation.logPrefix()} Trying to stop a non existing transaction
with id ${requestPayload.transactionId.toString()}
`
671 chargingStation.getBeginEndMeterValues() === true &&
672 chargingStation.getOcppStrictCompliance() === false &&
673 chargingStation.getOutOfOrderEndMeterValues() === true &&
674 (await chargingStation.ocppRequestService.requestHandler<
675 OCPP16MeterValuesRequest,
676 OCPP16MeterValuesResponse
677 >(chargingStation, OCPP16RequestCommand.METER_VALUES, {
678 connectorId: transactionConnectorId,
679 transactionId: requestPayload.transactionId,
681 OCPP16ServiceUtils.buildTransactionEndMeterValue(
683 transactionConnectorId,
684 requestPayload.meterStop
689 chargingStation.isChargingStationAvailable() === false ||
690 chargingStation.isConnectorAvailable(transactionConnectorId) === false
692 await OCPP16ServiceUtils.sendAndSetConnectorStatus(
694 transactionConnectorId,
695 OCPP16ChargePointStatus.Unavailable
698 await OCPP16ServiceUtils.sendAndSetConnectorStatus(
700 transactionConnectorId,
701 OCPP16ChargePointStatus.Available
704 if (chargingStation.stationInfo.powerSharedByConnectors) {
705 chargingStation.powerDivider--;
707 ChargingStationUtils.resetConnectorStatus(
708 chargingStation.getConnectorStatus(transactionConnectorId)
710 chargingStation.stopMeterValues(transactionConnectorId);
711 parentPort?.postMessage(MessageChannelUtils.buildUpdatedMessage(chargingStation));
712 const logMsg = `${chargingStation.logPrefix()} Transaction
with id ${requestPayload.transactionId.toString()} STOPPED on $
{
713 chargingStation
.stationInfo
.chargingStationId
714 }#${transactionConnectorId?.toString()}
with status '${
715 payload.idTagInfo?.status ?? 'undefined'
718 Utils.isNullOrUndefined(payload.idTagInfo) ||
719 payload.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED