Permalink
Browse files

fixed smart overrefreshing bug

  • Loading branch information...
1 parent 3a5b1a6 commit cc437f6ea89e540782b7073b7264da5ad1d06fee @valexa committed Jun 21, 2011
Showing with 13 additions and 10 deletions.
  1. +1 −1 MainCore.h
  2. +12 −9 MainCore.m
View
@@ -27,7 +27,7 @@
NSMutableDictionary *fans;
NSMutableDictionary *temps;
NSTimeInterval lastSMARTCheck;
- NSMutableArray *lastSmartDict;
+ NSMutableArray *lastSmartTemps;
}
-(void)saveSetting:(id)object forKey:(NSString*)key;
View
@@ -40,7 +40,7 @@ - (id)init{
defaults = [NSUserDefaults standardUserDefaults];
fans = [[NSMutableDictionary alloc] init];
temps = [[NSMutableDictionary alloc] init];
- lastSmartDict = [[NSMutableArray alloc] init];
+ lastSmartTemps = [[NSMutableArray alloc] init];
[smcWrapper openConn];
@@ -57,7 +57,7 @@ - (id)init{
-(void)dealloc{
[temps release];
[fans release];
- [lastSmartDict release];
+ [lastSmartTemps release];
[super dealloc];
}
@@ -207,15 +207,18 @@ -(void)syncTemp{
NSMutableDictionary *foundKeys = [NSMutableDictionary dictionaryWithDictionary:smcKeys];
//add smart temps
- if (CFAbsoluteTimeGetCurrent() - lastSMARTCheck > 960) {
- [lastSmartDict removeAllObjects];
- [lastSmartDict addObjectsFromArray:[VADiskPooler getDrives]];
+ if (CFAbsoluteTimeGetCurrent() - lastSMARTCheck > 660) {
+ [lastSmartTemps removeAllObjects];
+ for (NSString *drive in [VADiskPooler getDrives]) {
+ int temp = [VADiskPooler smartTemperature:drive];
+ [lastSmartTemps addObject:[NSNumber numberWithInt:temp]];
+ }
lastSMARTCheck = CFAbsoluteTimeGetCurrent();
}
- for (NSString *drive in lastSmartDict) {
- int temp = [VADiskPooler smartTemperature:drive];
- //NSLog(@"SMART temp is %i for %@",temp,drive);
- [foundKeys setObject:[NSNumber numberWithInt:temp] forKey:[NSString stringWithFormat:@"SMART%i",[lastSmartDict indexOfObject:drive]+1]];
+ for (NSNumber *temp in lastSmartTemps) {
+ int index = [lastSmartTemps indexOfObject:temp]+1;
+ [foundKeys setObject:temp forKey:[NSString stringWithFormat:@"SMART%i",index]];
+ NSLog(@"SMART temp is %@ for drive %i",temp,index);
}
//extract avg and max

0 comments on commit cc437f6

Please sign in to comment.