pv view
This commit is contained in:
parent
0357980b3a
commit
c44c7e782d
|
@ -35,7 +35,12 @@ export type ConfigurationValues = {
|
|||
calibrationChargeDate: Date | null;
|
||||
};
|
||||
|
||||
export interface Pv {}
|
||||
export interface Pv {
|
||||
PvId: number;
|
||||
Voltage: I_BoxDataValue;
|
||||
Power: I_BoxDataValue;
|
||||
Current: I_BoxDataValue;
|
||||
}
|
||||
|
||||
export interface Battery {
|
||||
BatteryId: number;
|
||||
|
@ -339,6 +344,49 @@ export const extractValues = (
|
|||
const paths = topologyPaths[topologyKey];
|
||||
let topologyValues: { unit: string; value: string | number }[] = [];
|
||||
|
||||
if (topologyKey === 'pvView') {
|
||||
extractedValues[topologyKey] = [];
|
||||
const node_ids_from_csv = timeSeriesData.value[
|
||||
'/Config/Devices/BatteryNodes'
|
||||
].value
|
||||
.toString()
|
||||
.split(',');
|
||||
|
||||
let pv_index = 0;
|
||||
let pathIndex = 0;
|
||||
|
||||
while (pathIndex < paths.length) {
|
||||
let pv = {};
|
||||
let existingKeys = 0;
|
||||
|
||||
//We prepare a battery object for each node. We extract the nodes from the '/Config/Devices/BatteryNodes' path. For example, nodes can be [2,4,5,6] (one is missing)
|
||||
//BatteryKeys[0] is the battery id. We set the battery id to the corresponding node id.
|
||||
battery[BatteryKeys[0]] = node_ids_from_csv[pv_index];
|
||||
//Then, search all the remaining battery keys
|
||||
for (let i = 1; i < BatteryKeys.length; i++) {
|
||||
const path = paths[pathIndex];
|
||||
if (timeSeriesData.value.hasOwnProperty(path)) {
|
||||
existingKeys++;
|
||||
|
||||
battery[BatteryKeys[i]] = {
|
||||
unit: timeSeriesData.value[path].unit.includes('~')
|
||||
? timeSeriesData.value[path].unit.replace('~', '')
|
||||
: timeSeriesData.value[path].unit,
|
||||
value:
|
||||
typeof timeSeriesData.value[path].value === 'string'
|
||||
? timeSeriesData.value[path].value
|
||||
: Number(timeSeriesData.value[path].value).toFixed(1)
|
||||
};
|
||||
}
|
||||
pathIndex++;
|
||||
}
|
||||
battery_index++;
|
||||
if (existingKeys > 0) {
|
||||
extractedValues[topologyKey].push(battery as Battery);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (topologyKey === 'batteryView') {
|
||||
extractedValues[topologyKey] = [];
|
||||
const node_ids_from_csv = timeSeriesData.value[
|
||||
|
|
Loading…
Reference in New Issue