@@ -38,6 +38,16 @@ export function GlobalStateProvider({ children, fetch }) { // TODO temp fix for
38
38
const [ bcpuNames , setBcpuNames ] = useState ( [ ] ) ;
39
39
const [ connectivityNames , setConnectivityNames ] = useState ( [ ] ) ;
40
40
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
+ } ) ;
41
51
42
52
let peripheralsMessages = { } ;
43
53
@@ -128,6 +138,25 @@ export function GlobalStateProvider({ children, fetch }) { // TODO temp fix for
128
138
updatePeripherals ( device , item . href , item . type ) ;
129
139
} ) ;
130
140
} ) ;
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
+ } ) ;
131
160
} else {
132
161
setClockingState ( [ ] ) ;
133
162
setFleState ( [ ] ) ;
@@ -136,9 +165,49 @@ export function GlobalStateProvider({ children, fetch }) { // TODO temp fix for
136
165
setIoState ( [ ] ) ;
137
166
setSocState ( { } ) ;
138
167
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
+ } ) ;
139
178
}
140
179
}
141
180
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
+
142
211
function GetOptions ( id ) {
143
212
const found = attributes . find ( ( elem ) => id === elem . id ) ;
144
213
return ( found === undefined ) ? [ ] : found . options ;
@@ -150,6 +219,7 @@ export function GlobalStateProvider({ children, fetch }) { // TODO temp fix for
150
219
151
220
const values = useMemo ( ( ) => ( {
152
221
updateGlobalState,
222
+ updateThermalAndPowerData,
153
223
clockingState,
154
224
fleState,
155
225
bramState,
@@ -163,8 +233,10 @@ export function GlobalStateProvider({ children, fetch }) { // TODO temp fix for
163
233
connectivityNames,
164
234
dmaNames,
165
235
fetchAttributes,
236
+ thermalData,
237
+ powerData,
166
238
// eslint-disable-next-line react-hooks/exhaustive-deps
167
- } ) , [ bramState , clockingState , dspState , fleState , ioState , socState ] ) ;
239
+ } ) , [ bramState , clockingState , dspState , fleState , ioState , socState , thermalData , powerData ] ) ;
168
240
169
241
return (
170
242
< GlobalStateContext . Provider value = { values } >
0 commit comments