Java Reference
In-Depth Information
data apparatus that is generating time-dependent data. We choose a software
simulation code for the example, but we could just as well use a software mock-
up of experimental data. For simplicity we refer to the data-generation source as
a simulation code rather than repeatedly mention that it could just as well be a
remote sensor device.
When choosing a simulation code to use for the demonstration, we must keep
in mind that we need the code to run long enough to permit demonstration of
the use of control data that modifies some parameters of the simulation as it
runs. If we choose a typical time-dependent calculation that exhibits transient
behavior, such as a simple heat-diffusion problem, a steady state is likely to
be reached much too quickly to demonstrate the time-dependent behavior of our
client/server design. Thus a problem whose solution is a periodic function of time
is more appropriate for demonstration purposes. A suitable simulation parameter
to be modified can be a time constant that modifies the frequency of the periodic
solution.
With these concepts in mind, we choose a simple harmonic motion example -
a mass m on a perfect, frictionless spring with spring constant k set in motion
with an initial amplitude A .Wedefine the coordinate system with x
=
0atthe
center of the motion - so the mass m oscillates between x
=+
A and
A . This is
a simple first-year physics problem with the following solutions:
position x = A sin ( ω t )
velocity v = d x / d t = ω A cos ( ω t )
acceleration a = d v/ d t =− ω
2 A sin ( ω t )
1 / 2 m v
2
kinetic energy K
=
1 / 2 kx 2
potential energy p =
where
m .
While not very interesting as a numerical example, this choice has the advan-
tage that it is very easy to calculate - so easy, in fact, that we have to build in
a delay on the server side to approximate what would happen in a truly com-
plex simulation. At least the numerics of this example will not get in the way
of explaining the client/server implementation. A control parameter to be varied
could be the mass or spring constant or, equivalently, the frequency
ω
2
=
k
/
.Ifwe
were to plot the position as a function of time, the plot would be a simple sine
curve with amplitude A and period T
ω
we would
see the shape of the curve change to a sine curve with increased or decreased
period.
We describe the implementation of this example in four phases. First,
Section 20.3 describes the factory and server interfaces. Section 20.4 dis-
cusses the implementation of the factory interfaces while Section 20.5 describes
the
=
2
π/ω
.Ifwethen changed
ω
server
implementation.
Finally,
the
client
implementation
is
built
in
Section 20.6.
Search WWH ::




Custom Search