From 01e9e1dae8784202be7ec683d3f34d00c112eee1 Mon Sep 17 00:00:00 2001 From: Eddie Ehlin Date: Sun, 17 Feb 2013 12:46:48 +0100 Subject: Added support for recurring thresholds --- iBean/iBean.xcodeproj/project.pbxproj | 12 ++--- .../UserInterfaceState.xcuserstate | Bin 50031 -> 48738 bytes .../xcdebugger/Breakpoints.xcbkptlist | 12 ++--- iBean/iBean/.DS_Store | Bin 6148 -> 6148 bytes iBean/iBean/AppDelegate+Storage.m | 11 ++++ iBean/iBean/Threshold.h | 5 +- iBean/iBean/Threshold.m | 5 +- iBean/iBean/ThresholdViewController.h | 1 + iBean/iBean/ThresholdViewController.m | 2 + .../iBean.xcdatamodeld/iBean.xcdatamodel/contents | 5 +- iBean/iBean/iPhoneStoryboard.storyboard | 56 ++++++++++++++++++--- 11 files changed, 85 insertions(+), 24 deletions(-) diff --git a/iBean/iBean.xcodeproj/project.pbxproj b/iBean/iBean.xcodeproj/project.pbxproj index 2721cd3..3cabdce 100644 --- a/iBean/iBean.xcodeproj/project.pbxproj +++ b/iBean/iBean.xcodeproj/project.pbxproj @@ -36,10 +36,10 @@ 024CB02016C04BD5009CBC15 /* UIColor+Extra.m in Sources */ = {isa = PBXBuildFile; fileRef = 024CB01F16C04BD5009CBC15 /* UIColor+Extra.m */; }; 024CB03716C2EF10009CBC15 /* UITableView+Extra.m in Sources */ = {isa = PBXBuildFile; fileRef = 024CB03616C2EF10009CBC15 /* UITableView+Extra.m */; }; 024CB03916C2EFD5009CBC15 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 024CB03816C2EFD5009CBC15 /* QuartzCore.framework */; }; + 024CC6B016D0F33200F84F3D /* Threshold.m in Sources */ = {isa = PBXBuildFile; fileRef = 024CC6AF16D0F33200F84F3D /* Threshold.m */; }; 024F676D16A4A61D004A1201 /* InstantExtractionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 024F676C16A4A61D004A1201 /* InstantExtractionViewController.m */; }; 0276253916B58D6000EE2F4E /* SettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0276253816B58D6000EE2F4E /* SettingsViewController.m */; }; 0276253C16B59E4C00EE2F4E /* Configuration.m in Sources */ = {isa = PBXBuildFile; fileRef = 0276253B16B59E4C00EE2F4E /* Configuration.m */; }; - 0276253F16B59E4C00EE2F4E /* Threshold.m in Sources */ = {isa = PBXBuildFile; fileRef = 0276253E16B59E4C00EE2F4E /* Threshold.m */; }; 0276254216B5A64000EE2F4E /* ThresholdListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0276254116B5A64000EE2F4E /* ThresholdListViewController.m */; }; 0276254516B5AACF00EE2F4E /* ThresholdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0276254416B5AACF00EE2F4E /* ThresholdViewController.m */; }; 0276254816B5BC5300EE2F4E /* ThresholdCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 0276254716B5BC5300EE2F4E /* ThresholdCell.m */; }; @@ -96,14 +96,14 @@ 024CB03516C2EF10009CBC15 /* UITableView+Extra.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UITableView+Extra.h"; sourceTree = ""; }; 024CB03616C2EF10009CBC15 /* UITableView+Extra.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UITableView+Extra.m"; sourceTree = ""; }; 024CB03816C2EFD5009CBC15 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; + 024CC6AE16D0F33200F84F3D /* Threshold.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Threshold.h; sourceTree = ""; }; + 024CC6AF16D0F33200F84F3D /* Threshold.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Threshold.m; sourceTree = ""; }; 024F676B16A4A61D004A1201 /* InstantExtractionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InstantExtractionViewController.h; sourceTree = ""; }; 024F676C16A4A61D004A1201 /* InstantExtractionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InstantExtractionViewController.m; sourceTree = ""; }; 0276253716B58D6000EE2F4E /* SettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsViewController.h; sourceTree = ""; }; 0276253816B58D6000EE2F4E /* SettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingsViewController.m; sourceTree = ""; }; 0276253A16B59E4C00EE2F4E /* Configuration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Configuration.h; sourceTree = ""; }; 0276253B16B59E4C00EE2F4E /* Configuration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Configuration.m; sourceTree = ""; }; - 0276253D16B59E4C00EE2F4E /* Threshold.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Threshold.h; sourceTree = ""; }; - 0276253E16B59E4C00EE2F4E /* Threshold.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Threshold.m; sourceTree = ""; }; 0276254016B5A64000EE2F4E /* ThresholdListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThresholdListViewController.h; sourceTree = ""; }; 0276254116B5A64000EE2F4E /* ThresholdListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ThresholdListViewController.m; sourceTree = ""; }; 0276254316B5AACF00EE2F4E /* ThresholdViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThresholdViewController.h; sourceTree = ""; }; @@ -232,8 +232,8 @@ 020C55DF169792F800D8224C /* Data */ = { isa = PBXGroup; children = ( - 0276253D16B59E4C00EE2F4E /* Threshold.h */, - 0276253E16B59E4C00EE2F4E /* Threshold.m */, + 024CC6AE16D0F33200F84F3D /* Threshold.h */, + 024CC6AF16D0F33200F84F3D /* Threshold.m */, 0276253A16B59E4C00EE2F4E /* Configuration.h */, 0276253B16B59E4C00EE2F4E /* Configuration.m */, 020C5684169F603700D8224C /* Interface */, @@ -440,12 +440,12 @@ 02E557BA16AC85A20080FBBA /* BeanCollectionExtractionScrollView.m in Sources */, 0276253916B58D6000EE2F4E /* SettingsViewController.m in Sources */, 0276253C16B59E4C00EE2F4E /* Configuration.m in Sources */, - 0276253F16B59E4C00EE2F4E /* Threshold.m in Sources */, 0276254216B5A64000EE2F4E /* ThresholdListViewController.m in Sources */, 0276254516B5AACF00EE2F4E /* ThresholdViewController.m in Sources */, 0276254816B5BC5300EE2F4E /* ThresholdCell.m in Sources */, 024CB02016C04BD5009CBC15 /* UIColor+Extra.m in Sources */, 024CB03716C2EF10009CBC15 /* UITableView+Extra.m in Sources */, + 024CC6B016D0F33200F84F3D /* Threshold.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate b/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate index 7bbba69..dd74adc 100644 Binary files a/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate and b/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist b/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist index c2f8927..ee63edf 100644 --- a/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist +++ b/iBean/iBean.xcodeproj/xcuserdata/eddiex.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist @@ -34,11 +34,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "iBean/ThresholdViewController.m" - timestampString = "381271322.430192" + timestampString = "382793252.607427" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "86" - endingLineNumber = "86" + startingLineNumber = "87" + endingLineNumber = "87" landmarkName = "-commitThreshold:" landmarkType = "5"> @@ -125,11 +125,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "iBean/AppDelegate+Storage.m" - timestampString = "381513161.061541" + timestampString = "382794135.600835" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "200" - endingLineNumber = "200" + startingLineNumber = "210" + endingLineNumber = "210" landmarkName = "-processThresholds" landmarkType = "5"> diff --git a/iBean/iBean/.DS_Store b/iBean/iBean/.DS_Store index 4128183..00a4276 100644 Binary files a/iBean/iBean/.DS_Store and b/iBean/iBean/.DS_Store differ diff --git a/iBean/iBean/AppDelegate+Storage.m b/iBean/iBean/AppDelegate+Storage.m index 8448f3e..6fb3ca8 100644 --- a/iBean/iBean/AppDelegate+Storage.m +++ b/iBean/iBean/AppDelegate+Storage.m @@ -189,6 +189,14 @@ //Time to go through all thresholds and se which one(s) that are hit! for (Threshold *t in sortedThresholds) { + //Case 1 - Threshold is hit & is set to be recurring + if (([configuration.extractionCount integerValue] % [t.value integerValue]) == 0 && [t.recurring boolValue] == YES) + { + //Enable/re-enable the threshold. + t.enabled = [NSNumber numberWithBool:YES]; + } + + //Case 2 - Threshold is hit & enabled if ([configuration.extractionCount integerValue] >= [t.value integerValue] && [t.enabled boolValue] == YES) { NSLog(@"Threshold %@ active (%@ >= %@)", t.name, configuration.extractionCount, t.value); @@ -196,6 +204,9 @@ } } + //Save context (to make sure that altered thresholds gets saved). + [self saveContext]; + //Now, let's go through all active thresholds. [self processActiveThreshold]; } diff --git a/iBean/iBean/Threshold.h b/iBean/iBean/Threshold.h index 7034bcd..f82a392 100644 --- a/iBean/iBean/Threshold.h +++ b/iBean/iBean/Threshold.h @@ -2,7 +2,7 @@ // Threshold.h // iBean // -// Created by Eddie Ehlin on 2013-01-27. +// Created by Eddie Ehlin on 2013-02-17. // Copyright (c) 2013 Eddie Ehlin. All rights reserved. // @@ -13,9 +13,10 @@ @interface Threshold : NSManagedObject +@property (nonatomic, retain) NSNumber * enabled; @property (nonatomic, retain) NSString * name; @property (nonatomic, retain) NSNumber * value; -@property (nonatomic, retain) NSNumber * enabled; +@property (nonatomic, retain) NSNumber * recurring; @property (nonatomic, retain) Configuration *configuration; @end diff --git a/iBean/iBean/Threshold.m b/iBean/iBean/Threshold.m index e8c6d85..53eb15c 100644 --- a/iBean/iBean/Threshold.m +++ b/iBean/iBean/Threshold.m @@ -2,7 +2,7 @@ // Threshold.m // iBean // -// Created by Eddie Ehlin on 2013-01-27. +// Created by Eddie Ehlin on 2013-02-17. // Copyright (c) 2013 Eddie Ehlin. All rights reserved. // @@ -12,9 +12,10 @@ @implementation Threshold +@dynamic enabled; @dynamic name; @dynamic value; -@dynamic enabled; +@dynamic recurring; @dynamic configuration; @end diff --git a/iBean/iBean/ThresholdViewController.h b/iBean/iBean/ThresholdViewController.h index 29d4874..6922514 100644 --- a/iBean/iBean/ThresholdViewController.h +++ b/iBean/iBean/ThresholdViewController.h @@ -24,6 +24,7 @@ @property (weak, nonatomic) IBOutlet UILabel *thresholdValueLabel; @property (weak, nonatomic) IBOutlet UIStepper *thresholdValueStepper; @property (weak, nonatomic) IBOutlet UISwitch *thresholdEnabledSwitch; +@property (weak, nonatomic) IBOutlet UISwitch *thresholdRecurringSwitch; /* UI Actions */ - (IBAction)valueStepperChanged:(id)sender; diff --git a/iBean/iBean/ThresholdViewController.m b/iBean/iBean/ThresholdViewController.m index 2e01373..050e61a 100644 --- a/iBean/iBean/ThresholdViewController.m +++ b/iBean/iBean/ThresholdViewController.m @@ -63,6 +63,7 @@ self.thresholdNameTextField.text = tmpThreshold.name; self.thresholdEnabledSwitch.on = [tmpThreshold.enabled boolValue]; self.thresholdValueStepper.value = [tmpThreshold.value doubleValue]; + self.thresholdRecurringSwitch.on = [tmpThreshold.recurring boolValue]; [self valueStepperChanged:self]; } @@ -101,6 +102,7 @@ threshold.name = self.thresholdNameTextField.text; threshold.value = [NSNumber numberWithDouble:self.thresholdValueStepper.value]; threshold.enabled = [NSNumber numberWithBool:self.thresholdEnabledSwitch.on]; + threshold.recurring = [NSNumber numberWithBool:self.thresholdRecurringSwitch.on]; //Commit changes and save succeeds then return to list of thresholds. commitError = [(AppDelegate*) [[UIApplication sharedApplication] delegate] save]; diff --git a/iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents b/iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents index f421adc..66998b3 100644 --- a/iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents +++ b/iBean/iBean/iBean.xcdatamodeld/iBean.xcdatamodel/contents @@ -1,5 +1,5 @@ - + @@ -25,6 +25,7 @@ + @@ -32,6 +33,6 @@ - + \ No newline at end of file diff --git a/iBean/iBean/iPhoneStoryboard.storyboard b/iBean/iBean/iPhoneStoryboard.storyboard index 9be079b..2f77028 100644 --- a/iBean/iBean/iPhoneStoryboard.storyboard +++ b/iBean/iBean/iPhoneStoryboard.storyboard @@ -513,28 +513,70 @@ - + - + + + - - + + + + + + + + + + + + + + + + + + + + + + + @@ -553,8 +595,9 @@ - + + @@ -1364,6 +1407,7 @@ + -- cgit v1.2.3