}
}
- public getEnergyActiveImportRegisterByTransactionId(transactionId: number): number {
- const transactionConnectorStatus = this.getConnectorStatus(
- this.getConnectorIdByTransactionId(transactionId)
+ public getEnergyActiveImportRegisterByTransactionId(
+ transactionId: number,
+ meterStop = false
+ ): number {
+ return this.getEnergyActiveImportRegister(
+ this.getConnectorStatus(this.getConnectorIdByTransactionId(transactionId)),
+ meterStop
);
- if (this.getMeteringPerTransaction()) {
- return transactionConnectorStatus?.transactionEnergyActiveImportRegisterValue ?? 0;
- }
- return transactionConnectorStatus?.energyActiveImportRegisterValue ?? 0;
}
public getEnergyActiveImportRegisterByConnectorId(connectorId: number): number {
- const connectorStatus = this.getConnectorStatus(connectorId);
- if (this.getMeteringPerTransaction()) {
- return connectorStatus?.transactionEnergyActiveImportRegisterValue ?? 0;
- }
- return connectorStatus?.energyActiveImportRegisterValue ?? 0;
+ return this.getEnergyActiveImportRegister(this.getConnectorStatus(connectorId));
}
public getAuthorizeRemoteTxRequests(): boolean {
logger.error(this.logPrefix() + ' WebSocket error:', error);
}
+ private getEnergyActiveImportRegister(
+ connectorStatus: ConnectorStatus,
+ meterStop = false
+ ): number {
+ if (this.getMeteringPerTransaction()) {
+ return (
+ (meterStop === true
+ ? Math.round(connectorStatus?.transactionEnergyActiveImportRegisterValue)
+ : connectorStatus?.transactionEnergyActiveImportRegisterValue) ?? 0
+ );
+ }
+ return (
+ (meterStop === true
+ ? Math.round(connectorStatus?.energyActiveImportRegisterValue)
+ : connectorStatus?.energyActiveImportRegisterValue) ?? 0
+ );
+ }
+
private getUseConnectorId0(stationInfo?: ChargingStationInfo): boolean | undefined {
const localStationInfo = stationInfo ?? this.stationInfo;
return !Utils.isUndefined(localStationInfo.useConnectorId0)
StopTransactionResponse
>(this, RequestCommand.STOP_TRANSACTION, {
transactionId,
- meterStop: this.getEnergyActiveImportRegisterByTransactionId(transactionId),
+ meterStop: this.getEnergyActiveImportRegisterByTransactionId(transactionId, true),
idTag: this.getTransactionIdTag(transactionId),
reason,
});
>(this.chargingStation, RequestCommand.STOP_TRANSACTION, {
transactionId: requestPayload.transactionId,
meterStop: this.chargingStation.getEnergyActiveImportRegisterByTransactionId(
- requestPayload.transactionId
+ requestPayload.transactionId,
+ true
),
idTag: this.chargingStation.getTransactionIdTag(requestPayload.transactionId),
reason: StopTransactionReason.NONE,
OCPP16StopTransactionResponse
>(chargingStation, OCPP16RequestCommand.STOP_TRANSACTION, {
transactionId,
- meterStop: chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId),
+ meterStop: chargingStation.getEnergyActiveImportRegisterByTransactionId(
+ transactionId,
+ true
+ ),
idTag: chargingStation.getTransactionIdTag(transactionId),
reason: OCPP16StopTransactionReason.UNLOCK_COMMAND,
});
OCPP16StopTransactionResponse
>(chargingStation, OCPP16RequestCommand.STOP_TRANSACTION, {
transactionId,
- meterStop: chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId),
+ meterStop: chargingStation.getEnergyActiveImportRegisterByTransactionId(
+ transactionId,
+ true
+ ),
idTag: chargingStation.getTransactionIdTag(transactionId),
});
return Constants.OCPP_RESPONSE_ACCEPTED;