Show
Ignore:
Timestamp:
08/14/09 23:28:59 (15 years ago)
Author:
phil
Message:

completed the gas meter calculation algorithm

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • webserver/example/EnergyMeters/Source/EnergyMeters/Meters_ISRs.c

    r30 r32  
    7070     * enough on the web page to be read by the server  
    7171     */ 
    72     if ( currentTime > ((unsigned long long)meterItems[METER_INDEX_GAS].timeLastTick + ((unsigned long long)ACCUMULATE_TICK_THRESHOLD_SEC * (unsigned long long)1000)) ) 
     72    if ( currentTime > ((unsigned long long)meterItems[METER_INDEX_GAS].timeBeforeLastTick + ((unsigned long long)ACCUMULATE_TICK_THRESHOLD_SEC * (unsigned long long)1000)) ) 
    7373    { 
    74       /* if the last meter tick happened longer than DEBOUNCE_TICK_THRESHOLD_MS ago (i.e. the switch did not just bounce) */ 
     74      /* if the last meter tick happened longer than DEBOUNCE_TICK_THRESHOLD_MS ago (i.e. the switch did not just bounce), 
     75       * we create a new data item 
     76       */ 
    7577      meterItems[METER_INDEX_GAS].timeBeforeLastTick = meterItems[METER_INDEX_GAS].timeLastTick;     /* when did the tick before the last tick occur? (epoch in milliseconds) */ 
    7678      meterItems[METER_INDEX_GAS].timeLastTick = currentTime; /* when did the last tick occur? (epoch in milliseconds) */ 
     
    8183    else 
    8284    { 
    83       ; /* nothing to do, curentValue was increased already above */ 
     85      /* do not create a new data item, but update the current "last" data item */ 
     86      meterItems[METER_INDEX_GAS].timeLastTick = currentTime; 
     87      meterItems[METER_INDEX_GAS].valueLastTick = meterItems[METER_INDEX_GAS].currentValue; 
    8488    } 
    8589  }