Update battery view for Salimax/SodistoreMax
Update Mainstats as well. We still do not have detailed battery view for SodistoreMax.
This commit is contained in:
parent
bcde77c567
commit
f3168e7215
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useContext, useEffect, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
Container,
|
Container,
|
||||||
Grid,
|
Grid,
|
||||||
|
|
@ -26,12 +26,12 @@ import routes from '../../../Resources/routes.json';
|
||||||
import CircularProgress from '@mui/material/CircularProgress';
|
import CircularProgress from '@mui/material/CircularProgress';
|
||||||
import MainStats from './MainStats';
|
import MainStats from './MainStats';
|
||||||
import DetailedBatteryView from './DetailedBatteryView';
|
import DetailedBatteryView from './DetailedBatteryView';
|
||||||
|
import { ProductIdContext } from '../../../contexts/ProductIdContextProvider';
|
||||||
|
|
||||||
interface BatteryViewProps {
|
interface BatteryViewProps {
|
||||||
values: JSONRecordData;
|
values: JSONRecordData;
|
||||||
s3Credentials: I_S3Credentials;
|
s3Credentials: I_S3Credentials;
|
||||||
installationId: number;
|
installationId: number;
|
||||||
productNum: number;
|
|
||||||
connected: boolean;
|
connected: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,13 +56,7 @@ function BatteryView(props: BatteryViewProps) {
|
||||||
navigate(routes.mainstats);
|
navigate(routes.mainstats);
|
||||||
};
|
};
|
||||||
|
|
||||||
// const findBatteryData = (batteryId: number) => {
|
const { product, setProduct } = useContext(ProductIdContext);
|
||||||
// for (let i = 0; i < props.values.batteryView.length; i++) {
|
|
||||||
// if (props.values.batteryView[i].BatteryId == batteryId) {
|
|
||||||
// return props.values.batteryView[i];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (sortedBatteryView.length == 0) {
|
if (sortedBatteryView.length == 0) {
|
||||||
|
|
@ -191,26 +185,12 @@ function BatteryView(props: BatteryViewProps) {
|
||||||
s3Credentials={props.s3Credentials}
|
s3Credentials={props.s3Credentials}
|
||||||
batteryData={battery}
|
batteryData={battery}
|
||||||
installationId={props.installationId}
|
installationId={props.installationId}
|
||||||
productNum={props.productNum}
|
productNum={product}
|
||||||
></DetailedBatteryView>
|
></DetailedBatteryView>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
{/*{props.values.batteryView.map((battery) => (*/}
|
|
||||||
{/* <Route*/}
|
|
||||||
{/* key={routes.detailed_view + battery.BatteryId}*/}
|
|
||||||
{/* path={routes.detailed_view + battery.BatteryId}*/}
|
|
||||||
{/* element={*/}
|
|
||||||
{/* <DetailedBatteryView*/}
|
|
||||||
{/* s3Credentials={props.s3Credentials}*/}
|
|
||||||
{/* batteryData={findBatteryData(battery.BatteryId)}*/}
|
|
||||||
{/* installationId={props.installationId}*/}
|
|
||||||
{/* productNum={props.productNum}*/}
|
|
||||||
{/* ></DetailedBatteryView>*/}
|
|
||||||
{/* }*/}
|
|
||||||
{/* />*/}
|
|
||||||
{/*))}*/}
|
|
||||||
</Routes>
|
</Routes>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|
@ -266,7 +246,9 @@ function BatteryView(props: BatteryViewProps) {
|
||||||
textAlign: 'center'
|
textAlign: 'center'
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{battery.FwVersion}
|
{product == 0
|
||||||
|
? battery.FwVersion
|
||||||
|
: battery.BatteryDeligreenDataRecord.FwVersion}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell
|
<TableCell
|
||||||
sx={{
|
sx={{
|
||||||
|
|
@ -274,7 +256,9 @@ function BatteryView(props: BatteryViewProps) {
|
||||||
textAlign: 'center'
|
textAlign: 'center'
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{battery.Dc.Power + ' ' + 'W'}
|
{product == 0
|
||||||
|
? battery.Dc.Power + ' ' + 'W'
|
||||||
|
: battery.BatteryDeligreenDataRecord.Power + ' ' + 'W'}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell
|
<TableCell
|
||||||
sx={{
|
sx={{
|
||||||
|
|
@ -282,108 +266,192 @@ function BatteryView(props: BatteryViewProps) {
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
|
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
battery.Dc.Voltage < 44 || battery.Dc.Voltage > 57
|
product == 0
|
||||||
|
? battery.Dc.Voltage < 44 || battery.Dc.Voltage > 57
|
||||||
|
? '#FF033E'
|
||||||
|
: '#32CD32'
|
||||||
|
: battery.BatteryDeligreenDataRecord
|
||||||
|
.TotalBatteryVoltage < 44 ||
|
||||||
|
battery.BatteryDeligreenDataRecord
|
||||||
|
.TotalBatteryVoltage > 57
|
||||||
? '#FF033E'
|
? '#FF033E'
|
||||||
: '#32CD32',
|
: '#32CD32',
|
||||||
color: battery.Dc.Voltage ? 'black' : 'white'
|
color:
|
||||||
|
product === 0
|
||||||
|
? battery.Dc.Voltage
|
||||||
|
? 'black'
|
||||||
|
: 'white'
|
||||||
|
: battery.BatteryDeligreenDataRecord
|
||||||
|
.TotalBatteryVoltage
|
||||||
|
? 'black'
|
||||||
|
: 'white'
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{battery.Dc.Voltage + ' ' + 'V'}
|
{product === 0
|
||||||
|
? battery.Dc.Voltage + ' ' + 'V'
|
||||||
|
: battery.BatteryDeligreenDataRecord
|
||||||
|
.TotalBatteryVoltage +
|
||||||
|
' ' +
|
||||||
|
'V'}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell
|
<TableCell
|
||||||
sx={{
|
sx={{
|
||||||
width: '10%',
|
width: '10%',
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
battery.Soc < 20
|
product === 0
|
||||||
|
? battery.Soc < 20
|
||||||
|
? '#FF033E'
|
||||||
|
: battery.Soc < 50
|
||||||
|
? '#ffbf00'
|
||||||
|
: '#32CD32'
|
||||||
|
: battery.BatteryDeligreenDataRecord.Soc < 20
|
||||||
? '#FF033E'
|
? '#FF033E'
|
||||||
: battery.Soc < 50
|
: battery.BatteryDeligreenDataRecord.Soc < 50
|
||||||
? '#ffbf00'
|
? '#ffbf00'
|
||||||
: '#32CD32',
|
: '#32CD32',
|
||||||
color: battery.Soc ? 'inherit' : 'white'
|
color:
|
||||||
|
product === 0
|
||||||
|
? battery.Soc
|
||||||
|
? 'inherit'
|
||||||
|
: 'white'
|
||||||
|
: battery.BatteryDeligreenDataRecord.Soc
|
||||||
|
? 'inherit'
|
||||||
|
: 'white'
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{battery.Soc + ' %'}
|
{product == 0
|
||||||
|
? battery.Soc + ' %'
|
||||||
|
: battery.BatteryDeligreenDataRecord.Soc + ' %'}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell
|
<TableCell
|
||||||
sx={{
|
sx={() => {
|
||||||
width: '10%',
|
if (product === 0) {
|
||||||
textAlign: 'center',
|
const avg = battery.Temperatures.Cells.Average;
|
||||||
backgroundColor:
|
return {
|
||||||
battery.Temperatures.Cells.Average > 300
|
width: '10%',
|
||||||
? '#FF033E'
|
textAlign: 'center',
|
||||||
: battery.Temperatures.Cells.Average > 280
|
backgroundColor:
|
||||||
? '#ffbf00'
|
avg > 300
|
||||||
: battery.Temperatures.Cells.Average < 245
|
? '#FF033E'
|
||||||
? '#008FFB'
|
: avg > 280
|
||||||
: '#32CD32'
|
? '#ffbf00'
|
||||||
|
: avg < 245
|
||||||
|
? '#008FFB'
|
||||||
|
: '#32CD32'
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const avg =
|
||||||
|
(battery.BatteryDeligreenDataRecord.TemperaturesList
|
||||||
|
.CellTemperature1 +
|
||||||
|
battery.BatteryDeligreenDataRecord
|
||||||
|
.TemperaturesList.CellTemperature2 +
|
||||||
|
battery.BatteryDeligreenDataRecord
|
||||||
|
.TemperaturesList.CellTemperature3 +
|
||||||
|
battery.BatteryDeligreenDataRecord
|
||||||
|
.TemperaturesList.CellTemperature4) /
|
||||||
|
4;
|
||||||
|
|
||||||
|
return {
|
||||||
|
width: '10%',
|
||||||
|
textAlign: 'center',
|
||||||
|
backgroundColor:
|
||||||
|
avg > 300
|
||||||
|
? '#FF033E'
|
||||||
|
: avg > 280
|
||||||
|
? '#ffbf00'
|
||||||
|
: avg < 245
|
||||||
|
? '#008FFB'
|
||||||
|
: '#32CD32'
|
||||||
|
};
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{battery.Temperatures.Cells.Average + ' °C'}
|
{product === 0
|
||||||
|
? battery.Temperatures.Cells.Average + ' °C'
|
||||||
|
: (
|
||||||
|
(battery.BatteryDeligreenDataRecord.TemperaturesList
|
||||||
|
.CellTemperature1 +
|
||||||
|
battery.BatteryDeligreenDataRecord
|
||||||
|
.TemperaturesList.CellTemperature2 +
|
||||||
|
battery.BatteryDeligreenDataRecord
|
||||||
|
.TemperaturesList.CellTemperature3 +
|
||||||
|
battery.BatteryDeligreenDataRecord
|
||||||
|
.TemperaturesList.CellTemperature4) /
|
||||||
|
4
|
||||||
|
).toFixed(1) + ' °C'}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
||||||
<TableCell
|
{product === 0 && (
|
||||||
style={{
|
<>
|
||||||
width: '20%',
|
<TableCell
|
||||||
textAlign: 'center',
|
style={{
|
||||||
padding: '8px',
|
width: '20%',
|
||||||
fontWeight:
|
textAlign: 'center',
|
||||||
battery.Warnings !== '' ? 'bold' : 'inherit',
|
padding: '8px',
|
||||||
backgroundColor:
|
fontWeight:
|
||||||
battery.Warnings === '' ? 'inherit' : '#ff9900',
|
battery.Warnings !== '' ? 'bold' : 'inherit',
|
||||||
color: battery.Warnings != '' ? 'black' : 'inherit'
|
backgroundColor:
|
||||||
}}
|
battery.Warnings === '' ? 'inherit' : '#ff9900',
|
||||||
>
|
color: battery.Warnings !== '' ? 'black' : 'inherit'
|
||||||
{battery.Warnings === '' ? (
|
}}
|
||||||
'None'
|
|
||||||
) : battery.Warnings.toString().split('-').length > 1 ? (
|
|
||||||
<Link
|
|
||||||
style={{ color: 'black' }}
|
|
||||||
to={
|
|
||||||
currentLocation.pathname.substring(
|
|
||||||
0,
|
|
||||||
currentLocation.pathname.lastIndexOf('/') + 1
|
|
||||||
) +
|
|
||||||
routes.log +
|
|
||||||
'?open=warning'
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
Multiple Warnings
|
{battery.Warnings === '' ? (
|
||||||
</Link>
|
'None'
|
||||||
) : (
|
) : battery.Warnings.toString().split('-').length >
|
||||||
battery.Warnings
|
1 ? (
|
||||||
)}
|
<Link
|
||||||
</TableCell>
|
style={{ color: 'black' }}
|
||||||
<TableCell
|
to={
|
||||||
sx={{
|
currentLocation.pathname.substring(
|
||||||
width: '20%',
|
0,
|
||||||
textAlign: 'center',
|
currentLocation.pathname.lastIndexOf('/') + 1
|
||||||
fontWeight: battery.Alarms !== '' ? 'bold' : 'inherit',
|
) +
|
||||||
backgroundColor:
|
routes.log +
|
||||||
battery.Alarms === '' ? 'inherit' : '#FF033E',
|
'?open=warning'
|
||||||
color: battery.Alarms != '' ? 'black' : 'inherit'
|
}
|
||||||
}}
|
>
|
||||||
>
|
Multiple Warnings
|
||||||
{battery.Alarms === '' ? (
|
</Link>
|
||||||
'None'
|
) : (
|
||||||
) : battery.Alarms.toString().split('-').length > 1 ? (
|
battery.Warnings
|
||||||
<Link
|
)}
|
||||||
style={{ color: 'black' }}
|
</TableCell>
|
||||||
to={
|
|
||||||
currentLocation.pathname.substring(
|
<TableCell
|
||||||
0,
|
sx={{
|
||||||
currentLocation.pathname.lastIndexOf('/') + 1
|
width: '20%',
|
||||||
) +
|
textAlign: 'center',
|
||||||
routes.log +
|
fontWeight:
|
||||||
'?open=error'
|
battery.Alarms !== '' ? 'bold' : 'inherit',
|
||||||
}
|
backgroundColor:
|
||||||
|
battery.Alarms === '' ? 'inherit' : '#FF033E',
|
||||||
|
color: battery.Alarms !== '' ? 'black' : 'inherit'
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Multiple Alarms
|
{battery.Alarms === '' ? (
|
||||||
</Link>
|
'None'
|
||||||
) : (
|
) : battery.Alarms.toString().split('-').length >
|
||||||
battery.Alarms
|
1 ? (
|
||||||
)}
|
<Link
|
||||||
</TableCell>
|
style={{ color: 'black' }}
|
||||||
|
to={
|
||||||
|
currentLocation.pathname.substring(
|
||||||
|
0,
|
||||||
|
currentLocation.pathname.lastIndexOf('/') + 1
|
||||||
|
) +
|
||||||
|
routes.log +
|
||||||
|
'?open=error'
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Multiple Alarms
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
battery.Alarms
|
||||||
|
)}
|
||||||
|
</TableCell>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))}
|
))}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
|
|
|
||||||
|
|
@ -367,7 +367,15 @@ function MainStats(props: MainStatsProps) {
|
||||||
setStartDate(newDate);
|
setStartDate(newDate);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
renderInput={(props) => <TextField {...props} />}
|
renderInput={(params) => (
|
||||||
|
<TextField
|
||||||
|
{...params}
|
||||||
|
sx={{
|
||||||
|
marginTop: 2, // Apply styles here
|
||||||
|
width: '100%' // Optional: You can adjust the width or other styling here
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<DateTimePicker
|
<DateTimePicker
|
||||||
|
|
@ -379,7 +387,15 @@ function MainStats(props: MainStatsProps) {
|
||||||
setEndDate(newDate);
|
setEndDate(newDate);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
renderInput={(props) => <TextField {...props} />}
|
renderInput={(params) => (
|
||||||
|
<TextField
|
||||||
|
{...params}
|
||||||
|
sx={{
|
||||||
|
marginTop: 2, // Apply styles here
|
||||||
|
width: '100%' // Optional: You can adjust the width or other styling here
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -427,7 +427,6 @@ function Installation(props: singleInstallationProps) {
|
||||||
values={values}
|
values={values}
|
||||||
s3Credentials={s3Credentials}
|
s3Credentials={s3Credentials}
|
||||||
installationId={props.current_installation.id}
|
installationId={props.current_installation.id}
|
||||||
productNum={props.current_installation.product}
|
|
||||||
connected={connected}
|
connected={connected}
|
||||||
></BatteryView>
|
></BatteryView>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,31 @@ interface BatteryStrings {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Device {
|
export interface Device {
|
||||||
|
BatteryDeligreenDataRecord: {
|
||||||
|
BatteryCapacity: number;
|
||||||
|
BusCurrent: number;
|
||||||
|
BusVoltage: number;
|
||||||
|
CellVoltage: string;
|
||||||
|
FwVersion: number;
|
||||||
|
NumberOfCycles: number;
|
||||||
|
Power: number;
|
||||||
|
RatedCapacity: number;
|
||||||
|
ResidualCapacity: number;
|
||||||
|
Soc: number;
|
||||||
|
Soh: number;
|
||||||
|
|
||||||
|
TemperaturesList: {
|
||||||
|
CellTemperature1: number;
|
||||||
|
CellTemperature2: number;
|
||||||
|
CellTemperature3: number;
|
||||||
|
CellTemperature4: number;
|
||||||
|
EnvironmentTemperature: number;
|
||||||
|
PowerTemperature: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
TotalBatteryVoltage: number;
|
||||||
|
};
|
||||||
|
|
||||||
Leds: Leds;
|
Leds: Leds;
|
||||||
Eoc: boolean;
|
Eoc: boolean;
|
||||||
Soc: number;
|
Soc: number;
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,7 @@ function Topology(props: TopologyProps) {
|
||||||
|
|
||||||
const { product, setProduct } = useContext(ProductIdContext);
|
const { product, setProduct } = useContext(ProductIdContext);
|
||||||
|
|
||||||
console.log('product VALUE IS ', product);
|
//console.log('product VALUE IS ', product);
|
||||||
|
|
||||||
//console.log(props.values.DcDc.Dc.Battery.Voltage);
|
|
||||||
|
|
||||||
const [showValues, setShowValues] = useState(false);
|
const [showValues, setShowValues] = useState(false);
|
||||||
|
|
||||||
const handleSwitch = () => () => {
|
const handleSwitch = () => () => {
|
||||||
|
|
|
||||||
|
|
@ -83,13 +83,22 @@ export const transformInputToBatteryViewDataJson = async (
|
||||||
const prefixes = ['', 'k', 'M', 'G', 'T'];
|
const prefixes = ['', 'k', 'M', 'G', 'T'];
|
||||||
const MAX_NUMBER = 9999999;
|
const MAX_NUMBER = 9999999;
|
||||||
const categories = ['Soc', 'Temperature', 'Power', 'Voltage', 'Current'];
|
const categories = ['Soc', 'Temperature', 'Power', 'Voltage', 'Current'];
|
||||||
const pathCategories = [
|
const pathCategories =
|
||||||
'.Soc',
|
product === 0
|
||||||
'.Temperatures.Cells.Average',
|
? [
|
||||||
'.Dc.Power',
|
'.Soc',
|
||||||
'.Dc.Voltage',
|
'.Temperatures.Cells.Average',
|
||||||
'.Dc.Current'
|
'.Dc.Power',
|
||||||
];
|
'.Dc.Voltage',
|
||||||
|
'.Dc.Current'
|
||||||
|
]
|
||||||
|
: [
|
||||||
|
'.BatteryDeligreenDataRecord.Soc',
|
||||||
|
'.BatteryDeligreenDataRecord.TemperaturesList.EnvironmentTemperature',
|
||||||
|
'.BatteryDeligreenDataRecord.Power',
|
||||||
|
'.BatteryDeligreenDataRecord.TotalBatteryVoltage',
|
||||||
|
'.BatteryDeligreenDataRecord.BusCurrent'
|
||||||
|
];
|
||||||
|
|
||||||
const pathsToSearch = [
|
const pathsToSearch = [
|
||||||
'Battery.Devices.1',
|
'Battery.Devices.1',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue