Java Reference
In-Depth Information
Each process has a unique name that distinguishes it from the other
processes. The DiscreteEvent class records the name of the process that acti-
vated the event. This information is used to distinguish events that can be
raised by different processes but have the same name. For instance, the drill,
the cutter and the assembler all activate WORKDONE events, but the AGV is
listening only to those raised by the drill and the cutter.
In some cases the event name and the owner name are not enough to dis-
tinguish events. For example, the AGV raises the UNLOADED event when a
nut or a screw is unloaded from a machine. The drill and the cutter are lis-
tening to this event and they should be able to recognize when a piece is
unloaded from their output buffers. Thus the UNLOADED event carries the
information about the type of piece that has been unloaded.
Class Subscription records the association between the event name, the
publisher (the process that broadcasts the event) and the listener (the
process that is listening to the event). Before the simulation starts, processes
should subscribe to the events they are listening to. The clock maintains a
collection of event
listener subscriptions.
Every process implements a callback function that the clock invokes
when an event is raised. This function implements the finite state machine
that models the process behaviour. It determines which state transition
should be triggered when a given event is notified.
The clock implements an iterative procedure (see Figure 9.10) that
consists of three steps:
Whenever a process activates a new event, the clock re-schedules the list
of events.
It waits for the user's command to process the event with the shortest
time residue.
The clock notifies the event to all the subscribed processes (e.g. the
PieceSource itself).
PieceSource
DiscreteEvent
Subscription
DiscreteClock
activ ateEvent
new
wait
scheduleEvent
notifyEvent
notifyEvent
Figure 9.10 The iterative event activation notification cycle
 
Search WWH ::




Custom Search