|
|
@ -641,32 +641,64 @@
|
|
|
|
uint8_t count = [_transferData count];
|
|
|
|
uint8_t count = [_transferData count];
|
|
|
|
NSMenuItem *monthlyMenu;
|
|
|
|
NSMenuItem *monthlyMenu;
|
|
|
|
for (ii = 0; ii < count; ii++) {
|
|
|
|
for (ii = 0; ii < count; ii++) {
|
|
|
|
NSDate *previousMonthDate = [self dateFromMonthsBack:ii];
|
|
|
|
if (ii > 0) {
|
|
|
|
|
|
|
|
[menuWanTraffic addItem:[NSMenuItem separatorItem]];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Parse monthly transfer
|
|
|
|
|
|
|
|
NSDate *previousMonthDate = [self dateFromMonthsBack:ii];
|
|
|
|
|
|
|
|
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
|
|
|
|
|
|
|
|
NSDateComponents *dateComp = [gregorian components:NSYearCalendarUnit | NSMonthCalendarUnit fromDate:previousMonthDate];
|
|
|
|
|
|
|
|
|
|
|
|
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
|
|
|
|
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
|
|
|
|
[dateFormat setDateFormat:@"M-yyyy"];
|
|
|
|
[dateFormat setDateFormat:@"MM-yyyy"];
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t bytesIn = ([[[_transferData objectAtIndex:ii] objectAtIndex:0] longLongValue] * 1024 * 1024);
|
|
|
|
uint64_t bytesIn = ([[[_transferData objectAtIndex:ii] objectAtIndex:0] longLongValue] * 1024 * 1024);
|
|
|
|
uint64_t bytesOut = ([[[_transferData objectAtIndex:ii] objectAtIndex:1] longLongValue] * 1024 * 1024);
|
|
|
|
uint64_t bytesOut = ([[[_transferData objectAtIndex:ii] objectAtIndex:1] longLongValue] * 1024 * 1024);
|
|
|
|
|
|
|
|
|
|
|
|
NSString *strMonthtlyTitle = [NSString stringWithFormat:@"%@: %@/%@", [dateFormat stringFromDate:previousMonthDate], [self stringFromSize:bytesIn], [self stringFromSize:bytesOut]];
|
|
|
|
NSString *strMonthtlyTitle = [NSString stringWithFormat:@"%@\t%@/%@", [dateFormat stringFromDate:previousMonthDate], [self stringFromSize:bytesIn], [self stringFromSize:bytesOut]];
|
|
|
|
|
|
|
|
|
|
|
|
monthlyMenu = [[NSMenuItem alloc] initWithTitle:strMonthtlyTitle action:nil keyEquivalent:@""];
|
|
|
|
monthlyMenu = [[NSMenuItem alloc] initWithTitle:strMonthtlyTitle action:nil keyEquivalent:@""];
|
|
|
|
[menuWanTraffic addItem:monthlyMenu];
|
|
|
|
[menuWanTraffic addItem:monthlyMenu];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Calculate average speed for the month
|
|
|
|
|
|
|
|
uint64_t secondsInMonth;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ii == 0) {
|
|
|
|
|
|
|
|
NSDateComponents *todayComp = [gregorian components:NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit fromDate:[NSDate date]];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
secondsInMonth = ([todayComp day] * 24 * 60 * 60) + ([todayComp hour] * 60 * 60) + ([todayComp minute] * 60) + [todayComp second];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
NSCalendar* cal = [NSCalendar currentCalendar];
|
|
|
|
|
|
|
|
NSDateComponents* comps = [[[NSDateComponents alloc] init] autorelease];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[comps setMonth:[dateComp month]];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSRange range = [cal rangeOfUnit:NSDayCalendarUnit
|
|
|
|
|
|
|
|
inUnit:NSMonthCalendarUnit
|
|
|
|
|
|
|
|
forDate:[cal dateFromComponents:comps]];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
secondsInMonth = (range.length * 24 * 60 * 60);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSLog(@"%llu", secondsInMonth);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double speedIn = bytesIn / secondsInMonth;
|
|
|
|
|
|
|
|
double speedOut = bytesOut / secondsInMonth;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
speedIn = round(2.2f * speedIn) / 2.2f;
|
|
|
|
|
|
|
|
speedOut = round(2.2f * speedOut) / 2.2f;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSString *strMonthtlyAvrg = [NSString stringWithFormat:@"\t\t\t%@/s %@/s", [self stringFromSpeed:speedIn], [self stringFromSpeed:speedOut]];
|
|
|
|
|
|
|
|
monthlyMenu = [[NSMenuItem alloc] initWithTitle:strMonthtlyAvrg action:nil keyEquivalent:@""];
|
|
|
|
|
|
|
|
[menuWanTraffic addItem:monthlyMenu];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[gregorian release];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void) populateMenuClients
|
|
|
|
- (void) populateMenuClients
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
|
|
|
|
NSString * clientsStringData;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSString *keyData = @"{arp_table::";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clientsStringData = [ _statusStringData substringFromIndex:([_statusStringData rangeOfString:keyData].location + [keyData length]) ];
|
|
|
|
|
|
|
|
clientsStringData = [ clientsStringData substringToIndex:[clientsStringData rangeOfString:@"}"].location ];
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSString *clientsStringData = [wrt_request_client getKey:_statusStringData key:@"arp_table"];
|
|
|
|
NSString *clientsStringData = [wrt_request_client getKey:_statusStringData key:@"arp_table"];
|
|
|
|
|
|
|
|
|
|
|
|
// Remove any white spaces
|
|
|
|
// Remove any white spaces
|
|
|
|