Commit 6afba47260cea4535771f4d40ac6dcdd7f54b477

Authored by Imanol-Mikel Barba Sabariego
1 parent dcf63fcf

--no commit message

DUREX Vendor Control/Base.lproj/Localizable.strings
... ... @@ -78,6 +78,7 @@
78 78 "Discounted Price" = "Discounted Price";
79 79 "1€ Change" = "1€ Change";
80 80 "50c Change" = "50c Change";
  81 +"Money Paid" = "Money Paid";
81 82 "Update Date & Time" = "Update Date & Time";
82 83 "Update product price" = "Update product price";
83 84 "Update product name" = "Update product name";
84 85 \ No newline at end of file
... ...
DUREX Vendor Control/CommunicationProtocol.h
... ... @@ -17,7 +17,7 @@
17 17 #define MONEY_OUT_NUM_UNITS ((int)3)
18 18 #define CHANGE_NUM_UNITS ((int)2)
19 19 #define MAX_PRODUCTS ((int)16)
20   -
  20 +#define SALE_STRING_LENGTH ((int)36)
21 21  
22 22 @interface CommunicationProtocol : NSObject
23 23  
... ... @@ -30,7 +30,7 @@
30 30 -(Boolean) updatePrice: (uint8_t) channel : (uint8_t) product : (uint8_t) eur : (uint8_t) cents;
31 31 -(Boolean) updateProductName: (uint8_t) channel : (uint8_t) product : (NSString*) name;
32 32 -(NSString*) readSensorData;
33   --(NSString*) readSalesLog: (NSDate*) start : (NSDate*) end;
  33 +-(NSString*) readSalesLog: (NSDateComponents*) start : (NSDateComponents*) end;
