Java Reference
In-Depth Information
The execution model is not pre-emptive. Every new command is inserted
in a command list. The device thread extracts commands from this list one
at a time. Only special commands (e.g. STOP ) are executed immediately and
cause the interruption of other commands.
Decision point
Do the robot's devices need to synchronize their activities?
The mobile platform and the sensors share a reference to the robot's
current position. The platform modifies the robot position (the x , y coordi-
nates and the direction), while the sensors use its value to simulate distance
measurements. This is a typical one-writer
multiple-readers situation that
requires synchronized access to the shared resource: when the platform is
updating the current position no sensor should be allowed to read the po-
sition; all the sensors should be allowed to read the position simultaneously
after it has been updated.
It might happen that the platform needs to update the robot position while
the sensors are reading the old value. We choose the simplest solution that
forces the platform to wait for the sensors to complete their reading opera-
tion. This might cause a random delay between two consecutive movement
steps of the mobile platform. Since position updating requires writing the
values of three primitive variables, we decide not to worry about this
Decision point
How does the remote controller request services from the robot and get the
result of a task?
Every device behaves as an autonomous slave component that offers
services on demand. Thus class Device implements two methods for receiv-
ing commands from the master and for writing out the result. The current
prototype does not deal with the synchronization between robot and
controller. Thus, for simplicity, every device prints the result of a task on the
standard output using method writeOut() .
Since the robot's devices are encapsulated within the robot's shell, the
remote controller is not allowed to access the device's services directly.
Thus the remote controller submits commands to the robot according to the
following format:
<device name>.<command><parameter>
For example, the remote controller requests platform “P1” to move
forward sending the command:
Search WWH ::

Custom Search