summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLLightState.m
blob: f33080b7e220eb39689dbdfe5dfa33b97b9d7b2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//  SDLLightState.m
//

#import "SDLLightState.h"
#import "SDLRPCParameterNames.h"
#import "NSMutableDictionary+Store.h"
#import "SDLRGBColor.h"

NS_ASSUME_NONNULL_BEGIN

@implementation SDLLightState

- (instancetype)initWithId:(SDLLightName)id status:(SDLLightStatus)status{
    self = [self init];
    if(!self) {
        return nil;
    }
    self.id = id;
    self.status = status;

    return self;
}

- (instancetype)initWithId:(SDLLightName)id status:(SDLLightStatus)status density:(double)density color:(SDLRGBColor *)color {
    self = [self init];
    if(!self) {
        return nil;
    }
    self.id = id;
    self.status = status;
    self.density = @(density);
    self.color = color;

    return self;
}

- (instancetype)initWithId:(SDLLightName)id lightStatus:(SDLLightStatus)lightStatus lightDensity:(double)lightDensity lightColor:(UIColor *)lightColor {
    self = [self init];
    if(!self) {
        return nil;
    }
    self.id = id;
    self.status = lightStatus;
    self.density = @(lightDensity);
    self.color = [[SDLRGBColor alloc] initWithColor:lightColor];

    return self;
}

- (void)setId:(SDLLightName)id {
    [store sdl_setObject:id forName:SDLRPCParameterNameId];
}

- (SDLLightName)id {
    NSError *error;
    return [store sdl_enumForName:SDLRPCParameterNameId error:&error];
}

- (void)setStatus:(SDLLightStatus)status {
    [store sdl_setObject:status forName:SDLRPCParameterNameStatus];
}

- (SDLLightStatus)status {
    NSError *error;
    return [store sdl_enumForName:SDLRPCParameterNameStatus error:&error];
}

- (void)setDensity:(nullable NSNumber<SDLFloat> *)density {
    [store sdl_setObject:density forName:SDLRPCParameterNameDensity];
}

- (nullable NSNumber<SDLFloat> *)density {
    return [store sdl_objectForName:SDLRPCParameterNameDensity ofClass:NSNumber.class];
}

- (void)setColor:(nullable SDLRGBColor *)color {
    [store sdl_setObject:color forName:SDLRPCParameterNameColor];
}

- (nullable SDLRGBColor *)color {
    return [store sdl_objectForName:SDLRPCParameterNameColor ofClass:[SDLRGBColor class]];
}

@end

NS_ASSUME_NONNULL_END