diff --git a/csharp/App/SaliMax/src/AggregationService/Aggregator.cs b/csharp/App/SaliMax/src/AggregationService/Aggregator.cs index 994f6747b..e031b76af 100644 --- a/csharp/App/SaliMax/src/AggregationService/Aggregator.cs +++ b/csharp/App/SaliMax/src/AggregationService/Aggregator.cs @@ -206,9 +206,11 @@ public static class Aggregator var dMaxSoc = batterySoc.Any() ? batterySoc.Max() : 0.0; var dMinSoc = batterySoc.Any() ? batterySoc.Min() : 0.0; - var dSumGridExportPower = gridPowerExport.Any() ? gridPowerExport.Max() : 0.0; - var dSumGridImportPower = gridPowerImport.Any() ? gridPowerImport.Max() : 0.0; - var dSumPvPower = pvPowerSum.Any() ? pvPowerSum.Max() : 0.0; + var dSumGridExportPower = gridPowerExport.Any() ? gridPowerExport.Max()/1000 : 0.0; + var dSumGridImportPower = gridPowerImport.Any() ? gridPowerImport.Max()/1000 : 0.0; + var dSumPvPower = pvPowerSum.Any() ? pvPowerSum.Max() : 0.0; + + Console.WriteLine("-------------------------------------------------------------------"+dSumPvPower); AggregatedData aggregatedData = new AggregatedData { @@ -254,7 +256,7 @@ public static class Aggregator var heatingPowerAvg = new List(); - Console.WriteLine("-----------------------------------------------------------------------------------------------------------------"); + Console.WriteLine("File timestamp should start after "+ afterTimestamp); foreach (var csvFile in csvFiles) @@ -346,6 +348,8 @@ public static class Aggregator }; // 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($"Min SOC: {aggregatedData.MinSoc}"); @@ -355,7 +359,6 @@ public static class Aggregator Console.WriteLine($"SumGridExportPower: {aggregatedData.GridExportPower}"); Console.WriteLine($"SumGridImportPower: {aggregatedData.GridImportPower}"); - Console.WriteLine($"Min SOC: {aggregatedData.MinSoc}"); Console.WriteLine("CSV data reading and storage completed."); diff --git a/csharp/App/SaliMax/src/AggregationService/HourlyData.cs b/csharp/App/SaliMax/src/AggregationService/HourlyData.cs index 478963343..b7935d0fa 100644 --- a/csharp/App/SaliMax/src/AggregationService/HourlyData.cs +++ b/csharp/App/SaliMax/src/AggregationService/HourlyData.cs @@ -66,7 +66,7 @@ public class AggregatedData if (_S3Config is null) 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 response = await request.PutAsync(new StringContent(csv)); diff --git a/typescript/frontend-marios2/src/Resources/routes.json b/typescript/frontend-marios2/src/Resources/routes.json index c592e0bfe..630f00c10 100644 --- a/typescript/frontend-marios2/src/Resources/routes.json +++ b/typescript/frontend-marios2/src/Resources/routes.json @@ -13,6 +13,7 @@ "list": "list/", "overview": "overview", "manage": "manage", + "batteryview": "batteryview", "log": "log", "information": "information", "configuration": "configuration", diff --git a/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx b/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx new file mode 100644 index 000000000..a5e8dfa7d --- /dev/null +++ b/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx @@ -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 ( + + + + + Battery + Firmware + Power + Voltage + SoC + Temperature + Warnings + Alarms + + + + {batteryData.map((battery) => ( + + + {battery.BatteryId} + + + {battery.FwVersion} + + + {battery.Power} + + 57 + ? '#FF033E' + : '#32CD32', + color: battery.Voltage === '' ? 'white' : 'inherit' + }} + > + {battery.Voltage} + + + {battery.Soc} + + 270 ? '#FF033E' : '#32CD32 ' + }} + > + {battery.AverageTemperature} + + + + {battery.Warnings === '' ? 'None' : battery.Warnings} + + + {battery.Alarms === '' ? 'None' : battery.Alarms} + + + ))} + +
+
+ ); +} + +export default BatteryView; diff --git a/typescript/frontend-marios2/src/content/dashboards/Installations/Installation.tsx b/typescript/frontend-marios2/src/content/dashboards/Installations/Installation.tsx index 126a41d23..f1a333266 100644 --- a/typescript/frontend-marios2/src/content/dashboards/Installations/Installation.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/Installations/Installation.tsx @@ -35,6 +35,7 @@ import Overview from '../Overview/overview'; import Configuration from '../Configuration/Configuration'; import { fetchData } from 'src/content/dashboards/Installations/fetchData'; import CancelIcon from '@mui/icons-material/Cancel'; +import BatteryView from '../BatteryView/BatteryView'; interface singleInstallationProps { current_installation?: I_Installation; @@ -168,13 +169,15 @@ function Installation(props: singleInstallationProps) { useEffect(() => { if ( installationId == props.current_installation.id && - (currentTab == 'live' || currentTab == 'configuration') + (currentTab == 'live' || + currentTab == 'configuration' || + currentTab == 'batteryview') ) { //let isMounted = true; setFormValues(props.current_installation); var interval; - if (currentTab == 'live') { + if (currentTab == 'live' || currentTab == 'batteryview') { interval = setInterval(fetchDataPeriodically, 2000); } if (currentTab == 'configuration') { @@ -184,7 +187,7 @@ function Installation(props: singleInstallationProps) { // Cleanup function to cancel interval and update isMounted when unmounted return () => { //isMounted = false; - if (currentTab == 'live') { + if (currentTab == 'live' || currentTab == 'batteryview') { clearInterval(interval); } }; @@ -660,6 +663,9 @@ function Installation(props: singleInstallationProps) { {currentTab === 'overview' && ( )} + {currentTab === 'batteryview' && ( + + )} {currentTab === 'configuration' && currentUser.hasWriteAccess && ( }, + { - value: 'overview', - label: + value: 'batteryview', + label: ( + + ) }, - , + { value: 'manage', label: ( @@ -146,7 +148,12 @@ function InstallationTabs() { value: 'overview', label: }, - , + { + value: 'batteryview', + label: ( + + ) + }, { value: 'log', label: @@ -178,7 +185,15 @@ function InstallationTabs() { value: 'overview', label: }, - , + { + value: 'batteryview', + label: ( + + ) + }, { value: 'manage', label: ( @@ -227,7 +242,15 @@ function InstallationTabs() { value: 'overview', label: }, - , + { + value: 'batteryview', + label: ( + + ) + }, { value: 'log', label: diff --git a/typescript/frontend-marios2/src/content/dashboards/Log/graph.util.tsx b/typescript/frontend-marios2/src/content/dashboards/Log/graph.util.tsx index f1c5f5207..2b3eb7013 100644 --- a/typescript/frontend-marios2/src/content/dashboards/Log/graph.util.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/Log/graph.util.tsx @@ -76,6 +76,8 @@ export type TopologyValues = { DcDcNum: BoxData; calibrationChargeForced: BoxData; mode: BoxData; + + batteryView: BoxData; }; type TopologyPaths = { [key in keyof TopologyValues]: string[] }; @@ -149,6 +151,89 @@ export const topologyPaths: TopologyPaths = { '/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'], installedDcDcPower: ['/DcDc/SystemControl/NumberOfConnectedSlaves'], gridSetPoint: ['/Config/GridSetPoint'], diff --git a/typescript/frontend-marios2/src/content/dashboards/Overview/chartOptions.tsx b/typescript/frontend-marios2/src/content/dashboards/Overview/chartOptions.tsx index 9f0f46a46..3bf50f000 100644 --- a/typescript/frontend-marios2/src/content/dashboards/Overview/chartOptions.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/Overview/chartOptions.tsx @@ -259,11 +259,9 @@ export const getChartOptions = ( ? Math.ceil(chartInfo.min / findPower(chartInfo.min).value) * findPower(chartInfo.min).value : 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) * - findPower(chartInfo.max).value + findPower(chartInfo.min).value ).toFixed(2) : undefined, max: @@ -275,11 +273,9 @@ export const getChartOptions = ( : chartInfo.max <= 0 ? 0 : 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) * - findPower(chartInfo.max).value + findPower(chartInfo.max).value ).toFixed(2) : undefined, title: { diff --git a/typescript/frontend-marios2/src/content/dashboards/Overview/overview.tsx b/typescript/frontend-marios2/src/content/dashboards/Overview/overview.tsx index 8e2de0acd..a43983196 100644 --- a/typescript/frontend-marios2/src/content/dashboards/Overview/overview.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/Overview/overview.tsx @@ -26,10 +26,10 @@ interface OverviewProps { const computeLast7Days = (): string[] => { const currentDate = new Date(); const daysOfWeek = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; - let currentDayIndex = currentDate.getDay() + 1; + let currentDayIndex = currentDate.getDay(); const last7Days = []; - for (let i = 0; i <= 7; i++) { + for (let i = 0; i < 7; i++) { last7Days.push(daysOfWeek[currentDayIndex]); currentDayIndex++; if (currentDayIndex > 6) { @@ -420,6 +420,7 @@ function Overview(props: OverviewProps) {