Commit dcf63fcf16adbac526f69c2dc8e724930f25db67
1 parent
eaec457e
--no commit message
Showing
23 changed files
with
761 additions
and
310 deletions
DUREX Vendor Control/Base.lproj/Localizable.strings
@@ -34,8 +34,10 @@ | @@ -34,8 +34,10 @@ | ||
34 | "Channel Engine Status" = "Channel Engine Status"; | 34 | "Channel Engine Status" = "Channel Engine Status"; |
35 | "Door Sensor" = "Door Sensor"; | 35 | "Door Sensor" = "Door Sensor"; |
36 | "Coil Sensor" = "Coil Sensor"; | 36 | "Coil Sensor" = "Coil Sensor"; |
37 | +"OPEN" = "OPEN"; | ||
38 | +"CLOSED" = "CLOSED"; | ||
37 | "Money Collected" = "Money Collected"; | 39 | "Money Collected" = "Money Collected"; |
38 | -"Money Given" = "Money Given"; | 40 | +"Money Returned" = "Money Returned"; |
39 | "Products Sold" = "Products Sold"; | 41 | "Products Sold" = "Products Sold"; |
40 | "Product 1" = "Product 1"; | 42 | "Product 1" = "Product 1"; |
41 | "Product 2" = "Product 2"; | 43 | "Product 2" = "Product 2"; |
@@ -72,7 +74,7 @@ | @@ -72,7 +74,7 @@ | ||
72 | "50c Coins" = "50c Coins"; | 74 | "50c Coins" = "50c Coins"; |
73 | "Channel" = "Channel"; | 75 | "Channel" = "Channel"; |
74 | "Product Code" = "Product Code"; | 76 | "Product Code" = "Product Code"; |
75 | -"Nominal Price" = "Nominal Price"; | 77 | +"Normal Price" = "Normal Price"; |
76 | "Discounted Price" = "Discounted Price"; | 78 | "Discounted Price" = "Discounted Price"; |
77 | "1€ Change" = "1€ Change"; | 79 | "1€ Change" = "1€ Change"; |
78 | "50c Change" = "50c Change"; | 80 | "50c Change" = "50c Change"; |
DUREX Vendor Control/CommunicationProtocol.h
@@ -13,15 +13,14 @@ | @@ -13,15 +13,14 @@ | ||
13 | #define MAX_RETRIES ((int)3) | 13 | #define MAX_RETRIES ((int)3) |
14 | #define MAX_PRODUCT_NAME_LENGTH ((int)64) | 14 | #define MAX_PRODUCT_NAME_LENGTH ((int)64) |
15 | #define MAX_CHANNELS ((int)16) | 15 | #define MAX_CHANNELS ((int)16) |
16 | -#define MONEY_NUM_UNITS ((int)5) | 16 | +#define MONEY_IN_NUM_UNITS ((int)5) |
17 | +#define MONEY_OUT_NUM_UNITS ((int)3) | ||
18 | +#define CHANGE_NUM_UNITS ((int)2) | ||
17 | #define MAX_PRODUCTS ((int)16) | 19 | #define MAX_PRODUCTS ((int)16) |
18 | 20 | ||
19 | 21 | ||
20 | @interface CommunicationProtocol : NSObject | 22 | @interface CommunicationProtocol : NSObject |
21 | 23 | ||
22 | -@property Boolean messageAvailableMobile; | ||
23 | -@property Boolean messageAvailableDevice; | ||
24 | - | ||
25 | -(Boolean) waitForMessageAvailableMobile: (Boolean) status; | 24 | -(Boolean) waitForMessageAvailableMobile: (Boolean) status; |
26 | -(Boolean) waitForMessageAvailableDevice: (Boolean) status; | 25 | -(Boolean) waitForMessageAvailableDevice: (Boolean) status; |
27 | -(Boolean) writeMessage: (NSString*) message; | 26 | -(Boolean) writeMessage: (NSString*) message; |
@@ -31,6 +30,7 @@ | @@ -31,6 +30,7 @@ | ||
31 | -(Boolean) updatePrice: (uint8_t) channel : (uint8_t) product : (uint8_t) eur : (uint8_t) cents; | 30 | -(Boolean) updatePrice: (uint8_t) channel : (uint8_t) product : (uint8_t) eur : (uint8_t) cents; |
32 | -(Boolean) updateProductName: (uint8_t) channel : (uint8_t) product : (NSString*) name; | 31 | -(Boolean) updateProductName: (uint8_t) channel : (uint8_t) product : (NSString*) name; |
33 | -(NSString*) readSensorData; | 32 | -(NSString*) readSensorData; |
33 | +-(NSString*) readSalesLog: (NSDate*) start : (NSDate*) end; | ||
34 | +(id) sharedProtocol; | 34 | +(id) sharedProtocol; |
35 | 35 | ||
36 | @end | 36 | @end |
DUREX Vendor Control/CommunicationProtocol.m
@@ -10,6 +10,9 @@ | @@ -10,6 +10,9 @@ | ||
10 | 10 | ||
11 | @interface CommunicationProtocol () | 11 | @interface CommunicationProtocol () |
12 | 12 | ||
13 | +@property Boolean messageAvailableMobile; | ||
14 | +@property Boolean messageAvailableDevice; | ||
15 | + | ||
13 | @end | 16 | @end |
14 | 17 | ||
15 | @implementation CommunicationProtocol | 18 | @implementation CommunicationProtocol |
@@ -20,6 +23,8 @@ | @@ -20,6 +23,8 @@ | ||
20 | static dispatch_once_t onceToken; | 23 | static dispatch_once_t onceToken; |
21 | dispatch_once(&onceToken, ^{ | 24 | dispatch_once(&onceToken, ^{ |
22 | shared = [[self alloc] init]; | 25 | shared = [[self alloc] init]; |
26 | + [shared setMessageAvailableDevice:FALSE]; | ||
27 | + [shared setMessageAvailableMobile:FALSE]; | ||
23 | }); | 28 | }); |
24 | return shared; | 29 | return shared; |
25 | } | 30 | } |
@@ -358,37 +363,61 @@ | @@ -358,37 +363,61 @@ | ||
358 | { | 363 | { |
359 | NSString *command = @"A4"; | 364 | NSString *command = @"A4"; |
360 | [self writeMessage:command]; | 365 | [self writeMessage:command]; |
361 | - //NSString *answer = [self readMessage]; | 366 | + NSString *answer = [self readMessage]; |
362 | 367 | ||
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) | 368 | + /*NSMutableString *answer = [[NSMutableString alloc]initWithString:@"P400255002550025510"]; |
369 | + for(int i = 0; i < 15; i++) | ||
370 | + { | ||
371 | + [answer appendString:@"0"]; | ||
372 | + } | ||
373 | + for(int i = 0; i < 9; i++) | ||
374 | + { | ||
375 | + [answer appendString:@"4"]; | ||
376 | + } | ||
377 | + for(int i = 0; i < 32; i++) | ||
375 | { | 378 | { |
376 | - command_str[i] = '0'; | ||
377 | - command_str[i+1] = '0'; | ||
378 | - command_str[i+2] = '0'; | 379 | + [answer appendString:@"2"]; |
379 | } | 380 | } |
380 | - for(int i = 40; i < 16; i+=2) | 381 | + [answer appendString:@"1"]; |
382 | + [answer appendString:@"1"];*/ | ||
383 | + | ||
384 | + if([[answer substringToIndex:2]isEqualToString:@"P4"]) | ||
381 | { | 385 | { |
382 | - command_str[i] = '0'; | ||
383 | - command_str[i+1] = '0'; | 386 | + return answer; |
384 | } | 387 | } |
385 | - command_str[63] = '1'; | ||
386 | - command_str[64] = '1'; | 388 | + return nil; |
389 | +} | ||
390 | + | ||
391 | +-(NSString*) readSalesLog : (NSDate*) start : (NSDate*) end | ||
392 | +{ | ||
393 | + NSMutableString *startDate = [[NSMutableString alloc] init]; | ||
394 | + NSMutableString *endDate = [[NSMutableString alloc] init]; | ||
395 | + NSMutableString *command = [NSMutableString stringWithString:@"A2"]; | ||
396 | + if(start == nil) | ||
397 | + { | ||
398 | + [startDate setString:@""]; | ||
399 | + } | ||
400 | + else | ||
401 | + { | ||
402 | + | ||
403 | + } | ||
404 | + if(end == nil) | ||
405 | + { | ||
406 | + [endDate setString:@""]; | ||
407 | + } | ||
408 | + else | ||
409 | + { | ||
410 | + | ||
411 | + } | ||
412 | + [command appendString:startDate]; | ||
413 | + [command appendString:@"-"]; | ||
414 | + [command appendString:endDate]; | ||
415 | + [self writeMessage:command]; | ||
416 | + //NSString *answer = [self readMessage]; | ||
387 | 417 | ||
388 | - NSMutableString *answer = [[NSMutableString alloc]init]; | ||
389 | - [answer appendString:[NSString stringWithUTF8String:command_str]]; | 418 | + NSMutableString *answer = [[NSMutableString alloc]initWithString:@"P21405141651102416090662045001500512P21406141651102416090662045001500512P2P2"]; |
390 | 419 | ||
391 | - if([[answer substringToIndex:2] isEqualToString:@"P4"]) | 420 | + if([[answer substringToIndex:2]isEqualToString:@"P2"]) |
392 | { | 421 | { |
393 | return answer; | 422 | return answer; |
394 | } | 423 | } |
DUREX Vendor Control/DUREX Vendor Control.xcodeproj/project.pbxproj
@@ -36,6 +36,10 @@ | @@ -36,6 +36,10 @@ | ||
36 | F98356DB192EAFD400EA6821 /* CommunicationProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = F98356DA192EAFD400EA6821 /* CommunicationProtocol.m */; }; | 36 | F98356DB192EAFD400EA6821 /* CommunicationProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = F98356DA192EAFD400EA6821 /* CommunicationProtocol.m */; }; |
37 | F98356E1192EC84700EA6821 /* MenuTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F98356E0192EC84700EA6821 /* MenuTableViewController.m */; }; | 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 | F98446F019B9EAE9005C4992 /* Sensors.m in Sources */ = {isa = PBXBuildFile; fileRef = F98446EF19B9EAE9005C4992 /* Sensors.m */; }; |
39 | + F989B5FB19BBC80300657DD9 /* carat-open.png in Resources */ = {isa = PBXBuildFile; fileRef = F989B5F919BBC80300657DD9 /* carat-open.png */; }; | ||
40 | + F989B5FC19BBC80300657DD9 /* carat.png in Resources */ = {isa = PBXBuildFile; fileRef = F989B5FA19BBC80300657DD9 /* carat.png */; }; | ||
41 | + F989B5FF19BCD7A100657DD9 /* Sale.m in Sources */ = {isa = PBXBuildFile; fileRef = F989B5FE19BCD7A100657DD9 /* Sale.m */; }; | ||
42 | + F989B60219BCE28C00657DD9 /* SalesLog.m in Sources */ = {isa = PBXBuildFile; fileRef = F989B60119BCE28C00657DD9 /* SalesLog.m */; }; | ||
39 | F9A8EF7C192FE201009E7532 /* Stack.m in Sources */ = {isa = PBXBuildFile; fileRef = F9A8EF7B192FE201009E7532 /* Stack.m */; }; | 43 | F9A8EF7C192FE201009E7532 /* Stack.m in Sources */ = {isa = PBXBuildFile; fileRef = F9A8EF7B192FE201009E7532 /* Stack.m */; }; |
40 | F9C77F50192CDE30002DBE8A /* system.json in Resources */ = {isa = PBXBuildFile; fileRef = F9C77F4F192CDE30002DBE8A /* system.json */; }; | 44 | F9C77F50192CDE30002DBE8A /* system.json in Resources */ = {isa = PBXBuildFile; fileRef = F9C77F4F192CDE30002DBE8A /* system.json */; }; |
41 | F9E4D8FD19B8FD32009A7359 /* EMConnectingView_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = F9E4D8FF19B8FD32009A7359 /* EMConnectingView_iPad.xib */; }; | 45 | F9E4D8FD19B8FD32009A7359 /* EMConnectingView_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = F9E4D8FF19B8FD32009A7359 /* EMConnectingView_iPad.xib */; }; |
@@ -118,6 +122,12 @@ | @@ -118,6 +122,12 @@ | ||
118 | F98356E0192EC84700EA6821 /* MenuTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MenuTableViewController.m; sourceTree = SOURCE_ROOT; }; | 122 | 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; }; | 123 | 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; }; | 124 | F98446EF19B9EAE9005C4992 /* Sensors.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Sensors.m; sourceTree = SOURCE_ROOT; }; |
125 | + F989B5F919BBC80300657DD9 /* carat-open.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "carat-open.png"; sourceTree = SOURCE_ROOT; }; | ||
126 | + F989B5FA19BBC80300657DD9 /* carat.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = carat.png; sourceTree = SOURCE_ROOT; }; | ||
127 | + F989B5FD19BCD7A100657DD9 /* Sale.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sale.h; sourceTree = SOURCE_ROOT; }; | ||
128 | + F989B5FE19BCD7A100657DD9 /* Sale.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Sale.m; sourceTree = SOURCE_ROOT; }; | ||
129 | + F989B60019BCE28C00657DD9 /* SalesLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SalesLog.h; sourceTree = SOURCE_ROOT; }; | ||
130 | + F989B60119BCE28C00657DD9 /* SalesLog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SalesLog.m; sourceTree = SOURCE_ROOT; }; | ||
121 | F9A8EF7A192FE201009E7532 /* Stack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Stack.h; sourceTree = SOURCE_ROOT; }; | 131 | F9A8EF7A192FE201009E7532 /* Stack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Stack.h; sourceTree = SOURCE_ROOT; }; |
122 | F9A8EF7B192FE201009E7532 /* Stack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Stack.m; sourceTree = SOURCE_ROOT; }; | 132 | F9A8EF7B192FE201009E7532 /* Stack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Stack.m; sourceTree = SOURCE_ROOT; }; |
123 | F9C77F4F192CDE30002DBE8A /* system.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = system.json; sourceTree = SOURCE_ROOT; }; | 133 | F9C77F4F192CDE30002DBE8A /* system.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = system.json; sourceTree = SOURCE_ROOT; }; |
@@ -190,6 +200,8 @@ | @@ -190,6 +200,8 @@ | ||
190 | F92F568E19B763FD00A1EACA /* NameChangerViewController.m */, | 200 | F92F568E19B763FD00A1EACA /* NameChangerViewController.m */, |
191 | 34AAB880189804FF0019860D /* main.m */, | 201 | 34AAB880189804FF0019860D /* main.m */, |
192 | F98446EF19B9EAE9005C4992 /* Sensors.m */, | 202 | F98446EF19B9EAE9005C4992 /* Sensors.m */, |
203 | + F989B5FE19BCD7A100657DD9 /* Sale.m */, | ||
204 | + F989B60119BCE28C00657DD9 /* SalesLog.m */, | ||
193 | ); | 205 | ); |
194 | name = "DUREX Vendor Control"; | 206 | name = "DUREX Vendor Control"; |
195 | path = TestAppExample; | 207 | path = TestAppExample; |
@@ -283,6 +295,8 @@ | @@ -283,6 +295,8 @@ | ||
283 | F92F567619B75F5E00A1EACA /* PriceChangerViewController.h */, | 295 | F92F567619B75F5E00A1EACA /* PriceChangerViewController.h */, |
284 | F92F568D19B763FD00A1EACA /* NameChangerViewController.h */, | 296 | F92F568D19B763FD00A1EACA /* NameChangerViewController.h */, |
285 | F98446EE19B9EAE9005C4992 /* Sensors.h */, | 297 | F98446EE19B9EAE9005C4992 /* Sensors.h */, |
298 | + F989B5FD19BCD7A100657DD9 /* Sale.h */, | ||
299 | + F989B60019BCE28C00657DD9 /* SalesLog.h */, | ||
286 | ); | 300 | ); |
287 | name = Headers; | 301 | name = Headers; |
288 | sourceTree = "<group>"; | 302 | sourceTree = "<group>"; |
@@ -291,6 +305,8 @@ | @@ -291,6 +305,8 @@ | ||
291 | isa = PBXGroup; | 305 | isa = PBXGroup; |
292 | children = ( | 306 | children = ( |
293 | 34AAB88C189805300019860D /* Images.xcassets */, | 307 | 34AAB88C189805300019860D /* Images.xcassets */, |
308 | + F989B5F919BBC80300657DD9 /* carat-open.png */, | ||
309 | + F989B5FA19BBC80300657DD9 /* carat.png */, | ||
294 | F97B90C919B859F500DDA9EF /* icon_checkmark.png */, | 310 | F97B90C919B859F500DDA9EF /* icon_checkmark.png */, |
295 | F97B90CA19B859F500DDA9EF /* icon_delete.png */, | 311 | F97B90CA19B859F500DDA9EF /* icon_delete.png */, |
296 | F961D80E199A5F2D00E9282C /* back_arrow.png */, | 312 | F961D80E199A5F2D00E9282C /* back_arrow.png */, |
@@ -360,6 +376,7 @@ | @@ -360,6 +376,7 @@ | ||
360 | F9015D9719B7305E006C7882 /* DatePickerViewController_iPad.xib in Resources */, | 376 | F9015D9719B7305E006C7882 /* DatePickerViewController_iPad.xib in Resources */, |
361 | F961D819199A711300E9282C /* EMConnectingView.xib in Resources */, | 377 | F961D819199A711300E9282C /* EMConnectingView.xib in Resources */, |
362 | F9C77F50192CDE30002DBE8A /* system.json in Resources */, | 378 | F9C77F50192CDE30002DBE8A /* system.json in Resources */, |
379 | + F989B5FC19BBC80300657DD9 /* carat.png in Resources */, | ||
363 | F92F569B19B76A5D00A1EACA /* NameChangerViewController_iPad.xib in Resources */, | 380 | F92F569B19B76A5D00A1EACA /* NameChangerViewController_iPad.xib in Resources */, |
364 | F92F567D19B7609C00A1EACA /* PriceChangerViewController.xib in Resources */, | 381 | F92F567D19B7609C00A1EACA /* PriceChangerViewController.xib in Resources */, |
365 | F92F569219B7665F00A1EACA /* NameChangerViewController.xib in Resources */, | 382 | F92F569219B7665F00A1EACA /* NameChangerViewController.xib in Resources */, |
@@ -367,6 +384,7 @@ | @@ -367,6 +384,7 @@ | ||
367 | F961D816199A5FA000E9282C /* Localizable.strings in Resources */, | 384 | F961D816199A5FA000E9282C /* Localizable.strings in Resources */, |
368 | F97B90CB19B859F500DDA9EF /* icon_checkmark.png in Resources */, | 385 | F97B90CB19B859F500DDA9EF /* icon_checkmark.png in Resources */, |
369 | 34AAB88D189805300019860D /* Images.xcassets in Resources */, | 386 | 34AAB88D189805300019860D /* Images.xcassets in Resources */, |
387 | + F989B5FB19BBC80300657DD9 /* carat-open.png in Resources */, | ||
370 | F92F568419B760A800A1EACA /* PriceChangerViewController_iPad.xib in Resources */, | 388 | F92F568419B760A800A1EACA /* PriceChangerViewController_iPad.xib in Resources */, |
371 | F961D804199A5F1000E9282C /* MainStoryboard.storyboard in Resources */, | 389 | F961D804199A5F1000E9282C /* MainStoryboard.storyboard in Resources */, |
372 | ); | 390 | ); |
@@ -381,9 +399,11 @@ | @@ -381,9 +399,11 @@ | ||
381 | files = ( | 399 | files = ( |
382 | F92F569019B763FD00A1EACA /* NameChangerViewController.m in Sources */, | 400 | F92F569019B763FD00A1EACA /* NameChangerViewController.m in Sources */, |
383 | F933F80419B6819400521B90 /* DatePickerViewController.m in Sources */, | 401 | F933F80419B6819400521B90 /* DatePickerViewController.m in Sources */, |
402 | + F989B5FF19BCD7A100657DD9 /* Sale.m in Sources */, | ||
384 | F98356D6192E835F00EA6821 /* InitialViewController.m in Sources */, | 403 | F98356D6192E835F00EA6821 /* InitialViewController.m in Sources */, |
385 | F9A8EF7C192FE201009E7532 /* Stack.m in Sources */, | 404 | F9A8EF7C192FE201009E7532 /* Stack.m in Sources */, |
386 | 34AAB885189804FF0019860D /* EMDevicePickerViewController.m in Sources */, | 405 | 34AAB885189804FF0019860D /* EMDevicePickerViewController.m in Sources */, |
406 | + F989B60219BCE28C00657DD9 /* SalesLog.m in Sources */, | ||
387 | F92F567919B75F5E00A1EACA /* PriceChangerViewController.m in Sources */, | 407 | F92F567919B75F5E00A1EACA /* PriceChangerViewController.m in Sources */, |
388 | 34AAB883189804FF0019860D /* DUREXAppDelegate.m in Sources */, | 408 | 34AAB883189804FF0019860D /* DUREXAppDelegate.m in Sources */, |
389 | F98356DB192EAFD400EA6821 /* CommunicationProtocol.m in Sources */, | 409 | F98356DB192EAFD400EA6821 /* CommunicationProtocol.m in Sources */, |
DUREX Vendor Control/DUREX Vendor Control.xcodeproj/project.xcworkspace/xcuserdata/imanol.xcuserdatad/UserInterfaceState.xcuserstate
No preview for this file type
DUREX Vendor Control/DUREX Vendor Control.xcodeproj/xcuserdata/imanol.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
@@ -2,86 +2,4 @@ | @@ -2,86 +2,4 @@ | ||
2 | <Bucket | 2 | <Bucket |
3 | type = "1" | 3 | type = "1" |
4 | version = "2.0"> | 4 | version = "2.0"> |
5 | - <Breakpoints> | ||
6 | - <BreakpointProxy | ||
7 | - BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> | ||
8 | - <BreakpointContent | ||
9 | - shouldBeEnabled = "No" | ||
10 | - ignoreCount = "0" | ||
11 | - continueAfterRunningActions = "No" | ||
12 | - filePath = "CommunicationProtocol.m" | ||
13 | - timestampString = "431435824.615796" | ||
14 | - startingColumnNumber = "9223372036854775807" | ||
15 | - endingColumnNumber = "9223372036854775807" | ||
16 | - startingLineNumber = "109" | ||
17 | - endingLineNumber = "109" | ||
18 | - landmarkName = "-readMessage" | ||
19 | - landmarkType = "5"> | ||
20 | - </BreakpointContent> | ||
21 | - </BreakpointProxy> | ||
22 | - <BreakpointProxy | ||
23 | - BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> | ||
24 | - <BreakpointContent | ||
25 | - shouldBeEnabled = "No" | ||
26 | - ignoreCount = "0" | ||
27 | - continueAfterRunningActions = "No" | ||
28 | - filePath = "CommunicationProtocol.m" | ||
29 | - timestampString = "431391382.511911" | ||
30 | - startingColumnNumber = "9223372036854775807" | ||
31 | - endingColumnNumber = "9223372036854775807" | ||
32 | - startingLineNumber = "100" | ||
33 | - endingLineNumber = "100" | ||
34 | - landmarkName = "-waitForMessageAvailableDevice:" | ||
35 | - landmarkType = "5"> | ||
36 | - </BreakpointContent> | ||
37 | - </BreakpointProxy> | ||
38 | - <BreakpointProxy | ||
39 | - BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> | ||
40 | - <BreakpointContent | ||
41 | - shouldBeEnabled = "No" | ||
42 | - ignoreCount = "0" | ||
43 | - continueAfterRunningActions = "No" | ||
44 | - filePath = "CommunicationProtocol.m" | ||
45 | - timestampString = "431391382.511911" | ||
46 | - startingColumnNumber = "9223372036854775807" | ||
47 | - endingColumnNumber = "9223372036854775807" | ||
48 | - startingLineNumber = "104" | ||
49 | - endingLineNumber = "104" | ||
50 | - landmarkName = "-waitForMessageAvailableDevice:" | ||
51 | - landmarkType = "5"> | ||
52 | - </BreakpointContent> | ||
53 | - </BreakpointProxy> | ||
54 | - <BreakpointProxy | ||
55 | - BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> | ||
56 | - <BreakpointContent | ||
57 | - shouldBeEnabled = "No" | ||
58 | - ignoreCount = "0" | ||
59 | - continueAfterRunningActions = "No" | ||
60 | - filePath = "DatePickerViewController.m" | ||
61 | - timestampString = "431511161.110287" | ||
62 | - startingColumnNumber = "9223372036854775807" | ||
63 | - endingColumnNumber = "9223372036854775807" | ||
64 | - startingLineNumber = "71" | ||
65 | - endingLineNumber = "71" | ||
66 | - landmarkName = "-closePopup:" | ||
67 | - landmarkType = "5"> | ||
68 | - </BreakpointContent> | ||
69 | - </BreakpointProxy> | ||
70 | - <BreakpointProxy | ||
71 | - BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> | ||
72 | - <BreakpointContent | ||
73 | - shouldBeEnabled = "No" | ||
74 | - ignoreCount = "0" | ||
75 | - continueAfterRunningActions = "No" | ||
76 | - filePath = "FirstAppExample/EMDevicePickerViewController.m" | ||
77 | - timestampString = "431555215.246709" | ||
78 | - startingColumnNumber = "9223372036854775807" | ||
79 | - endingColumnNumber = "9223372036854775807" | ||
80 | - startingLineNumber = "107" | ||
81 | - endingLineNumber = "107" | ||
82 | - landmarkName = "-tableView:didSelectRowAtIndexPath:" | ||
83 | - landmarkType = "5"> | ||
84 | - </BreakpointContent> | ||
85 | - </BreakpointProxy> | ||
86 | - </Breakpoints> | ||
87 | </Bucket> | 5 | </Bucket> |
DUREX Vendor Control/FirstAppExample/Base.lproj/MainStoryboard.storyboard
@@ -7,7 +7,6 @@ | @@ -7,7 +7,6 @@ | ||
7 | <!--Device Picker View Controller - Select device--> | 7 | <!--Device Picker View Controller - Select device--> |
8 | <scene sceneID="ZOj-VY-rze"> | 8 | <scene sceneID="ZOj-VY-rze"> |
9 | <objects> | 9 | <objects> |
10 | - <placeholder placeholderIdentifier="IBFirstResponder" id="MD6-l6-Rrg" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
11 | <tableViewController id="0dd-lZ-pDC" customClass="EMDevicePickerViewController" sceneMemberID="viewController"> | 10 | <tableViewController id="0dd-lZ-pDC" customClass="EMDevicePickerViewController" sceneMemberID="viewController"> |
12 | <tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="jWc-kM-kFO"> | 11 | <tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="jWc-kM-kFO"> |
13 | <rect key="frame" x="0.0" y="0.0" width="320" height="568"/> | 12 | <rect key="frame" x="0.0" y="0.0" width="320" height="568"/> |
@@ -49,6 +48,7 @@ | @@ -49,6 +48,7 @@ | ||
49 | <segue destination="iNx-eR-wSX" kind="push" identifier="ConnectionSegue" id="3oK-BK-2Qs"/> | 48 | <segue destination="iNx-eR-wSX" kind="push" identifier="ConnectionSegue" id="3oK-BK-2Qs"/> |
50 | </connections> | 49 | </connections> |
51 | </tableViewController> | 50 | </tableViewController> |
51 | + <placeholder placeholderIdentifier="IBFirstResponder" id="MD6-l6-Rrg" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
52 | </objects> | 52 | </objects> |
53 | <point key="canvasLocation" x="342" y="-9"/> | 53 | <point key="canvasLocation" x="342" y="-9"/> |
54 | </scene> | 54 | </scene> |
DUREX Vendor Control/FirstAppExample/main.m
DUREX Vendor Control/MenuTableViewController.h
@@ -14,22 +14,30 @@ | @@ -14,22 +14,30 @@ | ||
14 | #import "PriceChangerViewController.h" | 14 | #import "PriceChangerViewController.h" |
15 | #import "NameChangerViewController.h" | 15 | #import "NameChangerViewController.h" |
16 | #import "Sensors.h" | 16 | #import "Sensors.h" |
17 | +#import "SalesLog.h" | ||
17 | 18 | ||
18 | #define num(x) [NSNumber numberWithUnsignedInt:x] | 19 | #define num(x) [NSNumber numberWithUnsignedInt:x] |
19 | 20 | ||
20 | -#define MENU_ELEMENTS @"Maintenance",@"Basic Configuration",@"Sending a Report" | 21 | +#define CELL_CARAT_TAG 100 |
22 | + | ||
23 | +#define MENU_ELEMENTS @"[1000]Maintenance",@"[1001]Basic Configuration",@"[1002]Sending a Report" | ||
21 | #define MENU_CELLS_PER_SECTION num(3) | 24 | #define MENU_CELLS_PER_SECTION num(3) |
22 | -#define MENU_HEADERS nil | 25 | +#define MENU_HEADERS nil |
23 | 26 | ||
24 | -#define MAINTENANCE_ELEMENTS @"Channels Present",@"Product Present in Channel",@"Channel Engine Status",@"Door Sensor",@"Coil sensor",@"Money Collected",@"10€ Notes",@"5€ Notes",@"2€ Coins",@"1€ Coins",@"50c Coins",@"Money given",@"10€ Notes",@"5€ Notes",@"2€ Coins",@"1€ Coins",@"50c Coins",@"Products Sold",@"Change Available",@"1€ Coins",@"50c Coins",@"Sales log",@"Incident report",@"Send report" | ||
25 | -#define MAINTENANCE_CELLS_PER_SECTION num(21),num(3) | 27 | +#define MAINTENANCE_ELEMENTS @">[2000]Channels Present",@">[2001]Product Present in Channel",@">[2002]Channel Engine Status",@"[2003]Door Sensor",@"[2004]Coil Sensor",@">[2005]Money Collected",@">[2006]Money Returned",@">[2007]Products Sold",@">[2008]Change Available",@"[2009]Sales log",@"[2010]Incident report",@"[2011]Send report" |
28 | +#define MAINTENANCE_CHANNELS @"*Channel 1",@"*Channel 2",@"*Channel 3",@"*Channel 4",@"*Channel 5",@"*Channel 6",@"*Channel 7",@"*Channel 8",@"*Channel 9",@"*Channel 10",@"*Channel 11",@"*Channel 12",@"*Channel 13",@"*Channel 14",@"*Channel 15",@"*Channel 16" | ||
29 | +#define MAINTENANCE_MONEY_IN @"*10€ Notes",@"*5€ Notes",@"*2€ Coins",@"*1€ Coins",@"*50c Coins" | ||
30 | +#define MAINTENANCE_MONEY_OUT @"*2€ Coins",@"*1€ Coins",@"*50c Coins" | ||
31 | +#define MAINTENANCE_CHANGE @"*1€ Coins",@"*50c Coins" | ||
32 | +#define MAINTENANCE_PRODUCTS @"*Product 1",@"*Product 2",@"*Product 3",@"*Product 4",@"*Product 5",@"*Product 6",@"*Product 7",@"*Product 8",@"*Product 9",@"*Product 10",@"*Product 11",@"*Product 12",@"*Product 13",@"*Product 14",@"*Product 15",@"*Product 16" | ||
33 | +#define MAINTENANCE_CELLS_PER_SECTION num(9),num(3) | ||
26 | #define MAINTENANCE_HEADERS NSLocalizedString(@"Sensors", nil),NSLocalizedString(@"Commands", nil) | 34 | #define MAINTENANCE_HEADERS NSLocalizedString(@"Sensors", nil),NSLocalizedString(@"Commands", nil) |
27 | 35 | ||
28 | -#define SALES_ELEMENTS @"20€ Notes",@"10€ Notes",@"5€ Notes",@"2€ Coins",@"1€ Coins",@"50c Coins",@"Channel",@"Product Code",@"Nominal Price",@"Discounted Price",@"1€ Change",@"50c Change",@"20€ Notes",@"10€ Notes",@"5€ Notes",@"2€ Coins",@"1€ Coins",@"50c Coins",@"Channel",@"Product Code",@"Nominal Price",@"Discounted Price",@"1€ Change",@"50c Change",@"20€ Notes",@"10€ Notes",@"5€ Notes",@"2€ Coins",@"1€ Coins",@"50c Coins",@"Channel",@"Product Code",@"Nominal Price",@"Discounted Price",@"1€ Change",@"50c Change" | ||
29 | -#define SALES_CELLS_PER_SECTION num(12),num(12),num(12) | ||
30 | -#define SALES_HEADERS @"14/06/2014",@"25/06/2014",@"05/07/2014" | 36 | +#define SALES_ELEMENTS @"10€ Notes",@"5€ Notes",@"2€ Coins",@"1€ Coins",@"50c Coins",@"Channel",@"Product Code",@"Normal Price",@"Discounted Price",@"1€ Change",@"50c Change" |
37 | +#define SALES_CELLS_PER_SECTION num(11) | ||
38 | +#define SALES_HEADERS @"14/06/2014" | ||
31 | 39 | ||
32 | -#define CONFIGURATION_ELEMENTS @"Update Date & Time",@"Update product price",@"Update product name" | 40 | +#define CONFIGURATION_ELEMENTS @"[3000]Update Date & Time",@"[3001]Update product price",@"[3002]Update product name" |
33 | #define CONFIGURATION_CELLS_PER_SECTION num(3) | 41 | #define CONFIGURATION_CELLS_PER_SECTION num(3) |
34 | #define CONFIGURATION_HEADERS nil | 42 | #define CONFIGURATION_HEADERS nil |
35 | 43 | ||
@@ -50,6 +58,7 @@ enum { | @@ -50,6 +58,7 @@ enum { | ||
50 | @property (strong,nonatomic) PriceChangerViewController *priceChangerViewController; | 58 | @property (strong,nonatomic) PriceChangerViewController *priceChangerViewController; |
51 | @property (strong,nonatomic) NameChangerViewController *nameChangerViewController; | 59 | @property (strong,nonatomic) NameChangerViewController *nameChangerViewController; |
52 | @property (strong,nonatomic) Sensors *sensorStatus; | 60 | @property (strong,nonatomic) Sensors *sensorStatus; |
61 | +@property (strong,nonatomic) SalesLog *salesLog; | ||
53 | 62 | ||
54 | - (void) navBack; | 63 | - (void) navBack; |
55 | 64 |
DUREX Vendor Control/MenuTableViewController.m
@@ -13,30 +13,30 @@ | @@ -13,30 +13,30 @@ | ||
13 | IBOutlet UIActivityIndicatorView *_activityIndicator; | 13 | IBOutlet UIActivityIndicatorView *_activityIndicator; |
14 | NSTimer *_writeTimer; | 14 | NSTimer *_writeTimer; |
15 | } | 15 | } |
16 | -@property (nonatomic,strong) const NSArray *menuElements; | ||
17 | -@property (nonatomic,strong) const NSArray *menuStructure; | ||
18 | -@property (nonatomic,strong) const NSArray *menuHeaders; | 16 | +@property (nonatomic,strong) const NSMutableArray *menuElements; |
17 | +@property (nonatomic,strong) const NSMutableArray *menuStructure; | ||
18 | +@property (nonatomic,strong) const NSMutableArray *menuHeaders; | ||
19 | 19 | ||
20 | -@property (nonatomic,strong) const NSArray *maintenanceElements; | ||
21 | -@property (nonatomic,strong) const NSArray *maintenanceStructure; | ||
22 | -@property (nonatomic,strong) const NSArray *maintenanceHeaders; | 20 | +@property (nonatomic,strong) const NSMutableArray *maintenanceElements; |
21 | +@property (nonatomic,strong) const NSMutableArray *maintenanceStructure; | ||
22 | +@property (nonatomic,strong) const NSMutableArray *maintenanceHeaders; | ||
23 | 23 | ||
24 | -@property (nonatomic,strong) const NSArray *salesElements; | ||
25 | -@property (nonatomic,strong) const NSArray *salesStructure; | ||
26 | -@property (nonatomic,strong) const NSArray *salesHeaders; | 24 | +@property (nonatomic,strong) const NSMutableArray *salesElements; |
25 | +@property (nonatomic,strong) const NSMutableArray *salesStructure; | ||
26 | +@property (nonatomic,strong) const NSMutableArray *salesHeaders; | ||
27 | 27 | ||
28 | -@property (nonatomic,strong) const NSArray *configElements; | ||
29 | -@property (nonatomic,strong) const NSArray *configStructure; | ||
30 | -@property (nonatomic,strong) const NSArray *configHeaders; | 28 | +@property (nonatomic,strong) const NSMutableArray *configElements; |
29 | +@property (nonatomic,strong) const NSMutableArray *configStructure; | ||
30 | +@property (nonatomic,strong) const NSMutableArray *configHeaders; | ||
31 | 31 | ||
32 | @property (nonatomic,strong) const NSArray *cellIdentifiers; | 32 | @property (nonatomic,strong) const NSArray *cellIdentifiers; |
33 | 33 | ||
34 | @property (nonatomic,strong) CommunicationProtocol* protocol; | 34 | @property (nonatomic,strong) CommunicationProtocol* protocol; |
35 | @property uint8_t currentNavLevel; | 35 | @property uint8_t currentNavLevel; |
36 | @property NSString *currentCellIdentifier; | 36 | @property NSString *currentCellIdentifier; |
37 | -@property const NSArray *currentElements; | ||
38 | -@property const NSArray *currentStructure; | ||
39 | -@property const NSArray *currentHeaders; | 37 | +@property const NSMutableArray *currentElements; |
38 | +@property const NSMutableArray *currentStructure; | ||
39 | +@property const NSMutableArray *currentHeaders; | ||
40 | 40 | ||
41 | @end | 41 | @end |
42 | 42 | ||
@@ -54,22 +54,22 @@ | @@ -54,22 +54,22 @@ | ||
54 | 54 | ||
55 | - (void) initializeMenuEntries | 55 | - (void) initializeMenuEntries |
56 | { | 56 | { |
57 | - [self setMenuElements:[[NSArray alloc] initWithObjects:MENU_ELEMENTS, nil]]; | ||
58 | - [self setMenuStructure:[[NSArray alloc] initWithObjects:MENU_CELLS_PER_SECTION, nil]]; | 57 | + [self setMenuElements:[[NSMutableArray alloc] initWithObjects:MENU_ELEMENTS, nil]]; |
58 | + [self setMenuStructure:[[NSMutableArray alloc] initWithObjects:MENU_CELLS_PER_SECTION, nil]]; | ||
59 | if([[self menuStructure] count] > 1) | 59 | if([[self menuStructure] count] > 1) |
60 | { | 60 | { |
61 | - [self setMenuHeaders:[[NSArray alloc] initWithObjects:MENU_HEADERS, nil]]; | 61 | + [self setMenuHeaders:[[NSMutableArray alloc] initWithObjects:MENU_HEADERS, nil]]; |
62 | } | 62 | } |
63 | else | 63 | else |
64 | { | 64 | { |
65 | [self setMenuHeaders:nil]; | 65 | [self setMenuHeaders:nil]; |
66 | } | 66 | } |
67 | 67 | ||
68 | - [self setConfigElements:[[NSArray alloc] initWithObjects:CONFIGURATION_ELEMENTS, nil]]; | ||
69 | - [self setConfigStructure:[[NSArray alloc] initWithObjects:CONFIGURATION_CELLS_PER_SECTION, nil]]; | 68 | + [self setConfigElements:[[NSMutableArray alloc] initWithObjects:CONFIGURATION_ELEMENTS, nil]]; |
69 | + [self setConfigStructure:[[NSMutableArray alloc] initWithObjects:CONFIGURATION_CELLS_PER_SECTION, nil]]; | ||
70 | if([[self configStructure] count] > 1) | 70 | if([[self configStructure] count] > 1) |
71 | { | 71 | { |
72 | - [self setConfigHeaders:[[NSArray alloc] initWithObjects:CONFIGURATION_HEADERS, nil]]; | 72 | + [self setConfigHeaders:[[NSMutableArray alloc] initWithObjects:CONFIGURATION_HEADERS, nil]]; |
73 | } | 73 | } |
74 | else | 74 | else |
75 | { | 75 | { |
@@ -79,34 +79,49 @@ | @@ -79,34 +79,49 @@ | ||
79 | [self setCellIdentifiers:[[NSArray alloc] initWithObjects:CELL_IDENTIFIERS, nil]]; | 79 | [self setCellIdentifiers:[[NSArray alloc] initWithObjects:CELL_IDENTIFIERS, nil]]; |
80 | } | 80 | } |
81 | 81 | ||
82 | -- (void) generateMaintenanceLevel | 82 | +- (Boolean) generateMaintenanceLevel |
83 | { | 83 | { |
84 | - [[self sensorStatus] setResponse:[_protocol readSensorData]]; | ||
85 | - //DO SUM SHIET | ||
86 | - [self setMaintenanceElements:[[NSArray alloc] initWithObjects:MAINTENANCE_ELEMENTS, nil]]; | ||
87 | - [self setMaintenanceStructure:[[NSArray alloc] initWithObjects:MAINTENANCE_CELLS_PER_SECTION, nil]]; | 84 | + NSString *sensorData = [_protocol readSensorData]; |
85 | + if(sensorData == nil) | ||
86 | + { | ||
87 | + NSLog(@"[MenuTableViewController.m]: Error reading sensor data"); | ||
88 | + return FALSE; | ||
89 | + } | ||
90 | + [[self sensorStatus] setResponseValue:sensorData]; | ||
91 | + [self setMaintenanceElements:[[NSMutableArray alloc] initWithObjects:MAINTENANCE_ELEMENTS, nil]]; | ||
92 | + [self setMaintenanceStructure:[[NSMutableArray alloc] initWithObjects:MAINTENANCE_CELLS_PER_SECTION, nil]]; | ||
88 | if([[self maintenanceStructure] count] > 1) | 93 | if([[self maintenanceStructure] count] > 1) |
89 | { | 94 | { |
90 | - [self setMaintenanceHeaders:[[NSArray alloc] initWithObjects:MAINTENANCE_HEADERS, nil]]; | 95 | + [self setMaintenanceHeaders:[[NSMutableArray alloc] initWithObjects:MAINTENANCE_HEADERS, nil]]; |
91 | } | 96 | } |
92 | else | 97 | else |
93 | { | 98 | { |
94 | [self setMaintenanceHeaders:nil]; | 99 | [self setMaintenanceHeaders:nil]; |
95 | } | 100 | } |
101 | + return TRUE; | ||
96 | } | 102 | } |
97 | 103 | ||
98 | -- (void) generateSalesNavLevel | 104 | +- (Boolean) generateSalesNavLevel |
99 | { | 105 | { |
100 | - [self setSalesElements:[[NSArray alloc] initWithObjects:SALES_ELEMENTS, nil]]; | ||
101 | - [self setSalesStructure:[[NSArray alloc] initWithObjects:SALES_CELLS_PER_SECTION, nil]]; | 106 | + //LAUNCH DATE RANGE SELECTOR |
107 | + NSString *salesData = [_protocol readSalesLog: nil : nil]; | ||
108 | + if(salesData == nil) | ||
109 | + { | ||
110 | + NSLog(@"[MenuTableViewController.m]: Error reading sales log"); | ||
111 | + return FALSE; | ||
112 | + } | ||
113 | + [[self salesLog] setResponseValue:salesData]; | ||
114 | + [self setSalesElements:[[NSMutableArray alloc] initWithObjects:SALES_ELEMENTS, nil]]; | ||
115 | + [self setSalesStructure:[[NSMutableArray alloc] initWithObjects:SALES_CELLS_PER_SECTION, nil]]; | ||
102 | if([[self salesStructure] count] > 1) | 116 | if([[self salesStructure] count] > 1) |
103 | { | 117 | { |
104 | - [self setSalesHeaders:[[NSArray alloc] initWithObjects:SALES_HEADERS, nil]]; | 118 | + [self setSalesHeaders:[[NSMutableArray alloc] initWithObjects:SALES_HEADERS, nil]]; |
105 | } | 119 | } |
106 | else | 120 | else |
107 | { | 121 | { |
108 | [self setSalesHeaders:nil]; | 122 | [self setSalesHeaders:nil]; |
109 | } | 123 | } |
124 | + return TRUE; | ||
110 | } | 125 | } |
111 | 126 | ||
112 | - (void) changeNavLevel: (uint8_t) level : (BOOL) push | 127 | - (void) changeNavLevel: (uint8_t) level : (BOOL) push |
@@ -147,10 +162,15 @@ | @@ -147,10 +162,15 @@ | ||
147 | [self setCurrentHeaders:[self configHeaders]]; | 162 | [self setCurrentHeaders:[self configHeaders]]; |
148 | } | 163 | } |
149 | //AND SO ON... | 164 | //AND SO ON... |
165 | + [self reloadTable:UITableViewRowAnimationAutomatic]; | ||
166 | +} | ||
167 | + | ||
168 | +- (void) reloadTable: (UITableViewRowAnimation) animation | ||
169 | +{ | ||
150 | [[self tableView] reloadData]; | 170 | [[self tableView] reloadData]; |
151 | NSRange range = NSMakeRange(0, [self numberOfSectionsInTableView:[self tableView]]); | 171 | NSRange range = NSMakeRange(0, [self numberOfSectionsInTableView:[self tableView]]); |
152 | NSIndexSet *sections = [NSIndexSet indexSetWithIndexesInRange:range]; | 172 | NSIndexSet *sections = [NSIndexSet indexSetWithIndexesInRange:range]; |
153 | - [[self tableView] reloadSections:sections withRowAnimation:UITableViewRowAnimationAutomatic]; | 173 | + [[self tableView] reloadSections:sections withRowAnimation:animation]; |
154 | } | 174 | } |
155 | 175 | ||
156 | - (void) navBack | 176 | - (void) navBack |
@@ -217,12 +237,6 @@ | @@ -217,12 +237,6 @@ | ||
217 | 237 | ||
218 | //Initialize sensor status | 238 | //Initialize sensor status |
219 | [self setSensorStatus:[[Sensors alloc]init]]; | 239 | [self setSensorStatus:[[Sensors alloc]init]]; |
220 | - | ||
221 | - // Uncomment the following line to preserve selection between presentations. | ||
222 | - // self.clearsSelectionOnViewWillAppear = NO; | ||
223 | - | ||
224 | - // Uncomment the following line to display an Edit button in the navigation bar for this view controller. | ||
225 | - // self.navigationItem.rightBarButtonItem = self.editButtonItem; | ||
226 | } | 240 | } |
227 | 241 | ||
228 | -(void)viewDidAppear:(BOOL)animated | 242 | -(void)viewDidAppear:(BOOL)animated |
@@ -230,8 +244,6 @@ | @@ -230,8 +244,6 @@ | ||
230 | [super viewDidAppear:animated]; | 244 | [super viewDidAppear:animated]; |
231 | 245 | ||
232 | //DUREX protocol | 246 | //DUREX protocol |
233 | - [_protocol setMessageAvailableMobile:false]; | ||
234 | - [_protocol setMessageAvailableDevice:false]; | ||
235 | if(![_protocol establishConnection]) | 247 | if(![_protocol establishConnection]) |
236 | { | 248 | { |
237 | UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Communication error" message:@"Error while trying to connect to the device" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; | 249 | UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Communication error" message:@"Error while trying to connect to the device" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; |
@@ -243,7 +255,7 @@ | @@ -243,7 +255,7 @@ | ||
243 | 255 | ||
244 | -(void)didReceiveNotification:(NSNotification*) notification | 256 | -(void)didReceiveNotification:(NSNotification*) notification |
245 | { | 257 | { |
246 | - | 258 | + |
247 | } | 259 | } |
248 | 260 | ||
249 | -(void)dealloc | 261 | -(void)dealloc |
@@ -274,94 +286,267 @@ | @@ -274,94 +286,267 @@ | ||
274 | 286 | ||
275 | #pragma mark - Table view delegate | 287 | #pragma mark - Table view delegate |
276 | 288 | ||
277 | -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath | 289 | +- (void) addTags : (NSMutableArray*) rows : (NSInteger) tag |
278 | { | 290 | { |
279 | - NSLog(@"Section: %ld Row: %ld",(long)[indexPath section],(long)[indexPath row]); | ||
280 | - [tableView deselectRowAtIndexPath:indexPath animated:YES]; | ||
281 | - NSString *cellName = [[[[self tableView] cellForRowAtIndexPath:indexPath]textLabel]text]; | ||
282 | - if([cellName isEqualToString:NSLocalizedString(@"Maintenance", nil)] && [self currentNavLevel] == MENU) | 291 | + for(int i = 0; i < [rows count]; i++) |
283 | { | 292 | { |
284 | - NSLog(@"[MenuTableViewController.m]: Changing to navLevel: MAINTENANCE"); | ||
285 | - [self generateMaintenanceLevel]; | ||
286 | - [self changeNavLevel:MAINTENANCE:TRUE]; | 293 | + NSMutableString *name = [NSMutableString stringWithString:[rows objectAtIndex:i]]; |
294 | + [name insertString:[NSString stringWithFormat:@"[%d]",tag] atIndex:1]; | ||
295 | + [rows replaceObjectAtIndex:i withObject:name]; | ||
287 | } | 296 | } |
288 | - else if([cellName isEqualToString:NSLocalizedString(@"Sales log", nil)] && [self currentNavLevel] == MAINTENANCE) | 297 | +} |
298 | + | ||
299 | +- (void) toggleDropList : (NSIndexPath*) index | ||
300 | +{ | ||
301 | + Boolean folded = FALSE; | ||
302 | + NSString *elementName = [[self currentElements] objectAtIndex:index.row]; | ||
303 | + NSMutableString *newElementName = [[NSMutableString alloc] init]; | ||
304 | + if([elementName characterAtIndex:0] == '>') | ||
289 | { | 305 | { |
290 | - NSLog(@"[MenuTableViewController.m]: Changing to navLevel: SALES"); | ||
291 | - [self generateSalesNavLevel]; | ||
292 | - [self changeNavLevel:SALES:TRUE]; | 306 | + [newElementName setString:@"v"]; |
307 | + [newElementName appendString:[elementName substringFromIndex:1]]; | ||
308 | + folded = TRUE; | ||
293 | } | 309 | } |
294 | - else if([cellName isEqualToString:NSLocalizedString(@"Basic Configuration", nil)] && [self currentNavLevel] == MENU) | 310 | + else |
295 | { | 311 | { |
296 | - NSLog(@"[MenuTableViewController.m]: Changing to navLevel: BASIC_CONFIGURATION"); | ||
297 | - [self changeNavLevel:BASIC_CONFIGURATION:TRUE]; | 312 | + [newElementName setString:@">"]; |
313 | + [newElementName appendString:[elementName substringFromIndex:1]]; | ||
298 | } | 314 | } |
299 | - //Update Date & Time command | ||
300 | - else if([cellName isEqualToString:NSLocalizedString(@"Update Date & Time", nil)] && [self currentNavLevel] == BASIC_CONFIGURATION) | 315 | + [[self currentElements] replaceObjectAtIndex:index.row withObject:newElementName]; |
316 | + NSMutableString *cellName = [NSMutableString stringWithString:[elementName substringFromIndex:1]]; | ||
317 | + NSInteger lastPos = [cellName rangeOfString:@"]"].location; | ||
318 | + NSInteger cellTag = [[cellName substringWithRange:NSMakeRange(1,lastPos)] intValue]; | ||
319 | + [cellName setString:[cellName substringFromIndex:lastPos+1]]; | ||
320 | + | ||
321 | + //Cells in MENU | ||
322 | + if([self currentNavLevel] == MAINTENANCE) | ||
301 | { | 323 | { |
302 | - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) | 324 | + if([cellName isEqualToString:@"Channels Present"] || |
325 | + [cellName isEqualToString:@"Product Present in Channel"] || | ||
326 | + [cellName isEqualToString:@"Channel Engine Status"]) | ||
303 | { | 327 | { |
304 | - self.datePickerViewController = [[DatePickerViewController alloc] initWithNibName:@"DatePickerViewController_iPad" bundle:nil]; | ||
305 | - self.datePickerViewController.delegate = self; | ||
306 | - [self.datePickerViewController showInView:self.navigationController.view animated:YES]; | 328 | + NSMutableArray *newRows = [[NSMutableArray alloc] initWithObjects:MAINTENANCE_CHANNELS, nil]; |
329 | + [newRows setArray:[newRows subarrayWithRange:NSMakeRange(0, [[self sensorStatus] numChannels])]]; | ||
330 | + if(folded) | ||
331 | + { | ||
332 | + [self addTags: newRows : cellTag]; | ||
333 | + [self addRowsAtIndexPath: newRows : index]; | ||
334 | + } | ||
335 | + else | ||
336 | + { | ||
337 | + [self removeRowsAtIndexPath: [newRows count] : index]; | ||
338 | + } | ||
307 | } | 339 | } |
308 | - else | 340 | + else if([cellName isEqualToString:@"Money Collected"]) |
309 | { | 341 | { |
310 | - self.datePickerViewController = [[DatePickerViewController alloc] initWithNibName:@"DatePickerViewController" bundle:nil]; | ||
311 | - self.datePickerViewController.delegate = self; | ||
312 | - [self.datePickerViewController showInView:self.navigationController.view animated:YES]; | 342 | + NSMutableArray *newRows = [[NSMutableArray alloc] initWithObjects:MAINTENANCE_MONEY_IN, nil]; |
343 | + if(folded) | ||
344 | + { | ||
345 | + [self addTags: newRows : cellTag]; | ||
346 | + [self addRowsAtIndexPath: newRows : index]; | ||
347 | + } | ||
348 | + else | ||
349 | + { | ||
350 | + [self removeRowsAtIndexPath: [newRows count] : index]; | ||
351 | + } | ||
352 | + } | ||
353 | + else if([cellName isEqualToString:@"Money Returned"]) | ||
354 | + { | ||
355 | + NSMutableArray *newRows = [[NSMutableArray alloc] initWithObjects:MAINTENANCE_MONEY_OUT, nil]; | ||
356 | + if(folded) | ||
357 | + { | ||
358 | + [self addTags: newRows : cellTag]; | ||
359 | + [self addRowsAtIndexPath: newRows : index]; | ||
360 | + } | ||
361 | + else | ||
362 | + { | ||
363 | + [self removeRowsAtIndexPath: [newRows count] : index]; | ||
364 | + } | ||
365 | + } | ||
366 | + else if([cellName isEqualToString:@"Products Sold"]) | ||
367 | + { | ||
368 | + NSMutableArray *newRows = [[NSMutableArray alloc] initWithObjects:MAINTENANCE_PRODUCTS, nil]; | ||
369 | + if(folded) | ||
370 | + { | ||
371 | + [self addTags: newRows : cellTag]; | ||
372 | + [self addRowsAtIndexPath: newRows : index]; | ||
373 | + } | ||
374 | + else | ||
375 | + { | ||
376 | + [self removeRowsAtIndexPath: [newRows count] : index]; | ||
377 | + } | ||
378 | + } | ||
379 | + else if([cellName isEqualToString:@"Change Available"]) | ||
380 | + { | ||
381 | + NSMutableArray *newRows = [[NSMutableArray alloc] initWithObjects:MAINTENANCE_CHANGE, nil]; | ||
382 | + if(folded) | ||
383 | + { | ||
384 | + [self addTags: newRows : cellTag]; | ||
385 | + [self addRowsAtIndexPath: newRows : index]; | ||
386 | + } | ||
387 | + else | ||
388 | + { | ||
389 | + [self removeRowsAtIndexPath: [newRows count] : index]; | ||
390 | + } | ||
313 | } | 391 | } |
314 | } | 392 | } |
315 | - //Update Product Price command | ||
316 | - else if([cellName isEqualToString:NSLocalizedString(@"Update product price", nil)] && [self currentNavLevel] == BASIC_CONFIGURATION) | 393 | + [self reloadTable:UITableViewRowAnimationNone]; |
394 | +} | ||
395 | + | ||
396 | +- (void) addRowsAtIndexPath : (NSArray*) rows : (NSIndexPath*) indexPath | ||
397 | +{ | ||
398 | + NSIndexSet *indexSet = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange([indexPath row] + 1, [rows count])]; | ||
399 | + [[self currentElements] insertObjects:rows atIndexes:indexSet]; | ||
400 | + [[self currentStructure] replaceObjectAtIndex:[indexPath section] withObject:[NSNumber numberWithInt:([[[self currentStructure] objectAtIndex:[indexPath section]] intValue] + [rows count])]]; | ||
401 | +} | ||
402 | + | ||
403 | +- (void) removeRowsAtIndexPath : (NSUInteger) numRows : (NSIndexPath*) indexPath | ||
404 | +{ | ||
405 | + NSIndexSet *indexSet = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange([indexPath row] + 1, numRows)]; | ||
406 | + [[self currentElements] removeObjectsAtIndexes:indexSet]; | ||
407 | + [[self currentStructure] replaceObjectAtIndex:[indexPath section] withObject:[NSNumber numberWithInt:([[[self currentStructure] objectAtIndex:[indexPath section]] intValue] - numRows)]]; | ||
408 | +} | ||
409 | + | ||
410 | +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section | ||
411 | +{ | ||
412 | + return [[[self currentStructure] objectAtIndex:section] intValue]; | ||
413 | +} | ||
414 | + | ||
415 | +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath | ||
416 | +{ | ||
417 | + NSLog(@"Section: %ld Row: %ld",(long)[indexPath section],(long)[indexPath row]); | ||
418 | + [tableView deselectRowAtIndexPath:indexPath animated:YES]; | ||
419 | + UITableViewCell *cell = [[self tableView] cellForRowAtIndexPath:indexPath]; | ||
420 | + NSString *cellName = [[cell textLabel]text]; | ||
421 | + //Cells in MENU | ||
422 | + if([self currentNavLevel] == MENU) | ||
317 | { | 423 | { |
318 | - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) | 424 | + if([cellName isEqualToString:NSLocalizedString(@"Maintenance", nil)]) |
319 | { | 425 | { |
320 | - self.priceChangerViewController = [[PriceChangerViewController alloc] initWithNibName:@"PriceChangerViewController_iPad" bundle:nil]; | ||
321 | - self.priceChangerViewController.delegate = self; | ||
322 | - [self.priceChangerViewController showInView:self.navigationController.view animated:YES]; | 426 | + NSLog(@"[MenuTableViewController.m]: Changing to navLevel: MAINTENANCE"); |
427 | + if([self generateMaintenanceLevel]) | ||
428 | + { | ||
429 | + [self changeNavLevel:MAINTENANCE:TRUE]; | ||
430 | + } | ||
431 | + else | ||
432 | + { | ||
433 | + NSLog(@"[MenuTableViewController.m]: Error while changing to navLevel: MAINTENANCE"); | ||
434 | + } | ||
323 | } | 435 | } |
324 | - else | 436 | + else if([cellName isEqualToString:NSLocalizedString(@"Basic Configuration", nil)]) |
325 | { | 437 | { |
326 | - self.priceChangerViewController = [[PriceChangerViewController alloc] initWithNibName:@"PriceChangerViewController" bundle:nil]; | ||
327 | - self.priceChangerViewController.delegate = self; | ||
328 | - [self.priceChangerViewController showInView:self.navigationController.view animated:YES]; | 438 | + NSLog(@"[MenuTableViewController.m]: Changing to navLevel: BASIC_CONFIGURATION"); |
439 | + [self changeNavLevel:BASIC_CONFIGURATION:TRUE]; | ||
440 | + } | ||
441 | + else if([cellName isEqualToString:NSLocalizedString(@"Sending a Report", nil)]) | ||
442 | + { | ||
443 | + | ||
329 | } | 444 | } |
330 | } | 445 | } |
331 | - //Update Product Name command | ||
332 | - else if([cellName isEqualToString:NSLocalizedString(@"Update product name", nil)] && [self currentNavLevel] == BASIC_CONFIGURATION) | 446 | + //Cells in MAINTENANCE |
447 | + else if([self currentNavLevel] == MAINTENANCE) | ||
333 | { | 448 | { |
334 | - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) | 449 | + if([cellName isEqualToString:NSLocalizedString(@"Channels Present", nil)] || |
450 | + [cellName isEqualToString:NSLocalizedString(@"Product Present in Channel", nil)] || | ||
451 | + [cellName isEqualToString:NSLocalizedString(@"Channel Engine Status", nil)] || | ||
452 | + [cellName isEqualToString:NSLocalizedString(@"Money Collected", nil)] || | ||
453 | + [cellName isEqualToString:NSLocalizedString(@"Money Returned", nil)] || | ||
454 | + [cellName isEqualToString:NSLocalizedString(@"Products Sold", nil)] || | ||
455 | + [cellName isEqualToString:NSLocalizedString(@"Change Available", nil)]) | ||
335 | { | 456 | { |
336 | - self.nameChangerViewController = [[NameChangerViewController alloc] initWithNibName:@"NameChangerViewController_iPad" bundle:nil]; | ||
337 | - self.nameChangerViewController.delegate = self; | ||
338 | - [self.nameChangerViewController showInView:self.navigationController.view animated:YES]; | 457 | + [self toggleDropList:indexPath]; |
339 | } | 458 | } |
340 | - else | 459 | + else if([cellName isEqualToString:NSLocalizedString(@"Sales log", nil)]) |
460 | + { | ||
461 | + NSLog(@"[MenuTableViewController.m]: Changing to navLevel: SALES"); | ||
462 | + if([self generateSalesNavLevel]) | ||
463 | + { | ||
464 | + [self changeNavLevel:SALES:TRUE]; | ||
465 | + } | ||
466 | + else | ||
467 | + { | ||
468 | + NSLog(@"[MenuTableViewController.m]: Error while changing to navLevel: SALES"); | ||
469 | + } | ||
470 | + } | ||
471 | + } | ||
472 | + //Cells in BASIC_CONFIGURATION | ||
473 | + else if([self currentNavLevel] == BASIC_CONFIGURATION) | ||
474 | + { | ||
475 | + //Update Date & Time command | ||
476 | + if([cellName isEqualToString:NSLocalizedString(@"Update Date & Time", nil)]) | ||
477 | + { | ||
478 | + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) | ||
479 | + { | ||
480 | + self.datePickerViewController = [[DatePickerViewController alloc] initWithNibName:@"DatePickerViewController_iPad" bundle:nil]; | ||
481 | + self.datePickerViewController.delegate = self; | ||
482 | + [self.datePickerViewController showInView:self.navigationController.view animated:YES]; | ||
483 | + } | ||
484 | + else | ||
485 | + { | ||
486 | + self.datePickerViewController = [[DatePickerViewController alloc] initWithNibName:@"DatePickerViewController" bundle:nil]; | ||
487 | + self.datePickerViewController.delegate = self; | ||
488 | + [self.datePickerViewController showInView:self.navigationController.view animated:YES]; | ||
489 | + } | ||
490 | + } | ||
491 | + //Update Product Price command | ||
492 | + else if([cellName isEqualToString:NSLocalizedString(@"Update product price", nil)]) | ||
341 | { | 493 | { |
342 | - self.nameChangerViewController = [[NameChangerViewController alloc] initWithNibName:@"NameChangerViewController" bundle:nil]; | ||
343 | - self.nameChangerViewController.delegate = self; | ||
344 | - [self.nameChangerViewController showInView:self.navigationController.view animated:YES]; | 494 | + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) |
495 | + { | ||
496 | + self.priceChangerViewController = [[PriceChangerViewController alloc] initWithNibName:@"PriceChangerViewController_iPad" bundle:nil]; | ||
497 | + self.priceChangerViewController.delegate = self; | ||
498 | + [self.priceChangerViewController showInView:self.navigationController.view animated:YES]; | ||
499 | + } | ||
500 | + else | ||
501 | + { | ||
502 | + self.priceChangerViewController = [[PriceChangerViewController alloc] initWithNibName:@"PriceChangerViewController" bundle:nil]; | ||
503 | + self.priceChangerViewController.delegate = self; | ||
504 | + [self.priceChangerViewController showInView:self.navigationController.view animated:YES]; | ||
505 | + } | ||
506 | + } | ||
507 | + //Update Product Name command | ||
508 | + else if([cellName isEqualToString:NSLocalizedString(@"Update product name", nil)]) | ||
509 | + { | ||
510 | + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) | ||
511 | + { | ||
512 | + self.nameChangerViewController = [[NameChangerViewController alloc] initWithNibName:@"NameChangerViewController_iPad" bundle:nil]; | ||
513 | + self.nameChangerViewController.delegate = self; | ||
514 | + [self.nameChangerViewController showInView:self.navigationController.view animated:YES]; | ||
515 | + } | ||
516 | + else | ||
517 | + { | ||
518 | + self.nameChangerViewController = [[NameChangerViewController alloc] initWithNibName:@"NameChangerViewController" bundle:nil]; | ||
519 | + self.nameChangerViewController.delegate = self; | ||
520 | + [self.nameChangerViewController showInView:self.navigationController.view animated:YES]; | ||
521 | + } | ||
345 | } | 522 | } |
346 | } | 523 | } |
347 | } | 524 | } |
348 | 525 | ||
349 | #pragma mark - Table view data source | 526 | #pragma mark - Table view data source |
350 | 527 | ||
351 | -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView | 528 | +-(NSInteger)tableView: (UITableView *)tableView indentationLevelForRowAtIndexPath: (NSIndexPath *)indexPath |
352 | { | 529 | { |
353 | - return [[self currentStructure] count]; | 530 | + NSInteger indent = 0; |
531 | + if([[[self currentElements] objectAtIndex:indexPath.row] characterAtIndex:0] == '*') | ||
532 | + { | ||
533 | + indent++; | ||
534 | + } | ||
535 | + return indent; | ||
354 | } | 536 | } |
355 | 537 | ||
356 | -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section | 538 | +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView |
357 | { | 539 | { |
358 | - return [[[self currentStructure]objectAtIndex:section] integerValue]; | 540 | + return [[self currentStructure] count]; |
359 | } | 541 | } |
360 | 542 | ||
361 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | 543 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath |
362 | { | 544 | { |
545 | + Boolean needsIndent = FALSE; | ||
546 | + Boolean foldedList = FALSE; | ||
547 | + Boolean unfoldedList = FALSE; | ||
363 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[self currentCellIdentifier] forIndexPath:indexPath]; | 548 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[self currentCellIdentifier] forIndexPath:indexPath]; |
364 | - | 549 | + //INSTANTIATE CELL IF NEEDED |
365 | if (cell == nil) | 550 | if (cell == nil) |
366 | { | 551 | { |
367 | NSLog(@"[MenuTableViewController.m]: Initializing cell"); | 552 | NSLog(@"[MenuTableViewController.m]: Initializing cell"); |
@@ -375,6 +560,7 @@ | @@ -375,6 +560,7 @@ | ||
375 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[self currentCellIdentifier]]; | 560 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[self currentCellIdentifier]]; |
376 | } | 561 | } |
377 | } | 562 | } |
563 | + //CALCULATE TRUE ROW TO RETRIEVE NAME | ||
378 | uint8_t offset = 0; | 564 | uint8_t offset = 0; |
379 | if([indexPath section] ) | 565 | if([indexPath section] ) |
380 | { | 566 | { |
@@ -383,24 +569,263 @@ | @@ -383,24 +569,263 @@ | ||
383 | offset += [[[self currentStructure] objectAtIndex:i] unsignedCharValue]; | 569 | offset += [[[self currentStructure] objectAtIndex:i] unsignedCharValue]; |
384 | } | 570 | } |
385 | } | 571 | } |
386 | - [[cell textLabel] setText:NSLocalizedString([[self currentElements] objectAtIndex:[indexPath row]+offset],nil)]; | 572 | + //RETRIEVE NAME |
573 | + NSMutableString *cellText = [NSMutableString stringWithString:[[self currentElements] objectAtIndex:[indexPath row]+offset]]; | ||
574 | + //SET INDENT | ||
575 | + [cell setIndentationWidth:10]; | ||
576 | + //PARSE AND REMOVE CELL MODIFIER | ||
577 | + if([cellText characterAtIndex:0] == '>') | ||
578 | + { | ||
579 | + foldedList = TRUE; | ||
580 | + [cellText setString:[cellText substringFromIndex:1]]; | ||
581 | + } | ||
582 | + else if([cellText characterAtIndex:0] == 'v') | ||
583 | + { | ||
584 | + unfoldedList = TRUE; | ||
585 | + [cellText setString:[cellText substringFromIndex:1]]; | ||
586 | + } | ||
587 | + else if([cellText characterAtIndex:0] == '*') | ||
588 | + { | ||
589 | + needsIndent = TRUE; | ||
590 | + [cellText setString:[cellText substringFromIndex:1]]; | ||
591 | + } | ||
592 | + //PARSE AND REMOVE TAG | ||
593 | + NSInteger lastPos = [cellText rangeOfString:@"]"].location; | ||
594 | + NSInteger cellTag = [[cellText substringWithRange:NSMakeRange(1,lastPos)] intValue]; | ||
595 | + [cell setTag:cellTag]; | ||
596 | + [cellText setString:[cellText substringFromIndex:lastPos+1]]; | ||
597 | + //SET FINAL TEXT | ||
598 | + [[cell textLabel] setText:NSLocalizedString(cellText,nil)]; | ||
599 | + | ||
600 | + //MAINTENANCE CELLS | ||
387 | if([self currentNavLevel] == MAINTENANCE) | 601 | if([self currentNavLevel] == MAINTENANCE) |
388 | { | 602 | { |
389 | - if( [[[cell textLabel] text] isEqualToString:NSLocalizedString(@"Sales log",nil)] || [[[cell textLabel] text] isEqualToString:NSLocalizedString(@"Incident report",nil)] || [[[cell textLabel] text] isEqualToString:NSLocalizedString(@"Send report",nil)]) | 603 | + [[[cell contentView] viewWithTag:CELL_CARAT_TAG] removeFromSuperview]; |
604 | + [[cell detailTextLabel] setText:@""]; | ||
605 | + [cell setAccessoryView:nil]; | ||
606 | + [cell setAccessoryType:UITableViewCellAccessoryNone]; | ||
607 | + if(foldedList) | ||
390 | { | 608 | { |
391 | - [[cell detailTextLabel] setText:@""]; | 609 | + NSInteger cellHeight = cell.contentView.frame.size.height; |
610 | + UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,cellHeight/2 - (11/2),11,11)]; | ||
611 | + imageView.image = [UIImage imageNamed:@"carat.png"]; | ||
612 | + imageView.tag = CELL_CARAT_TAG; | ||
613 | + [cell.contentView addSubview:imageView]; | ||
614 | + } | ||
615 | + else if(unfoldedList) | ||
616 | + { | ||
617 | + NSInteger cellHeight = cell.contentView.frame.size.height; | ||
618 | + UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,cellHeight/2 - (11/2),11,11)]; | ||
619 | + imageView.image = [UIImage imageNamed:@"carat-open.png"]; | ||
620 | + imageView.tag = CELL_CARAT_TAG; | ||
621 | + [cell.contentView addSubview:imageView]; | ||
622 | + } | ||
623 | + if([[[cell textLabel] text] isEqualToString:NSLocalizedString(@"Channels Present",nil)]) | ||
624 | + { | ||
625 | + [[cell detailTextLabel] setText:[NSString stringWithFormat:@"%d",[[self sensorStatus] numChannels]]]; | ||
392 | [cell setAccessoryView:nil]; | 626 | [cell setAccessoryView:nil]; |
393 | - [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; | ||
394 | } | 627 | } |
395 | - else | 628 | + else if([[[cell textLabel] text] isEqualToString:NSLocalizedString(@"Product Present in Channel",nil)]) |
396 | { | 629 | { |
397 | - [[cell detailTextLabel] setText:@"VALUE"]; | ||
398 | [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_checkmark"]]]; | 630 | [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_checkmark"]]]; |
399 | - if( [[[cell textLabel] text] isEqualToString:NSLocalizedString(@"CH4 presence",nil)]) | 631 | + for(int i = 0; i < [[self sensorStatus] numChannels]; i++) |
632 | + { | ||
633 | + if([[[[self sensorStatus] channelProductAvailability] objectAtIndex:i] intValue] != 1) | ||
634 | + { | ||
635 | + [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_delete"]]]; | ||
636 | + break; | ||
637 | + } | ||
638 | + } | ||
639 | + } | ||
640 | + else if([[[cell textLabel] text] isEqualToString:NSLocalizedString(@"Channel Engine Status",nil)]) | ||
641 | + { | ||
642 | + [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_checkmark"]]]; | ||
643 | + for(int i = 0; i < [[self sensorStatus] numChannels]; i++) | ||
644 | + { | ||
645 | + if([[[[self sensorStatus] channelStatus] objectAtIndex:i] intValue] != 1) | ||
646 | + { | ||
647 | + [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_delete"]]]; | ||
648 | + break; | ||
649 | + } | ||
650 | + } | ||
651 | + } | ||
652 | + else if([[NSRegularExpression regularExpressionWithPattern:@"Channel (\\d+)" options:0 error:NULL] numberOfMatchesInString:[[cell textLabel] text] options:0 range:(NSMakeRange(0,[[[cell textLabel] text] length]))] != 0) | ||
653 | + { | ||
654 | + NSUInteger index = [[[[cell textLabel] text] substringFromIndex:8] intValue] - 1; | ||
655 | + if([cell tag] == 2001) // Products Present in Channel tag | ||
656 | + { | ||
657 | + if([[[[self sensorStatus] channelProductAvailability] objectAtIndex:index] intValue] == 1) | ||
658 | + { | ||
659 | + [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_checkmark"]]]; | ||
660 | + } | ||
661 | + else | ||
662 | + { | ||
663 | + [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_delete"]]]; | ||
664 | + } | ||
665 | + } | ||
666 | + else if([cell tag] == 2002) // Channel engine status tag | ||
667 | + { | ||
668 | + if([[[[self sensorStatus] channelStatus] objectAtIndex:index] intValue] == 1) | ||
669 | + { | ||
670 | + [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_checkmark"]]]; | ||
671 | + } | ||
672 | + else | ||
673 | + { | ||
674 | + [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_delete"]]]; | ||
675 | + } | ||
676 | + } | ||
677 | + | ||
678 | + } | ||
679 | + else if([[[cell textLabel] text] isEqualToString:NSLocalizedString(@"Door Sensor",nil)]) | ||
680 | + { | ||
681 | + if([[self sensorStatus] doorOpen]) | ||
400 | { | 682 | { |
683 | + [[cell detailTextLabel] setText:NSLocalizedString(@"OPEN",nil)]; | ||
401 | [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_delete"]]]; | 684 | [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_delete"]]]; |
402 | } | 685 | } |
403 | - | 686 | + else |
687 | + { | ||
688 | + [[cell detailTextLabel] setText:NSLocalizedString(@"CLOSED",nil)]; | ||
689 | + [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_checkmark"]]]; | ||
690 | + } | ||
691 | + } | ||
692 | + else if([[[cell textLabel] text] isEqualToString:NSLocalizedString(@"Coil Sensor",nil)]) | ||
693 | + { | ||
694 | + if([[self sensorStatus] coilOpen]) | ||
695 | + { | ||
696 | + [[cell detailTextLabel] setText:NSLocalizedString(@"OPEN",nil)]; | ||
697 | + [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_delete"]]]; | ||
698 | + } | ||
699 | + else | ||
700 | + { | ||
701 | + [[cell detailTextLabel] setText:NSLocalizedString(@"CLOSED",nil)]; | ||
702 | + [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_checkmark"]]]; | ||
703 | + } | ||
704 | + } | ||
705 | + else if([[[cell textLabel] text] isEqualToString:NSLocalizedString(@"Money Collected",nil)]) | ||
706 | + { | ||
707 | + double numCollected = 0; | ||
708 | + numCollected += [[[[self sensorStatus] moneyCollected] objectAtIndex:0] intValue] * 10; | ||
709 | + numCollected += [[[[self sensorStatus] moneyCollected] objectAtIndex:1] intValue] * 5; | ||
710 | + numCollected += [[[[self sensorStatus] moneyCollected] objectAtIndex:2] intValue] * 2; | ||
711 | + numCollected += [[[[self sensorStatus] moneyCollected] objectAtIndex:3] intValue] * 1; | ||
712 | + numCollected += [[[[self sensorStatus] moneyCollected] objectAtIndex:4] intValue] * 0.50; | ||
713 | + [[cell detailTextLabel] setText:[NSString stringWithFormat:@"%.2f",numCollected]]; | ||
714 | + } | ||
715 | + else if([[[cell textLabel] text] isEqualToString:NSLocalizedString(@"Money Returned",nil)]) | ||
716 | + { | ||
717 | + double numReturned = 0; | ||
718 | + numReturned += [[[[self sensorStatus] moneyReturned] objectAtIndex:0] intValue] * 2; | ||
719 | + numReturned += [[[[self sensorStatus] moneyReturned] objectAtIndex:1] intValue] * 1; | ||
720 | + numReturned += [[[[self sensorStatus] moneyReturned] objectAtIndex:2] intValue] * 0.50; | ||
721 | + [[cell detailTextLabel] setText:[NSString stringWithFormat:@"%.2f",numReturned]]; | ||
722 | + } | ||
723 | + else if([[[cell textLabel] text] isEqualToString:NSLocalizedString(@"Products Sold",nil)]) | ||
724 | + { | ||
725 | + NSInteger numSold = 0; | ||
726 | + for(int i = 0; i < MAX_PRODUCTS; i++) | ||
727 | + { | ||
728 | + numSold += [[[[self sensorStatus] productsSold] objectAtIndex:i] intValue]; | ||
729 | + } | ||
730 | + [[cell detailTextLabel] setText:[NSString stringWithFormat:@"%d",numSold]]; | ||
731 | + } | ||
732 | + else if([[NSRegularExpression regularExpressionWithPattern:@"Product (\\d+)" options:0 error:NULL] numberOfMatchesInString:[[cell textLabel] text] options:0 range:(NSMakeRange(0,[[[cell textLabel] text] length]))] != 0) | ||
733 | + { | ||
734 | + NSUInteger index = [[[[cell textLabel] text] substringFromIndex:8] intValue] - 1; | ||
735 | + if([cell tag] == 2007) | ||
736 | + { | ||
737 | + [[cell detailTextLabel] setText:[[[[self sensorStatus] productsSold] objectAtIndex:index] stringValue]]; | ||
738 | + } | ||
739 | + } | ||
740 | + else if([[[cell textLabel] text] isEqualToString:NSLocalizedString(@"Change Available",nil)]) | ||
741 | + { | ||
742 | + [[cell detailTextLabel] setText:@""]; | ||
743 | + [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_checkmark"]]]; | ||
744 | + for(int i = 0; i < CHANGE_NUM_UNITS; i++) | ||
745 | + { | ||
746 | + if([[[[self sensorStatus] changeAvailable] objectAtIndex:i] intValue] != 1) | ||
747 | + { | ||
748 | + [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_delete"]]]; | ||
749 | + break; | ||
750 | + } | ||
751 | + } | ||
752 | + } | ||
753 | + else if([[[cell textLabel] text] isEqualToString:NSLocalizedString(@"10€ Notes",nil)]) | ||
754 | + { | ||
755 | + if([cell tag] == 2005) | ||
756 | + { | ||
757 | + [[cell detailTextLabel] setText:[[[[self sensorStatus] moneyCollected] objectAtIndex:0] stringValue]]; | ||
758 | + } | ||
759 | + } | ||
760 | + else if([[[cell textLabel] text] isEqualToString:NSLocalizedString(@"5€ Notes",nil)]) | ||
761 | + { | ||
762 | + if([cell tag] == 2005) | ||
763 | + { | ||
764 | + [[cell detailTextLabel] setText:[[[[self sensorStatus] moneyCollected] objectAtIndex:1] stringValue]]; | ||
765 | + } | ||
766 | + } | ||
767 | + else if([[[cell textLabel] text] isEqualToString:NSLocalizedString(@"2€ Coins",nil)]) | ||
768 | + { | ||
769 | + if([cell tag] == 2005) | ||
770 | + { | ||
771 | + [[cell detailTextLabel] setText:[[[[self sensorStatus] moneyCollected] objectAtIndex:2] stringValue]]; | ||
772 | + } | ||
773 | + else if([cell tag] == 2006) | ||
774 | + { | ||
775 | + [[cell detailTextLabel] setText:[[[[self sensorStatus] moneyReturned] objectAtIndex:0] stringValue]]; | ||
776 | + } | ||
777 | + } | ||
778 | + else if([[[cell textLabel] text] isEqualToString:NSLocalizedString(@"1€ Coins",nil)]) | ||
779 | + { | ||
780 | + if([cell tag] == 2005) | ||
781 | + { | ||
782 | + [[cell detailTextLabel] setText:[[[[self sensorStatus] moneyCollected] objectAtIndex:3] stringValue]]; | ||
783 | + } | ||
784 | + else if([cell tag] == 2006) | ||
785 | + { | ||
786 | + [[cell detailTextLabel] setText:[[[[self sensorStatus] moneyReturned] objectAtIndex:1] stringValue]]; | ||
787 | + } | ||
788 | + else if([cell tag] == 2008) | ||
789 | + { | ||
790 | + if([[[[self sensorStatus] changeAvailable] objectAtIndex:0] intValue] == 1) | ||
791 | + { | ||
792 | + [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_checkmark"]]]; | ||
793 | + } | ||
794 | + else | ||
795 | + { | ||
796 | + [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_delete"]]]; | ||
797 | + } | ||
798 | + } | ||
799 | + } | ||
800 | + else if([[[cell textLabel] text] isEqualToString:NSLocalizedString(@"50c Coins",nil)]) | ||
801 | + { | ||
802 | + if([cell tag] == 2005) | ||
803 | + { | ||
804 | + [[cell detailTextLabel] setText:[[[[self sensorStatus] moneyCollected] objectAtIndex:4] stringValue]]; | ||
805 | + } | ||
806 | + else if([cell tag] == 2006) | ||
807 | + { | ||
808 | + [[cell detailTextLabel] setText:[[[[self sensorStatus] moneyReturned] objectAtIndex:2] stringValue]]; | ||
809 | + } | ||
810 | + else if([cell tag] == 2008) | ||
811 | + { | ||
812 | + if([[[[self sensorStatus] changeAvailable] objectAtIndex:1] intValue] == 1) | ||
813 | + { | ||
814 | + [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_checkmark"]]]; | ||
815 | + } | ||
816 | + else | ||
817 | + { | ||
818 | + [cell setAccessoryView: [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_delete"]]]; | ||
819 | + } | ||
820 | + } | ||
821 | + } | ||
822 | + else if([[[cell textLabel] text] isEqualToString:NSLocalizedString(@"Sales log",nil)] || | ||
823 | + [[[cell textLabel] text] isEqualToString:NSLocalizedString(@"Incident report",nil)] || | ||
824 | + [[[cell textLabel] text] isEqualToString:NSLocalizedString(@"Send report",nil)]) | ||
825 | + { | ||
826 | + [[cell detailTextLabel] setText:@""]; | ||
827 | + [cell setAccessoryView:nil]; | ||
828 | + [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; | ||
404 | } | 829 | } |
405 | } | 830 | } |
406 | return cell; | 831 | return cell; |
@@ -435,54 +860,4 @@ | @@ -435,54 +860,4 @@ | ||
435 | [_protocol updateProductName:channel :code :name]; | 860 | [_protocol updateProductName:channel :code :name]; |
436 | } | 861 | } |
437 | 862 | ||
438 | - | ||
439 | -/* | ||
440 | -// Override to support conditional editing of the table view. | ||
441 | -- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath | ||
442 | -{ | ||
443 | - // Return NO if you do not want the specified item to be editable. | ||
444 | - return YES; | ||
445 | -} | ||
446 | -*/ | ||
447 | - | ||
448 | -/* | ||
449 | -// Override to support editing the table view. | ||
450 | -- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath | ||
451 | -{ | ||
452 | - if (editingStyle == UITableViewCellEditingStyleDelete) { | ||
453 | - // Delete the row from the data source | ||
454 | - [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; | ||
455 | - } else if (editingStyle == UITableViewCellEditingStyleInsert) { | ||
456 | - // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view | ||
457 | - } | ||
458 | -} | ||
459 | -*/ | ||
460 | - | ||
461 | -/* | ||
462 | -// Override to support rearranging the table view. | ||
463 | -- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath | ||
464 | -{ | ||
465 | -} | ||
466 | -*/ | ||
467 | - | ||
468 | -/* | ||
469 | -// Override to support conditional rearranging of the table view. | ||
470 | -- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath | ||
471 | -{ | ||
472 | - // Return NO if you do not want the item to be re-orderable. | ||
473 | - return YES; | ||
474 | -} | ||
475 | -*/ | ||
476 | - | ||
477 | -/* | ||
478 | -#pragma mark - Navigation | ||
479 | - | ||
480 | -// In a storyboard-based application, you will often want to do a little preparation before navigation | ||
481 | -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender | ||
482 | -{ | ||
483 | - // Get the new view controller using [segue destinationViewController]. | ||
484 | - // Pass the selected object to the new view controller. | ||
485 | -} | ||
486 | -*/ | ||
487 | - | ||
488 | @end | 863 | @end |
DUREX Vendor Control/Sale.h
0 → 100644
1 | +// | ||
2 | +// Sale.h | ||
3 | +// DUREX Vendor Control | ||
4 | +// | ||
5 | +// Created by Imanol Barba on 07/09/14. | ||
6 | +// Copyright (c) 2014 Emmoco. All rights reserved. | ||
7 | +// | ||
8 | + | ||
9 | +#import <Foundation/Foundation.h> | ||
10 | +#import "CommunicationProtocol.h" | ||
11 | + | ||
12 | +@interface Sale : NSObject | ||
13 | + | ||
14 | +@property (strong,nonatomic) NSMutableArray *moneyPaid; | ||
15 | +@property (strong,nonatomic) NSMutableArray *moneyReturned; | ||
16 | +@property NSString *productCode; | ||
17 | +@property NSString *normalPrice; | ||
18 | +@property NSString *discountedPrice; | ||
19 | +@property NSDate *saleTime; | ||
20 | + | ||
21 | +- (id) init; | ||
22 | + | ||
23 | +@end |
DUREX Vendor Control/Sale.m
0 → 100644
1 | +// | ||
2 | +// Sale.m | ||
3 | +// DUREX Vendor Control | ||
4 | +// | ||
5 | +// Created by Imanol Barba on 07/09/14. | ||
6 | +// Copyright (c) 2014 Emmoco. All rights reserved. | ||
7 | +// | ||
8 | + | ||
9 | +#import "Sale.h" | ||
10 | + | ||
11 | +@implementation Sale | ||
12 | + | ||
13 | +- (id) init | ||
14 | +{ | ||
15 | + [self setMoneyPaid:[[NSMutableArray alloc]init]]; | ||
16 | + [self setMoneyReturned:[[NSMutableArray alloc]init]]; | ||
17 | + return self; | ||
18 | +} | ||
19 | + | ||
20 | +@end |
DUREX Vendor Control/SalesLog.h
0 → 100644
1 | +// | ||
2 | +// SalesLog.h | ||
3 | +// DUREX Vendor Control | ||
4 | +// | ||
5 | +// Created by Imanol Barba on 07/09/14. | ||
6 | +// Copyright (c) 2014 Emmoco. All rights reserved. | ||
7 | +// | ||
8 | + | ||
9 | +#import <Foundation/Foundation.h> | ||
10 | + | ||
11 | +@interface SalesLog : NSObject | ||
12 | + | ||
13 | +@property (strong,nonatomic) NSString *response; | ||
14 | +@property (strong,nonatomic) NSMutableArray *sales; | ||
15 | + | ||
16 | +- (id) init; | ||
17 | +- (void) setResponseValue:(NSString *)response; | ||
18 | + | ||
19 | +@end |
DUREX Vendor Control/SalesLog.m
0 → 100644
1 | +// | ||
2 | +// SalesLog.m | ||
3 | +// DUREX Vendor Control | ||
4 | +// | ||
5 | +// Created by Imanol Barba on 07/09/14. | ||
6 | +// Copyright (c) 2014 Emmoco. All rights reserved. | ||
7 | +// | ||
8 | + | ||
9 | +#import "SalesLog.h" | ||
10 | + | ||
11 | +@implementation SalesLog | ||
12 | + | ||
13 | +- (id) init | ||
14 | +{ | ||
15 | + [self setSales:[[NSMutableArray alloc] init]]; | ||
16 | + return self; | ||
17 | +} | ||
18 | + | ||
19 | +- (void) setResponseValue:(NSString *)response | ||
20 | +{ | ||
21 | + [self setResponse: response]; | ||
22 | + [self parseResponse]; | ||
23 | +} | ||
24 | + | ||
25 | +- (void) parseResponse | ||
26 | +{ | ||
27 | + | ||
28 | +} | ||
29 | + | ||
30 | +@end |
DUREX Vendor Control/Sensors.h
@@ -13,16 +13,16 @@ | @@ -13,16 +13,16 @@ | ||
13 | 13 | ||
14 | @property (strong,nonatomic) NSString *response; | 14 | @property (strong,nonatomic) NSString *response; |
15 | @property NSUInteger numChannels; | 15 | @property NSUInteger numChannels; |
16 | -@property NSMutableArray *channelProductAvailability; | ||
17 | -@property NSMutableArray *channelStatus; | 16 | +@property (strong,nonatomic) NSMutableArray *channelProductAvailability; |
17 | +@property (strong,nonatomic) NSMutableArray *channelStatus; | ||
18 | @property Boolean doorOpen; | 18 | @property Boolean doorOpen; |
19 | @property Boolean coilOpen; | 19 | @property Boolean coilOpen; |
20 | -@property NSMutableArray *moneyCollected; | ||
21 | -@property NSMutableArray *moneyReturned; | ||
22 | -@property NSMutableArray *productsSold; | ||
23 | -@property NSMutableArray *changeAvailable; | 20 | +@property (strong,nonatomic) NSMutableArray *moneyCollected; |
21 | +@property (strong,nonatomic) NSMutableArray *moneyReturned; | ||
22 | +@property (strong,nonatomic) NSMutableArray *productsSold; | ||
23 | +@property (strong,nonatomic) NSMutableArray *changeAvailable; | ||
24 | 24 | ||
25 | - (id) init; | 25 | - (id) init; |
26 | -- (void) setResponse:(NSString *)response; | 26 | +- (void) setResponseValue:(NSString *)response; |
27 | 27 | ||
28 | @end | 28 | @end |
DUREX Vendor Control/Sensors.m
@@ -20,14 +20,15 @@ | @@ -20,14 +20,15 @@ | ||
20 | [self setChannelStatus:[[NSMutableArray alloc]init]]; | 20 | [self setChannelStatus:[[NSMutableArray alloc]init]]; |
21 | [self setMoneyCollected:[[NSMutableArray alloc]init]]; | 21 | [self setMoneyCollected:[[NSMutableArray alloc]init]]; |
22 | [self setMoneyReturned:[[NSMutableArray alloc]init]]; | 22 | [self setMoneyReturned:[[NSMutableArray alloc]init]]; |
23 | + [self setProductsSold:[[NSMutableArray alloc]init]]; | ||
23 | [self setChangeAvailable:[[NSMutableArray alloc] init]]; | 24 | [self setChangeAvailable:[[NSMutableArray alloc] init]]; |
24 | 25 | ||
25 | return self; | 26 | return self; |
26 | } | 27 | } |
27 | 28 | ||
28 | -- (void) setResponse:(NSString *)response | 29 | +- (void) setResponseValue:(NSString *)response |
29 | { | 30 | { |
30 | - self.response = response; | 31 | + [self setResponse:response]; |
31 | [self parseResponse]; | 32 | [self parseResponse]; |
32 | } | 33 | } |
33 | 34 | ||
@@ -38,13 +39,18 @@ | @@ -38,13 +39,18 @@ | ||
38 | uint16_t channelAvailability = 0; | 39 | uint16_t channelAvailability = 0; |
39 | uint16_t channelMotors = 0; | 40 | uint16_t channelMotors = 0; |
40 | 41 | ||
42 | + NSRange substrRange; | ||
43 | + substrRange.length = 5; | ||
44 | + substrRange.location = 2; | ||
45 | + | ||
46 | + channelStatus = [[[self response] substringWithRange:substrRange] intValue]; | ||
47 | + substrRange.location += 5; | ||
48 | + | ||
49 | + channelAvailability = [[[self response] substringWithRange:substrRange] intValue]; | ||
50 | + substrRange.location += 5; | ||
41 | 51 | ||
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); | 52 | + channelMotors = [[[self response] substringWithRange:substrRange] intValue]; |
53 | + substrRange.location += 5; | ||
48 | 54 | ||
49 | for(int i = 0; i < MAX_CHANNELS; i++) | 55 | for(int i = 0; i < MAX_CHANNELS; i++) |
50 | { | 56 | { |
@@ -52,7 +58,7 @@ | @@ -52,7 +58,7 @@ | ||
52 | { | 58 | { |
53 | channelCount++; | 59 | channelCount++; |
54 | } | 60 | } |
55 | - channelStatus <<= 1; | 61 | + channelStatus >>= 1; |
56 | } | 62 | } |
57 | [self setNumChannels:channelCount]; | 63 | [self setNumChannels:channelCount]; |
58 | 64 | ||
@@ -66,7 +72,7 @@ | @@ -66,7 +72,7 @@ | ||
66 | { | 72 | { |
67 | [[self channelProductAvailability] insertObject:[NSNumber numberWithBool:FALSE] atIndex:i]; | 73 | [[self channelProductAvailability] insertObject:[NSNumber numberWithBool:FALSE] atIndex:i]; |
68 | } | 74 | } |
69 | - channelAvailability <<= 1; | 75 | + channelAvailability >>= 1; |
70 | } | 76 | } |
71 | 77 | ||
72 | for(int i = 0; i < MAX_CHANNELS; i++) | 78 | for(int i = 0; i < MAX_CHANNELS; i++) |
@@ -79,10 +85,10 @@ | @@ -79,10 +85,10 @@ | ||
79 | { | 85 | { |
80 | [[self channelStatus] insertObject:[NSNumber numberWithBool:FALSE] atIndex:i]; | 86 | [[self channelStatus] insertObject:[NSNumber numberWithBool:FALSE] atIndex:i]; |
81 | } | 87 | } |
82 | - channelMotors <<= 1; | 88 | + channelMotors >>= 1; |
83 | } | 89 | } |
84 | 90 | ||
85 | - if([[self response] characterAtIndex:8] == '1') | 91 | + if([[self response] characterAtIndex:17] == '1') |
86 | { | 92 | { |
87 | [self setDoorOpen:TRUE]; | 93 | [self setDoorOpen:TRUE]; |
88 | } | 94 | } |
@@ -91,7 +97,7 @@ | @@ -91,7 +97,7 @@ | ||
91 | [self setDoorOpen:FALSE]; | 97 | [self setDoorOpen:FALSE]; |
92 | } | 98 | } |
93 | 99 | ||
94 | - if([[self response] characterAtIndex:9] == '1') | 100 | + if([[self response] characterAtIndex:18] == '1') |
95 | { | 101 | { |
96 | [self setCoilOpen:TRUE]; | 102 | [self setCoilOpen:TRUE]; |
97 | } | 103 | } |
@@ -99,16 +105,15 @@ | @@ -99,16 +105,15 @@ | ||
99 | { | 105 | { |
100 | [self setCoilOpen:FALSE]; | 106 | [self setCoilOpen:FALSE]; |
101 | } | 107 | } |
102 | - NSRange substrRange; | ||
103 | substrRange.length = 3; | 108 | substrRange.length = 3; |
104 | - substrRange.location = 10; | 109 | + substrRange.location = 19; |
105 | 110 | ||
106 | - for(int i = 0; i < MONEY_NUM_UNITS; i++) | 111 | + for(int i = 0; i < MONEY_IN_NUM_UNITS; i++) |
107 | { | 112 | { |
108 | [[self moneyCollected] insertObject:[NSNumber numberWithInt:[[[self response] substringWithRange:substrRange] intValue]] atIndex:i]; | 113 | [[self moneyCollected] insertObject:[NSNumber numberWithInt:[[[self response] substringWithRange:substrRange] intValue]] atIndex:i]; |
109 | substrRange.location += 3; | 114 | substrRange.location += 3; |
110 | } | 115 | } |
111 | - for(int i = 0; i < MONEY_NUM_UNITS; i++) | 116 | + for(int i = 0; i < MONEY_OUT_NUM_UNITS; i++) |
112 | { | 117 | { |
113 | [[self moneyReturned] insertObject:[NSNumber numberWithInt:[[[self response] substringWithRange:substrRange] intValue]] atIndex:i]; | 118 | [[self moneyReturned] insertObject:[NSNumber numberWithInt:[[[self response] substringWithRange:substrRange] intValue]] atIndex:i]; |
114 | substrRange.location += 3; | 119 | substrRange.location += 3; |
@@ -121,7 +126,7 @@ | @@ -121,7 +126,7 @@ | ||
121 | substrRange.location += 2; | 126 | substrRange.location += 2; |
122 | } | 127 | } |
123 | 128 | ||
124 | - if([[self response] characterAtIndex:64] == '1') | 129 | + if([[self response] characterAtIndex:75] == '1') |
125 | { | 130 | { |
126 | [[self changeAvailable]insertObject:[NSNumber numberWithBool:TRUE] atIndex:0]; | 131 | [[self changeAvailable]insertObject:[NSNumber numberWithBool:TRUE] atIndex:0]; |
127 | } | 132 | } |
@@ -130,7 +135,7 @@ | @@ -130,7 +135,7 @@ | ||
130 | [[self changeAvailable]insertObject:[NSNumber numberWithBool:FALSE] atIndex:0]; | 135 | [[self changeAvailable]insertObject:[NSNumber numberWithBool:FALSE] atIndex:0]; |
131 | } | 136 | } |
132 | 137 | ||
133 | - if([[self response] characterAtIndex:65] == '1') | 138 | + if([[self response] characterAtIndex:76] == '1') |
134 | { | 139 | { |
135 | [[self changeAvailable]insertObject:[NSNumber numberWithBool:TRUE] atIndex:1]; | 140 | [[self changeAvailable]insertObject:[NSNumber numberWithBool:TRUE] atIndex:1]; |
136 | } | 141 | } |
@@ -138,8 +143,6 @@ | @@ -138,8 +143,6 @@ | ||
138 | { | 143 | { |
139 | [[self changeAvailable]insertObject:[NSNumber numberWithBool:FALSE] atIndex:1]; | 144 | [[self changeAvailable]insertObject:[NSNumber numberWithBool:FALSE] atIndex:1]; |
140 | } | 145 | } |
141 | - | ||
142 | - | ||
143 | } | 146 | } |
144 | 147 | ||
145 | @end | 148 | @end |
DUREX Vendor Control/carat-open.png
0 → 100644
870 Bytes
DUREX Vendor Control/carat.png
0 → 100644
180 Bytes
DUREX Vendor Control/en.lproj/Localizable.strings
@@ -34,8 +34,10 @@ | @@ -34,8 +34,10 @@ | ||
34 | "Channel Engine Status" = "Channel Engine Status"; | 34 | "Channel Engine Status" = "Channel Engine Status"; |
35 | "Door Sensor" = "Door Sensor"; | 35 | "Door Sensor" = "Door Sensor"; |
36 | "Coil Sensor" = "Coil Sensor"; | 36 | "Coil Sensor" = "Coil Sensor"; |
37 | +"OPEN" = "OPEN"; | ||
38 | +"CLOSED" = "CLOSED"; | ||
37 | "Money Collected" = "Money Collected"; | 39 | "Money Collected" = "Money Collected"; |
38 | -"Money Given" = "Money Given"; | 40 | +"Money Returned" = "Money Returned"; |
39 | "Products Sold" = "Products Sold"; | 41 | "Products Sold" = "Products Sold"; |
40 | "Product 1" = "Product 1"; | 42 | "Product 1" = "Product 1"; |
41 | "Product 2" = "Product 2"; | 43 | "Product 2" = "Product 2"; |
@@ -72,7 +74,7 @@ | @@ -72,7 +74,7 @@ | ||
72 | "50c Coins" = "50c Coins"; | 74 | "50c Coins" = "50c Coins"; |
73 | "Channel" = "Channel"; | 75 | "Channel" = "Channel"; |
74 | "Product Code" = "Product Code"; | 76 | "Product Code" = "Product Code"; |
75 | -"Nominal Price" = "Nominal Price"; | 77 | +"Normal Price" = "Normal Price"; |
76 | "Discounted Price" = "Discounted Price"; | 78 | "Discounted Price" = "Discounted Price"; |
77 | "1€ Change" = "1€ Change"; | 79 | "1€ Change" = "1€ Change"; |
78 | "50c Change" = "50c Change"; | 80 | "50c Change" = "50c Change"; |
DUREX Vendor Control/es.lproj/Localizable.strings
@@ -34,8 +34,10 @@ | @@ -34,8 +34,10 @@ | ||
34 | "Channel Engine Status" = "Estado de los motores"; | 34 | "Channel Engine Status" = "Estado de los motores"; |
35 | "Door Sensor" = "Sensor de puerta"; | 35 | "Door Sensor" = "Sensor de puerta"; |
36 | "Coil Sensor" = "Sensor de bobina"; | 36 | "Coil Sensor" = "Sensor de bobina"; |
37 | +"OPEN" = "ABIERTO"; | ||
38 | +"CLOSED" = "CERRADO"; | ||
37 | "Money Collected" = "Recaudación efectuada"; | 39 | "Money Collected" = "Recaudación efectuada"; |
38 | -"Money Given" = "Efectivo devuelto"; | 40 | +"Money Returned" = "Efectivo devuelto"; |
39 | "Products Sold" = "Productos vendidos"; | 41 | "Products Sold" = "Productos vendidos"; |
40 | "Product 1" = "Producto 1"; | 42 | "Product 1" = "Producto 1"; |
41 | "Product 2" = "Producto 2"; | 43 | "Product 2" = "Producto 2"; |
@@ -72,7 +74,7 @@ | @@ -72,7 +74,7 @@ | ||
72 | "50c Coins" = "Monedas de 50c"; | 74 | "50c Coins" = "Monedas de 50c"; |
73 | "Channel" = "Canal"; | 75 | "Channel" = "Canal"; |
74 | "Product Code" = "Código del producto"; | 76 | "Product Code" = "Código del producto"; |
75 | -"Nominal Price" = "Precio Nominal"; | 77 | +"Normal Price" = "Precio Normal"; |
76 | "Discounted Price" = "Precio con descuento"; | 78 | "Discounted Price" = "Precio con descuento"; |
77 | "1€ Change" = "Cambio de 1€"; | 79 | "1€ Change" = "Cambio de 1€"; |
78 | "50c Change" = "Cambio de 50c"; | 80 | "50c Change" = "Cambio de 50c"; |
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
@@ -31,8 +31,8 @@ | @@ -31,8 +31,8 @@ | ||
31 | endingColumnNumber = "9223372036854775807" | 31 | endingColumnNumber = "9223372036854775807" |
32 | startingLineNumber = "32" | 32 | startingLineNumber = "32" |
33 | endingLineNumber = "32" | 33 | endingLineNumber = "32" |
34 | - landmarkName = "-viewDidLoad" | ||
35 | - landmarkType = "5"> | 34 | + landmarkName = "@implementation InitialViewController" |
35 | + landmarkType = "3"> | ||
36 | </BreakpointContent> | 36 | </BreakpointContent> |
37 | </BreakpointProxy> | 37 | </BreakpointProxy> |
38 | </Breakpoints> | 38 | </Breakpoints> |
TODO
1 | BUGS: | 1 | BUGS: |
2 | - messageAvailable checks and status checks NOT working (long operations) | 2 | - messageAvailable checks and status checks NOT working (long operations) |
3 | - On date change, response is overwritten by previous query, trimming needed according to numBytes | 3 | - On date change, response is overwritten by previous query, trimming needed according to numBytes |
4 | +- Sanitize input on name/price change | ||
5 | +- Seemingly random crashes | ||
4 | 6 | ||
5 | TODO: | 7 | TODO: |
6 | -- Sensors class | ||
7 | -- A4 parser | ||
8 | -- Dropdown cells | ||
9 | -- Generate view | ||
10 | 8 | ||
11 | -- Sale class | ||
12 | - A2 command | 9 | - A2 command |
13 | - Sale parser | 10 | - Sale parser |
14 | - Generate view | 11 | - Generate view |
@@ -16,6 +13,8 @@ TODO: | @@ -16,6 +13,8 @@ TODO: | ||
16 | - Implement sensor status logging and sending to remote server | 13 | - Implement sensor status logging and sending to remote server |
17 | - Lewis infrastructure for data viewing (SQL, Webpage, CSV parser) | 14 | - Lewis infrastructure for data viewing (SQL, Webpage, CSV parser) |
18 | 15 | ||
16 | +- Channels and codes to 2 ciphers | ||
17 | + | ||
19 | - Incident class | 18 | - Incident class |
20 | - Incident parser | 19 | - Incident parser |
21 | - A3 command | 20 | - A3 command |