SE-555 A4: GPS Position Observer
Posted blgpython
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SE-555 A4: GPS Position Observer相关的知识,希望对你有一定的参考价值。
SE-555 A4: GPS Position Observer
In this assignment, you will implement the Observer pattern in a multi-threaded
application that receives notifications of position updates from a (simulated) GPS
device.
Assignment Overview
When you start your application, it should prompt the user for the name of a file
containing GPS data (see the Resources section below for sample files). After the
prompt, your application must create some Observers that attach to the GPS
data server - the Subject. The specific function of the Observers - and the format
of the data they display - will be specified by your instructor. In any case, when
the Observers attach to the GPS data server, they change their displays
whenever the Subject performs an update().
In the observers illustrated above, the latitude/longitude and elevation
Observers are capable of subscribing and de-subscribing from the Subject via
the button UI. The plotter Observer attaches to the Subject on startup in this
example, but you may add the ability to subscribe and de-subscribe if you wish.
Assignment Details
The following class diagram illustrates the classes and interfaces that implement
this application. Consider it as a general guideline for the structure of the
application. You may depart from it in the details of the implementation of the
concrete observer classes and GPSCoordinate class, but you must define and
implement the Subject and Observer interfaces shown. If you feel you
need to make major changes to this design, consult your instructor first.
As a Subject, your implementation of GPSServer must be capable of accepting
subscriptions from multiple Observers.
代写SE-555 A4作业、代做GPS Position作业、代写java实验作业
The following sequence diagram illustrates the GPSClient creating a GPSServer
(the Subject) and three Observers: ElevationObserver, PositionObserver, and
PositionPlotter. After creating GPSServer, the GPSClient starts the GPServer.
Internally, the GPSServer starts a secondary thread that periodically generates
GPS data (simulated by reading it from a specified file). At the beginning, the
PositionPlotter observer immediately subscribes to the GPSServer. At some later
point, the user of the GPSClient application directs (via GUI interaction) the
ElevationObserver and PositionObserver to subscribe (attach) to the GPSServer.
Subsequent GPS data that is generated is propagated back to all subscribed
Observers when the GPSServer internally calls notifyObservers(), which in turn
iterates through the collection of Observers, calling each Observers‘s update()
method (on the secondary thread). In response, each Observer updates it‘s
current specific display of GPS data. Because UI updates cannot be invoked
on any thread except the UI thread, the Observers have to use the
SwingUtilities.invokeLater() method to invoke Swing methods.
You may also want to browse through the javadoc (javadoc.zip click on
index.html) corresponding to the methods in the classes above.
Files and resources
The GPS data files and GPSCoordinate.java can be downloaded from canvas (A4
folder).
To read data from the file, you might want to use some of the following code:
doubleReader = new Scanner(gpsFile);
// one or more occurrences of commas, semicolons or whitespace
doubleReader.useDelimiter("[,;\s]+");
while( doubleReader.hasNextDouble() ) {// read each double
recordNo++;
Thread.sleep( DELAY ); //simulate delays between generation of coordinates
double longitude = doubleReader.nextDouble();
double latitude = doubleReader.nextDouble();
double elev = doubleReader.nextDouble();
GPSCoordinate c = new GPSCoordinate(longitude, latitude, elev );
System.out.printf("%4d Lat: %10.6f, Long: %10.6f, El: %8.3f
", recordNo, latitude,
longitude, elev );
}
Submission (DUE Thursday 5 pm)
(Note that you do NOT need to actually plot the positions --- a simple
print message with coordinates values is enough)
In addition to code, you are also required to create (using Enterprise Architect),
a reverse-engineered UML Class diagram of your individual solution. Save the
class diagram in a .pdf file and include it in your submission along with your
.java files.
When submitting your work, submit one zip folder per group containing ONLY:
the “src” folder of your eclipse project, and the .pdf file on your reverseengineered
UML class diagram.
因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:[email protected]
微信:codinghelp
以上是关于SE-555 A4: GPS Position Observer的主要内容,如果未能解决你的问题,请参考以下文章
基于SE555定时器时钟输出信号方案设计(基本原理输出信号频率设计与实际不符合的解决)