Make PPRSingleton more generic

PPRSingleton sharedInstance now returns "instancetype" which removes the need to cast the result when getting the shared instance of a subclass.
PPRSingletonTest update to reflect new interface and to check the returned instance class.
Shift state and Settings Tab

This change moves publishing of changes to currently selected facility to a shift object which is published with shift state and implement changing shift state.

The changes to shift state are persisted in user settings.

A settings tab is added to the user interface to allow uses to reset the stored user settings to defaults.

Add PPRShift object to hold shift state.

Modify PPRClientViewController change key for notification.

Modify PPRShiftViewController
- change the keys for facility id and add keys for shift
- refactor handling of change of facility to be part of shift.

Add PPRSettingsViewController to handle reseting shift state.

Add PPRSettingsNavigationController for future display of shift state in tab bar.

Modify Main,storyboard to add Settings tab.

Modify StringKeys.h to add user settings keys and shift change notification keys.
Add PPRStickyMessageNoticeView

The standard StickyNoticeView in the NoticeView “pod” does not display the notice view message. This is a clone of StickyNoticeView combined with the message display of ErrorNoticeView.
Add scheduler time simulation and settings controls.

This change adds to the scheduler the concept of scheduler time which can be used to test the scheduling of the application.
The scheduler time maintained by a one second timer. Each time the scheduler time is updates, a notification is posted.
The settings tab allows the time to be set and a “warp” factor which can be used to speed up the “clock”.

PPRClockTabBarItem has been added to display the scheduler time.
PPRSettingViewController has been modified to replace the “Settings” tab bar label with a ClockTabBarItem and register the clock display for update notification.
PPRScheduler is modified to manage the schedulerTime and provides routines to calculate the equivalent wall time clock value for a schedulerTime value.
PPRAppDelegate has been modified to start the scheduler timer and to post notifications when the schedulerTime has changed. Experimental NoticeView messages have been removed and a more generic display of notifications provided.
Main.storyboard has had controls added to control the schedulerTime.
Refactor ActorManager and update TestInitialiser

This change move test initialisation from PPRActionManager to PPRTestInitialiser for actions and refactors PPRActorManager to use the PPRActor object.

PPRAction is modified to calculate a dueTime description.
PPRScheduleTableView is modified to use PPRAction objects to display actions.
A new daily event is added to Group Home 1 in TestInitialiser.
Add Shift Manager

This change adds the shift manager singleton which is used to preserve state between application restarts.

Added PPRShiftManager
Added PPRShiftManagerTests
Modified PPRTestIntialiser to use shift manager
Modified PPRShiftViewController to move the shift related “key” strings to the new PPRShiftManager.
Fix a bug on a test case.
Improve ActionManager and add Tests

This change improves ActionManager and adds tests for action manager.
Tests for updateAction methods will be in a subsequent commit.

PPRAction
- add completionTime and facility to object.
- completionTime is selected in dueTimeDescription when status is “Done”

PPRActionManager
- improved class documentation
- getAction now handles prototype actions matching facility and action id
- added update methods to set specific elements of state give an action id

PPRActionManagerTests
- Added tests for insert and get action.
Change interface for updateAction etc to pass back update action and add tests

PPRActionManager
- updated updateAction interfaces and publish getActionById method in header file

PPRScheduleTableViewController
- update to use new interfaces

PPRActionManagerTests
- added tests
Add a status navigation bar button to toggle between available and unavailable when on shift

This change adds a navigation bar button to the client and schedule table view that allows the user to toggle between being available and unavailable.

Added PPRStatusBarButtonItem
- A UIBarButtonItem subclass to display the shift status and toggle availability.

Added PPRStatusShowingTableViewController
- Looks for a PPRStatusBarButtonItem in the navigation bar and adds it as an observer for shift change notifications
- Connects the button action to a routine that toggles the availability.

PPRClientTableViewController now is a subclass of PPRStatusShowingTableViewController
PPRScheduleTableViewController now a subclass of PPRStatusShowingTableViewController
Modified Main.storyboard
- add status buttons to client table view and schedule table view
Improve Facility Manager + Client Manager

This change improves the tests and documentation of the facility manager.
Attempting to retrieve a facility with an unknown facility id now calls failure.
Client manager has been modified to populate the error object of failure callbacks.

PPRFacilityManger
- improve documentation and call failure on unknown facilityId

PPRFacilityManagerTests
- add getFacilityById test

PPRClientManager
-
Merge pull request #13 from davidbernard/generic_singleton

Generic singleton
Add scheduling of events

The schedule now loads actions from the action manager whenever the facility is set in the shift settings. The actions are scanned every second for due actions and
due actions a “processed” by a due action processor.

PPRActionViewController
- add a table for action context specific instructions
- rename details to action

PPRClientTableViewController
- obtain facilityId from Shift Manager

