Skip to content

Commit 2700373

Browse files
authored
Power and Thermal Specification for RPE - Front end (updated) #TODO (#277)
1 parent bb2f088 commit 2700373

File tree

5 files changed

+560
-88
lines changed

5 files changed

+560
-88
lines changed

backend/api/device.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ def patch(self, device_id : str):
312312
device = device_mgr.get_device(device_id)
313313
schema = DeviceSchema()
314314
device.update_spec(schema.load(request.json)['specification'])
315+
device.compute_output_power()
315316
from submodule.rs_project import RsProjectManager
316317
RsProjectManager.get_instance().set_modified(True)
317318
return schema.dump(device), 200

src/GlobalStateProvider.js

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ export function GlobalStateProvider({ children, fetch }) { // TODO temp fix for
3838
const [bcpuNames, setBcpuNames] = useState([]);
3939
const [connectivityNames, setConnectivityNames] = useState([]);
4040
const [dmaNames, setDmaNames] = useState([]);
41+
const [thermalData, setThermalData] = useState({
42+
ambientTypical: 25,
43+
ambientWorseCase: 50,
44+
thetaJa: 10,
45+
});
46+
const [powerData, setPowerData] = useState({
47+
powerBudget: 1.0,
48+
fpgaScaling: 25,
49+
pcScaling: 25,
50+
});
4151

4252
let peripheralsMessages = {};
4353

@@ -128,6 +138,25 @@ export function GlobalStateProvider({ children, fetch }) { // TODO temp fix for
128138
updatePeripherals(device, item.href, item.type);
129139
});
130140
});
141+
142+
server.GET(server.deviceInfo(device), (result) => {
143+
if (result && result.specification) {
144+
const { specification } = result;
145+
setThermalData({
146+
ambientTypical: specification.thermal?.ambient?.typical || 25,
147+
ambientWorseCase: specification.thermal?.ambient?.worsecase || 50,
148+
thetaJa: specification.thermal?.theta_ja || 10,
149+
});
150+
setPowerData({
151+
powerBudget: specification.power?.budget || 1.0,
152+
fpgaScaling:
153+
(specification.power?.typical_dynamic_scaling?.fpga_complex || 0) * 100,
154+
pcScaling:
155+
(specification.power?.typical_dynamic_scaling?.processing_complex || 0)
156+
* 100,
157+
});
158+
}
159+
});
131160
} else {
132161
setClockingState([]);
133162
setFleState([]);
@@ -136,9 +165,49 @@ export function GlobalStateProvider({ children, fetch }) { // TODO temp fix for
136165
setIoState([]);
137166
setSocState({});
138167
setPeripherals([]);
168+
setThermalData({
169+
ambientTypical: 25,
170+
ambientWorseCase: 50,
171+
thetaJa: 10,
172+
});
173+
setPowerData({
174+
powerBudget: 1.0,
175+
fpgaScaling: 25,
176+
pcScaling: 25,
177+
});
139178
}
140179
}
141180

181+
function updateThermalAndPowerData(device, newThermalData, newPowerData) {
182+
const updatedData = {
183+
specification: {
184+
thermal: {
185+
ambient: {
186+
typical: newThermalData.ambientTypical,
187+
worsecase: newThermalData.ambientWorseCase,
188+
},
189+
theta_ja: newThermalData.thetaJa,
190+
},
191+
power: {
192+
budget: newPowerData.powerBudget,
193+
typical_dynamic_scaling: {
194+
fpga_complex: newPowerData.fpgaScaling / 100,
195+
processing_complex: newPowerData.pcScaling / 100,
196+
},
197+
},
198+
},
199+
};
200+
201+
server.PATCH(server.deviceInfo(device), updatedData, (response) => {
202+
if (response.ok) {
203+
setThermalData(newThermalData);
204+
setPowerData(newPowerData);
205+
} else {
206+
console.error('Error updating thermal and power data:', response.statusText);
207+
}
208+
});
209+
}
210+
142211
function GetOptions(id) {
143212
const found = attributes.find((elem) => id === elem.id);
144213
return (found === undefined) ? [] : found.options;
@@ -150,6 +219,7 @@ export function GlobalStateProvider({ children, fetch }) { // TODO temp fix for
150219

151220
const values = useMemo(() => ({
152221
updateGlobalState,
222+
updateThermalAndPowerData,
153223
clockingState,
154224
fleState,
155225
bramState,
@@ -163,8 +233,10 @@ export function GlobalStateProvider({ children, fetch }) { // TODO temp fix for
163233
connectivityNames,
164234
dmaNames,
165235
fetchAttributes,
236+
thermalData,
237+
powerData,
166238
// eslint-disable-next-line react-hooks/exhaustive-deps
167-
}), [bramState, clockingState, dspState, fleState, ioState, socState]);
239+
}), [bramState, clockingState, dspState, fleState, ioState, socState, thermalData, powerData]);
168240

169241
return (
170242
<GlobalStateContext.Provider value={values}>

0 commit comments

Comments
 (0)