Commit | Line | Data |
---|---|---|
c8eeb62b JB |
1 | // Partial Copyright Jerome Benoit. 2021. All Rights Reserved. |
2 | ||
e7aeea18 | 3 | import { |
e7aeea18 | 4 | OCPP16AuthorizationStatus, |
ef6fa3fb | 5 | OCPP16AuthorizeRequest, |
e7aeea18 | 6 | OCPP16AuthorizeResponse, |
ef6fa3fb | 7 | OCPP16StartTransactionRequest, |
e7aeea18 | 8 | OCPP16StartTransactionResponse, |
ef6fa3fb | 9 | OCPP16StopTransactionRequest, |
e7aeea18 | 10 | OCPP16StopTransactionResponse, |
e7aeea18 JB |
11 | } from '../../../types/ocpp/1.6/Transaction'; |
12 | import { | |
ef6fa3fb JB |
13 | OCPP16BootNotificationRequest, |
14 | OCPP16HeartbeatRequest, | |
e7aeea18 | 15 | OCPP16RequestCommand, |
ef6fa3fb | 16 | OCPP16StatusNotificationRequest, |
e7aeea18 JB |
17 | } from '../../../types/ocpp/1.6/Requests'; |
18 | import { | |
e7aeea18 | 19 | OCPP16BootNotificationResponse, |
f22266fd | 20 | OCPP16HeartbeatResponse, |
e7aeea18 | 21 | OCPP16RegistrationStatus, |
f22266fd | 22 | OCPP16StatusNotificationResponse, |
e7aeea18 | 23 | } from '../../../types/ocpp/1.6/Responses'; |
ef6fa3fb JB |
24 | import { |
25 | OCPP16MeterValuesRequest, | |
26 | OCPP16MeterValuesResponse, | |
27 | } from '../../../types/ocpp/1.6/MeterValues'; | |
c0560973 | 28 | |
73b9adec | 29 | import type ChargingStation from '../../ChargingStation'; |
a4bc2942 | 30 | import { ErrorType } from '../../../types/ocpp/ErrorType'; |
d1888640 | 31 | import { JsonType } from '../../../types/JsonType'; |
93b4a429 | 32 | import { OCPP16ChargePointErrorCode } from '../../../types/ocpp/1.6/ChargePointErrorCode'; |
c0560973 | 33 | import { OCPP16ChargePointStatus } from '../../../types/ocpp/1.6/ChargePointStatus'; |
fd0c36fa | 34 | import { OCPP16ServiceUtils } from './OCPP16ServiceUtils'; |
c0560973 | 35 | import { OCPP16StandardParametersKey } from '../../../types/ocpp/1.6/Configuration'; |
e58068fd | 36 | import OCPPError from '../../../exception/OCPPError'; |
c0560973 | 37 | import OCPPResponseService from '../OCPPResponseService'; |
74c6a954 | 38 | import { ResponseHandler } from '../../../types/ocpp/Responses'; |
c0560973 | 39 | import Utils from '../../../utils/Utils'; |
9f2e3130 | 40 | import logger from '../../../utils/Logger'; |
c0560973 | 41 | |
909dcf2d JB |
42 | const moduleName = 'OCPP16ResponseService'; |
43 | ||
c0560973 | 44 | export default class OCPP16ResponseService extends OCPPResponseService { |
58144adb JB |
45 | private responseHandlers: Map<OCPP16RequestCommand, ResponseHandler>; |
46 | ||
9f2e3130 | 47 | public constructor(chargingStation: ChargingStation) { |
909dcf2d | 48 | if (new.target?.name === moduleName) { |
06127450 | 49 | throw new TypeError(`Cannot construct ${new.target?.name} instances directly`); |
9f2e3130 | 50 | } |
58144adb JB |
51 | super(chargingStation); |
52 | this.responseHandlers = new Map<OCPP16RequestCommand, ResponseHandler>([ | |
53 | [OCPP16RequestCommand.BOOT_NOTIFICATION, this.handleResponseBootNotification.bind(this)], | |
54 | [OCPP16RequestCommand.HEARTBEAT, this.handleResponseHeartbeat.bind(this)], | |
55 | [OCPP16RequestCommand.AUTHORIZE, this.handleResponseAuthorize.bind(this)], | |
56 | [OCPP16RequestCommand.START_TRANSACTION, this.handleResponseStartTransaction.bind(this)], | |
57 | [OCPP16RequestCommand.STOP_TRANSACTION, this.handleResponseStopTransaction.bind(this)], | |
58 | [OCPP16RequestCommand.STATUS_NOTIFICATION, this.handleResponseStatusNotification.bind(this)], | |
e7aeea18 | 59 | [OCPP16RequestCommand.METER_VALUES, this.handleResponseMeterValues.bind(this)], |
58144adb JB |
60 | ]); |
61 | } | |
62 | ||
e7aeea18 JB |
63 | public async handleResponse( |
64 | commandName: OCPP16RequestCommand, | |
65 | payload: JsonType | string, | |
66 | requestPayload: JsonType | |
67 | ): Promise<void> { | |
68 | if ( | |
69 | this.chargingStation.isRegistered() || | |
70 | commandName === OCPP16RequestCommand.BOOT_NOTIFICATION | |
71 | ) { | |
124f3553 JB |
72 | if (this.responseHandlers.has(commandName)) { |
73 | try { | |
74 | await this.responseHandlers.get(commandName)(payload, requestPayload); | |
75 | } catch (error) { | |
e7aeea18 JB |
76 | logger.error( |
77 | this.chargingStation.logPrefix() + ' Handle request response error: %j', | |
78 | error | |
79 | ); | |
124f3553 JB |
80 | throw error; |
81 | } | |
82 | } else { | |
83 | // Throw exception | |
e7aeea18 JB |
84 | throw new OCPPError( |
85 | ErrorType.NOT_IMPLEMENTED, | |
86 | `${commandName} is not implemented to handle request response payload ${JSON.stringify( | |
87 | payload, | |
88 | null, | |
89 | 2 | |
90 | )}`, | |
91 | commandName | |
92 | ); | |
887fef76 | 93 | } |
c0560973 | 94 | } else { |
e7aeea18 JB |
95 | throw new OCPPError( |
96 | ErrorType.SECURITY_ERROR, | |
97 | `${commandName} cannot be issued to handle request response payload ${JSON.stringify( | |
98 | payload, | |
99 | null, | |
100 | 2 | |
101 | )} while the charging station is not registered on the central server. `, | |
102 | commandName | |
103 | ); | |
c0560973 JB |
104 | } |
105 | } | |
106 | ||
624df199 | 107 | private handleResponseBootNotification(payload: OCPP16BootNotificationResponse): void { |
c0560973 | 108 | if (payload.status === OCPP16RegistrationStatus.ACCEPTED) { |
e7aeea18 JB |
109 | this.chargingStation.addConfigurationKey( |
110 | OCPP16StandardParametersKey.HeartBeatInterval, | |
a95873d8 JB |
111 | payload.interval.toString(), |
112 | {}, | |
113 | { overwrite: true, save: true } | |
e7aeea18 JB |
114 | ); |
115 | this.chargingStation.addConfigurationKey( | |
116 | OCPP16StandardParametersKey.HeartbeatInterval, | |
117 | payload.interval.toString(), | |
00db15b8 | 118 | { visible: false }, |
a95873d8 | 119 | { overwrite: true, save: true } |
e7aeea18 JB |
120 | ); |
121 | this.chargingStation.heartbeatSetInterval | |
122 | ? this.chargingStation.restartHeartbeat() | |
123 | : this.chargingStation.startHeartbeat(); | |
672fed6e | 124 | } |
74c6a954 | 125 | if (Object.values(OCPP16RegistrationStatus).includes(payload.status)) { |
e7aeea18 JB |
126 | const logMsg = `${this.chargingStation.logPrefix()} Charging station in '${ |
127 | payload.status | |
128 | }' state on the central server`; | |
129 | payload.status === OCPP16RegistrationStatus.REJECTED | |
130 | ? logger.warn(logMsg) | |
131 | : logger.info(logMsg); | |
c0560973 | 132 | } else { |
e7aeea18 JB |
133 | logger.error( |
134 | this.chargingStation.logPrefix() + | |
135 | ' Charging station boot notification response received: %j with undefined registration status', | |
136 | payload | |
137 | ); | |
c0560973 JB |
138 | } |
139 | } | |
140 | ||
e7aeea18 | 141 | private handleResponseHeartbeat( |
f22266fd | 142 | payload: OCPP16HeartbeatResponse, |
ef6fa3fb | 143 | requestPayload: OCPP16HeartbeatRequest |
e7aeea18 JB |
144 | ): void { |
145 | logger.debug( | |
146 | this.chargingStation.logPrefix() + | |
147 | ' Heartbeat response received: %j to Heartbeat request: %j', | |
148 | payload, | |
149 | requestPayload | |
150 | ); | |
58144adb JB |
151 | } |
152 | ||
e7aeea18 JB |
153 | private handleResponseAuthorize( |
154 | payload: OCPP16AuthorizeResponse, | |
ef6fa3fb | 155 | requestPayload: OCPP16AuthorizeRequest |
e7aeea18 | 156 | ): void { |
58144adb | 157 | let authorizeConnectorId: number; |
734d790d | 158 | for (const connectorId of this.chargingStation.connectors.keys()) { |
e7aeea18 JB |
159 | if ( |
160 | connectorId > 0 && | |
161 | this.chargingStation.getConnectorStatus(connectorId)?.authorizeIdTag === | |
162 | requestPayload.idTag | |
163 | ) { | |
734d790d | 164 | authorizeConnectorId = connectorId; |
58144adb JB |
165 | break; |
166 | } | |
167 | } | |
168 | if (payload.idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED) { | |
a2653482 | 169 | this.chargingStation.getConnectorStatus(authorizeConnectorId).idTagAuthorized = true; |
e7aeea18 JB |
170 | logger.debug( |
171 | `${this.chargingStation.logPrefix()} IdTag ${ | |
172 | requestPayload.idTag | |
173 | } authorized on connector ${authorizeConnectorId}` | |
174 | ); | |
58144adb | 175 | } else { |
a2653482 | 176 | this.chargingStation.getConnectorStatus(authorizeConnectorId).idTagAuthorized = false; |
734d790d | 177 | delete this.chargingStation.getConnectorStatus(authorizeConnectorId).authorizeIdTag; |
e7aeea18 | 178 | logger.debug( |
e8e865ea | 179 | `${this.chargingStation.logPrefix()} IdTag ${requestPayload.idTag} refused with status '${ |
e7aeea18 | 180 | payload.idTagInfo.status |
e8e865ea | 181 | }' on connector ${authorizeConnectorId}` |
e7aeea18 | 182 | ); |
58144adb JB |
183 | } |
184 | } | |
185 | ||
e7aeea18 JB |
186 | private async handleResponseStartTransaction( |
187 | payload: OCPP16StartTransactionResponse, | |
ef6fa3fb | 188 | requestPayload: OCPP16StartTransactionRequest |
e7aeea18 | 189 | ): Promise<void> { |
c0560973 JB |
190 | const connectorId = requestPayload.connectorId; |
191 | ||
192 | let transactionConnectorId: number; | |
734d790d JB |
193 | for (const id of this.chargingStation.connectors.keys()) { |
194 | if (id > 0 && id === connectorId) { | |
195 | transactionConnectorId = id; | |
c0560973 JB |
196 | break; |
197 | } | |
198 | } | |
199 | if (!transactionConnectorId) { | |
e7aeea18 JB |
200 | logger.error( |
201 | this.chargingStation.logPrefix() + | |
202 | ' Trying to start a transaction on a non existing connector Id ' + | |
203 | connectorId.toString() | |
204 | ); | |
c0560973 JB |
205 | return; |
206 | } | |
e7aeea18 JB |
207 | if ( |
208 | this.chargingStation.getConnectorStatus(connectorId).transactionRemoteStarted && | |
209 | this.chargingStation.getAuthorizeRemoteTxRequests() && | |
210 | this.chargingStation.getLocalAuthListEnabled() && | |
211 | this.chargingStation.hasAuthorizedTags() && | |
212 | !this.chargingStation.getConnectorStatus(connectorId).idTagLocalAuthorized | |
213 | ) { | |
214 | logger.error( | |
215 | this.chargingStation.logPrefix() + | |
216 | ' Trying to start a transaction with a not local authorized idTag ' + | |
217 | this.chargingStation.getConnectorStatus(connectorId).localAuthorizeIdTag + | |
218 | ' on connector Id ' + | |
219 | connectorId.toString() | |
220 | ); | |
a2653482 JB |
221 | await this.resetConnectorOnStartTransactionError(connectorId); |
222 | return; | |
223 | } | |
e7aeea18 JB |
224 | if ( |
225 | this.chargingStation.getConnectorStatus(connectorId).transactionRemoteStarted && | |
226 | this.chargingStation.getAuthorizeRemoteTxRequests() && | |
227 | this.chargingStation.getMayAuthorizeAtRemoteStart() && | |
228 | !this.chargingStation.getConnectorStatus(connectorId).idTagLocalAuthorized && | |
229 | !this.chargingStation.getConnectorStatus(connectorId).idTagAuthorized | |
230 | ) { | |
231 | logger.error( | |
232 | this.chargingStation.logPrefix() + | |
233 | ' Trying to start a transaction with a not authorized idTag ' + | |
234 | this.chargingStation.getConnectorStatus(connectorId).authorizeIdTag + | |
235 | ' on connector Id ' + | |
236 | connectorId.toString() | |
237 | ); | |
a2653482 JB |
238 | await this.resetConnectorOnStartTransactionError(connectorId); |
239 | return; | |
240 | } | |
e7aeea18 JB |
241 | if ( |
242 | this.chargingStation.getConnectorStatus(connectorId).idTagAuthorized && | |
243 | this.chargingStation.getConnectorStatus(connectorId).authorizeIdTag !== requestPayload.idTag | |
244 | ) { | |
245 | logger.error( | |
246 | this.chargingStation.logPrefix() + | |
247 | ' Trying to start a transaction with an idTag ' + | |
248 | requestPayload.idTag + | |
249 | ' different from the authorize request one ' + | |
250 | this.chargingStation.getConnectorStatus(connectorId).authorizeIdTag + | |
251 | ' on connector Id ' + | |
252 | connectorId.toString() | |
253 | ); | |
a2653482 JB |
254 | await this.resetConnectorOnStartTransactionError(connectorId); |
255 | return; | |
256 | } | |
e7aeea18 JB |
257 | if ( |
258 | this.chargingStation.getConnectorStatus(connectorId).idTagLocalAuthorized && | |
259 | this.chargingStation.getConnectorStatus(connectorId).localAuthorizeIdTag !== | |
260 | requestPayload.idTag | |
261 | ) { | |
262 | logger.error( | |
263 | this.chargingStation.logPrefix() + | |
264 | ' Trying to start a transaction with an idTag ' + | |
265 | requestPayload.idTag + | |
266 | ' different from the local authorized one ' + | |
267 | this.chargingStation.getConnectorStatus(connectorId).localAuthorizeIdTag + | |
268 | ' on connector Id ' + | |
269 | connectorId.toString() | |
270 | ); | |
a2653482 | 271 | await this.resetConnectorOnStartTransactionError(connectorId); |
163547b1 JB |
272 | return; |
273 | } | |
734d790d | 274 | if (this.chargingStation.getConnectorStatus(connectorId)?.transactionStarted) { |
e7aeea18 JB |
275 | logger.debug( |
276 | this.chargingStation.logPrefix() + | |
277 | ' Trying to start a transaction on an already used connector ' + | |
278 | connectorId.toString() + | |
279 | ': %j', | |
280 | this.chargingStation.getConnectorStatus(connectorId) | |
281 | ); | |
c0560973 JB |
282 | return; |
283 | } | |
e7aeea18 JB |
284 | if ( |
285 | this.chargingStation.getConnectorStatus(connectorId)?.status !== | |
286 | OCPP16ChargePointStatus.AVAILABLE && | |
287 | this.chargingStation.getConnectorStatus(connectorId)?.status !== | |
288 | OCPP16ChargePointStatus.PREPARING | |
289 | ) { | |
290 | logger.error( | |
291 | `${this.chargingStation.logPrefix()} Trying to start a transaction on connector ${connectorId.toString()} with status ${ | |
292 | this.chargingStation.getConnectorStatus(connectorId)?.status | |
293 | }` | |
294 | ); | |
290d006c JB |
295 | return; |
296 | } | |
f3a6f63b | 297 | if (!Number.isInteger(payload.transactionId)) { |
e7aeea18 JB |
298 | logger.warn( |
299 | `${this.chargingStation.logPrefix()} Trying to start a transaction on connector ${connectorId.toString()} with a non integer transaction Id ${ | |
300 | payload.transactionId | |
301 | }, converting to integer` | |
302 | ); | |
f3a6f63b JB |
303 | payload.transactionId = Utils.convertToInt(payload.transactionId); |
304 | } | |
c0560973 | 305 | |
f0c6ed89 | 306 | if (payload.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED) { |
734d790d JB |
307 | this.chargingStation.getConnectorStatus(connectorId).transactionStarted = true; |
308 | this.chargingStation.getConnectorStatus(connectorId).transactionId = payload.transactionId; | |
309 | this.chargingStation.getConnectorStatus(connectorId).transactionIdTag = requestPayload.idTag; | |
e7aeea18 JB |
310 | this.chargingStation.getConnectorStatus( |
311 | connectorId | |
312 | ).transactionEnergyActiveImportRegisterValue = 0; | |
313 | this.chargingStation.getConnectorStatus(connectorId).transactionBeginMeterValue = | |
314 | OCPP16ServiceUtils.buildTransactionBeginMeterValue( | |
315 | this.chargingStation, | |
316 | connectorId, | |
317 | requestPayload.meterStart | |
318 | ); | |
319 | this.chargingStation.getBeginEndMeterValues() && | |
ef6fa3fb JB |
320 | (await this.chargingStation.ocppRequestService.sendMessageHandler< |
321 | OCPP16MeterValuesRequest, | |
322 | OCPP16MeterValuesResponse | |
323 | >(OCPP16RequestCommand.METER_VALUES, { | |
93b4a429 | 324 | connectorId, |
ef6fa3fb JB |
325 | transactionId: payload.transactionId, |
326 | meterValue: | |
327 | this.chargingStation.getConnectorStatus(connectorId).transactionBeginMeterValue, | |
328 | })); | |
329 | await this.chargingStation.ocppRequestService.sendMessageHandler< | |
330 | OCPP16StatusNotificationRequest, | |
331 | OCPP16StatusNotificationResponse | |
332 | >(OCPP16RequestCommand.STATUS_NOTIFICATION, { | |
333 | connectorId, | |
334 | status: OCPP16ChargePointStatus.CHARGING, | |
335 | errorCode: OCPP16ChargePointErrorCode.NO_ERROR, | |
336 | }); | |
e7aeea18 JB |
337 | this.chargingStation.getConnectorStatus(connectorId).status = |
338 | OCPP16ChargePointStatus.CHARGING; | |
339 | logger.info( | |
340 | this.chargingStation.logPrefix() + | |
341 | ' Transaction ' + | |
342 | payload.transactionId.toString() + | |
343 | ' STARTED on ' + | |
344 | this.chargingStation.stationInfo.chargingStationId + | |
345 | '#' + | |
346 | connectorId.toString() + | |
347 | ' for idTag ' + | |
348 | requestPayload.idTag | |
349 | ); | |
c0560973 JB |
350 | if (this.chargingStation.stationInfo.powerSharedByConnectors) { |
351 | this.chargingStation.stationInfo.powerDivider++; | |
352 | } | |
e7aeea18 JB |
353 | const configuredMeterValueSampleInterval = this.chargingStation.getConfigurationKey( |
354 | OCPP16StandardParametersKey.MeterValueSampleInterval | |
355 | ); | |
356 | this.chargingStation.startMeterValues( | |
357 | connectorId, | |
358 | configuredMeterValueSampleInterval | |
359 | ? Utils.convertToInt(configuredMeterValueSampleInterval.value) * 1000 | |
360 | : 60000 | |
361 | ); | |
c0560973 | 362 | } else { |
e7aeea18 JB |
363 | logger.warn( |
364 | this.chargingStation.logPrefix() + | |
365 | ' Starting transaction id ' + | |
366 | payload.transactionId.toString() + | |
e8e865ea | 367 | " REJECTED with status '" + |
e7aeea18 | 368 | payload?.idTagInfo?.status + |
e8e865ea | 369 | "', idTag " + |
e7aeea18 JB |
370 | requestPayload.idTag |
371 | ); | |
a2653482 JB |
372 | await this.resetConnectorOnStartTransactionError(connectorId); |
373 | } | |
374 | } | |
375 | ||
376 | private async resetConnectorOnStartTransactionError(connectorId: number): Promise<void> { | |
377 | this.chargingStation.resetConnectorStatus(connectorId); | |
e7aeea18 JB |
378 | if ( |
379 | this.chargingStation.getConnectorStatus(connectorId).status !== | |
380 | OCPP16ChargePointStatus.AVAILABLE | |
381 | ) { | |
ef6fa3fb JB |
382 | await this.chargingStation.ocppRequestService.sendMessageHandler< |
383 | OCPP16StatusNotificationRequest, | |
384 | OCPP16StatusNotificationResponse | |
385 | >(OCPP16RequestCommand.STATUS_NOTIFICATION, { | |
386 | connectorId, | |
387 | status: OCPP16ChargePointStatus.AVAILABLE, | |
388 | errorCode: OCPP16ChargePointErrorCode.NO_ERROR, | |
389 | }); | |
e7aeea18 JB |
390 | this.chargingStation.getConnectorStatus(connectorId).status = |
391 | OCPP16ChargePointStatus.AVAILABLE; | |
c0560973 JB |
392 | } |
393 | } | |
394 | ||
e7aeea18 JB |
395 | private async handleResponseStopTransaction( |
396 | payload: OCPP16StopTransactionResponse, | |
ef6fa3fb | 397 | requestPayload: OCPP16StopTransactionRequest |
e7aeea18 | 398 | ): Promise<void> { |
f479a792 JB |
399 | const transactionConnectorId = this.chargingStation.getConnectorIdByTransactionId( |
400 | requestPayload.transactionId | |
401 | ); | |
c0560973 | 402 | if (!transactionConnectorId) { |
e7aeea18 JB |
403 | logger.error( |
404 | this.chargingStation.logPrefix() + | |
405 | ' Trying to stop a non existing transaction ' + | |
406 | requestPayload.transactionId.toString() | |
407 | ); | |
c0560973 JB |
408 | return; |
409 | } | |
410 | if (payload.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED) { | |
e7aeea18 JB |
411 | this.chargingStation.getBeginEndMeterValues() && |
412 | !this.chargingStation.getOcppStrictCompliance() && | |
413 | this.chargingStation.getOutOfOrderEndMeterValues() && | |
ef6fa3fb JB |
414 | (await this.chargingStation.ocppRequestService.sendMessageHandler< |
415 | OCPP16MeterValuesRequest, | |
416 | OCPP16MeterValuesResponse | |
417 | >(OCPP16RequestCommand.METER_VALUES, { | |
418 | connectorId: transactionConnectorId, | |
419 | transactionId: requestPayload.transactionId, | |
420 | meterValue: OCPP16ServiceUtils.buildTransactionEndMeterValue( | |
421 | this.chargingStation, | |
422 | transactionConnectorId, | |
423 | requestPayload.meterStop | |
424 | ), | |
425 | })); | |
e7aeea18 JB |
426 | if ( |
427 | !this.chargingStation.isChargingStationAvailable() || | |
428 | !this.chargingStation.isConnectorAvailable(transactionConnectorId) | |
429 | ) { | |
ef6fa3fb JB |
430 | await this.chargingStation.ocppRequestService.sendMessageHandler< |
431 | OCPP16StatusNotificationRequest, | |
432 | OCPP16StatusNotificationResponse | |
433 | >(OCPP16RequestCommand.STATUS_NOTIFICATION, { | |
434 | connectorId: transactionConnectorId, | |
435 | status: OCPP16ChargePointStatus.UNAVAILABLE, | |
436 | errorCode: OCPP16ChargePointErrorCode.NO_ERROR, | |
437 | }); | |
e7aeea18 JB |
438 | this.chargingStation.getConnectorStatus(transactionConnectorId).status = |
439 | OCPP16ChargePointStatus.UNAVAILABLE; | |
c0560973 | 440 | } else { |
ef6fa3fb JB |
441 | await this.chargingStation.ocppRequestService.sendMessageHandler< |
442 | OCPP16BootNotificationRequest, | |
443 | OCPP16BootNotificationResponse | |
444 | >(OCPP16RequestCommand.STATUS_NOTIFICATION, { | |
445 | connectorId: transactionConnectorId, | |
446 | status: OCPP16ChargePointStatus.AVAILABLE, | |
447 | errorCode: OCPP16ChargePointErrorCode.NO_ERROR, | |
448 | }); | |
e7aeea18 JB |
449 | this.chargingStation.getConnectorStatus(transactionConnectorId).status = |
450 | OCPP16ChargePointStatus.AVAILABLE; | |
c0560973 JB |
451 | } |
452 | if (this.chargingStation.stationInfo.powerSharedByConnectors) { | |
453 | this.chargingStation.stationInfo.powerDivider--; | |
454 | } | |
e7aeea18 JB |
455 | logger.info( |
456 | this.chargingStation.logPrefix() + | |
457 | ' Transaction ' + | |
458 | requestPayload.transactionId.toString() + | |
459 | ' STOPPED on ' + | |
460 | this.chargingStation.stationInfo.chargingStationId + | |
461 | '#' + | |
462 | transactionConnectorId.toString() | |
463 | ); | |
a2653482 | 464 | this.chargingStation.resetConnectorStatus(transactionConnectorId); |
c0560973 | 465 | } else { |
e7aeea18 JB |
466 | logger.warn( |
467 | this.chargingStation.logPrefix() + | |
468 | ' Stopping transaction id ' + | |
469 | requestPayload.transactionId.toString() + | |
e8e865ea JB |
470 | " REJECTED with status '" + |
471 | payload.idTagInfo?.status + | |
472 | "'" | |
e7aeea18 | 473 | ); |
c0560973 JB |
474 | } |
475 | } | |
476 | ||
e7aeea18 | 477 | private handleResponseStatusNotification( |
ef6fa3fb | 478 | payload: OCPP16StatusNotificationRequest, |
f22266fd | 479 | requestPayload: OCPP16StatusNotificationResponse |
e7aeea18 JB |
480 | ): void { |
481 | logger.debug( | |
482 | this.chargingStation.logPrefix() + | |
483 | ' Status notification response received: %j to StatusNotification request: %j', | |
484 | payload, | |
485 | requestPayload | |
486 | ); | |
c0560973 JB |
487 | } |
488 | ||
e7aeea18 | 489 | private handleResponseMeterValues( |
ef6fa3fb | 490 | payload: OCPP16MeterValuesRequest, |
f22266fd | 491 | requestPayload: OCPP16MeterValuesResponse |
e7aeea18 JB |
492 | ): void { |
493 | logger.debug( | |
494 | this.chargingStation.logPrefix() + | |
495 | ' MeterValues response received: %j to MeterValues request: %j', | |
496 | payload, | |
497 | requestPayload | |
498 | ); | |
c0560973 | 499 | } |
c0560973 | 500 | } |