Event Generation Next: Control Instruction Up: Event Based Instructions Previous: Event Based Instructions

Event Generation

The Generate  class extends Atom which means that event generation terminates instantaneously. Generating an event in a machine calls the machine newMove method to indicate that something new happens in the system; thus, instructions waiting for the event (see next 5.3) will have the possibility to see it as present during the current instant.

 
public class Generate extends Atom
{
  private String eventName;

  public Generate(String eventName){ 
    this.eventName = eventName; 
  }

  final public boolean equals(Instruction inst){
    return  super.equals(inst) && 
      eventName.equals(((Generate)inst).eventName);
  }

  final public String toString(){ 
    return "generate " + eventName; 
  }

  final protected void action(Machine machine){
    Event event = machine.getEvent(eventName);
    machine.newMove();
    event.generate(machine);
  }
}