34 34 +(id) sharedProtocol;
35 35  
36 36 @end
... ...
DUREX Vendor Control/CommunicationProtocol.m
... ... @@ -311,12 +311,6 @@
311 311  
312 312 -(Boolean) updateTime: (NSDateComponents*) date
313 313 {
314   - if(date == nil)
315   - {
316   - NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
317   - NSCalendarUnit units = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
318   - date = [calendar components:units fromDate:[NSDate date]];
319   - }
320 314 NSMutableString *command = [NSMutableString stringWithFormat: @"A5"];
321 315 NSInteger year = [date year];
322 316 year = year - (year/100)*100;
... ... @@ -363,9 +357,9 @@
363 357 {
364 358 NSString *command = @"A4";
365 359 [self writeMessage:command];
366   - NSString *answer = [self readMessage];
  360 + //NSString *answer = [self readMessage];
367 361  
368   - /*NSMutableString *answer = [[NSMutableString alloc]initWithString:@"P400255002550025510"];
  362 + NSMutableString *answer = [[NSMutableString alloc]initWithString:@"P400255002550025510"];
369 363 for(int i = 0; i < 15; i++)
370 364 {
371 365 [answer appendString:@"0"];
... ... @@ -379,19 +373,19 @@
379 373 [answer appendString:@"2"];
380 374 }
381 375 [answer appendString:@"1"];
382   - [answer appendString:@"1"];*/
383   -
384   - if([[answer substringToIndex:2]isEqualToString:@"P4"])
  376 + [answer appendString:@"1"];
  377 +
  378 + if([answer length] > 1 && [[answer substringToIndex:2]isEqualToString:@"P4"])
385 379 {
386 380 return answer;
387 381 }
388 382 return nil;
389 383 }
390 384  
391   --(NSString*) readSalesLog : (NSDate*) start : (NSDate*) end
  385 +-(NSString*) readSalesLog : (NSDateComponents*) start : (NSDateComponents*) end
392 386 {
393   - NSMutableString *startDate = [[NSMutableString alloc] init];
394   - NSMutableString *endDate = [[NSMutableString alloc] init];
  387 + NSMutableString *startDate = [NSMutableString stringWithString:@""];
  388 + NSMutableString *endDate = [NSMutableString stringWithString:@""];
395 389 NSMutableString *command = [NSMutableString stringWithString:@"A2"];
396 390 if(start == nil)
397 391 {
... ... @@ -399,7 +393,10 @@
399 393 }
400 394 else
401 395 {
402   -
  396 + NSInteger year = [start year];
  397 + year = year - (year/100)*100;
  398 + [startDate appendString:[NSString stringWithFormat:@"%02ld",(long)year]];
  399 + [startDate appendString:[NSString stringWithFormat:@"%02ld%02ld%02ld%02ld",(long)[start month],(long)[start day],(long)[start hour],(long)[start minute]]];
403 400 }
404 401 if(end == nil)
405 402 {
... ... @@ -407,7 +404,10 @@
407 404 }
408 405 else
409 406 {
410   -
  407 + NSInteger year = [end year];
  408 + year = year - (year/100)*100;
  409 + [endDate appendString:[NSString stringWithFormat:@"%02ld",(long)year]];
  410 + [endDate appendString:[NSString stringWithFormat:@"%02ld%02ld%02ld%02ld",(long)[end month],(long)[end day],(long)[end hour],(long)[end minute]]];
411 411 }
412 412 [command appendString:startDate];
413 413 [command appendString:@"-"];
... ... @@ -417,7 +417,7 @@
417 417  
418 418 NSMutableString *answer = [[NSMutableString alloc]initWithString:@"P21405141651102416090662045001500512P21406141651102416090662045001500512P2P2"];
419 419  
420   - if([[answer substringToIndex:2]isEqualToString:@"P2"])
  420 + if([answer length] > 1 && [[answer substringToIndex:2]isEqualToString:@"P2"])
421 421 {
422 422 return answer;
423 423 }
... ...
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,4 +2,230 @@
2 2 <Bucket
3 3 type = "1"
4 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 = "SalesLog.m"
  13 + timestampString = "431824868.885164"
  14 + startingColumnNumber = "9223372036854775807"
  15 + endingColumnNumber = "9223372036854775807"
  16 + startingLineNumber = "21"
  17 + endingLineNumber = "21"
  18 + landmarkName = "-setResponseValue:"
  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 = "MenuTableViewController.m"
  29 + timestampString = "431828056.269485"
  30 + startingColumnNumber = "9223372036854775807"
  31 + endingColumnNumber = "9223372036854775807"
  32 + startingLineNumber = "599"
  33 + endingLineNumber = "599"
  34 + landmarkName = "-tableView:cellForRowAtIndexPath:"
  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 = "MenuTableViewController.m"
  45 + timestampString = "431828056.269485"
  46 + startingColumnNumber = "9223372036854775807"
  47 + endingColumnNumber = "9223372036854775807"
  48 + startingLineNumber = "541"
  49 + endingLineNumber = "541"
  50 + landmarkName = "-tableView:cellForRowAtIndexPath:"
  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 = "MenuTableViewController.m"
  61 + timestampString = "431828056.269485"
  62 + startingColumnNumber = "9223372036854775807"
  63 + endingColumnNumber = "9223372036854775807"
  64 + startingLineNumber = "423"
  65 + endingLineNumber = "423"
  66 + landmarkName = "-tableView:didSelectRowAtIndexPath:"
  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 = "CommunicationProtocol.m"
  77 + timestampString = "431825157.011553"
  78 + startingColumnNumber = "9223372036854775807"
  79 + endingColumnNumber = "9223372036854775807"
  80 + startingLineNumber = "359"
  81 + endingLineNumber = "359"
  82 + landmarkName = "-readSensorData"
  83 + landmarkType = "5">
  84 + </BreakpointContent>
  85 + </BreakpointProxy>
  86 + <BreakpointProxy
  87 + BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
  88 + <BreakpointContent
  89 + shouldBeEnabled = "No"
  90 + ignoreCount = "0"
  91 + continueAfterRunningActions = "No"
  92 + filePath = "CommunicationProtocol.m"
  93 + timestampString = "431825158.083281"
  94 + startingColumnNumber = "9223372036854775807"
  95 + endingColumnNumber = "9223372036854775807"
  96 + startingLineNumber = "358"
  97 + endingLineNumber = "358"
  98 + landmarkName = "-readSensorData"
  99 + landmarkType = "5">
  100 + </BreakpointContent>
  101 + </BreakpointProxy>
  102 + <BreakpointProxy
  103 + BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
  104 + <BreakpointContent
  105 + shouldBeEnabled = "No"
  106 + ignoreCount = "0"
  107 + continueAfterRunningActions = "No"
  108 + filePath = "CommunicationProtocol.m"
  109 + timestampString = "431825237.058289"
  110 + startingColumnNumber = "9223372036854775807"
  111 + endingColumnNumber = "9223372036854775807"
  112 + startingLineNumber = "378"
  113 + endingLineNumber = "378"
  114 + landmarkName = "-readSensorData"
  115 + landmarkType = "5">
  116 + </BreakpointContent>
  117 + </BreakpointProxy>
  118 + <BreakpointProxy
  119 + BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
  120 + <BreakpointContent
  121 + shouldBeEnabled = "No"
  122 + ignoreCount = "0"
  123 + continueAfterRunningActions = "No"
  124 + filePath = "MenuTableViewController.m"
  125 + timestampString = "431828056.269485"
  126 + startingColumnNumber = "9223372036854775807"
  127 + endingColumnNumber = "9223372036854775807"
  128 + startingLineNumber = "458"
  129 + endingLineNumber = "458"
  130 + landmarkName = "-tableView:didSelectRowAtIndexPath:"
  131 + landmarkType = "5">
  132 + </BreakpointContent>
  133 + </BreakpointProxy>
  134 + <BreakpointProxy
  135 + BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
  136 + <BreakpointContent
  137 + shouldBeEnabled = "No"
  138 + ignoreCount = "0"
  139 + continueAfterRunningActions = "No"
  140 + filePath = "MenuTableViewController.m"
  141 + timestampString = "431828056.269485"
  142 + startingColumnNumber = "9223372036854775807"
  143 + endingColumnNumber = "9223372036854775807"
  144 + startingLineNumber = "457"
  145 + endingLineNumber = "457"
  146 + landmarkName = "-tableView:didSelectRowAtIndexPath:"
  147 + landmarkType = "5">
  148 + </BreakpointContent>
  149 + </BreakpointProxy>
  150 + <BreakpointProxy
  151 + BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
  152 + <BreakpointContent
  153 + shouldBeEnabled = "No"
  154 + ignoreCount = "0"
  155 + continueAfterRunningActions = "No"
  156 + filePath = "SalesLog.m"
  157 + timestampString = "431825829.779956"
  158 + startingColumnNumber = "9223372036854775807"
  159 + endingColumnNumber = "9223372036854775807"
  160 + startingLineNumber = "27"
  161 + endingLineNumber = "27"
  162 + landmarkName = "-parseResponse"
  163 + landmarkType = "5">
  164 + </BreakpointContent>
  165 + </BreakpointProxy>
  166 + <BreakpointProxy
  167 + BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
  168 + <BreakpointContent
  169 + shouldBeEnabled = "No"
  170 + ignoreCount = "0"
  171 + continueAfterRunningActions = "No"
  172 + filePath = "SalesLog.m"
  173 + timestampString = "431825975.950785"
  174 + startingColumnNumber = "9223372036854775807"
  175 + endingColumnNumber = "9223372036854775807"
  176 + startingLineNumber = "36"
  177 + endingLineNumber = "36"
  178 + landmarkName = "-parseResponse"
  179 + landmarkType = "5">
  180 + </BreakpointContent>
  181 + </BreakpointProxy>
  182 + <BreakpointProxy
  183 + BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
  184 + <BreakpointContent
  185 + shouldBeEnabled = "Yes"
  186 + ignoreCount = "0"
  187 + continueAfterRunningActions = "No"
  188 + filePath = "SalesLog.m"
  189 + timestampString = "431826402.024193"
  190 + startingColumnNumber = "9223372036854775807"
  191 + endingColumnNumber = "9223372036854775807"
  192 + startingLineNumber = "35"
  193 + endingLineNumber = "35"
  194 + landmarkName = "-parseResponse"
  195 + landmarkType = "5">
  196 + </BreakpointContent>
  197 + </BreakpointProxy>
  198 + <BreakpointProxy
  199 + BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
  200 + <BreakpointContent
  201 + shouldBeEnabled = "Yes"
  202 + ignoreCount = "0"
  203 + continueAfterRunningActions = "No"
  204 + filePath = "SalesLog.m"
  205 + timestampString = "431826425.066356"
  206 + startingColumnNumber = "9223372036854775807"
  207 + endingColumnNumber = "9223372036854775807"
  208 + startingLineNumber = "61"
  209 + endingLineNumber = "61"
  210 + landmarkName = "-parseResponse"
  211 + landmarkType = "5">
  212 + </BreakpointContent>
  213 + </BreakpointProxy>
  214 + <BreakpointProxy
  215 + BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
  216 + <BreakpointContent
  217 + shouldBeEnabled = "No"
  218 + ignoreCount = "0"
  219 + continueAfterRunningActions = "No"
  220 + filePath = "MenuTableViewController.m"
  221 + timestampString = "431828716.255822"
  222 + startingColumnNumber = "9223372036854775807"
  223 + endingColumnNumber = "9223372036854775807"
  224 + startingLineNumber = "650"
  225 + endingLineNumber = "650"
  226 + landmarkName = "-tableView:cellForRowAtIndexPath:"
  227 + landmarkType = "5">
  228 + </BreakpointContent>
  229 + </BreakpointProxy>
  230 + </Breakpoints>
5 231 </Bucket>
... ...
DUREX Vendor Control/FirstAppExample/Base.lproj/MainStoryboard.storyboard
... ... @@ -119,7 +119,7 @@
119 119 </subviews>
120 120 </tableViewCellContentView>
121 121 </tableViewCell>
122   - <tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="SalesCell" textLabel="HRc-DC-qxG" detailTextLabel="dhY-17-9fo" style="IBUITableViewCellStyleValue1" id="gpr-Mk-KfN">
  122 + <tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="SaleListCell" textLabel="HRc-DC-qxG" detailTextLabel="dhY-17-9fo" style="IBUITableViewCellStyleValue1" id="gpr-Mk-KfN">
123 123 <rect key="frame" x="0.0" y="218" width="320" height="44"/>
124 124 <autoresizingMask key="autoresizingMask"/>
125 125 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="gpr-Mk-KfN" id="bFe-TX-iWA">
... ...
DUREX Vendor Control/FirstAppExample/main.m
1   - //
  1 +//
2 2 // main.m
3 3 // TestAppExample
4 4 //
... ...
DUREX Vendor Control/MenuTableViewController.h
... ... @@ -33,20 +33,22 @@
33 33 #define MAINTENANCE_CELLS_PER_SECTION num(9),num(3)
34 34 #define MAINTENANCE_HEADERS NSLocalizedString(@"Sensors", nil),NSLocalizedString(@"Commands", nil)
35 35  
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"
  36 +#define SALE_ELEMENTS @"[3000]Money Paid",@"[3001]Channel",@"[3002]Product Code",@"[3003]Normal Price",@"[3004]Discounted Price",@"[3005]Money Returned"
  37 +#define SALE_MONEY_PAID @"10€ Notes",@"5€ Notes",@"2€ Coins",@"1€ Coins",@"50c Coins"
  38 +#define SALE_MONEY_RETURNED @"1€ Change",@"50c Change"
  39 +#define SALE_HEADERS nil
39 40  
40   -#define CONFIGURATION_ELEMENTS @"[3000]Update Date & Time",@"[3001]Update product price",@"[3002]Update product name"
  41 +#define CONFIGURATION_ELEMENTS @"[4000]Update Date & Time",@"[4001]Update product price",@"[4002]Update product name"
41 42 #define CONFIGURATION_CELLS_PER_SECTION num(3)
42 43 #define CONFIGURATION_HEADERS nil
43 44  
44   -#define CELL_IDENTIFIERS @"MenuCell",@"MaintenanceCell",@"SalesCell",@"ConfigCell",@"ReportCell"
  45 +#define CELL_IDENTIFIERS @"MenuCell",@"MaintenanceCell",@"SaleListCell",@"SaleCell",@"ConfigCell",@"ReportCell"
45 46  
46 47 enum {
47 48 MENU = 0,
48 49 MAINTENANCE,
49   - SALES,
  50 + SALE_LIST,
  51 + SALE,
50 52 BASIC_CONFIGURATION,
51 53 REPORT,
52 54 } navigationLevel;
... ...
DUREX Vendor Control/MenuTableViewController.m
... ... @@ -21,9 +21,9 @@
21 21 @property (nonatomic,strong) const NSMutableArray *maintenanceStructure;
22 22 @property (nonatomic,strong) const NSMutableArray *maintenanceHeaders;
23 23  
24   -@property (nonatomic,strong) const NSMutableArray *salesElements;
25   -@property (nonatomic,strong) const NSMutableArray *salesStructure;
26   -@property (nonatomic,strong) const NSMutableArray *salesHeaders;
  24 +@property (nonatomic,strong) const NSMutableArray *saleListElements;
  25 +@property (nonatomic,strong) const NSMutableArray *saleListStructure;
  26 +@property (nonatomic,strong) const NSMutableArray *saleListHeaders;
27 27  
28 28 @property (nonatomic,strong) const NSMutableArray *configElements;
29 29 @property (nonatomic,strong) const NSMutableArray *configStructure;
... ... @@ -101,7 +101,7 @@
101 101 return TRUE;
102 102 }
103 103  
104   -- (Boolean) generateSalesNavLevel
  104 +- (Boolean) generateSaleListNavLevel
105 105 {
106 106 //LAUNCH DATE RANGE SELECTOR
107 107 NSString *salesData = [_protocol readSalesLog: nil : nil];
... ... @@ -111,16 +111,9 @@
111 111 return FALSE;
112 112 }
113 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]];
116   - if([[self salesStructure] count] > 1)
117   - {
118   - [self setSalesHeaders:[[NSMutableArray alloc] initWithObjects:SALES_HEADERS, nil]];
119   - }
120   - else
121   - {
122   - [self setSalesHeaders:nil];
123   - }
  114 + [self setSaleListElements:[[NSMutableArray alloc] initWithObjects:nil, nil]];
  115 + [self setSaleListStructure:[[NSMutableArray alloc] initWithObjects:nil, nil]];
  116 + [self setSaleListHeaders:nil];
124 117 return TRUE;
125 118 }
126 119  
... ... @@ -147,12 +140,12 @@
147 140 [self setCurrentStructure:[self maintenanceStructure]];
148 141 [self setCurrentHeaders:[self maintenanceHeaders]];
149 142 }
150   - else if([self currentNavLevel] == SALES)
  143 + else if([self currentNavLevel] == SALE_LIST)
151 144 {
152 145 [[self navigationItem] setTitle:NSLocalizedString(@"Sales log", nil)];
153   - [self setCurrentElements:[self salesElements]];
154   - [self setCurrentStructure:[self salesStructure]];
155   - [self setCurrentHeaders:[self salesHeaders]];
  146 + [self setCurrentElements:[self saleListElements]];
  147 + [self setCurrentStructure:[self saleListStructure]];
  148 + [self setCurrentHeaders:[self saleListHeaders]];
156 149 }
157 150 else if([self currentNavLevel] == BASIC_CONFIGURATION)
158 151 {
... ... @@ -237,6 +230,9 @@
237 230  
238 231 //Initialize sensor status
239 232 [self setSensorStatus:[[Sensors alloc]init]];
  233 +
  234 + //Initialize sales log
  235 + [self setSalesLog:[[SalesLog alloc]init]];
240 236 }
241 237  
242 238 -(void)viewDidAppear:(BOOL)animated
... ... @@ -458,14 +454,14 @@
458 454 }
459 455 else if([cellName isEqualToString:NSLocalizedString(@"Sales log", nil)])
460 456 {
461   - NSLog(@"[MenuTableViewController.m]: Changing to navLevel: SALES");
462   - if([self generateSalesNavLevel])
  457 + NSLog(@"[MenuTableViewController.m]: Changing to navLevel: SALE_LIST");
  458 + if([self generateSaleListNavLevel])
463 459 {
464   - [self changeNavLevel:SALES:TRUE];
  460 + [self changeNavLevel:SALE_LIST:TRUE];
465 461 }
466 462 else
467 463 {
468   - NSLog(@"[MenuTableViewController.m]: Error while changing to navLevel: SALES");
  464 + NSLog(@"[MenuTableViewController.m]: Error while changing to navLevel: SALE_LIST");
469 465 }
470 466 }
471 467 }
... ... @@ -649,9 +645,9 @@
649 645 }
650 646 }
651 647 }
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)
  648 + else if([[NSRegularExpression regularExpressionWithPattern:[NSString stringWithFormat:@"%@ (\\d+)",NSLocalizedString(@"Channel",nil)] options:0 error:NULL] numberOfMatchesInString:[[cell textLabel] text] options:0 range:(NSMakeRange(0,[[[cell textLabel] text] length]))] != 0)
653 649 {
654   - NSUInteger index = [[[[cell textLabel] text] substringFromIndex:8] intValue] - 1;
  650 + NSUInteger index = [[[[cell textLabel] text] substringFromIndex:([NSLocalizedString(@"Channel",nil) length] + 1)] intValue] - 1;
655 651 if([cell tag] == 2001) // Products Present in Channel tag
656 652 {
657 653 if([[[[self sensorStatus] channelProductAvailability] objectAtIndex:index] intValue] == 1)
... ... @@ -729,9 +725,9 @@
729 725 }
730 726 [[cell detailTextLabel] setText:[NSString stringWithFormat:@"%d",numSold]];
731 727 }
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)
  728 + else if([[NSRegularExpression regularExpressionWithPattern:[NSString stringWithFormat:@"%@ (\\d+)",NSLocalizedString(@"Product",nil)] options:0 error:NULL] numberOfMatchesInString:[[cell textLabel] text] options:0 range:(NSMakeRange(0,[[[cell textLabel] text] length]))] != 0)
733 729 {
734   - NSUInteger index = [[[[cell textLabel] text] substringFromIndex:8] intValue] - 1;
  730 + NSUInteger index = [[[[cell textLabel] text] substringFromIndex:([NSLocalizedString(@"Product",nil) length] + 1)] intValue] - 1;
735 731 if([cell tag] == 2007)
736 732 {
737 733 [[cell detailTextLabel] setText:[[[[self sensorStatus] productsSold] objectAtIndex:index] stringValue]];
... ...
DUREX Vendor Control/Sale.h
... ... @@ -16,6 +16,7 @@
16 16 @property NSString *productCode;
17 17 @property NSString *normalPrice;
18 18 @property NSString *discountedPrice;
  19 +@property NSString *channel;
19 20 @property NSDate *saleTime;
20 21  
21 22 - (id) init;
... ...
DUREX Vendor Control/SalesLog.h
... ... @@ -7,6 +7,8 @@
7 7 //
8 8  
9 9 #import <Foundation/Foundation.h>
  10 +#import "CommunicationProtocol.h"
  11 +#import "Sale.h"
10 12  
11 13 @interface SalesLog : NSObject
12 14  
... ...
DUREX Vendor Control/SalesLog.m
... ... @@ -24,7 +24,43 @@
24 24  
25 25 - (void) parseResponse
26 26 {
27   -
  27 + NSInteger currentSale = 0;
  28 + NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
  29 + NSCalendarUnit units = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit;
  30 + NSDateComponents *saleDate = [[NSDateComponents alloc] init];
  31 + NSInteger currentYear = [[calendar components:units fromDate:[NSDate date]] year];
  32 + currentYear = (currentYear/100)*100;
  33 + while(![[[self response] substringWithRange:NSMakeRange((currentSale*SALE_STRING_LENGTH), 4)] isEqualToString:@"P2P2"])
  34 + {
  35 + Sale *sale = [[Sale alloc] init];
  36 + [saleDate setYear:(currentYear + [[[self response] substringWithRange:NSMakeRange(2 + currentSale*SALE_STRING_LENGTH, 2)] intValue])];
  37 + [saleDate setMonth:[[[self response] substringWithRange:NSMakeRange(4 + currentSale*SALE_STRING_LENGTH, 2)] intValue]];
  38 + [saleDate setDay:[[[self response] substringWithRange:NSMakeRange(6 + currentSale*SALE_STRING_LENGTH, 2)] intValue]];
  39 + [saleDate setHour:[[[self response] substringWithRange:NSMakeRange(8 + currentSale*SALE_STRING_LENGTH, 2)] intValue]];
  40 + [saleDate setMinute:[[[self response] substringWithRange:NSMakeRange(10 + currentSale*SALE_STRING_LENGTH, 2)] intValue]];
  41 + [sale setSaleTime:[saleDate date]];
  42 + NSLog(@"date: %@",saleDate);
  43 + [[sale moneyPaid] insertObject:[NSNumber numberWithInt:[[[self response] substringWithRange:NSMakeRange(12 + currentSale*SALE_STRING_LENGTH, 2)] intValue]] atIndex:0];
  44 + [[sale moneyPaid] insertObject:[NSNumber numberWithInt:[[[self response] substringWithRange:NSMakeRange(14 + currentSale*SALE_STRING_LENGTH, 2)] intValue]] atIndex:1];
  45 + [[sale moneyPaid] insertObject:[NSNumber numberWithInt:[[[self response] substringWithRange:NSMakeRange(16 + currentSale*SALE_STRING_LENGTH, 2)] intValue]] atIndex:2];
  46 + [[sale moneyPaid] insertObject:[NSNumber numberWithInt:[[[self response] substringWithRange:NSMakeRange(18 + currentSale*SALE_STRING_LENGTH, 2)] intValue]] atIndex:3];
  47 + [[sale moneyPaid] insertObject:[NSNumber numberWithInt:[[[self response] substringWithRange:NSMakeRange(20 + currentSale*SALE_STRING_LENGTH, 2)] intValue]] atIndex:4];
  48 + NSLog(@"moneyPaid: %@",[sale moneyPaid]);
  49 + [sale setChannel:[[self response] substringWithRange:NSMakeRange(22 + currentSale*SALE_STRING_LENGTH, 1)]];
  50 + NSLog(@"channel: %@",[sale channel]);
  51 + [sale setProductCode:[[self response] substringWithRange:NSMakeRange(23 + currentSale*SALE_STRING_LENGTH, 1)]];
  52 + NSLog(@"productCode: %@",[sale productCode]);
  53 + [sale setNormalPrice: [NSString stringWithFormat:@"%d,%02d",[[[self response] substringWithRange:NSMakeRange(24 + currentSale*SALE_STRING_LENGTH, 2)] intValue],[[[self response] substringWithRange:NSMakeRange(26 + currentSale*SALE_STRING_LENGTH, 2)] intValue]]];
  54 + NSLog(@"normalPrice: %@",[sale normalPrice]);
  55 + [sale setDiscountedPrice: [NSString stringWithFormat:@"%d,%02d",[[[self response] substringWithRange:NSMakeRange(28 + currentSale*SALE_STRING_LENGTH, 2)] intValue],[[[self response] substringWithRange:NSMakeRange(30 + currentSale*SALE_STRING_LENGTH, 2)] intValue]]];
  56 + NSLog(@"discountedPrice: %@",[sale discountedPrice]);
  57 + [[sale moneyReturned] insertObject:[NSNumber numberWithInt:[[[self response] substringWithRange:NSMakeRange(32 + currentSale*SALE_STRING_LENGTH, 2)] intValue]] atIndex:0];
  58 + [[sale moneyReturned] insertObject:[NSNumber numberWithInt:[[[self response] substringWithRange:NSMakeRange(34 + currentSale*SALE_STRING_LENGTH , 2)] intValue]] atIndex:1];
  59 + NSLog(@"moneyReturned: %@",[sale moneyReturned]);
  60 + [[self sales] insertObject:sale atIndex:currentSale];
  61 + currentSale++;
  62 + }
  63 + NSLog(@"%@",[self sales]);
28 64 }
29 65  
30 66 @end
... ...
DUREX Vendor Control/en.lproj/Localizable.strings
... ... @@ -76,6 +76,7 @@
76 76 "Product Code" = "Product Code";
77 77 "Normal Price" = "Normal Price";
78 78 "Discounted Price" = "Discounted Price";
  79 +"Money Paid" = "Money Paid";
79 80 "1€ Change" = "1€ Change";
80 81 "50c Change" = "50c Change";
81 82 "Update Date & Time" = "Update Date & Time";
... ...
DUREX Vendor Control/es.lproj/Localizable.strings
... ... @@ -76,6 +76,7 @@
76 76 "Product Code" = "Código del producto";
77 77 "Normal Price" = "Precio Normal";
78 78 "Discounted Price" = "Precio con descuento";
  79 +"Money Paid" = "Efectivo Pagado";
79 80 "1€ Change" = "Cambio de 1€";
80 81 "50c Change" = "Cambio de 50c";
81 82 "Update Date & Time" = "Actualizar fecha y hora";
... ...
... ... @@ -3,12 +3,13 @@ BUGS:
3 3 - On date change, response is overwritten by previous query, trimming needed according to numBytes
4 4 - Sanitize input on name/price change
5 5 - Seemingly random crashes
  6 +- Month headers on sale list
6 7  
7 8 TODO:
8 9  
9   -- A2 command
10   -- Sale parser
11   -- Generate view
  10 +- Populate sale list with dates
  11 +- On select any date, generate navlevel with index in salesLog
  12 +- Generate sale navLevel
12 13  
13 14 - Implement sensor status logging and sending to remote server
14 15 - Lewis infrastructure for data viewing (SQL, Webpage, CSV parser)
... ...