Skip to content
Browse files

Notify after the historical information is appended.

The notification apparently occurs right away, so we need to get the data all
set up before sending the notification or the log view doesn't update at the
right time.
  • Loading branch information...
1 parent a66492f commit d803d550c70985c54a879a671bbc59a7f7c5885e @dustin committed Feb 11, 2005
Showing with 15 additions and 10 deletions.
  1. +15 −10 Thermometer.m
View
25 Thermometer.m
@@ -39,16 +39,7 @@ - (void)dealloc
-(void)setValidReading:(float)r
{
- // Normal reading update stuff
- if(reading != r) {
- float oldreading=reading;
- reading=r;
- NSLog(@"Updated %@ (%.2f -> %.2f)", [self name], oldreading, reading);
-
- // Send the notification
- [[NSNotificationCenter defaultCenter]
- postNotificationName:DATA_UPDATED object:self];
- }
+ // Grab all the historical and trend data first
// Keep the array small enough.
while([lastReadings count] >= RING_BUFFER_SIZE) {
@@ -63,6 +54,20 @@ -(void)setValidReading:(float)r
TempReading *lastReading=[lastReadings lastObject];
// Remember the trend (upwards or downwards)
trend=r - [lastReading floatValue];
+
+ // Then process the reading change and send notifications
+
+ // Normal reading update stuff
+ if(reading != r) {
+ float oldreading=reading;
+ reading=r;
+ NSLog(@"Updated %@ (%.2f -> %.2f)", [self name], oldreading, reading);
+
+ // Send the notification
+ [[NSNotificationCenter defaultCenter]
+ postNotificationName:DATA_UPDATED object:self];
+ }
+
}
// Check for valid values

0 comments on commit d803d55

Please sign in to comment.
Something went wrong with that request. Please try again.