@citrineos/base
Version:
The base module for OCPP v2.0.1 including all interfaces. This module is not intended to be used directly, but rather as a dependency for other modules.
66 lines (65 loc) • 3.29 kB
TypeScript
import type { MeterValueDto } from '../interfaces/dto/meter.value.dto.js';
export declare class MeterValueUtils {
private static readonly validContexts;
/**
* Calculate the total Kwh
*
* @param {array} meterValues - meterValues of a transaction.
* @param {number} currentTotal - the current total Kwh to add to interval values, if needed.
* @param {number} meterStart - the starting Kwh value at the beginning of the transaction, if available.
* @return {number} total Kwh based on the best available energy measurement.
*/
static getTotalKwh(meterValues: MeterValueDto[], currentTotal: number, meterStart?: number): number;
static getMeterStart(meterValues: MeterValueDto[]): number | null;
/**
* Filter out meter values whose context is not one of the valid reading contexts.
* @param meterValues Array of MeterValueType to filter.
* @returns Filtered array containing only meter values in Transaction_Begin, Sample_Periodic or Transaction_End contexts.
*/
private static filterValidMeterValues;
/**
* Extracts Energy.Active.Import.Register measurand values into a timestamp-to-kWh map.
* @param meterValues Array of MeterValueType to search for register readings.
* @returns Map where each key is the reading timestamp (ms since epoch) and each value is the normalized kWh.
*/
private static getRegisterValuesMap;
/**
* Extracts Energy.Active.Import.Interval measurand values into a timestamp-to-kWh map.
* @param meterValues Array of MeterValueType to search for interval readings.
* @returns Map where each key is the reading timestamp (ms since epoch) and each value is the normalized kWh.
*/
private static getIntervalValuesMap;
/**
* Extracts Energy.Active.Net measurand values into a timestamp-to-kWh map.
* @param meterValues Array of MeterValueType to search for net readings.
* @returns Map where each key is the reading timestamp (ms since epoch) and each value is the normalized kWh.
*/
private static getNetValuesMap;
/**
* Find a specific measurand value from sampledValues
* @param sampledValues Array of sampled values
* @param measurand The measurand type to look for
* @param phased Whether to look for phased values (true) or non-phased values (false)
* @returns The normalized value in kWh, or null if not found
*/
private static findMeasurandValue;
/**
* Sum phased values for a specific measurand
* @param sampledValues Array of sampled values
* @param measurand The measurand type to sum
* @returns The sum of phase values in kWh, or null if no valid phase values found
*/
private static sumPhasedValues;
/**
* Convert a sampled value to kWh, applying unit multipliers.
* @param value A SampledValueType entry.
* @returns The converted value in kWh, or null if unit is missing.
*/
private static normalizeToKwh;
/**
* Sort the entries of a timestamp-to-kWh map ascending by timestamp and return the kWh values.
* @param valuesMap Map of timestamp (ms since epoch) to kWh.
* @returns Array of kWh values sorted by timestamp.
*/
private static getSortedKwhByTimestampAscending;
}