MCPcopy Create free account
hub / github.com/UtilitechAS/amsreader-firmware / setHourExport

Method setHourExport

lib/AmsDataStorage/src/AmsDataStorage.cpp:355–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353}
354
355void AmsDataStorage::setHourExport(uint8_t hour, uint32_t val) {
356 if(hour < 0 || hour > 24) return;
357
358 uint8_t accuracy = day.accuracy;
359 uint32_t update = val / pow(10, accuracy);
360 while(update > UINT16_MAX) {
361 accuracy++;
362 update = val / pow(10, accuracy);
363 }
364
365 if(accuracy != day.accuracy) {
366 setDayAccuracy(accuracy);
367 }
368
369 day.hExport[hour] = update;
370
371 uint32_t max = 0;
372 for(uint8_t i = 0; i < 24; i++) {
373 if(day.hImport[i] > max)
374 max = day.hImport[i];
375 if(day.hExport[i] > max)
376 max = day.hExport[i];
377 }
378
379 while(max < UINT16_MAX/10 && accuracy > 0) {
380 accuracy--;
381 max = max*10;
382 }
383
384 if(accuracy != day.accuracy) {
385 setDayAccuracy(accuracy);
386 }
387}
388
389uint32_t AmsDataStorage::getHourExport(uint8_t hour) {
390 if(hour < 0 || hour > 24) return 0;

Callers 1

modifyDayPlotMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected