Commit eaec457e2d7b0d1ce8a9f5b8b1215ee6819c6df4
1 parent
60bf0aab
--no commit message
Showing
12 changed files
with
255 additions
and
6 deletions
DUREX Vendor Control/Base.lproj/DatePickerViewController.xib
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | <objects> |
7 | 7 | <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="DatePickerViewController"> |
8 | 8 | <connections> |
9 | + <outlet property="datePicker" destination="SbL-OM-Pxu" id="d6i-Rf-ZdS"/> | |
9 | 10 | <outlet property="datePickerView" destination="o92-Jq-3Xo" id="IOi-YU-3Wz"/> |
10 | 11 | <outlet property="view" destination="7fx-e7-JEt" id="dL9-Ac-hWL"/> |
11 | 12 | </connections> | ... | ... |
DUREX Vendor Control/CommunicationProtocol.h
... | ... | @@ -12,9 +12,16 @@ |
12 | 12 | #define MAX_STRING_LENGTH ((int)200) |
13 | 13 | #define MAX_RETRIES ((int)3) |
14 | 14 | #define MAX_PRODUCT_NAME_LENGTH ((int)64) |
15 | +#define MAX_CHANNELS ((int)16) | |
16 | +#define MONEY_NUM_UNITS ((int)5) | |
17 | +#define MAX_PRODUCTS ((int)16) | |
18 | + | |
15 | 19 | |
16 | 20 | @interface CommunicationProtocol : NSObject |
17 | 21 | |
22 | +@property Boolean messageAvailableMobile; | |
23 | +@property Boolean messageAvailableDevice; | |
24 | + | |
18 | 25 | -(Boolean) waitForMessageAvailableMobile: (Boolean) status; |
19 | 26 | -(Boolean) waitForMessageAvailableDevice: (Boolean) status; |
20 | 27 | -(Boolean) writeMessage: (NSString*) message; |
... | ... | @@ -23,8 +30,7 @@ |
23 | 30 | -(Boolean) updateTime: (NSDateComponents*) date; |
24 | 31 | -(Boolean) updatePrice: (uint8_t) channel : (uint8_t) product : (uint8_t) eur : (uint8_t) cents; |
25 | 32 | -(Boolean) updateProductName: (uint8_t) channel : (uint8_t) product : (NSString*) name; |
33 | +-(NSString*) readSensorData; | |
26 | 34 | +(id) sharedProtocol; |
27 | -@property Boolean messageAvailableMobile; | |
28 | -@property Boolean messageAvailableDevice; | |
29 | 35 | |
30 | 36 | @end | ... | ... |
DUREX Vendor Control/CommunicationProtocol.m
... | ... | @@ -354,4 +354,45 @@ |
354 | 354 | return FALSE; |
355 | 355 | } |
356 | 356 | |
357 | +-(NSString*) readSensorData | |
358 | +{ | |
359 | + NSString *command = @"A4"; | |
360 | + [self writeMessage:command]; | |
361 | + //NSString *answer = [self readMessage]; | |
362 | + | |
363 | + char command_str[65]; | |
364 | + command_str[0] = 'P'; | |
365 | + command_str[1] = '4'; | |
366 | + command_str[2] = 255; | |
367 | + command_str[3] = 0; | |
368 | + command_str[4] = 255; | |
369 | + command_str[5] = 0; | |
370 | + command_str[6] = 255; | |
371 | + command_str[7] = 0; | |
372 | + command_str[8] = '1'; | |
373 | + command_str[9] = '0'; | |
374 | + for(int i = 10; i < 10; i+=3) | |
375 | + { | |
376 | + command_str[i] = '0'; | |
377 | + command_str[i+1] = '0'; | |
378 | + command_str[i+2] = '0'; | |
379 | + } | |
380 | + for(int i = 40; i < 16; i+=2) | |
381 | + { | |
382 | + command_str[i] = '0'; | |
383 | + command_str[i+1] = '0'; | |
384 | + } | |
385 | + command_str[63] = '1'; | |
386 | + command_str[64] = '1'; | |
387 | + | |
388 | + NSMutableString *answer = [[NSMutableString alloc]init]; | |
389 | + [answer appendString:[NSString stringWithUTF8String:command_str]]; | |
390 | + | |
391 | + if([[answer substringToIndex:2] isEqualToString:@"P4"]) | |
392 | + { | |
393 | + return answer; | |
394 | + } | |
395 | + return nil; | |
396 | +} | |
397 | + | |
357 | 398 | @end | ... | ... |
DUREX Vendor Control/DUREX Vendor Control.xcodeproj/project.pbxproj
... | ... | @@ -35,6 +35,7 @@ |
35 | 35 | F98356D8192E906600EA6821 /* bluetooth.png in Resources */ = {isa = PBXBuildFile; fileRef = F98356D7192E906600EA6821 /* bluetooth.png */; }; |
36 | 36 | F98356DB192EAFD400EA6821 /* CommunicationProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = F98356DA192EAFD400EA6821 /* CommunicationProtocol.m */; }; |
37 | 37 | F98356E1192EC84700EA6821 /* MenuTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F98356E0192EC84700EA6821 /* MenuTableViewController.m */; }; |
38 | + F98446F019B9EAE9005C4992 /* Sensors.m in Sources */ = {isa = PBXBuildFile; fileRef = F98446EF19B9EAE9005C4992 /* Sensors.m */; }; | |
38 | 39 | F9A8EF7C192FE201009E7532 /* Stack.m in Sources */ = {isa = PBXBuildFile; fileRef = F9A8EF7B192FE201009E7532 /* Stack.m */; }; |
39 | 40 | F9C77F50192CDE30002DBE8A /* system.json in Resources */ = {isa = PBXBuildFile; fileRef = F9C77F4F192CDE30002DBE8A /* system.json */; }; |
40 | 41 | F9E4D8FD19B8FD32009A7359 /* EMConnectingView_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = F9E4D8FF19B8FD32009A7359 /* EMConnectingView_iPad.xib */; }; |
... | ... | @@ -115,6 +116,8 @@ |
115 | 116 | F98356DA192EAFD400EA6821 /* CommunicationProtocol.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommunicationProtocol.m; sourceTree = SOURCE_ROOT; }; |
116 | 117 | F98356DF192EC84700EA6821 /* MenuTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuTableViewController.h; sourceTree = SOURCE_ROOT; }; |
117 | 118 | F98356E0192EC84700EA6821 /* MenuTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MenuTableViewController.m; sourceTree = SOURCE_ROOT; }; |
119 | + F98446EE19B9EAE9005C4992 /* Sensors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sensors.h; sourceTree = SOURCE_ROOT; }; | |
120 | + F98446EF19B9EAE9005C4992 /* Sensors.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Sensors.m; sourceTree = SOURCE_ROOT; }; | |
118 | 121 | F9A8EF7A192FE201009E7532 /* Stack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Stack.h; sourceTree = SOURCE_ROOT; }; |
119 | 122 | F9A8EF7B192FE201009E7532 /* Stack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Stack.m; sourceTree = SOURCE_ROOT; }; |
120 | 123 | F9C77F4F192CDE30002DBE8A /* system.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = system.json; sourceTree = SOURCE_ROOT; }; |
... | ... | @@ -180,12 +183,13 @@ |
180 | 183 | 34AAB877189804FF0019860D /* DUREXAppDelegate.m */, |
181 | 184 | F98356D5192E835F00EA6821 /* InitialViewController.m */, |
182 | 185 | F98356E0192EC84700EA6821 /* MenuTableViewController.m */, |
183 | - F98356DA192EAFD400EA6821 /* CommunicationProtocol.m */, | |
184 | 186 | F9A8EF7B192FE201009E7532 /* Stack.m */, |
187 | + F98356DA192EAFD400EA6821 /* CommunicationProtocol.m */, | |
185 | 188 | F933F80219B6819400521B90 /* DatePickerViewController.m */, |
186 | 189 | F92F567719B75F5E00A1EACA /* PriceChangerViewController.m */, |
187 | 190 | F92F568E19B763FD00A1EACA /* NameChangerViewController.m */, |
188 | 191 | 34AAB880189804FF0019860D /* main.m */, |
192 | + F98446EF19B9EAE9005C4992 /* Sensors.m */, | |
189 | 193 | ); |
190 | 194 | name = "DUREX Vendor Control"; |
191 | 195 | path = TestAppExample; |
... | ... | @@ -278,6 +282,7 @@ |
278 | 282 | F933F80119B6819400521B90 /* DatePickerViewController.h */, |
279 | 283 | F92F567619B75F5E00A1EACA /* PriceChangerViewController.h */, |
280 | 284 | F92F568D19B763FD00A1EACA /* NameChangerViewController.h */, |
285 | + F98446EE19B9EAE9005C4992 /* Sensors.h */, | |
281 | 286 | ); |
282 | 287 | name = Headers; |
283 | 288 | sourceTree = "<group>"; |
... | ... | @@ -383,6 +388,7 @@ |
383 | 388 | 34AAB883189804FF0019860D /* DUREXAppDelegate.m in Sources */, |
384 | 389 | F98356DB192EAFD400EA6821 /* CommunicationProtocol.m in Sources */, |
385 | 390 | F98356E1192EC84700EA6821 /* MenuTableViewController.m in Sources */, |
391 | + F98446F019B9EAE9005C4992 /* Sensors.m in Sources */, | |
386 | 392 | 34AAB889189804FF0019860D /* main.m in Sources */, |
387 | 393 | ); |
388 | 394 | runOnlyForDeploymentPostprocessing = 0; | ... | ... |
DUREX Vendor Control/DUREX Vendor Control.xcodeproj/project.xcworkspace/xcuserdata/imanol.xcuserdatad/UserInterfaceState.xcuserstate
No preview for this file type
DUREX Vendor Control/MenuTableViewController.h
... | ... | @@ -13,6 +13,7 @@ |
13 | 13 | #import "DatePickerViewController.h" |
14 | 14 | #import "PriceChangerViewController.h" |
15 | 15 | #import "NameChangerViewController.h" |
16 | +#import "Sensors.h" | |
16 | 17 | |
17 | 18 | #define num(x) [NSNumber numberWithUnsignedInt:x] |
18 | 19 | |
... | ... | @@ -48,6 +49,7 @@ enum { |
48 | 49 | @property (strong,nonatomic) DatePickerViewController *datePickerViewController; |
49 | 50 | @property (strong,nonatomic) PriceChangerViewController *priceChangerViewController; |
50 | 51 | @property (strong,nonatomic) NameChangerViewController *nameChangerViewController; |
52 | +@property (strong,nonatomic) Sensors *sensorStatus; | |
51 | 53 | |
52 | 54 | - (void) navBack; |
53 | 55 | ... | ... |
DUREX Vendor Control/MenuTableViewController.m
... | ... | @@ -81,6 +81,8 @@ |
81 | 81 | |
82 | 82 | - (void) generateMaintenanceLevel |
83 | 83 | { |
84 | + [[self sensorStatus] setResponse:[_protocol readSensorData]]; | |
85 | + //DO SUM SHIET | |
84 | 86 | [self setMaintenanceElements:[[NSArray alloc] initWithObjects:MAINTENANCE_ELEMENTS, nil]]; |
85 | 87 | [self setMaintenanceStructure:[[NSArray alloc] initWithObjects:MAINTENANCE_CELLS_PER_SECTION, nil]]; |
86 | 88 | if([[self maintenanceStructure] count] > 1) |
... | ... | @@ -107,8 +109,6 @@ |
107 | 109 | } |
108 | 110 | } |
109 | 111 | |
110 | - | |
111 | - | |
112 | 112 | - (void) changeNavLevel: (uint8_t) level : (BOOL) push |
113 | 113 | { |
114 | 114 | NSLog(@"[MenuTableViewController.m]: navLevel is %d",level); |
... | ... | @@ -215,6 +215,9 @@ |
215 | 215 | self.currentNavLevel = 255; |
216 | 216 | [self changeNavLevel:MENU:FALSE]; |
217 | 217 | |
218 | + //Initialize sensor status | |
219 | + [self setSensorStatus:[[Sensors alloc]init]]; | |
220 | + | |
218 | 221 | // Uncomment the following line to preserve selection between presentations. |
219 | 222 | // self.clearsSelectionOnViewWillAppear = NO; |
220 | 223 | ... | ... |
DUREX Vendor Control/Sensors.h
0 โ 100644
1 | +// | |
2 | +// Sensors.h | |
3 | +// DUREX Vendor Control | |
4 | +// | |
5 | +// Created by Imanol Barba on 9/5/14. | |
6 | +// Copyright (c) 2014 Emmoco. All rights reserved. | |
7 | +// | |
8 | + | |
9 | +#import <Foundation/Foundation.h> | |
10 | +#import "CommunicationProtocol.h" | |
11 | + | |
12 | +@interface Sensors : NSObject | |
13 | + | |
14 | +@property (strong,nonatomic) NSString *response; | |
15 | +@property NSUInteger numChannels; | |
16 | +@property NSMutableArray *channelProductAvailability; | |
17 | +@property NSMutableArray *channelStatus; | |
18 | +@property Boolean doorOpen; | |
19 | +@property Boolean coilOpen; | |
20 | +@property NSMutableArray *moneyCollected; | |
21 | +@property NSMutableArray *moneyReturned; | |
22 | +@property NSMutableArray *productsSold; | |
23 | +@property NSMutableArray *changeAvailable; | |
24 | + | |
25 | +- (id) init; | |
26 | +- (void) setResponse:(NSString *)response; | |
27 | + | |
28 | +@end | ... | ... |
DUREX Vendor Control/Sensors.m
0 โ 100644
1 | +// | |
2 | +// Sensors.m | |
3 | +// DUREX Vendor Control | |
4 | +// | |
5 | +// Created by Imanol Barba on 9/5/14. | |
6 | +// Copyright (c) 2014 Emmoco. All rights reserved. | |
7 | +// | |
8 | + | |
9 | +#import "Sensors.h" | |
10 | + | |
11 | +@interface Sensors () | |
12 | + | |
13 | +@end | |
14 | + | |
15 | +@implementation Sensors | |
16 | + | |
17 | +- (id) init | |
18 | +{ | |
19 | + [self setChannelProductAvailability:[[NSMutableArray alloc]init]]; | |
20 | + [self setChannelStatus:[[NSMutableArray alloc]init]]; | |
21 | + [self setMoneyCollected:[[NSMutableArray alloc]init]]; | |
22 | + [self setMoneyReturned:[[NSMutableArray alloc]init]]; | |
23 | + [self setChangeAvailable:[[NSMutableArray alloc] init]]; | |
24 | + | |
25 | + return self; | |
26 | +} | |
27 | + | |
28 | +- (void) setResponse:(NSString *)response | |
29 | +{ | |
30 | + self.response = response; | |
31 | + [self parseResponse]; | |
32 | +} | |
33 | + | |
34 | +- (void) parseResponse | |
35 | +{ | |
36 | + uint8_t channelCount = 0; | |
37 | + uint16_t channelStatus = 0; | |
38 | + uint16_t channelAvailability = 0; | |
39 | + uint16_t channelMotors = 0; | |
40 | + | |
41 | + | |
42 | + channelStatus |= [[self response] characterAtIndex:2]; | |
43 | + channelStatus |= ([[self response] characterAtIndex:3] << 8); | |
44 | + channelAvailability |= [[self response] characterAtIndex:4]; | |
45 | + channelAvailability |= ([[self response] characterAtIndex:5] << 8); | |
46 | + channelMotors |= [[self response] characterAtIndex:6]; | |
47 | + channelMotors |= ([[self response] characterAtIndex:7] << 8); | |
48 | + | |
49 | + for(int i = 0; i < MAX_CHANNELS; i++) | |
50 | + { | |
51 | + if(channelStatus & 0x01) | |
52 | + { | |
53 | + channelCount++; | |
54 | + } | |
55 | + channelStatus <<= 1; | |
56 | + } | |
57 | + [self setNumChannels:channelCount]; | |
58 | + | |
59 | + for(int i = 0; i < MAX_CHANNELS; i++) | |
60 | + { | |
61 | + if(channelAvailability & 0x01) | |
62 | + { | |
63 | + [[self channelProductAvailability] insertObject:[NSNumber numberWithBool:TRUE] atIndex:i]; | |
64 | + } | |
65 | + else | |
66 | + { | |
67 | + [[self channelProductAvailability] insertObject:[NSNumber numberWithBool:FALSE] atIndex:i]; | |
68 | + } | |
69 | + channelAvailability <<= 1; | |
70 | + } | |
71 | + | |
72 | + for(int i = 0; i < MAX_CHANNELS; i++) | |
73 | + { | |
74 | + if(channelMotors & 0x01) | |
75 | + { | |
76 | + [[self channelStatus] insertObject:[NSNumber numberWithBool:TRUE] atIndex:i]; | |
77 | + } | |
78 | + else | |
79 | + { | |
80 | + [[self channelStatus] insertObject:[NSNumber numberWithBool:FALSE] atIndex:i]; | |
81 | + } | |
82 | + channelMotors <<= 1; | |
83 | + } | |
84 | + | |
85 | + if([[self response] characterAtIndex:8] == '1') | |
86 | + { | |
87 | + [self setDoorOpen:TRUE]; | |
88 | + } | |
89 | + else | |
90 | + { | |
91 | + [self setDoorOpen:FALSE]; | |
92 | + } | |
93 | + | |
94 | + if([[self response] characterAtIndex:9] == '1') | |
95 | + { | |
96 | + [self setCoilOpen:TRUE]; | |
97 | + } | |
98 | + else | |
99 | + { | |
100 | + [self setCoilOpen:FALSE]; | |
101 | + } | |
102 | + NSRange substrRange; | |
103 | + substrRange.length = 3; | |
104 | + substrRange.location = 10; | |
105 | + | |
106 | + for(int i = 0; i < MONEY_NUM_UNITS; i++) | |
107 | + { | |
108 | + [[self moneyCollected] insertObject:[NSNumber numberWithInt:[[[self response] substringWithRange:substrRange] intValue]] atIndex:i]; | |
109 | + substrRange.location += 3; | |
110 | + } | |
111 | + for(int i = 0; i < MONEY_NUM_UNITS; i++) | |
112 | + { | |
113 | + [[self moneyReturned] insertObject:[NSNumber numberWithInt:[[[self response] substringWithRange:substrRange] intValue]] atIndex:i]; | |
114 | + substrRange.location += 3; | |
115 | + } | |
116 | + | |
117 | + substrRange.length = 2; | |
118 | + for(int i = 0; i < MAX_PRODUCTS; i++) | |
119 | + { | |
120 | + [[self productsSold] insertObject:[NSNumber numberWithInt:[[[self response] substringWithRange:substrRange] intValue]] atIndex:i]; | |
121 | + substrRange.location += 2; | |
122 | + } | |
123 | + | |
124 | + if([[self response] characterAtIndex:64] == '1') | |
125 | + { | |
126 | + [[self changeAvailable]insertObject:[NSNumber numberWithBool:TRUE] atIndex:0]; | |
127 | + } | |
128 | + else | |
129 | + { | |
130 | + [[self changeAvailable]insertObject:[NSNumber numberWithBool:FALSE] atIndex:0]; | |
131 | + } | |
132 | + | |
133 | + if([[self response] characterAtIndex:65] == '1') | |
134 | + { | |
135 | + [[self changeAvailable]insertObject:[NSNumber numberWithBool:TRUE] atIndex:1]; | |
136 | + } | |
137 | + else | |
138 | + { | |
139 | + [[self changeAvailable]insertObject:[NSNumber numberWithBool:FALSE] atIndex:1]; | |
140 | + } | |
141 | + | |
142 | + | |
143 | +} | |
144 | + | |
145 | +@end | ... | ... |
DUREX tests/DUREX test.xcodeproj/project.xcworkspace/xcuserdata/imanol.xcuserdatad/UserInterfaceState.xcuserstate
No preview for this file type
DUREX tests/DUREX test.xcodeproj/xcuserdata/imanol.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
... | ... | @@ -19,5 +19,21 @@ |
19 | 19 | landmarkType = "4"> |
20 | 20 | </BreakpointContent> |
21 | 21 | </BreakpointProxy> |
22 | + <BreakpointProxy | |
23 | + BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> | |
24 | + <BreakpointContent | |
25 | + shouldBeEnabled = "Yes" | |
26 | + ignoreCount = "0" | |
27 | + continueAfterRunningActions = "No" | |
28 | + filePath = "InitialViewController.m" | |
29 | + timestampString = "431638986.643987" | |
30 | + startingColumnNumber = "9223372036854775807" | |
31 | + endingColumnNumber = "9223372036854775807" | |
32 | + startingLineNumber = "32" | |
33 | + endingLineNumber = "32" | |
34 | + landmarkName = "-viewDidLoad" | |
35 | + landmarkType = "5"> | |
36 | + </BreakpointContent> | |
37 | + </BreakpointProxy> | |
22 | 38 | </Breakpoints> |
23 | 39 | </Bucket> | ... | ... |
TODO
... | ... | @@ -4,13 +4,14 @@ BUGS: |
4 | 4 | |
5 | 5 | TODO: |
6 | 6 | - Sensors class |
7 | -- A4 command | |
8 | 7 | - A4 parser |
9 | 8 | - Dropdown cells |
9 | +- Generate view | |
10 | 10 | |
11 | 11 | - Sale class |
12 | 12 | - A2 command |
13 | 13 | - Sale parser |
14 | +- Generate view | |
14 | 15 | |
15 | 16 | - Implement sensor status logging and sending to remote server |
16 | 17 | - Lewis infrastructure for data viewing (SQL, Webpage, CSV parser) | ... | ... |