#1743 Resolves CPU status indicator strobing and adds control to show/hide status panel and now playing channel details tabs.

This commit is contained in:
Dennis Sheirer
2023-11-18 03:26:21 -05:00
parent 82cb10a03d
commit 8bead998f5
6 changed files with 209 additions and 76 deletions

View File

@@ -31,8 +31,10 @@ import java.nio.file.Path;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.LongProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleLongProperty;
import javafx.beans.property.SimpleStringProperty;
@@ -64,6 +66,7 @@ public class ResourceMonitor
private DoubleProperty mJavaMemoryUsedPercentage = new SimpleDoubleProperty();
private DoubleProperty mSystemMemoryUsedPercentage = new SimpleDoubleProperty();
private DoubleProperty mCpuPercentage = new SimpleDoubleProperty();
private BooleanProperty mCpuAvailable = new SimpleBooleanProperty();
private DoubleProperty mDirectoryUsePercentEventLogs = new SimpleDoubleProperty();
private DoubleProperty mDirectoryUsePercentRecordings = new SimpleDoubleProperty();
private StringProperty mFileSizeEventLogs = new SimpleStringProperty();
@@ -143,7 +146,8 @@ public class ResourceMonitor
mMemoryUsed.set(mMemoryAllocated.getValue() - Runtime.getRuntime().freeMemory());
mJavaMemoryUsedPercentage.set((double)mMemoryUsed.get() / (double)mMemoryAllocated.get());
mSystemMemoryUsedPercentage.set((double)mMemoryAllocated.get() / (double)mMemoryTotal.get());
mCpuPercentage.set(loadFinal);
mCpuPercentage.set(loadFinal > 0 ? loadFinal : 0);
mCpuAvailable.set(loadFinal >= 0);
});
}
@@ -230,6 +234,15 @@ public class ResourceMonitor
return mCpuPercentage;
}
/**
* Indicates if the CPU usage percentage value is available on this operating system.
* @return false when the CPU load value is a negative value, indicating that the JVM for this OS doesn't support it.
*/
public BooleanProperty cpuAvailableProperty()
{
return mCpuAvailable;
}
/**
* Property for total system memory
*/

View File

@@ -23,6 +23,7 @@ import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.HBox;
/**
@@ -39,7 +40,7 @@ public class StatusBox extends HBox
public StatusBox(ResourceMonitor resourceMonitor)
{
mResourceMonitor = resourceMonitor;
setPadding(new Insets(0, 0, 2, 0));
setPadding(new Insets(1, 0, 1, 0));
setSpacing(6);
Label cpuLabel = new Label("CPU:");
cpuLabel.setPadding(new Insets(0, 0, 0, 10));
@@ -48,6 +49,8 @@ public class StatusBox extends HBox
ProgressBar cpuIndicator = new ProgressBar();
cpuIndicator.progressProperty().bind(mResourceMonitor.cpuPercentageProperty());
cpuIndicator.disableProperty().bind(mResourceMonitor.cpuAvailableProperty().not());
cpuIndicator.setTooltip(new Tooltip("Java process CPU usage. Disabled if the CPU loading is not available from the OS"));
getChildren().add(cpuIndicator);
Label memoryLabel = new Label("Allocated Memory:");
@@ -56,6 +59,7 @@ public class StatusBox extends HBox
ProgressBar memoryBar = new ProgressBar();
memoryBar.progressProperty().bind(mResourceMonitor.systemMemoryUsedPercentageProperty());
memoryBar.setTooltip(new Tooltip("Percentage of total system memory that Java has reserved from the Operating System."));
getChildren().add(memoryBar);
Label javaMemoryLabel = new Label("Used Memory:");
@@ -64,6 +68,7 @@ public class StatusBox extends HBox
ProgressBar javaMemoryBar = new ProgressBar();
javaMemoryBar.progressProperty().bind(mResourceMonitor.javaMemoryUsedPercentageProperty());
javaMemoryBar.setTooltip(new Tooltip("Percentage of allocated memory that Java/sdrtrunk is currently using. This value fluctuates as Java manages memory and garbage collection"));
getChildren().add(javaMemoryBar);
Label eventLogsLabel = new Label("Event Logs:");
@@ -72,6 +77,7 @@ public class StatusBox extends HBox
ProgressBar eventLogsBar = new ProgressBar();
eventLogsBar.progressProperty().bind(mResourceMonitor.directoryUsePercentEventLogsProperty());
eventLogsBar.setTooltip(new Tooltip("Percentage of drive space used for event logs based on user-specified max threshold in user preferences"));
getChildren().add(eventLogsBar);
Label eventLogsSizeLabel = new Label();
@@ -86,6 +92,7 @@ public class StatusBox extends HBox
ProgressBar recordingsBar = new ProgressBar();
recordingsBar.progressProperty().bind(mResourceMonitor.directoryUsePercentRecordingsProperty());
recordingsBar.setTooltip(new Tooltip("Percentage of drive space used for recordings based on user-specified max threshold in user preferences"));
getChildren().add(recordingsBar);
Label recordingsSizeLabel = new Label();

View File

@@ -1,37 +0,0 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2023 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.monitor;
import javafx.embed.swing.JFXPanel;
/**
* Status panel providing resource usage statistics.
*/
public class StatusPanel extends JFXPanel
{
private ResourceMonitor mResourceMonitor;
public StatusPanel(ResourceMonitor resourceMonitor)
{
mResourceMonitor = resourceMonitor;
}
}