@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.
69 lines (68 loc) • 3.25 kB
TypeScript
import { OCPP2_0_1 } from '../ocpp/model';
export declare class MeterValueUtils {
private static readonly validContexts;
/**
* Calculate the total Kwh
*
* @param {array} meterValues - meterValues of a transaction.
* @return {number} total Kwh based on the best available energy measurement.
*/
static getTotalKwh(meterValues: OCPP2_0_1.MeterValueType[]): number;
/**
* 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;
/**
* Calculate the total kWh consumed from a sorted array of kWh readings.
* @param sortedValues Array of kWh values sorted by timestamp.
* @returns The difference between last and first reading, or 0 if fewer than two readings.
*/
private static calculateTotalKwh;
}