/*
iPhly: Radio Control on the iPhone

Copyright (C) 2010-2011 Ari Krupnik & Associates

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License V2
as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#import "NSMutableDictionary+ModelConfig.h"


@implementation NSMutableDictionary (ModelConfig)

- (NSString *) name {
	return [self objectForKey: @"name"];
}
- (void) setName: (NSString *) name {
	[self setObject: name forKey: @"name"];
}

- (float) accelerometerSensitivity {
	return [[self objectForKey:@"accelerometerSensitivity"] floatValue];
}
- (void) setAccelerometerSensitivity: (float) s {
	[self setObject: [NSNumber numberWithFloat: s] forKey:@"accelerometerSensitivity"];
}

- (BOOL) isAirplane {
	return [[self objectForKey:@"model-type"] isEqualToString:@"airplane"];
}
- (BOOL) isCar {
	return [[self objectForKey:@"model-type"] isEqualToString:@"car"];
}

- (int) numChannels {
	return [(NSArray *) [self objectForKey: @"channels"] count];
}
- (NSMutableDictionary *) channel: (int) number {
	return [(NSArray *) [self objectForKey: @"channels"] objectAtIndex: number];
}

- (BOOL) reversing {
	return [[self objectForKey: @"reversing"] boolValue];
}
- (void) setReversing: (BOOL) reversing {
	[self setObject: [NSNumber numberWithBool: reversing] forKey:@"reversing"];
}

- (float) trim {
	return [[self objectForKey: @"trim"] floatValue];
}
- (void) setTrim: (float) trim {
	[self setObject: [NSNumber numberWithFloat: trim] forKey:@"trim"];
}

- (float) rate {
	return [[self objectForKey: @"rate"] floatValue];
}
- (void) setRate: (float) rate {
	[self setObject: [NSNumber numberWithFloat: rate] forKey:@"rate"];
}

@end
