Presentation is loading. Please wait.

Presentation is loading. Please wait.

Proposed Solution To Parts Of

Similar presentations


Presentation on theme: "Proposed Solution To Parts Of"— Presentation transcript:

1 Proposed Solution To Parts Of
Mandatory Fall 2012

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

3 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

4 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

5 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

6

7 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){…}

8 Fig.1

9 <?xml version="1.0"?> <JourneyRegister> <Journey userName=“Harald“ phoneNumber=“ ”> <start> <Location latitude=“ ” longitude=“ ” time=“ ” /> </start> <passedLocations> <Location latitude=“ ” longitude=“ ” time=“ ” /> <Location latitude=“ ” longitude=“ ” time=“ ” /> </passedLocations> <end"> <Location latitude=“ ” longitude=“ ” time=“ ” /> </end> </Journey> <start> <Location latitude=“ ” longitude=“ ” time=“ ” /> <passedLocations> <Location latitude=“ ” longitude=“ ” time=“ ” /> <Location latitude=“ ” longitude=“ ” time=“ ” /> </JourneyRegister>

10 Table: Location Table: PhoneInfo Table: Journey 12345678 12345678
LocationId JourneyId latitude longitude time 11 1 12 1 13 1 14 1 15 2 Table: PhoneInfo 16 2 phoneNumber userName Harald 17 2 Table: Journey JourneyId phoneNumber start start 1 11 14 2 15 17

11 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 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))

12 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.

13 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.

14 «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

15 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.

16 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.

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

18 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.

19 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

20 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

21 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.

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

23 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

24 :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(), …)

25 «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

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


Download ppt "Proposed Solution To Parts Of"

Similar presentations


Ads by Google