Fixed bugs regarding aggregated data, updated front-end

This commit is contained in:
Noe 2024-02-06 14:56:56 +01:00
parent 37bdd4a338
commit 38a14ca79b
10 changed files with 496 additions and 185 deletions

View File

@ -206,10 +206,12 @@ public static class Aggregator
var dMaxSoc = batterySoc.Any() ? batterySoc.Max() : 0.0; var dMaxSoc = batterySoc.Any() ? batterySoc.Max() : 0.0;
var dMinSoc = batterySoc.Any() ? batterySoc.Min() : 0.0; var dMinSoc = batterySoc.Any() ? batterySoc.Min() : 0.0;
var dSumGridExportPower = gridPowerExport.Any() ? gridPowerExport.Max() : 0.0; var dSumGridExportPower = gridPowerExport.Any() ? gridPowerExport.Max()/1000 : 0.0;
var dSumGridImportPower = gridPowerImport.Any() ? gridPowerImport.Max() : 0.0; var dSumGridImportPower = gridPowerImport.Any() ? gridPowerImport.Max()/1000 : 0.0;
var dSumPvPower = pvPowerSum.Any() ? pvPowerSum.Max() : 0.0; var dSumPvPower = pvPowerSum.Any() ? pvPowerSum.Max() : 0.0;
Console.WriteLine("-------------------------------------------------------------------"+dSumPvPower);
AggregatedData aggregatedData = new AggregatedData AggregatedData aggregatedData = new AggregatedData
{ {
MaxSoc = dMaxSoc, MaxSoc = dMaxSoc,
@ -254,7 +256,7 @@ public static class Aggregator
var heatingPowerAvg = new List<Double>(); var heatingPowerAvg = new List<Double>();
Console.WriteLine("-----------------------------------------------------------------------------------------------------------------");
Console.WriteLine("File timestamp should start after "+ afterTimestamp); Console.WriteLine("File timestamp should start after "+ afterTimestamp);
foreach (var csvFile in csvFiles) foreach (var csvFile in csvFiles)
@ -346,6 +348,8 @@ public static class Aggregator
}; };
// Print the stored CSV data for verification // Print the stored CSV data for verification
Console.WriteLine($"Pv Power: {aggregatedData.PvPower}");
Console.WriteLine($"Heating Power: {aggregatedData.HeatingPower}");
Console.WriteLine($"Max SOC: {aggregatedData.MaxSoc}"); Console.WriteLine($"Max SOC: {aggregatedData.MaxSoc}");
Console.WriteLine($"Min SOC: {aggregatedData.MinSoc}"); Console.WriteLine($"Min SOC: {aggregatedData.MinSoc}");
@ -355,7 +359,6 @@ public static class Aggregator
Console.WriteLine($"SumGridExportPower: {aggregatedData.GridExportPower}"); Console.WriteLine($"SumGridExportPower: {aggregatedData.GridExportPower}");
Console.WriteLine($"SumGridImportPower: {aggregatedData.GridImportPower}"); Console.WriteLine($"SumGridImportPower: {aggregatedData.GridImportPower}");
Console.WriteLine($"Min SOC: {aggregatedData.MinSoc}");
Console.WriteLine("CSV data reading and storage completed."); Console.WriteLine("CSV data reading and storage completed.");

View File

@ -66,7 +66,7 @@ public class AggregatedData
if (_S3Config is null) if (_S3Config is null)
return false; return false;
var s3Path = DateTime.Now.ToString("yyyy-MM-dd") + ".csv"; var s3Path = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + ".csv";
var request = _S3Config.CreatePutRequest(s3Path); var request = _S3Config.CreatePutRequest(s3Path);
var response = await request.PutAsync(new StringContent(csv)); var response = await request.PutAsync(new StringContent(csv));

View File

@ -13,6 +13,7 @@
"list": "list/", "list": "list/",
"overview": "overview", "overview": "overview",
"manage": "manage", "manage": "manage",
"batteryview": "batteryview",
"log": "log", "log": "log",
"information": "information", "information": "information",
"configuration": "configuration", "configuration": "configuration",

View File

