diff --git a/config/config.json b/config/config.json index 4422a65..78dc0ec 100644 --- a/config/config.json +++ b/config/config.json @@ -23,7 +23,9 @@ /* Maximum filesize to allow when uploading */ "maxUploadSize": 1048576, - /* Provide access point capture redirects on this gateway. -- provides automatic browser launching on Access Point access. */ + /* Provide access point capture redirects on this gateway. -- provides automatic browser launching on Access Point access. + (not implemented) + */ "accessPointGateway": "172.24.1.0/24", "accessPointServerAddress": "172.24.1.1" diff --git a/debugConfig/config.json b/debugConfig/config.json index 029b9c2..1e49995 100644 --- a/debugConfig/config.json +++ b/debugConfig/config.json @@ -23,7 +23,7 @@ /* Maximum filesize to allow when uploading */ "maxUploadSize": 1048576, - /* Provide access point capture redirects on this gateway. */ + /* Provide access point capture redirects on this gateway. (not implemented) */ "accessPointGateway": "192.168.0.0/24", "accessPointServerAddress" : "192.168.0.26:8080" diff --git a/react/public/var/config.json b/react/public/var/config.json index c1902a0..a16e5a4 100644 --- a/react/public/var/config.json +++ b/react/public/var/config.json @@ -1,5 +1,5 @@ { - "socket_server_port": 80, + "socket_server_port": 8080, "socket_server_address": "*", "max_upload_size": 1048576, diff --git a/react/src/JackHostStatus.tsx b/react/src/JackHostStatus.tsx index 9d3d351..626eb40 100644 --- a/react/src/JackHostStatus.tsx +++ b/react/src/JackHostStatus.tsx @@ -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 (
+ return (
{label}  
); } - if (status.restarting) - { + return (
+ {label} + + { + (status.cpuFreqMax === status.cpuFreqMin)? + ( + {fmtCpuFreq(status.cpuFreqMax)} {status.governor} + ) + :( + {fmtCpuFreq(status.cpuFreqMax)}-{fmtCpuFreq(status.cpuFreqMax)} {status.governor} + + ) + } + +
); + + + } + static getDisplayView(label: string, status?: JackHostStatus): React.ReactNode { + if (!status) { + return (
+ {label} +   +
); + } + if (status.restarting) { return ( -
+
{label} - + Restarting   { status.temperaturemC > -100000 && ( - 75000? RED_COLOR: GREEN_COLOR}}> + 75000 ? RED_COLOR : GREEN_COLOR }}> {tempDisplay(status.temperaturemC)} ) } -
); } else if (!status.active) { return ( -
+
{label} - + Stopped   { status.temperaturemC > -100000 && ( - 75000? RED_COLOR: GREEN_COLOR}}> + 75000 ? RED_COLOR : GREEN_COLOR }}> {tempDisplay(status.temperaturemC)} ) @@ -102,22 +149,22 @@ export default class JackHostStatus {
); } else { - let underrunError = status.msSinceLastUnderrun < 15*1000; + let underrunError = status.msSinceLastUnderrun < 15 * 1000; return ( -
+
{label} - + - XRuns: {status.underruns+""}   + XRuns: {status.underruns + ""}   - + CPU: {cpuDisplay(status.cpuUsage)}   - + {tempDisplay(status.temperaturemC)} diff --git a/react/src/SettingsDialog.tsx b/react/src/SettingsDialog.tsx index 4be88ac..ff6c92b 100644 --- a/react/src/SettingsDialog.tsx +++ b/react/src/SettingsDialog.tsx @@ -163,25 +163,23 @@ const SettingsDialog = withStyles(styles, { withTheme: true })( } - handleConnectionStateChanged() : void { - if (this.model.state.get() === State.Ready) - { - if (this.state.shuttingDown || this.state.restarting) - { - this.setState({shuttingDown: false, restarting: false}); + handleConnectionStateChanged(): void { + if (this.model.state.get() === State.Ready) { + if (this.state.shuttingDown || this.state.restarting) { + this.setState({ shuttingDown: false, restarting: false }); } } } handleApplyWifiConfig(wifiConfigSettings: WifiConfigSettings): void { - this.setState({showWifiConfigDialog: false}); + this.setState({ showWifiConfigDialog: false }); this.model.setWifiConfigSettings(wifiConfigSettings) - .then(() => { + .then(() => { - }) - .catch((err) => { - this.model.showAlert(err); - }); + }) + .catch((err) => { + this.model.showAlert(err); + }); } handleWifiConfigSettingsChanged(): void { @@ -394,8 +392,8 @@ const SettingsDialog = withStyles(styles, { withTheme: true })( return ( { this.props.onClose() }} TransitionComponent={Transition} - style={{userSelect: "none"}} - > + style={{ userSelect: "none" }} + >
@@ -420,18 +418,25 @@ const SettingsDialog = withStyles(styles, { withTheme: true })( AUDIO -
- { (!isConfigValid) ? - ( - Status: Not configured. - ): - JackHostStatus.getDisplayView("Status:\u00A0", this.state.jackStatus) - } -
- { this.state.jackConfiguration.errorState !== "" && + {(!isConfigValid) ? (
- {this.state.jackConfiguration.errorState } + Status: Not configured. + CPU: +
+ ) : + ( +
+ {JackHostStatus.getDisplayView("Status:\u00A0", this.state.jackStatus)} + {JackHostStatus.getCpuInfo("CPU:\u00A0", this.state.jackStatus)} +
+ ) + } + + {this.state.jackConfiguration.errorState !== "" && + ( +
+ {this.state.jackConfiguration.errorState}
) @@ -449,7 +454,8 @@ const SettingsDialog = withStyles(styles, { withTheme: true })( jackServerSettings={this.state.jackServerSettings} onClose={() => this.setState({ showJackServerSettingsDialog: false })} onApply={(jackServerSettings) => { - this.setState({ showJackServerSettingsDialog: false, + this.setState({ + showJackServerSettingsDialog: false, jackServerSettings: jackServerSettings }); this.model.setJackServerSettings(jackServerSettings); @@ -561,9 +567,9 @@ const SettingsDialog = withStyles(styles, { withTheme: true })( ) } this.setState({showWifiConfigDialog: false})} + onClose={() => this.setState({ showWifiConfigDialog: false })} onOk={(wifiConfigSettings) => this.handleApplyWifiConfig(wifiConfigSettings)} - /> + /> diff --git a/react/src/ZoomedDial.tsx b/react/src/ZoomedDial.tsx index b1b58c5..d3ba1ac 100644 --- a/react/src/ZoomedDial.tsx +++ b/react/src/ZoomedDial.tsx @@ -168,7 +168,7 @@ const ZoomedDial = withStyles(styles, { withTheme: true })( let instanceId = this.props.controlInfo.instanceId; if (instanceId === -1) return 0; let pedalBoardItem = this.model.pedalBoard.get()?.getItem(instanceId); - let value: number = pedalBoardItem?.getControlValue(this.props.controlInfo.uiControl.symbol) ?? 0; + let value: number = pedalBoardItem?.getControlValue(uiControl.symbol) ?? 0; this.defaultValue = value; return value; } @@ -350,7 +350,7 @@ const ZoomedDial = withStyles(styles, { withTheme: true })( render() { return ( - , ) { return ; }); +*/ const ZoomedUiControl = withStyles(styles, { withTheme: true })( diff --git a/src/JackHost.cpp b/src/JackHost.cpp index 2afb47e..d358fd6 100644 --- a/src/JackHost.cpp +++ b/src/JackHost.cpp @@ -67,6 +67,50 @@ namespace pipedal std::string GetJackErrorMessage(jack_status_t status); } +static void GetCpuFrequency(uint64_t*freqMin,uint64_t*freqMax) +{ + uint64_t fMax = 0; + uint64_t fMin = UINT64_MAX; + char deviceName[128]; + try { + for (int i = 0; true; ++i) + { + + snprintf(deviceName,sizeof(deviceName),"/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq",i); + std::ifstream f(deviceName); + if (!f) + { + break; + } + uint64_t freq; + f >> freq; + if (!f) break; + if (freq < fMin) fMin = freq; + if (freq > fMax) fMax = freq; + } + } catch (const std::exception &) + { + + } + if (fMin == 0) fMax = 0; + *freqMin = fMin; + *freqMax = fMax; +} +static std::string GetGovernor() +{ + std::string result; + try { + std::ifstream f("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"); + f >> result; + } catch (const std::exception &) + { + + } + return result; +} + + + class JackHostImpl : public JackHost { private: @@ -1404,6 +1448,9 @@ public: { result.cpuUsage_ = 0; } + GetCpuFrequency(&result.cpuFreqMax_,&result.cpuFreqMin_); + result.governor_ = GetGovernor(); + return result; } volatile bool listenForMidiEvent; @@ -1428,4 +1475,7 @@ JSON_MAP_REFERENCE(JackHostStatus, underruns) JSON_MAP_REFERENCE(JackHostStatus, cpuUsage) JSON_MAP_REFERENCE(JackHostStatus, msSinceLastUnderrun) JSON_MAP_REFERENCE(JackHostStatus, temperaturemC) +JSON_MAP_REFERENCE(JackHostStatus, cpuFreqMin) +JSON_MAP_REFERENCE(JackHostStatus, cpuFreqMax) +JSON_MAP_REFERENCE(JackHostStatus, governor) JSON_MAP_END() diff --git a/src/JackHost.hpp b/src/JackHost.hpp index d78befb..2080b47 100644 --- a/src/JackHost.hpp +++ b/src/JackHost.hpp @@ -110,6 +110,9 @@ public: float cpuUsage_ = 0; uint64_t msSinceLastUnderrun_ = 0; int32_t temperaturemC_ = -100000; + uint64_t cpuFreqMax_ = 0; + uint64_t cpuFreqMin_ = 0; + std::string governor_; DECLARE_JSON_MAP(JackHostStatus);