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