@ -0,0 +1,176 @@
import React from 'react';
import {
Paper,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
useTheme
} from '@mui/material';
import { TopologyValues } from '../Log/graph.util';
interface BatteryViewProps {
values: TopologyValues;
}
function BatteryView(props: BatteryViewProps) {
if (props.values === null) {
return null;
}
const theme = useTheme();
const numOfBatteries = props.values.batteryView.values[0].value
.toString()
.split(',').length;
const batteryData = [];
let batteryId = 1;
// Use a for loop to generate battery data
for (let index = 1; index <= numOfBatteries * 7; index += 7) {
const battery = {
BatteryId: 'Battery ' + batteryId.toString(),
FwVersion: props.values.batteryView.values[index].value,
Power:
Number(props.values.batteryView.values[index + 1].value).toFixed(2) +
' ' +
props.values.batteryView.values[index + 1].unit,
Voltage:
Number(props.values.batteryView.values[index + 2].value).toFixed(2) +
' ' +
props.values.batteryView.values[index + 2].unit,
Soc:
props.values.batteryView.values[index + 3].value +
' ' +
props.values.batteryView.values[index + 3].unit,
AverageTemperature:
props.values.batteryView.values[index + 4].value +
' ' +
props.values.batteryView.values[index + 4].unit,
Warnings: props.values.batteryView.values[index + 5].value,
Alarms: props.values.batteryView.values[index + 6].value
};
batteryId++;
batteryData.push(battery);
}
return (
<TableContainer component={Paper}>
<Table sx={{ minWidth: 650 }} aria-label="simple table">
<TableHead>
<TableRow>
<TableCell align="center">Battery</TableCell>
<TableCell align="center">Firmware</TableCell>
<TableCell align="center">Power</TableCell>
<TableCell align="center">Voltage</TableCell>
<TableCell align="center">SoC</TableCell>
<TableCell align="center">Temperature</TableCell>
<TableCell align="center">Warnings</TableCell>
<TableCell align="center">Alarms</TableCell>
</TableRow>
</TableHead>
<TableBody>
{batteryData.map((battery) => (
<TableRow
key={battery.BatteryId}
style={{
height: '10px'
}}
>
<TableCell
component="th"
scope="row"
align="center"
sx={{ fontWeight: 'bold' }}
>
{battery.BatteryId}
</TableCell>
<TableCell
sx={{
width: '10%',
textAlign: 'center'
}}
>
{battery.FwVersion}
</TableCell>
<TableCell
sx={{
width: '10%',
textAlign: 'center'
}}
>
{battery.Power}
</TableCell>
<TableCell
sx={{
width: '10%',
textAlign: 'center',
backgroundColor:
battery.Voltage < 44 || battery.Voltage > 57
? '#FF033E'
: '#32CD32',
color: battery.Voltage === '' ? 'white' : 'inherit'
}}
>
{battery.Voltage}
</TableCell>
<TableCell
sx={{
width: '10%',
textAlign: 'center',
backgroundColor:
battery.Soc < 20
? '#FF033E'
: battery.Soc < 50
? '#ffbf00 '
: '#32CD32',
color: battery.Soc === '' ? 'white' : 'inherit'
}}
>
{battery.Soc}
</TableCell>
<TableCell
sx={{
width: '10%',
textAlign: 'center',
backgroundColor:
battery.AverageTemperature > 270 ? '#FF033E' : '#32CD32 '
}}
>
{battery.AverageTemperature}
</TableCell>
<TableCell
style={{
width: '15%',
textAlign: 'center',
padding: '8px',
backgroundColor:
battery.Warnings === '' ? 'inherit' : 'FF033E'
}}
>
{battery.Warnings === '' ? 'None' : battery.Warnings}
</TableCell>
<TableCell
sx={{
width: '15%',
textAlign: 'center',
marginLeft: '10px',
backgroundColor: battery.Alarms === '' ? 'inherit' : 'FF033E'
}}
>
{battery.Alarms === '' ? 'None' : battery.Alarms}
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
);
}
export default BatteryView;

View File

@ -35,6 +35,7 @@ import Overview from '../Overview/overview';
import Configuration from '../Configuration/Configuration'; import Configuration from '../Configuration/Configuration';
import { fetchData } from 'src/content/dashboards/Installations/fetchData'; import { fetchData } from 'src/content/dashboards/Installations/fetchData';
import CancelIcon from '@mui/icons-material/Cancel'; import CancelIcon from '@mui/icons-material/Cancel';
import BatteryView from '../BatteryView/BatteryView';
interface singleInstallationProps { interface singleInstallationProps {
current_installation?: I_Installation; current_installation?: I_Installation;
@ -168,13 +169,15 @@ function Installation(props: singleInstallationProps) {
useEffect(() => { useEffect(() => {
if ( if (
installationId == props.current_installation.id && installationId == props.current_installation.id &&
(currentTab == 'live' || currentTab == 'configuration') (currentTab == 'live' ||
currentTab == 'configuration' ||
currentTab == 'batteryview')
) { ) {
//let isMounted = true; //let isMounted = true;
setFormValues(props.current_installation); setFormValues(props.current_installation);
var interval; var interval;
if (currentTab == 'live') { if (currentTab == 'live' || currentTab == 'batteryview') {
interval = setInterval(fetchDataPeriodically, 2000); interval = setInterval(fetchDataPeriodically, 2000);
} }
if (currentTab == 'configuration') { if (currentTab == 'configuration') {
@ -184,7 +187,7 @@ function Installation(props: singleInstallationProps) {
// Cleanup function to cancel interval and update isMounted when unmounted // Cleanup function to cancel interval and update isMounted when unmounted
return () => { return () => {
//isMounted = false; //isMounted = false;
if (currentTab == 'live') { if (currentTab == 'live' || currentTab == 'batteryview') {
clearInterval(interval); clearInterval(interval);
} }
}; };
@ -660,6 +663,9 @@ function Installation(props: singleInstallationProps) {
{currentTab === 'overview' && ( {currentTab === 'overview' && (
<Overview s3Credentials={s3Credentials}></Overview> <Overview s3Credentials={s3Credentials}></Overview>
)} )}
{currentTab === 'batteryview' && (
<BatteryView values={values}></BatteryView>
)}
{currentTab === 'configuration' && currentUser.hasWriteAccess && ( {currentTab === 'configuration' && currentUser.hasWriteAccess && (
<Configuration <Configuration
values={values} values={values}

View File

@ -79,7 +79,6 @@ function InstallationTabs() {
) { ) {
setCurrentTab('list'); setCurrentTab('list');
} }
if (installationId) { if (installationId) {
if (currentTab == 'list' || currentTab == 'tree') { if (currentTab == 'list' || currentTab == 'tree') {
navigate(`?installation=${installationId}&tab=live`, { navigate(`?installation=${installationId}&tab=live`, {
@ -105,11 +104,14 @@ function InstallationTabs() {
value: 'live', value: 'live',
label: <FormattedMessage id="live" defaultMessage="Live" /> label: <FormattedMessage id="live" defaultMessage="Live" />
}, },
{ {
value: 'overview', value: 'batteryview',
label: <FormattedMessage id="overview" defaultMessage="Overview" /> label: (
<FormattedMessage id="batteryview" defaultMessage="Battery View" />
)
}, },
,
{ {
value: 'manage', value: 'manage',
label: ( label: (
@ -146,7 +148,12 @@ function InstallationTabs() {
value: 'overview', value: 'overview',
label: <FormattedMessage id="overview" defaultMessage="Overview" /> label: <FormattedMessage id="overview" defaultMessage="Overview" />
}, },
, {
value: 'batteryview',
label: (
<FormattedMessage id="batteryview" defaultMessage="Battery View" />
)
},
{ {
value: 'log', value: 'log',
label: <FormattedMessage id="log" defaultMessage="Log" /> label: <FormattedMessage id="log" defaultMessage="Log" />
@ -178,7 +185,15 @@ function InstallationTabs() {
value: 'overview', value: 'overview',
label: <FormattedMessage id="overview" defaultMessage="Overview" /> label: <FormattedMessage id="overview" defaultMessage="Overview" />
}, },
, {
value: 'batteryview',
label: (
<FormattedMessage
id="batteryview"
defaultMessage="Battery View"
/>
)
},
{ {
value: 'manage', value: 'manage',
label: ( label: (
@ -227,7 +242,15 @@ function InstallationTabs() {
value: 'overview', value: 'overview',
label: <FormattedMessage id="overview" defaultMessage="Overview" /> label: <FormattedMessage id="overview" defaultMessage="Overview" />
}, },
, {
value: 'batteryview',
label: (
<FormattedMessage
id="batteryview"
defaultMessage="Battery View"
/>
)
},
{ {
value: 'log', value: 'log',
label: <FormattedMessage id="log" defaultMessage="Log" /> label: <FormattedMessage id="log" defaultMessage="Log" />

View File

@ -76,6 +76,8 @@ export type TopologyValues = {
DcDcNum: BoxData; DcDcNum: BoxData;
calibrationChargeForced: BoxData; calibrationChargeForced: BoxData;
mode: BoxData; mode: BoxData;
batteryView: BoxData;
}; };
type TopologyPaths = { [key in keyof TopologyValues]: string[] }; type TopologyPaths = { [key in keyof TopologyValues]: string[] };
@ -149,6 +151,89 @@ export const topologyPaths: TopologyPaths = {
'/Battery/Devices/10/Dc/Voltage' '/Battery/Devices/10/Dc/Voltage'
], ],
batteryView: [
'/Config/Devices/BatteryNodes',
'/Battery/Devices/1/FwVersion',
'/Battery/Devices/1/Dc/Power',
'/Battery/Devices/1/Dc/Voltage',
'/Battery/Devices/1/Soc',
'/Battery/Devices/1/Temperatures/Cells/Average',
'/Battery/Devices/1/Warnings',
'/Battery/Devices/1/Alarms',
'/Battery/Devices/2/FwVersion',
'/Battery/Devices/2/Dc/Power',
'/Battery/Devices/2/Dc/Voltage',
'/Battery/Devices/2/Soc',
'/Battery/Devices/2/Temperatures/Cells/Average',
'/Battery/Devices/2/Warnings',
'/Battery/Devices/2/Alarms',
'/Battery/Devices/3/FwVersion',
'/Battery/Devices/3/Dc/Power',
'/Battery/Devices/3/Dc/Voltage',
'/Battery/Devices/3/Soc',
'/Battery/Devices/3/Temperatures/Cells/Average',
'/Battery/Devices/3/Warnings',
'/Battery/Devices/3/Alarms',
'/Battery/Devices/4/FwVersion',
'/Battery/Devices/4/Dc/Power',
'/Battery/Devices/4/Dc/Voltage',
'/Battery/Devices/4/Soc',
'/Battery/Devices/4/Temperatures/Cells/Average',
'/Battery/Devices/4/Warnings',
'/Battery/Devices/4/Alarms',
'/Battery/Devices/5/FwVersion',
'/Battery/Devices/5/Dc/Power',
'/Battery/Devices/5/Dc/Voltage',
'/Battery/Devices/5/Soc',
'/Battery/Devices/5/Temperatures/Cells/Average',
'/Battery/Devices/5/Warnings',
'/Battery/Devices/5/Alarms',
'/Battery/Devices/6/FwVersion',
'/Battery/Devices/6/Dc/Power',
'/Battery/Devices/6/Dc/Voltage',
'/Battery/Devices/6/Soc',
'/Battery/Devices/6/Temperatures/Cells/Average',
'/Battery/Devices/6/Warnings',
'/Battery/Devices/6/Alarms',
'/Battery/Devices/7/FwVersion',
'/Battery/Devices/7/Dc/Power',
'/Battery/Devices/7/Dc/Voltage',
'/Battery/Devices/7/Soc',
'/Battery/Devices/7/Temperatures/Cells/Average',
'/Battery/Devices/7/Warnings',
'/Battery/Devices/7/Alarms',
'/Battery/Devices/8/FwVersion',
'/Battery/Devices/8/Dc/Power',
'/Battery/Devices/8/Dc/Voltage',
'/Battery/Devices/8/Soc',
'/Battery/Devices/8/Temperatures/Cells/Average',
'/Battery/Devices/8/Warnings',
'/Battery/Devices/8/Alarms',
'/Battery/Devices/9/FwVersion',
'/Battery/Devices/9/Dc/Power',
'/Battery/Devices/9/Dc/Voltage',
'/Battery/Devices/9/Soc',
'/Battery/Devices/9/Temperatures/Cells/Average',
'/Battery/Devices/9/Warnings',
'/Battery/Devices/9/Alarms',
'/Battery/Devices/10/FwVersion',
'/Battery/Devices/10/Dc/Power',
'/Battery/Devices/10/Dc/Voltage',
'/Battery/Devices/10/Soc',
'/Battery/Devices/10/Temperatures/Cells/Average',
'/Battery/Devices/10/Warnings',
'/Battery/Devices/10/Alarms'
],
minimumSoC: ['/Config/MinSoc'], minimumSoC: ['/Config/MinSoc'],
installedDcDcPower: ['/DcDc/SystemControl/NumberOfConnectedSlaves'], installedDcDcPower: ['/DcDc/SystemControl/NumberOfConnectedSlaves'],
gridSetPoint: ['/Config/GridSetPoint'], gridSetPoint: ['/Config/GridSetPoint'],

View File

@ -259,11 +259,9 @@ export const getChartOptions = (
? Math.ceil(chartInfo.min / findPower(chartInfo.min).value) * ? Math.ceil(chartInfo.min / findPower(chartInfo.min).value) *
findPower(chartInfo.min).value findPower(chartInfo.min).value
: Math.abs(chartInfo.min) < 1 : Math.abs(chartInfo.min) < 1
? -Math.max( ? +(
Math.ceil(chartInfo.min / findPower(chartInfo.min).value) * Math.ceil(chartInfo.min / findPower(chartInfo.min).value) *
findPower(chartInfo.min).value, findPower(chartInfo.min).value
Math.ceil(chartInfo.max / findPower(chartInfo.max).value) *
findPower(chartInfo.max).value
).toFixed(2) ).toFixed(2)
: undefined, : undefined,
max: max:
@ -275,9 +273,7 @@ export const getChartOptions = (
: chartInfo.max <= 0 : chartInfo.max <= 0
? 0 ? 0
: Math.abs(chartInfo.min) < 1 : Math.abs(chartInfo.min) < 1
? +Math.max( ? +(
Math.ceil(chartInfo.min / findPower(chartInfo.min).value) *
findPower(chartInfo.min).value,
Math.ceil(chartInfo.max / findPower(chartInfo.max).value) * Math.ceil(chartInfo.max / findPower(chartInfo.max).value) *
findPower(chartInfo.max).value findPower(chartInfo.max).value
).toFixed(2) ).toFixed(2)

View File

@ -26,10 +26,10 @@ interface OverviewProps {
const computeLast7Days = (): string[] => { const computeLast7Days = (): string[] => {
const currentDate = new Date(); const currentDate = new Date();
const daysOfWeek = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; const daysOfWeek = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
let currentDayIndex = currentDate.getDay() + 1; let currentDayIndex = currentDate.getDay();
const last7Days = []; const last7Days = [];
for (let i = 0; i <= 7; i++) { for (let i = 0; i < 7; i++) {
last7Days.push(daysOfWeek[currentDayIndex]); last7Days.push(daysOfWeek[currentDayIndex]);
currentDayIndex++; currentDayIndex++;
if (currentDayIndex > 6) { if (currentDayIndex > 6) {
@ -420,6 +420,7 @@ function Overview(props: OverviewProps) {
<Button <Button
variant="contained" variant="contained"
onClick={handle24HourData} onClick={handle24HourData}
disabled={loading}
sx={{ sx={{
marginTop: '20px', marginTop: '20px',
backgroundColor: dailyData ? '#808080' : '#ffc04d', backgroundColor: dailyData ? '#808080' : '#ffc04d',
@ -432,6 +433,7 @@ function Overview(props: OverviewProps) {
<Button <Button
variant="contained" variant="contained"
onClick={handleWeekData} onClick={handleWeekData}
disabled={loading}
sx={{ sx={{
marginTop: '20px', marginTop: '20px',
marginLeft: '10px', marginLeft: '10px',
@ -445,6 +447,7 @@ function Overview(props: OverviewProps) {
<Button <Button
variant="contained" variant="contained"
onClick={handleMonthData} onClick={handleMonthData}
disabled={loading}
sx={{ sx={{
marginTop: '20px', marginTop: '20px',
marginLeft: '10px', marginLeft: '10px',
@ -460,6 +463,7 @@ function Overview(props: OverviewProps) {
<Button <Button
variant="contained" variant="contained"
onClick={handleSetDate} onClick={handleSetDate}
disabled={loading}
sx={{ sx={{
marginTop: '20px', marginTop: '20px',
marginLeft: '10px', marginLeft: '10px',
@ -789,10 +793,10 @@ function Overview(props: OverviewProps) {
series={[ series={[
{ {
...dailyDataArray[chartState].chartData.soc, ...dailyDataArray[chartState].chartData.soc,
color: '#69d2e7' color: '#00ccff'
} }
]} ]}
type="area" type="line"
height={400} height={400}
/> />
)} )}
@ -898,10 +902,10 @@ function Overview(props: OverviewProps) {
series={[ series={[
{ {
...dailyDataArray[chartState].chartData.dcPower, ...dailyDataArray[chartState].chartData.dcPower,
color: '#69d2e7' color: '#00ccff'
} }
]} ]}
type="area" type="line"
height={400} height={400}
/> />
)} )}
@ -920,6 +924,10 @@ function Overview(props: OverviewProps) {
...weeklyDataArray.chartData.dcChargingPower, ...weeklyDataArray.chartData.dcChargingPower,
color: '#69d2e7' color: '#69d2e7'
}, },
{
...weeklyDataArray.chartData.heatingPower,
color: '#000000'
},
{ {
...weeklyDataArray.chartData.dcDischargingPower, ...weeklyDataArray.chartData.dcDischargingPower,
color: '#008FFB' color: '#008FFB'
@ -957,6 +965,132 @@ function Overview(props: OverviewProps) {
</Grid> </Grid>
</Grid> </Grid>
{dailyData && currentUser.hasWriteAccess && (
<Grid
container
direction="row"
justifyContent="center"
alignItems="stretch"
spacing={3}
>
<Grid item md={6} xs={12}>
<Card
sx={{
overflow: 'visible',
marginTop: '30px',
marginBottom: '30px'
}}
>
<Box
sx={{
marginLeft: '20px'
}}
>
<Box display="flex" alignItems="center">
<Box>
<Typography variant="subtitle1" noWrap>
<FormattedMessage
id="battery_temperature"
defaultMessage="Battery Temperature"
/>
</Typography>
</Box>
</Box>
<Box
sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-start',
pt: 3
}}
></Box>
</Box>
<ReactApexChart
options={{
...getChartOptions(
dailyDataArray[chartState].chartOverview
.temperature,
'daily',
[]
),
chart: {
events: {
beforeZoom: handleBeforeZoom
}
}
}}
series={[
{
...dailyDataArray[chartState].chartData.temperature,
color: '#00ccff'
}
]}
type="line"
height={400}
/>
</Card>
</Grid>
<Grid item md={6} xs={12}>
<Card
sx={{
overflow: 'visible',
marginTop: '30px',
marginBottom: '30px'
}}
>
<Box
sx={{
marginLeft: '20px'
}}
>
<Box display="flex" alignItems="center">
<Box>
<Typography variant="subtitle1" noWrap>
<FormattedMessage
id="dc_voltage"
defaultMessage="DC Bus Voltage"
/>
</Typography>
</Box>
</Box>
<Box
sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-start',
pt: 3
}}
></Box>
</Box>
<ReactApexChart
options={{
...getChartOptions(
dailyDataArray[chartState].chartOverview
.dcBusVoltage,
'daily',
[]
),
chart: {
events: {
beforeZoom: handleBeforeZoom
}
}
}}
series={[
{
...dailyDataArray[chartState].chartData
.dcBusVoltage,
color: '#00ccff'
}
]}
type="line"
height={400}
/>
</Card>
</Grid>
</Grid>
)}
{currentUser.hasWriteAccess && ( {currentUser.hasWriteAccess && (
<Grid <Grid
container container
@ -1020,7 +1154,7 @@ function Overview(props: OverviewProps) {
color: '#ff9900' color: '#ff9900'
} }
]} ]}
type="area" type="line"
height={400} height={400}
/> />
)} )}
@ -1121,7 +1255,7 @@ function Overview(props: OverviewProps) {
color: '#ff3333' color: '#ff3333'
} }
]} ]}
type="area" type="line"
height={400} height={400}
/> />
)} )}
@ -1139,6 +1273,7 @@ function Overview(props: OverviewProps) {
...weeklyDataArray.chartData.gridImportPower, ...weeklyDataArray.chartData.gridImportPower,
color: '#b30000' color: '#b30000'
}, },
{ {
...weeklyDataArray.chartData.gridExportPower, ...weeklyDataArray.chartData.gridExportPower,
color: '#ff3333' color: '#ff3333'
@ -1176,125 +1311,6 @@ function Overview(props: OverviewProps) {
</Grid> </Grid>
</Grid> </Grid>
)} )}
{/*{dailyData && currentUser.hasWriteAccess && (*/}
{/* <Grid*/}
{/* container*/}
{/* direction="row"*/}
{/* justifyContent="center"*/}
{/* alignItems="stretch"*/}
{/* spacing={3}*/}
{/* >*/}
{/* <Grid item md={6} xs={12}>*/}
{/* <Card*/}
{/* sx={{*/}
{/* overflow: 'visible',*/}
{/* marginTop: '30px',*/}
{/* marginBottom: '30px'*/}
{/* }}*/}
{/* >*/}
{/* <Box*/}
{/* sx={{*/}
{/* marginLeft: '20px'*/}
{/* }}*/}
{/* >*/}
{/* <Box display="flex" alignItems="center">*/}
{/* <Box>*/}
{/* <Typography variant="subtitle1" noWrap>*/}
{/* <FormattedMessage*/}
{/* id="battery_temperature"*/}
{/* defaultMessage="Battery Temperature"*/}
{/* />*/}
{/* </Typography>*/}
{/* </Box>*/}
{/* </Box>*/}
{/* <Box*/}
{/* sx={{*/}
{/* display: 'flex',*/}
{/* alignItems: 'center',*/}
{/* justifyContent: 'flex-start',*/}
{/* pt: 3*/}
{/* }}*/}
{/* ></Box>*/}
{/* </Box>*/}
{/* <ReactApexChart*/}
{/* options={{*/}
{/* ...getChartOptions(*/}
{/* dailyDataArray[chartState].chartOverview*/}
{/* .temperature,*/}
{/* 'daily',*/}
{/* []*/}
{/* ),*/}
{/* chart: {*/}
{/* events: {*/}
{/* beforeZoom: handleBeforeZoom*/}
{/* }*/}
{/* }*/}
{/* }}*/}
{/* series={[*/}
{/* dailyDataArray[chartState].chartData.temperature*/}
{/* ]}*/}
{/* type="area"*/}
{/* height={400}*/}
{/* />*/}
{/* </Card>*/}
{/* </Grid>*/}
{/* <Grid item md={6} xs={12}>*/}
{/* <Card*/}
{/* sx={{*/}
{/* overflow: 'visible',*/}
{/* marginTop: '30px',*/}
{/* marginBottom: '30px'*/}
{/* }}*/}
{/* >*/}
{/* <Box*/}
{/* sx={{*/}
{/* marginLeft: '20px'*/}
{/* }}*/}
{/* >*/}
{/* <Box display="flex" alignItems="center">*/}
{/* <Box>*/}
{/* <Typography variant="subtitle1" noWrap>*/}
{/* <FormattedMessage*/}
{/* id="dc_voltage"*/}
{/* defaultMessage="DC Bus Voltage"*/}
{/* />*/}
{/* </Typography>*/}
{/* </Box>*/}
{/* </Box>*/}
{/* <Box*/}
{/* sx={{*/}
{/* display: 'flex',*/}
{/* alignItems: 'center',*/}
{/* justifyContent: 'flex-start',*/}
{/* pt: 3*/}
{/* }}*/}
{/* ></Box>*/}
{/* </Box>*/}
{/* <ReactApexChart*/}
{/* options={{*/}
{/* ...getChartOptions(*/}
{/* dailyDataArray[chartState].chartOverview*/}
{/* .dcBusVoltage,*/}
{/* 'daily',*/}
{/* []*/}
{/* ),*/}
{/* chart: {*/}
{/* events: {*/}
{/* beforeZoom: handleBeforeZoom*/}
{/* }*/}
{/* }*/}
{/* }}*/}
{/* series={[*/}
{/* dailyDataArray[chartState].chartData.dcBusVoltage*/}
{/* ]}*/}
{/* type="area"*/}
{/* height={400}*/}
{/* />*/}
{/* </Card>*/}
{/* </Grid>*/}
{/* </Grid>*/}
{/*)}*/}
</Grid> </Grid>
)} )}
</Grid> </Grid>

View File

@ -32,6 +32,7 @@ export interface chartAggregatedDataInterface {
dcDischargingPower: { name: string; data: number[] }; dcDischargingPower: { name: string; data: number[] };
gridImportPower: { name: string; data: number[] }; gridImportPower: { name: string; data: number[] };
gridExportPower: { name: string; data: number[] }; gridExportPower: { name: string; data: number[] };
heatingPower: { name: string; data: number[] };
} }
export interface chartDataInterface { export interface chartDataInterface {
@ -257,7 +258,7 @@ export const transformInputToAggregatedData = async (
const MAX_NUMBER = 9999999; const MAX_NUMBER = 9999999;
const dateList = []; const dateList = [];
let currentDate = dayjs().add(1, 'day'); let currentDate = dayjs();
let currentDay = let currentDay =
type === 'weekly' type === 'weekly'
? currentDate.subtract(1, 'week') ? currentDate.subtract(1, 'week')
@ -266,11 +267,12 @@ export const transformInputToAggregatedData = async (
const pathsToSearch = [ const pathsToSearch = [
'/MinSoc', '/MinSoc',
'/MaxSoc', '/MaxSoc',
'/SumPvPower', '/PvPower',
'/SumDischargingBatteryPower', '/DischargingBatteryPower',
'/SumChargingBatteryPower', '/ChargingBatteryPower',
'/SumGridImportPower', '/GridImportPower',
'/SumGridExportPower' '/GridExportPower',
'/HeatingPower'
]; ];
const chartAggregatedData: chartAggregatedDataInterface = { const chartAggregatedData: chartAggregatedDataInterface = {
@ -278,6 +280,7 @@ export const transformInputToAggregatedData = async (
maxsoc: { name: 'max SOC', data: [] }, maxsoc: { name: 'max SOC', data: [] },
pvProduction: { name: 'Pv Energy', data: [] }, pvProduction: { name: 'Pv Energy', data: [] },
dcChargingPower: { name: 'Charging Battery Energy', data: [] }, dcChargingPower: { name: 'Charging Battery Energy', data: [] },
heatingPower: { name: 'Heating Power', data: [] },
dcDischargingPower: { name: 'Discharging Battery Energy', data: [] }, dcDischargingPower: { name: 'Discharging Battery Energy', data: [] },
gridImportPower: { name: 'Grid Import Energy', data: [] }, gridImportPower: { name: 'Grid Import Energy', data: [] },
gridExportPower: { name: 'Grid Export Energy', data: [] } gridExportPower: { name: 'Grid Export Energy', data: [] }
@ -313,6 +316,7 @@ export const transformInputToAggregatedData = async (
} }
const results = await Promise.all(timestampPromises); const results = await Promise.all(timestampPromises);
currentDay = currentDate.subtract(1, 'month');
for (let i = 0; i < results.length; i++) { for (let i = 0; i < results.length; i++) {
const result = results[i]; const result = results[i];
@ -332,13 +336,14 @@ export const transformInputToAggregatedData = async (
if (result[path].value > overviewData[path].max) { if (result[path].value > overviewData[path].max) {
overviewData[path].max = result[path].value; overviewData[path].max = result[path].value;
} }
if (path === '/SumGridExportPower' && result[path].value < 0.1) { if (path === '/GridExportPower' && result[path].value < 0.1) {
result[path].value = 0.3; result[path].value = 0.3;
} }
data[path].push(result[path].value as number); data[path].push(result[path].value as number);
} }
}); });
} }
currentDay = currentDay.add(1, 'day');
} }
pathsToSearch.forEach((path) => { pathsToSearch.forEach((path) => {
@ -371,7 +376,7 @@ export const transformInputToAggregatedData = async (
max: 100 max: 100
}; };
path = '/SumPvPower'; path = '/PvPower';
chartAggregatedData.pvProduction.data = data[path]; chartAggregatedData.pvProduction.data = data[path];
chartOverview.pvProduction = { chartOverview.pvProduction = {
@ -381,60 +386,60 @@ export const transformInputToAggregatedData = async (
max: overviewData[path].max max: overviewData[path].max
}; };
path = '/SumChargingBatteryPower'; path = '/ChargingBatteryPower';
chartAggregatedData.dcChargingPower.data = data[path]; chartAggregatedData.dcChargingPower.data = data[path];
path = '/SumDischargingBatteryPower'; path = '/DischargingBatteryPower';
chartAggregatedData.dcDischargingPower.data = data[path]; chartAggregatedData.dcDischargingPower.data = data[path];
path = '/HeatingPower';
chartAggregatedData.heatingPower.data = data[path];
chartOverview.dcPower = { chartOverview.dcPower = {
magnitude: Math.max( magnitude: Math.max(
overviewData['/SumChargingBatteryPower'].magnitude, overviewData['/ChargingBatteryPower'].magnitude,
overviewData['/SumDischargingBatteryPower'].magnitude overviewData['/HeatingPower'].magnitude,
overviewData['/DischargingBatteryPower'].magnitude
), ),
unit: '(kWh)', unit: '(kWh)',
min: Math.min( min: overviewData['/DischargingBatteryPower'].min,
overviewData['/SumChargingBatteryPower'].min, max:
overviewData['/SumDischargingBatteryPower'].min overviewData['/ChargingBatteryPower'].max +
), overviewData['/HeatingPower'].max
max: Math.max(
overviewData['/SumChargingBatteryPower'].max,
overviewData['/SumDischargingBatteryPower'].max
)
}; };
path = '/SumGridImportPower'; path = '/GridImportPower';
chartAggregatedData.gridImportPower.data = data[path]; chartAggregatedData.gridImportPower.data = data[path];
path = '/SumGridExportPower'; path = '/GridExportPower';
chartAggregatedData.gridExportPower.data = data[path]; chartAggregatedData.gridExportPower.data = data[path];
chartOverview.gridPower = { chartOverview.gridPower = {
magnitude: Math.max( magnitude: Math.max(
overviewData['/SumGridImportPower'].magnitude, overviewData['/GridImportPower'].magnitude,
overviewData['/SumGridExportPower'].magnitude overviewData['/GridExportPower'].magnitude
), ),
unit: '(kWh)', unit: '(kWh)',
min: min:
overviewData['/SumGridImportPower'].min + overviewData['/GridImportPower'].min +
overviewData['/SumGridExportPower'].min, overviewData['/GridExportPower'].min,
max: max:
overviewData['/SumGridImportPower'].max + overviewData['/GridImportPower'].max +
overviewData['/SumGridExportPower'].max overviewData['/GridExportPower'].max
}; };
chartOverview.overview = { chartOverview.overview = {
magnitude: 0, magnitude: 0,
unit: '(kWh)', unit: '(kWh)',
min: Math.min( min: Math.min(
overviewData['/SumGridImportPower'].min, overviewData['/GridImportPower'].min,
overviewData['/SumGridExportPower'].min, overviewData['/GridExportPower'].min,
overviewData['/SumPvPower'].min overviewData['/PvPower'].min
), ),
max: Math.max( max: Math.max(
overviewData['/SumGridImportPower'].max, overviewData['/GridImportPower'].max,
overviewData['/SumGridExportPower'].max, overviewData['/GridExportPower'].max,
overviewData['/SumPvPower'].max overviewData['/PvPower'].max
) )
}; };