General Requirement
The general requirement is to develop an app which records the amount of time a user spends within the vicinity of a location. Data on the wait time and the location where the wait was made should be transmitted to a server.
- Starting and ending recording is user-initiated. Thus the app should enable the user to toggle between start recording and end recording.
- The app should be able to recover in case the user forgot to initiate end of recording. Thus the app should check for location change at fixed intervals and therefrom determine if circumstances suggest that the user has forgotten to initiate end of recording.
- The app should send data to the server, but in case there is no data connection, it should be able to queue the data for transmission and send it out once a data connection is established next time the app is activated.
Assumptions
The following assumptions are made and included as business rule:
First, polling of location data is at 5 minutes interval. This saves battery life while still acceptable as practical and realistic noting that wait times less than 15 minutes (polling is less than 3 times) can be discarded for being reasonable.
Second, trucks are allowed to move for 500 meters in any 5-minute interval before it can be assumed to have left a queue and is back on the road. It can be that the truck has moved up the queue or the driver found a more suitable parking spot. If the truck has changed location for more than 500 meters in a 5-minute interval, the truck is assumed to have left the vicinity.
Software Algorithm
The following is the recommended app algorithm:
01 On app activation, determine if it is the initial run or the app is just being resumed. If the app is being resumed, re-establish app state, else initialise the app and record time and location. This is known as starting time and starting location. The current location and the current time is initially the same as the starting time and starting location.
02 Check if there is data pending transmission. If there is data pending transmission, check data connection and attempt to transmit. If transmission is successful, mark off transmitted data else keep data in queue pending transmission.
03 While app is not manually stopped, record time and location data every 5 minutes. This is known as polled time and polled location. Compare the polled data with the current data. If within a 5-minute interval the location data has changed for more than 500 meters, the truck is assumed to be moving towards cruising speed. The user is then prompted for confirmation.
04 If the user confirms that the truck is already on the road, the current location and the current time is transmitted to the server and the app state is reset to that of Step 01. If the user indicates that the truck is still waiting or in queue, the current time is updated with the polled time and the current location is updated with the polled location.
05 If the user does not provide any feedback, it will be assumed that indeed the truck is moving towards cruising speed already. The current location and the current time is transmitted to the server and the app state is reset to that of Step 01.
06 If the app is manually stopped, the time is recorded as ending time and the location is recorded as ending location. The ending data is compared with the starting data, and if the time interval is less than 15 minutes, the app state is reset to that of Step 01. If the time interval is 15 minutes or more, the ending time and ending location is transmitted to the server and the app state is reset to that of Step 01.
04 If the user confirms that the truck is already on the road, the current location and the current time is transmitted to the server and the app state is reset to that of Step 01. If the user indicates that the truck is still waiting or in queue, the current time is updated with the polled time and the current location is updated with the polled location.
05 If the user does not provide any feedback, it will be assumed that indeed the truck is moving towards cruising speed already. The current location and the current time is transmitted to the server and the app state is reset to that of Step 01.
06 If the app is manually stopped, the time is recorded as ending time and the location is recorded as ending location. The ending data is compared with the starting data, and if the time interval is less than 15 minutes, the app state is reset to that of Step 01. If the time interval is 15 minutes or more, the ending time and ending location is transmitted to the server and the app state is reset to that of Step 01.
Comments
Post a Comment