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}
|
values={values}
|
||||||
connected={connected}
|
connected={connected}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
|
batteryClusterNumber={props.current_installation.batteryClusterNumber}
|
||||||
></TopologySodistoreHome>
|
></TopologySodistoreHome>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ interface TopologySodistoreHomeProps {
|
||||||
values: JSONRecordData;
|
values: JSONRecordData;
|
||||||
connected: boolean;
|
connected: boolean;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
|
batteryClusterNumber:number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function TopologySodistoreHome(props: TopologySodistoreHomeProps) {
|
function TopologySodistoreHome(props: TopologySodistoreHomeProps) {
|
||||||
|
|
@ -37,6 +38,24 @@ function TopologySodistoreHome(props: TopologySodistoreHomeProps) {
|
||||||
|
|
||||||
const isMobile = window.innerWidth <= 1490;
|
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 (
|
return (
|
||||||
<Container maxWidth="xl" style={{ backgroundColor: 'white' }}>
|
<Container maxWidth="xl" style={{ backgroundColor: 'white' }}>
|
||||||
<Grid container>
|
<Grid container>
|
||||||
|
|
@ -187,15 +206,12 @@ function TopologySodistoreHome(props: TopologySodistoreHomeProps) {
|
||||||
orientation: 'horizontal',
|
orientation: 'horizontal',
|
||||||
data: props.values?.InverterRecord
|
data: props.values?.InverterRecord
|
||||||
? {
|
? {
|
||||||
value: props.values.InverterRecord.Battery1Power,
|
value: totalBatteryPower,
|
||||||
unit: 'W'
|
unit: 'W'
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
amount: props.values?.InverterRecord
|
amount: props.values?.InverterRecord
|
||||||
? getAmount(
|
? getAmount(highestConnectionValue, totalBatteryPower)
|
||||||
highestConnectionValue,
|
|
||||||
props.values.InverterRecord.Battery1Power,
|
|
||||||
)
|
|
||||||
: 0,
|
: 0,
|
||||||
showValues: showValues
|
showValues: showValues
|
||||||
}}
|
}}
|
||||||
|
|
@ -232,27 +248,33 @@ function TopologySodistoreHome(props: TopologySodistoreHomeProps) {
|
||||||
isFirst={false}
|
isFirst={false}
|
||||||
/>
|
/>
|
||||||
{/*-------------------------------------------------------------------------------------------------------------------------------------------------------------*/}
|
{/*-------------------------------------------------------------------------------------------------------------------------------------------------------------*/}
|
||||||
<TopologyColumn
|
{Array.from({ length: props.batteryClusterNumber }).map((_, index) => {
|
||||||
centerBox={{
|
const i = index + 1; // battery cluster index starting from 1
|
||||||
title: 'Battery',
|
|
||||||
data: props.values.InverterRecord
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
value: props.values.InverterRecord.Battery1Soc,
|
|
||||||
unit: '%'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: props.values.InverterRecord.Battery1Power,
|
|
||||||
unit: 'W'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
: undefined,
|
|
||||||
|
|
||||||
connected: true
|
return (
|
||||||
}}
|
<TopologyColumn
|
||||||
isLast={true}
|
key={i}
|
||||||
isFirst={false}
|
centerBox={{
|
||||||
/>
|
title: `Battery C${i}`,
|
||||||
|
data: props.values.InverterRecord
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
value: props.values.InverterRecord[`Battery${i}Soc`],
|
||||||
|
unit: '%'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: props.values.InverterRecord[`Battery${i}Power`],
|
||||||
|
unit: 'W'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
: undefined,
|
||||||
|
connected: true
|
||||||
|
}}
|
||||||
|
isFirst={false}
|
||||||
|
isLast={true}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</Grid>
|
</Grid>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue