CPU Use
This commit is contained in:
@@ -26,75 +26,122 @@ const GREEN_COLOR = "#666";
|
||||
|
||||
|
||||
|
||||
function tempDisplay(mC: number): string
|
||||
{
|
||||
return (mC/1000).toFixed(1) + "\u00B0C"; // degrees C.
|
||||
function tempDisplay(mC: number): string {
|
||||
return (mC / 1000).toFixed(1) + "\u00B0C"; // degrees C.
|
||||
}
|
||||
function cpuDisplay(cpu: number): string
|
||||
function cpuDisplay(cpu: number): string {
|
||||
return cpu.toFixed(1) + "%";
|
||||
}
|
||||
|
||||
function fmtCpuFreq(freq: number): string
|
||||
{
|
||||
return cpu.toFixed(1)+"%";
|
||||
if (freq >= 100000000)
|
||||
{
|
||||
return (freq/1000000).toFixed(1) + " GHz";
|
||||
}
|
||||
if (freq >= 10000000)
|
||||
{
|
||||
return (freq/1000000).toFixed(2) + " GHz";
|
||||
}
|
||||
if (freq >= 1000000)
|
||||
{
|
||||
return (freq/1000000).toFixed(3) + " GHz";
|
||||
}
|
||||
if (freq >= 1000)
|
||||
{
|
||||
return (freq/1000).toFixed(3) + " MHz";
|
||||
}
|
||||
return freq + " KHz";
|
||||
}
|
||||
|
||||
export default class JackHostStatus {
|
||||
deserialize(input: any): JackHostStatus
|
||||
{
|
||||
deserialize(input: any): JackHostStatus {
|
||||
this.active = input.active;
|
||||
this.restarting = input.restarting;
|
||||
this.underruns = input.underruns;
|
||||
this.cpuUsage = input.cpuUsage;
|
||||
this.msSinceLastUnderrun = input.msSinceLastUnderrun;
|
||||
this.temperaturemC = input.temperaturemC;
|
||||
this.cpuFreqMax = input.cpuFreqMax;
|
||||
this.cpuFreqMin = input.cpuFreqMin;
|
||||
this.governor = input.governor;
|
||||
return this;
|
||||
}
|
||||
hasTemperature() : boolean {
|
||||
hasTemperature(): boolean {
|
||||
return this.temperaturemC >= -100000;
|
||||
}
|
||||
active: boolean = false;
|
||||
restarting: boolean = false;
|
||||
underruns: number = 0;
|
||||
cpuUsage: number = 0;
|
||||
msSinceLastUnderrun: number = -5000*1000;
|
||||
msSinceLastUnderrun: number = -5000 * 1000;
|
||||
temperaturemC: number = -1000000;
|
||||
cpuFreqMax: number = 0;
|
||||
cpuFreqMin: number = 0;
|
||||
governor: string = "";
|
||||
|
||||
static getDisplayView(label: string,status?: JackHostStatus): React.ReactNode {
|
||||
static getCpuInfo(label: string, status?: JackHostStatus): React.ReactNode {
|
||||
if (!status) {
|
||||
return (<div style={{whiteSpace: "nowrap"}}>
|
||||
return (<div style={{ whiteSpace: "nowrap" }}>
|
||||
<Typography variant="caption" color="textSecondary">{label}</Typography>
|
||||
<Typography variant="caption"> </Typography>
|
||||
</div>);
|
||||
}
|
||||
if (status.restarting)
|
||||
{
|
||||
return (<div style={{ whiteSpace: "nowrap" }}>
|
||||
<Typography variant="caption" color="textSecondary">{label}</Typography>
|
||||
<Typography variant="caption" color="textSecondary">
|
||||
{
|
||||
(status.cpuFreqMax === status.cpuFreqMin)?
|
||||
(
|
||||
<span> {fmtCpuFreq(status.cpuFreqMax)} {status.governor} </span>
|
||||
)
|
||||
:(
|
||||
<span> {fmtCpuFreq(status.cpuFreqMax)}-{fmtCpuFreq(status.cpuFreqMax)} {status.governor} </span>
|
||||
|
||||
)
|
||||
}
|
||||
</Typography>
|
||||
</div>);
|
||||
|
||||
|
||||
}
|
||||
static getDisplayView(label: string, status?: JackHostStatus): React.ReactNode {
|
||||
if (!status) {
|
||||
return (<div style={{ whiteSpace: "nowrap" }}>
|
||||
<Typography variant="caption" color="textSecondary">{label}</Typography>
|
||||
<Typography variant="caption"> </Typography>
|
||||
</div>);
|
||||
}
|
||||
if (status.restarting) {
|
||||
return (
|
||||
<div style={{whiteSpace: "nowrap"}}>
|
||||
<div style={{ whiteSpace: "nowrap" }}>
|
||||
<Typography variant="caption" color="textSecondary">{label}</Typography>
|
||||
<span style={{color: RED_COLOR}}>
|
||||
<span style={{ color: RED_COLOR }}>
|
||||
<Typography variant="caption" color="inherit">Restarting </Typography>
|
||||
</span>
|
||||
{
|
||||
status.temperaturemC > -100000 &&
|
||||
(
|
||||
<span style={{color: status.temperaturemC > 75000? RED_COLOR: GREEN_COLOR}}>
|
||||
<span style={{ color: status.temperaturemC > 75000 ? RED_COLOR : GREEN_COLOR }}>
|
||||
<Typography variant="caption" color="inherit">{tempDisplay(status.temperaturemC)}</Typography>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
</div>
|
||||
);
|
||||
|
||||
} else if (!status.active) {
|
||||
return (
|
||||
<div style={{whiteSpace: "nowrap"}}>
|
||||
<div style={{ whiteSpace: "nowrap" }}>
|
||||
<Typography variant="caption" color="textSecondary">{label}</Typography>
|
||||
|
||||
<span style={{color: RED_COLOR}}>
|
||||
<span style={{ color: RED_COLOR }}>
|
||||
<Typography variant="caption" color="inherit">Stopped </Typography>
|
||||
</span>
|
||||
{
|
||||
status.temperaturemC > -100000 &&
|
||||
(
|
||||
<span style={{color: status.temperaturemC > 75000? RED_COLOR: GREEN_COLOR}}>
|
||||
<span style={{ color: status.temperaturemC > 75000 ? RED_COLOR : GREEN_COLOR }}>
|
||||
<Typography variant="caption" color="inherit">{tempDisplay(status.temperaturemC)}</Typography>
|
||||
</span>
|
||||
)
|
||||
@@ -102,22 +149,22 @@ export default class JackHostStatus {
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
let underrunError = status.msSinceLastUnderrun < 15*1000;
|
||||
let underrunError = status.msSinceLastUnderrun < 15 * 1000;
|
||||
return (
|
||||
<div style={{whiteSpace: "nowrap"}}>
|
||||
<div style={{ whiteSpace: "nowrap" }}>
|
||||
<Typography variant="caption" color="textSecondary">{label}</Typography>
|
||||
<span style={{color: underrunError? RED_COLOR: GREEN_COLOR}}>
|
||||
<span style={{ color: underrunError ? RED_COLOR : GREEN_COLOR }}>
|
||||
<Typography variant="caption" color="inherit">
|
||||
XRuns: {status.underruns+""}
|
||||
XRuns: {status.underruns + ""}
|
||||
</Typography>
|
||||
</span>
|
||||
<span style={{color: underrunError? RED_COLOR: GREEN_COLOR}}>
|
||||
<span style={{ color: underrunError ? RED_COLOR : GREEN_COLOR }}>
|
||||
<Typography variant="caption" color="inherit">
|
||||
CPU: {cpuDisplay(status.cpuUsage)}
|
||||
</Typography>
|
||||
</span>
|
||||
|
||||
<span style={{color: GREEN_COLOR}}>
|
||||
<span style={{ color: GREEN_COLOR }}>
|
||||
<Typography variant="caption" color="inherit">{tempDisplay(status.temperaturemC)}</Typography>
|
||||
</span>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user