update struct in battery view front end

This commit is contained in:
Noe 2024-03-11 16:11:18 +01:00
parent d88a18c982
commit 490d721795
1 changed files with 9 additions and 6 deletions

View File

@ -32,6 +32,7 @@ export type ConfigurationValues = {
minimumSoC: string | number;
gridSetPoint: number;
forceCalibrationCharge: number;
calibrationChargeDate: Date | null;
};
export interface Battery {
@ -158,6 +159,7 @@ export type TopologyValues = {
DcDcNum: I_BoxDataValue[];
calibrationChargeForced: I_BoxDataValue[];
mode: I_BoxDataValue[];
calibrationChargeDate: I_BoxDataValue[];
batteryView: Battery[];
};
@ -293,7 +295,8 @@ export const topologyPaths: TopologyPaths = {
maximumDischargePower: ['/Config/MaxBatteryDischargingCurrent'],
DcDcNum: ['/DcDc/SystemControl/NumberOfConnectedSlaves'],
calibrationChargeForced: ['/Config/ForceCalibrationCharge'],
mode: ['/EssControl/Mode']
mode: ['/EssControl/Mode'],
calibrationChargeDate: ['/EssControl/Date']
};
export const extractValues = (
@ -307,19 +310,19 @@ export const extractValues = (
if (topologyKey === 'batteryView') {
extractedValues[topologyKey] = [];
const numOfBatteries = timeSeriesData.value[
const battery_ids_from_csv = timeSeriesData.value[
'/Config/Devices/BatteryNodes'
].value
.toString()
.split(',').length;
.split(',');
let battery_id = 1;
let battery_index = 0;
let pathIndex = 0;
while (pathIndex < paths.length) {
let battery = {};
let existingKeys = 0;
battery[BatteryKeys[0]] = battery_id;
battery[BatteryKeys[0]] = battery_ids_from_csv[battery_index];
for (let i = 1; i < BatteryKeys.length; i++) {
const path = paths[pathIndex];
if (timeSeriesData.value.hasOwnProperty(path)) {
@ -337,7 +340,7 @@ export const extractValues = (
}
pathIndex++;
}
battery_id++;
battery_index++;
if (existingKeys > 0) {
extractedValues[topologyKey].push(battery as Battery);
}