Skip to content

Power and Thermal Specification for RPE - Front end (updated) #TODO #277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Dec 13, 2024
Merged
74 changes: 73 additions & 1 deletion src/GlobalStateProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@
const [bcpuNames, setBcpuNames] = useState([]);
const [connectivityNames, setConnectivityNames] = useState([]);
const [dmaNames, setDmaNames] = useState([]);
const [thermalData, setThermalData] = useState({
ambientTypical: 25,
ambientWorseCase: 50,
thetaJa: 10,
});
const [powerData, setPowerData] = useState({
powerBudget: 1.0,
fpgaScaling: 25,
pcScaling: 25,
});

let peripheralsMessages = {};

Expand Down Expand Up @@ -128,6 +138,25 @@
updatePeripherals(device, item.href, item.type);
});
});

server.GET(server.deviceInfo(device), (result) => {
if (result && result.specification) {
const { specification } = result;
setThermalData({
ambientTypical: specification.thermal?.ambient?.typical || 25,
ambientWorseCase: specification.thermal?.ambient?.worsecase || 50,
thetaJa: specification.thermal?.theta_ja || 10,
});
setPowerData({
powerBudget: specification.power?.budget || 1.0,
fpgaScaling:
(specification.power?.typical_dynamic_scaling?.fpga_complex || 0) * 100,
pcScaling:
(specification.power?.typical_dynamic_scaling?.processing_complex || 0)
* 100,
});
}
});
} else {
setClockingState([]);
setFleState([]);
Expand All @@ -136,9 +165,49 @@
setIoState([]);
setSocState({});
setPeripherals([]);
setThermalData({

Check warning on line 168 in src/GlobalStateProvider.js

View check run for this annotation

Codecov / codecov/patch

src/GlobalStateProvider.js#L168

Added line #L168 was not covered by tests
ambientTypical: 25,
ambientWorseCase: 50,
thetaJa: 10,
});
setPowerData({

Check warning on line 173 in src/GlobalStateProvider.js

View check run for this annotation

Codecov / codecov/patch

src/GlobalStateProvider.js#L173

Added line #L173 was not covered by tests
powerBudget: 1.0,
fpgaScaling: 25,
pcScaling: 25,
});
}
}

function updateThermalAndPowerData(device, newThermalData, newPowerData) {
const updatedData = {

Check warning on line 182 in src/GlobalStateProvider.js

View check run for this annotation

Codecov / codecov/patch

src/GlobalStateProvider.js#L181-L182

Added lines #L181 - L182 were not covered by tests
specification: {
thermal: {
ambient: {
typical: newThermalData.ambientTypical,
worsecase: newThermalData.ambientWorseCase,
},
theta_ja: newThermalData.thetaJa,
},
power: {
budget: newPowerData.powerBudget,
typical_dynamic_scaling: {
fpga_complex: newPowerData.fpgaScaling / 100,
processing_complex: newPowerData.pcScaling / 100,
},
},
},
};

server.PATCH(server.deviceInfo(device), updatedData, (response) => {
if (response.ok) {
setThermalData(newThermalData);
setPowerData(newPowerData);
} else {
console.error('Error updating thermal and power data:', response.statusText);

Check warning on line 206 in src/GlobalStateProvider.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Unexpected console statement

Check warning on line 206 in src/GlobalStateProvider.js

View check run for this annotation

Codecov / codecov/patch

src/GlobalStateProvider.js#L201-L206

Added lines #L201 - L206 were not covered by tests
}
});
}

function GetOptions(id) {
const found = attributes.find((elem) => id === elem.id);
return (found === undefined) ? [] : found.options;
Expand All @@ -150,6 +219,7 @@

const values = useMemo(() => ({
updateGlobalState,
updateThermalAndPowerData,
clockingState,
fleState,
bramState,
Expand All @@ -163,8 +233,10 @@
connectivityNames,
dmaNames,
fetchAttributes,
thermalData,
powerData,
// eslint-disable-next-line react-hooks/exhaustive-deps
}), [bramState, clockingState, dspState, fleState, ioState, socState]);
}), [bramState, clockingState, dspState, fleState, ioState, socState, thermalData, powerData]);

return (
<GlobalStateContext.Provider value={values}>
Expand Down
Loading
Loading