Proposed Solution To Parts Of

Slides:



Advertisements
Similar presentations
Introducing to Location in Android LOCATION IS EVERYTHING Kamil Lelonek Kamil Lelonek
Advertisements

Object Oriented Programming in Java. Object Oriented Programming Concepts in Java Object oriented Programming is a paradigm or organizing principle for.
OOD - Principles Design Class Diagrams Chapter 10 pp ; ;
Designing Classes Chapter 3. 2 Chapter Contents Encapsulation Specifying Methods Java Interfaces Writing an Interface Implementing an Interface An Interface.
Location Aware Devices  Location information can lead to creative applications  GPS hardware  cell tower positioning.
Modelling classes Drawing a Class Diagram. Class diagram First pick the classes –Choose relevant nouns, which have attributes and operations. Find the.
Cosc 5/4730 GPS/Location android.location. Simulator notes All the simulators can simulator GPS/location information – Android DDMS commands (geo) to.
Android Sensors & Async Callbacks Jules White Bradley Dept. of Electrical and Computer Engineering Virginia Tech
OBJECT ORIENTED PROGRAMMING LECTURE 12 Instructor: Rashi Garg Coordinator: Gaurav Saxena.
1 CMPT 275 Phase: Design. Janice Regan, Map of design phase DESIGN HIGH LEVEL DESIGN Modularization User Interface Module Interfaces Data Persistance.
1 CMSC 628: Introduction to Mobile Computing Nilanjan Banerjee Introduction to Mobile Computing University of Maryland Baltimore County
AITI Lecture 20 Trees, Binary Search Trees Adapted from MIT Course 1.00 Spring 2003 Lecture 28 and Tutorial Note 10 (Teachers: Please do not erase the.
Chapter 1 - Getting to know Greenfoot
111 Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract,
Chapter 9 Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design.
Programming Languages by Ravi Sethi Chapter 6: Groupings of Data and Operations.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 9, Object Design: Specifying Interfaces.
CompSci 100E 2.1 Java Basics - Expressions  Literals  A literal is a constant value also called a self-defining term  Possibilities: o Object: null,
Software Testing Input Space Partition Testing. 2 Input Space Coverage Four Structures for Modeling Software Graphs Logic Input Space Syntax Use cases.
Chapter 10 Defining Classes. The Internal Structure of Classes and Objects Object – collection of data and operations, in which the data can be accessed.
Location. GPS Global Positioning System – At least 4 satellites typically used 3 required extra for error detection and altitude typically accurate within.
HashCode() 1  if you override equals() you must override hashCode()  otherwise, the hashed containers won't work properly  recall that we did not override.
The Unified Modeling Language (UML)
Class Diagram Chapter 21 Applying UML and Patterns Craig Larman.
Objects – State u There are only two things we can do to an object u Inspect it’s state u Alter it’s state u This is a profound statement! u If you think.
Chapter 16 UML Class Diagrams.
Sensors – Part 2 SE 395/595. Location in Android LocationManager class – Configure providers and their listeners LocationListener class – Handles update.
OOD - Principles Design Class Diagrams
Web Application Design. Data –What data is available? –How do we store it or how is it stored in the DB? Schema Data types Etc. –Where is the data?
CO320 Catchup David Barnes with material from Dermot Shinners-Kennedy.
CEN th Lecture Advance Software Engineering (CEN-5011) Instructor: Masoud Sadjadi Object Design: Specifying.
Sub-Phase Low Level Design (cont)
Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa OBJECT DESIGN Now we need to design in such detail that.
Cosc 4735 LocationAware API. Previous on … Before we looked at GPS location. – d-gpslocation.pptx
Event-driven design will set you free The Observer Pattern 1.
BTS430 Systems Analysis and Design using UML Design Class Diagrams (ref=chapter 16 of Applying UML and Patterns)
Location Based Services. Android location APIs make it easy for you to build location-aware applications, without needing to focus on the details of the.
Software Engineering 2003 Jyrki Nummenmaa 1 OBJECT DESIGN Now we need to design in such detail that the design can be implemented. It will be.
1 © 2003, Cisco Systems, Inc. All rights reserved. DMTF and Cisco Profile overview/comparison August 17, 2005.
Section 2.2 The StringLog ADT Specification. 2.2 The StringLog ADT Specification The primary responsibility of the StringLog ADT is to remember all the.
1. 2 Android location services Determining a device’s current location Tracking device movements Proximity alerts.
Comp 1100 Entity-Relationship (ER) Model
Outline What’s in the document Open Issues Encoding Device Discovery
Design Class Diagrams
By Dan Gotlund & Eric Acierto
Chapter 16 UML Class Diagrams.
Android Location Based Services
Design Class Diagrams
UML Class & Object Diagram II
100% Exam Passing Guarantee & Money Back Assurance
draw a sequence diagram
Chapter 9, Object Design: Specifying Interfaces
Design by Contract Fall 2016 Version.
Subroutines Idea: useful code can be saved and re-used, with different data values Example: Our function to find the largest element of an array might.
Object Oriented Analysis and Design
Exam Fall 2013 Proposed Solution
Variables ICS2O.
Abstract Class As per dictionary, abstraction is the quality of dealing with ideas rather than events. For example, when you consider the case of ,
Exam Fall 2012 Proposed Solution
Coding Concepts (Data- Types)
Exam Fall 2014 Proposed Solution
Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract, Computer,
Introduction to Design Patterns
Java Programming Language
Data Structures & Algorithms
CS378 - Mobile Computing Location and Maps.
OBJECT DESIGN Now we need to design in such detail that the design can be implemented. It will be important to know, which structures the programming language.
Lists CMSC 202, Version 4/02.
Software Specifications
Problem 1 Given n, calculate 2n
Presentation transcript:

Proposed Solution To Parts Of Mandatory Fall 2012

PhoneBook Friend Relative - owner : String * - contacts Contact - name : String - address : String Friend Relative -firstMeet : String - relationship : String

PhoneBook Friend Relative City Municipality - ownerName : String * - contacts Contact Place «interface» 0..1 * - name : String + getAddress() : String Friend Relative City Municipality -firstMeet : String - relationship : String - address :String - address :String

PhoneBook City Municipality Friend Relative Country - ownerName : String * - contacts Contact Place «interface» 0..1 * - name : String - localPhone: String - countryPhoneCode: String - completePhoneNumber : String + getAddress() : String City Municipality Friend Relative - address :String - address :String -firstMeet : String - relationship : String * * 1 Country - countryPhoneCode: String

BodyTemperatureSensor BodyTemperatureSensor LocationManager Location + getTemp() : double + getTemp() : double + getLastKnownLocation() : Location - latitude : double longitude : double time : long UserInterfaceController + getMeHome() : void + getMeHomeIAmSick( emergencyLevel : Integer ) : void UserInterfaceController + getMeHome() : void + getMeHomeIAmSick( emergencyLevel : Integer ) : void + getLatitude() : double + getLongitude() : double + getTime() : long + setLatitude(latitude : double) : void + setLongitude(longitude : double) : void + setTime(time : long) : void OperatorController HeartBeatSensor + oneMoreBeat () : void «interface» HeartBeatListener + registerHeartBeatListener( heartBeatListener: HeartBeatListener) : void HeartBeatSensor HBIntervalUpdater + oneMoreBeat() - updateIntervals() There are some software that is available to you: The CommandProcesser class has two methods that will be called from some other

public class LocationManager { LocationListener[] locationListeners; public void requestLocationUpdates(int minTimeBetweenUpdates, LocationListener locationListener) {…} public Location getLastKnownLocation() {…} } public interface LocationListener{ public void onLocationChanged(Location location); public class PathTracker { public void onLocationChanged(Location location){…} public class Location{ private double latitude; private double longitude; private long time; public double getLatitude(){…} public double getLongitude(){…} public long getTime(){…} public void setLatitude(double latitude){…} public void setLongitude(double longitude){…} public void setTime(long time){…}

Fig.1

<?xml version="1.0"?> <JourneyRegister> <Journey userName=“Harald“ phoneNumber=“12345678”> <start> <Location latitude=“58.351944” longitude=“8.544444” time=“1319534189” /> </start> <passedLocations> <Location latitude=“58.351997” longitude=“8.544454” time=“1319590011” /> <Location latitude=“58.351999” longitude=“8.544455” time=“1319633452” /> </passedLocations> <end"> <Location latitude=“58.351944” longitude=“8.544444” time=“1319690012” /> </end> </Journey> <start> <Location latitude=“58.351944” longitude=“8.544444” time=“1319540400” /> <passedLocations> <Location latitude=“58.351997” longitude=“8.544460” time=“1319547303” /> <Location latitude=“58.351944” longitude=“8.544442” time=“1319551234” /> </JourneyRegister>

Table: Location Table: PhoneInfo Table: Journey 12345678 12345678 LocationId JourneyId latitude longitude time 11 1 58.351944 8.544444 1319534189 12 1 58.351997 8.544454 1319590011 13 1 58.351999 8.544455 1319633452 14 1 58.351944 8.544444 1319690012 15 2 58.351944 8.544444 1319540400 Table: PhoneInfo 16 2 58.351997 8.544460 1319547303 phoneNumber userName 12345678 Harald 17 2 58.351944 8.544442 1319551234 Table: Journey JourneyId phoneNumber start start 1 12345678 11 14 2 12345678 15 17

start.time < end.time The time attribute of class Location represents the time when the location where decided and it is given as the number of milliseconds since 1970. Propose one or more OCL constraints that ensure that the start time of the journey is before the end time of the journey. Also, make a constraint that ensures that all other locations of the journey are between the start and end time (role name start identify the start location, role name end identify the end location and role name passedLocations identifies the other locations of the journey). Context Journey inv: start.time < end.time Context Journey inv: passedLocation->forall((start.time < time) and (time< end.time)) -- The above constraint assumes that start and end is not members of passedLocation -- The following constraint assures this (not passedLocation->includes(start)) and (not passedLocation->includes(end))

c) The GPS device of the phone is handled by the LocationManager which is partly described above (Fig.1). The LocationManager is our software interface to the GPS device and it has among others the following operations: - getLastKnownLocation() : Location - requestLocationUpdates(minTimeBetweenUpdates : int, locationListener: LocationListener ) : void Operation getLastKnownLocation returns the current location. An object of a class that has implemented interface LocationListener can be registered as listener to location updates (class PathTracker has implemented this interface). Operation requestLocationUpdates is used to do the registration, parameter locationListener must then be a reference (link) to the object that are to receive the location updates; parameter minTimeBetweenUpdates is the minimum time interval in milliseconds between two location updates. A location update is performed by the LocationManager when it calls operation onLocationChanged (see interface LocationListener Fig. 1) of the object(s) that are to receive the location update (parameter location is the new location). The locations of one journey are to be registered in the JourneyRegister and the PathTracker is in some way involved in this registration.

C1 Start Journey Inspect and handle Journey(s) End Journey A use case diagram together with some “use case texts” that describe the user interaction with the phone for a journey from start to end. Precondition: PathTracer (PT) application started. User choose to register a journey. User gives name to journey or PT supplies default name. User choose to start the journey. Start Journey C1 Precondition: PathTracer (PT) application started. User can view current location of ongoing journey (if any). User can view the registered locations of all registered journeys. (User can delete and in different ways manipulate journeys.) Inspect and handle Journey(s) End Journey Precondition: PathTracer (PT) application started and ongoing journey. User choose to end ongoing journey.

«interface» LocationListener LocationManager C2 + requestLocationUpdates(minTimeBetweenUpdates : int, locationListener: LocationListener ) : void + getLastKnownLocation() : Location 1 * locationListeners The new model elements are given in red ! I’m ignoring the phone info. «interface» LocationListener PathTracker - isOngoingJourney : boolean JourneyRegister + onLocationChanged(location : Location) : void # setIsOngoingJourney(b : boolean) : void + getIsOngoingJourney() : boolean + commandNewJourney(name : String) : void + commandStartJourney() : void + commandEndJourney() : void 1 + createJourney(name : String) : Journey journeys currentJourney * 0..1 Journey - name : String + getName() : String + setName(newName : String) : void + addFirstLocation(loc : Location) + addEndLocation(loc : Location) + addLocation(loc : Location) thePhone 1 start 0..1 end 0..1 passedLocations * PhoneInfo Location

User choose to register a journey User gives name to journey – this is not shown here (part of GUI). In regard to the sequence diagram I assume (could have used OCL): - The application has been started. - The PathTracker has been registered as an LocationListener (e.g., by some call like this: locationManager. requestLocationUpdates(<some number>, pathTracker), where locationManager is a reference to the LocationManager and pathTracker is a reference to the PathTracker). - That there is no ongoing journey. :PathTracker :JourneyRegister User commandNewJourney(name) createJourney(name) :Journey setName(name) Property isOngoingJourney is still false since the journey has not been started yet. Returns reference to the created journey, this Journey is set as currentJourney of the :PathTracker.

User choose to start the journey I assume that the Journey has been created but not started. :PathTracker :LocationManager :Journey User commandStartJourney() startLoc = getLastKnownLocation() addFirstLocation(startLoc) Property isOngoingJourney is set to true since the journey has started.

While the journey goes on I assume that the Journey has been started. :LocationManager :PathTracker :Journey onLocationChanged(location) addLocation(location) onLocationChanged(location) addLocation(location)

User choose to end the journey I assume that the Journey has been created and started. :PathTracker :LocationManager :Journey User commandEndJourney() endLoc = getLastKnownLocation() addEndLocation(endLoc) Property isOngoingJourney is set to false since the journey has ended.

Translating the sequence diagrams to communication diagrams are rather strait forward. Below is “While the journey goes on ” C4 :LocationManager 1.onLocationChanged(location) :PathTracker 2.addLocation(location) :Journey

choose to register journey User choose to register a journey :PathTracker :JourneyRegister User choose to register journey asks for a new journey creates a new journey and sets its name

choose to start journey User choose to start the journey :PathTracker :LocationManager :Journey User choose to start journey receives “register journey” command gets current location current location forward current location to journey current location add current location as start location I have not supplied “User choose to end a journey” – it would be very similar to this one.

While the journey goes on :PathTracker :LocationManager :Journey new location observed location forward current location to journey location add location

D – Parts of a solution You are to define class DangerousZoneInfo (a call to getDangerousZoneInfo returns such a value) which should describe one dangerous zone (the zone is defined as a circle, see description of addProximityAlert above); DangerousZoneInfo should also contain a textual description of the type of danger. DangerousZoneInfo - latitudeCentre : double longitudeCentre : double radius : float description : String + getCentreLatitude() : double + getCentreLongitude() : double + getRadius() : float + getDescription() : String + setCentreLatitude(latitude : double) : void + setCentreLongitude(longitude : double) : void + setRadius(r : float) : void + setDescription(txt : String) : void

:DangerousZonePoller :DangerousZoneCommunicator LocationManager + getDangerousZoneInfo() : DangerousZoneInfo + addProximityAlert(double latitude, double longitude, float radius) : void 1 1 DangerousZonePoller + pollingForDangerousZoneInfo() : void Get DangerousZoneInfo and inform LocationManager. :LocationManager :DangerousZonePoller :DangerousZoneCommunicator info = getDangerousZoneInfo() [info not equal null] addProximityAlert(infor.getCentreLatitude(), …) info = getDangerousZoneInfo() [info not equal null] addProximityAlert(infor.getCentreLatitude(), …)

«interface» AlertListener LocationManager + addAlertListener(AlertListener : alertListener ) : void + removeAlertListener(AlertListener : alertListener ) : void * alertListeners The PathTracker manages the alerts from LocationManager and turns the speaker on and off. «interface» AlertListener + alertOn() : void + alertOff() : void PathTracker 1 LoadSpeaker + alertOn() : void + alertOff() : void + on() : void + off() : void

:LocationManager :PathTracker :LoadSpeaker alertOn() on() alertOff() off()