repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refactor(ui): align text casing
[e-mobility-charging-stations-simulator.git]
/
src
/
charging-station
/
ocpp
/
OCPPRequestService.ts
diff --git
a/src/charging-station/ocpp/OCPPRequestService.ts
b/src/charging-station/ocpp/OCPPRequestService.ts
index f956d381b30109d14c708b06fae9c7637830d7f5..57f6a06191081d328bc8069be96b1133699a2611 100644
(file)
--- a/
src/charging-station/ocpp/OCPPRequestService.ts
+++ b/
src/charging-station/ocpp/OCPPRequestService.ts
@@
-47,7
+47,7
@@
export abstract class OCPPRequestService {
private readonly version: OCPPVersion
private readonly ocppResponseService: OCPPResponseService
protected readonly ajv: Ajv
private readonly version: OCPPVersion
private readonly ocppResponseService: OCPPResponseService
protected readonly ajv: Ajv
- protected abstract
jsonSchemasValidateFunction
: Map<RequestCommand, ValidateFunction<JsonType>>
+ protected abstract
payloadValidateFunctions
: Map<RequestCommand, ValidateFunction<JsonType>>
protected constructor (version: OCPPVersion, ocppResponseService: OCPPResponseService) {
this.version = version
protected constructor (version: OCPPVersion, ocppResponseService: OCPPResponseService) {
this.version = version
@@
-158,13
+158,13
@@
export abstract class OCPPRequestService {
if (chargingStation.stationInfo?.ocppStrictCompliance === false) {
return true
}
if (chargingStation.stationInfo?.ocppStrictCompliance === false) {
return true
}
- if (!this.
jsonSchemasValidateFunction
.has(commandName as RequestCommand)) {
+ if (!this.
payloadValidateFunctions
.has(commandName as RequestCommand)) {
logger.warn(
`${chargingStation.logPrefix()} ${moduleName}.validateRequestPayload: No JSON schema found for command '${commandName}' PDU validation`
)
return true
}
logger.warn(
`${chargingStation.logPrefix()} ${moduleName}.validateRequestPayload: No JSON schema found for command '${commandName}' PDU validation`
)
return true
}
- const validate = this.
jsonSchemasValidateFunction
.get(commandName as RequestCommand)
+ const validate = this.
payloadValidateFunctions
.get(commandName as RequestCommand)
payload = clone<T>(payload)
OCPPServiceUtils.convertDateToISOString<T>(payload)
if (validate?.(payload) === true) {
payload = clone<T>(payload)
OCPPServiceUtils.convertDateToISOString<T>(payload)
if (validate?.(payload) === true) {
@@
-192,7
+192,7
@@
export abstract class OCPPRequestService {
return true
}
if (
return true
}
if (
- !this.ocppResponseService.
jsonSchemasIncomingRequestResponseValidateFunction
.has(
+ !this.ocppResponseService.
incomingRequestResponsePayloadValidateFunctions
.has(
commandName as IncomingRequestCommand
)
) {
commandName as IncomingRequestCommand
)
) {
@@
-201,10
+201,9
@@
export abstract class OCPPRequestService {
)
return true
}
)
return true
}
- const validate =
- this.ocppResponseService.jsonSchemasIncomingRequestResponseValidateFunction.get(
- commandName as IncomingRequestCommand
- )
+ const validate = this.ocppResponseService.incomingRequestResponsePayloadValidateFunctions.get(
+ commandName as IncomingRequestCommand
+ )
payload = clone<T>(payload)
OCPPServiceUtils.convertDateToISOString<T>(payload)
if (validate?.(payload) === true) {
payload = clone<T>(payload)
OCPPServiceUtils.convertDateToISOString<T>(payload)
if (validate?.(payload) === true) {
@@
-308,7
+307,7
@@
export abstract class OCPPRequestService {
// Buffer
chargingStation.bufferMessage(messageToSend)
if (messageType === MessageType.CALL_MESSAGE) {
// Buffer
chargingStation.bufferMessage(messageToSend)
if (messageType === MessageType.CALL_MESSAGE) {
- this.
cacheRequestPromise
(
+ this.
setCachedRequest
(
chargingStation,
messageId,
messagePayload as JsonType,
chargingStation,
messageId,
messagePayload as JsonType,
@@
-364,7
+363,7
@@
export abstract class OCPPRequestService {
)} payload: ${messageToSend}`
)
if (messageType === MessageType.CALL_MESSAGE) {
)} payload: ${messageToSend}`
)
if (messageType === MessageType.CALL_MESSAGE) {
- this.
cacheRequestPromise
(
+ this.
setCachedRequest
(
chargingStation,
messageId,
messagePayload as JsonType,
chargingStation,
messageId,
messagePayload as JsonType,
@@
-454,7
+453,7
@@
export abstract class OCPPRequestService {
(messagePayload as OCPPError).code,
(messagePayload as OCPPError).message,
(messagePayload as OCPPError).details ?? {
(messagePayload as OCPPError).code,
(messagePayload as OCPPError).message,
(messagePayload as OCPPError).details ?? {
- command: (messagePayload as OCPPError).command
?? commandName
+ command: (messagePayload as OCPPError).command
}
] satisfies ErrorResponse)
break
}
] satisfies ErrorResponse)
break
@@
-462,7
+461,7
@@
export abstract class OCPPRequestService {
return messageToSend
}
return messageToSend
}
- private
cacheRequestPromise
(
+ private
setCachedRequest
(
chargingStation: ChargingStation,
messageId: string,
messagePayload: JsonType,
chargingStation: ChargingStation,
messageId: string,
messagePayload: JsonType,