Java Reference
In-Depth Information
Class DiscreteEvent is the basic component of the architecture. It implements
the Comparable interface in order to define a natural sorting criterion for
event objects. The clock's list of events will use the compareTo() method to
insert event objects in their ordered position.
package workcell;
public class DiscreteEvent implements Comparable {
String name; // the name of the event
long raiseTime; // the absolut raise time
Object value; // the data associated to the event
String ownerName; // the process that activates this
// event
public DiscreteEvent(String name, long raiseTime,
String ownerName, Object value){
this .name # name;
this .raiseTime # raiseTime;
this .ownerName # ownerName;
this .value # value;
public int compareTo(Object obj) {
if ( this .raiseTime < ((DiscreteEvent) obj).raiseTime)
return -1;
if ( this .raiseTime > ((DiscreteEvent) obj).raiseTime)
return 1;
return 0;
Class DiscreteProcess is the parent class of every sequential process. It is
abstract since every subclass needs to redefine the notifyEvent() method that
implements the specific finite state automaton. The attachTo() method regis-
ters this instance of DiscreteProcess in the clock's subscription list. The
activateEvent() method creates inserts a new instance of DiscreteEvent in the
clock's list of active events.
package workcell;
public abstract class DiscreteProcess {
String name; // the name of this process
DiscreteClock clock; // a reference to the global clock
public DiscreteProcess(String name, DiscreteClock clock) {
this .name # name;
this .clock # clock;
public void attachTo(String eventName,
DiscreteProcess publisher) {
clock.subscribe( this , eventName, publisher);
Search WWH ::

Custom Search