requestPayload.transactionId,
true
),
- idTag: this.chargingStation.getTransactionIdTag(requestPayload.transactionId),
- ...(requestPayload.reason && { reason: requestPayload.reason }),
+ idTag: requestPayload.idTag,
+ reason: requestPayload.reason,
});
case BroadcastChannelProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR:
this.chargingStation.startAutomaticTransactionGenerator(requestPayload.connectorIds);
private buildResponsePayload(uuid: string): ResponsePayload {
const responsesStatus = this.responses
.get(uuid)
- ?.responses.every((response) => response.status === ResponseStatus.SUCCESS)
+ ?.responses.every(({ status }) => status === ResponseStatus.SUCCESS)
? ResponseStatus.SUCCESS
: ResponseStatus.FAILURE;
return {
commandParams?: JsonType
): Request {
let connectorId: number;
+ let energyActiveImportRegister: number;
commandParams = commandParams as JsonObject;
switch (commandName) {
case OCPP16RequestCommand.AUTHORIZE:
connectorId = chargingStation.getConnectorIdByTransactionId(
commandParams?.transactionId as number
);
+ energyActiveImportRegister = chargingStation.getEnergyActiveImportRegisterByTransactionId(
+ commandParams?.transactionId as number,
+ true
+ );
return {
transactionId: commandParams?.transactionId,
- ...(!Utils.isUndefined(commandParams?.idTag) && { idTag: commandParams.idTag }),
- meterStop: commandParams?.meterStop,
+ idTag:
+ commandParams?.idTag ??
+ chargingStation.getTransactionIdTag(commandParams?.transactionId as number),
+ meterStop: commandParams?.meterStop ?? energyActiveImportRegister,
timestamp: new Date().toISOString(),
- ...(commandParams?.reason && { reason: commandParams.reason }),
+ reason: commandParams?.reason,
...(chargingStation.getTransactionDataMeterValues() && {
transactionData: OCPP16ServiceUtils.buildTransactionDataMeterValues(
chargingStation.getConnectorStatus(connectorId).transactionBeginMeterValue,
OCPP16ServiceUtils.buildTransactionEndMeterValue(
chargingStation,
connectorId,
- commandParams?.meterStop as number
+ (commandParams?.meterStop as number) ?? energyActiveImportRegister
)
),
}),