adapted PV battery box according to cluster number dynamically
This commit is contained in:
parent
4b35fca8f2
commit
861ab64cfb
|
|
@ -470,6 +470,7 @@ function SodioHomeInstallation(props: singleInstallationProps) {
|
|||
values={values}
|
||||
connected={connected}
|
||||
loading={loading}
|
||||
batteryClusterNumber={props.current_installation.batteryClusterNumber}
|
||||
></TopologySodistoreHome>
|
||||
}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ interface TopologySodistoreHomeProps {
|
|||
values: JSONRecordData;
|
||||
connected: boolean;
|
||||
loading: boolean;
|
||||
batteryClusterNumber:number;
|
||||
}
|
||||
|
||||
function TopologySodistoreHome(props: TopologySodistoreHomeProps) {
|
||||
|
|
@ -37,6 +38,24 @@ function TopologySodistoreHome(props: TopologySodistoreHomeProps) {
|
|||
|
||||
const isMobile = window.innerWidth <= 1490;
|
||||
|
||||
const totalBatteryPower: number = Number(
|
||||
props.values && props.values.InverterRecord
|
||||
? Array.from({ length: props.batteryClusterNumber }).reduce(
|
||||
(sum: number, _, index) => {
|
||||
const i = index + 1;
|
||||
|
||||
const rawPower =
|
||||
props.values.InverterRecord[`Battery${i}Power`] as unknown;
|
||||
|
||||
const power = Number(rawPower) || 0;
|
||||
|
||||
return sum + power;
|
||||
},
|
||||
0
|
||||
)
|
||||
: 0
|
||||
);
|
||||
|
||||
return (
|
||||
<Container maxWidth="xl" style={{ backgroundColor: 'white' }}>
|
||||
<Grid container>
|
||||
|
|
@ -187,15 +206,12 @@ function TopologySodistoreHome(props: TopologySodistoreHomeProps) {
|
|||
orientation: 'horizontal',
|
||||
data: props.values?.InverterRecord
|
||||
? {
|
||||
value: props.values.InverterRecord.Battery1Power,
|
||||
value: totalBatteryPower,
|
||||
unit: 'W'
|
||||
}
|
||||
: undefined,
|
||||
amount: props.values?.InverterRecord
|
||||
? getAmount(
|
||||
highestConnectionValue,
|
||||
props.values.InverterRecord.Battery1Power,
|
||||
)
|
||||
? getAmount(highestConnectionValue, totalBatteryPower)
|
||||
: 0,
|
||||
showValues: showValues
|
||||
}}
|
||||
|
|
@ -232,27 +248,33 @@ function TopologySodistoreHome(props: TopologySodistoreHomeProps) {
|
|||
isFirst={false}
|
||||
/>
|
||||
{/*-------------------------------------------------------------------------------------------------------------------------------------------------------------*/}
|
||||
{Array.from({ length: props.batteryClusterNumber }).map((_, index) => {
|
||||
const i = index + 1; // battery cluster index starting from 1
|
||||
|
||||
return (
|
||||
<TopologyColumn
|
||||
key={i}
|
||||
centerBox={{
|
||||
title: 'Battery',
|
||||
title: `Battery C${i}`,
|
||||
data: props.values.InverterRecord
|
||||
? [
|
||||
{
|
||||
value: props.values.InverterRecord.Battery1Soc,
|
||||
value: props.values.InverterRecord[`Battery${i}Soc`],
|
||||
unit: '%'
|
||||
},
|
||||
{
|
||||
value: props.values.InverterRecord.Battery1Power,
|
||||
value: props.values.InverterRecord[`Battery${i}Power`],
|
||||
unit: 'W'
|
||||
}
|
||||
]
|
||||
: undefined,
|
||||
|
||||
connected: true
|
||||
}}
|
||||
isLast={true}
|
||||
isFirst={false}
|
||||
isLast={true}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</Grid>
|
||||
</>
|
||||
)}
|
||||
|
|
|
|||
Loading…
Reference in New Issue