Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/api/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ def patch(self, device_id : str):
device = device_mgr.get_device(device_id)
schema = DeviceSchema()
device.update_spec(schema.load(request.json)['specification'])
device.compute_output_power()
from submodule.rs_project import RsProjectManager
RsProjectManager.get_instance().set_modified(True)
return schema.dump(device), 200
Expand Down
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 @@ export function GlobalStateProvider({ children, fetch }) { // TODO temp fix for
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 @@ export function GlobalStateProvider({ children, fetch }) { // TODO temp fix for
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 @@ export function GlobalStateProvider({ children, fetch }) { // TODO temp fix for
setIoState([]);
setSocState({});
setPeripherals([]);
setThermalData({
ambientTypical: 25,
ambientWorseCase: 50,
thetaJa: 10,
});
setPowerData({
powerBudget: 1.0,
fpgaScaling: 25,
pcScaling: 25,
});
}
}

function updateThermalAndPowerData(device, newThermalData, newPowerData) {
const updatedData = {
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);
}
});
}

function GetOptions(id) {
const found = attributes.find((elem) => id === elem.id);
return (found === undefined) ? [] : found.options;
Expand All @@ -150,6 +219,7 @@ export function GlobalStateProvider({ children, fetch }) { // TODO temp fix for

const values = useMemo(() => ({
updateGlobalState,
updateThermalAndPowerData,
clockingState,
fleState,
bramState,
Expand All @@ -163,8 +233,10 @@ export function GlobalStateProvider({ children, fetch }) { // TODO temp fix for
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