PPRSettingsViewController
- reset settings using shift manager

PPRScheduleViewController
- move action status constants to action
- set completion time if action completed
- add postpone functionality
- loadActions loads actions, filters on facility and sorts by due time
- action statuses “Notified” and “Scheduled” supported.
- display completionTime for “Done” actions

PPRAction
- add facility and completion time properties
- add method to calculate the instructions for an action

PPRClientAction
- add method to calculate the instructions for an action

Add PPRActionScheduler
- class to support creation of scheduled actions

Add PPRClientActionScheduler
- subclass of PPRActionScheduler for scheduling client actions

Add PPRFacilityActionScheduler
- subclass of PPRActionScheduler for scheduling facility actions

PPRActionManager
- add methods to update action status

PPRScheduler
- add functionality to maintain the schedule of actions, process due actions through an assigned processor.

PPRTestInitialiser
- Initialise Action and Facility schedulers and schedule actions for the facilities and clients.

PPRSchedulerTests
- Add tests for scheduler

PPRActionSchedulerTests
- Add tests for action scheduler

PPRClientActionScheduleTests
- Add tests for facility scheduler

PPRFacilityActionSchedulerTests
Fix init routine of test initialiser
Merge remote-tracking branch 'pegwing_ppreminderer/master' into notificatio_manager
Make it so that tapping a client shows a table with name and other notes.
Merge pull request #16 from davidbernard/clock_toolbar_item

Scheduler Time and associated controls and settings
Notification Manager and merge

This change adds the notification manager. The notification manager generates and tracks the local notifications made by the application. Local notifications are used to remind the user to perform actions when they are not actively using the application.
Also when the application is in background, the system my terminate the application in which case the only means of reminding the user is via a schedule local notification which allows the user to restart the application to action to reminder.
The scheduler is modified to separate the scheduler state of a item such as an action and the status of the action. Actions are now scheduled, postponed or completed and schedule items are either scheduled, notified, due or completed.
The scheduler state is now saved so that when  the application moves between active and inactive, it “appears” that the scheduler clock has been running when the application has been inactive.
The setting screen has been improved.
Actions now record a completion time which is display in the schedule when complete.
Facilities now have context relevant instructions.

Postponed button and status is represented by “Orange”
On shift button is now green and Off shift is now red.

PPRStickyNoticeView
- Adjust layout

PPRClockTabBarItem
- Factor out initialisation

PPRActionViewController
- Indentation change

PPRSettingNavigationControllerViewController
- Explicitly initialise the clock tab bar item

PPRSettingsViewController
- Changing the date picker does not immediately change the scheduler time. A button has been added to set the time from the picker.
- Resetting default settings now clears actions from the action manager and reloads the scheduler’s schedule
- Use a slider to set the warp factor

PPRSchedulerViewController
Separate schedule state from action state
- tick now sets completion time
- the new action states are displayed

PPRNotification
- An new abstract class representing notifications and how to represent them in UILocalNotifications

PPRActionNotification
- A new class representing action notifications

PPRAction
- Now explicitly initialised with a facility.
- notificationDescription added to provide text suitable for display in a notification.
- Modified to handle new state model.

PPRInstruction
- A new abstract class to represent instructions. Extracted from PPRClientInstruction

PPRClientInstruction
- Now a subclass of PPRInstruction

PPRFacilityInstruction
- A new class for facility instructions

PPRScheduleTime
- Now explicitly checks NSDateComponent offset parameters for relevant uninitialised fields - setting them to 0. This fixes a display issue where these date components were being display as max int.
- Display of offset fields explicitly cast to long

PPRFacility
- Now has facility context relevant instructions.

PPRClientAction
- Add routine to generate notification suitable text.
- Initialise with scheduled event.

PPRFacilityAction
- New class to represent facility actions.

PPRScheduleItem
- A new class to manage schedule status.

PPRActionScheduleItem
- A new subclass of schedule item manage the scheduling of actions.

PPRNotificationManager
- A new class for managing notifications

PPRFacilityActionScheduler
- now uses PPRFacilityAction

PPRActionManager
- actions map public so it can be reset.

PPRScheduler
- Due item processing separated from Future time processing
- Scheduler state save and restore routines added to support application changing state between active and inactive.
- Now using PPRScheduleIItem to manage scheduler rather than state of actions.

PPRTestInitialiser
- the test initialiser publishes its internal state to improve testings
- added a test facility instruction
- improved initialisation of schedule time “offsets”
- loading test data factored out of init
- scheduling events factored out of init

PPRAppDelegate
- due and future items processing generate notifications
- scheduler state saving and restoring added
- “NotiveView” display of received notifications improved.

PPRShiftTests
- add tests for shift object

PPRSchedulerTests
- change due to interface changes.
Order classes in alphabetical order.
PPRActionTests
- add tests for dueTimeDescription