From: Peter H.M. J. <p.h...@tb...> - 2004-10-13 14:46:18
|
Hi Dirk, Step 1: make sure youre vehicle implements the EventListenerInterface Step 2: crane.addListener(someVehicule,CONTAINER_RELEASED_EVENT); Now your vehicule is subscribed to the CONTAINER_RELEASED_EVENTS. More on the addListener method is described in http://www.simulation.tudelft.nl/dsol/event/apidocs/nl/tudelft/simulation/ev ent/EventProducer.html Does this solve your question? Peter -----Original Message----- From: dso...@li... [mailto:dso...@li...] On Behalf Of Dirk Samson Sent: Wednesday, October 13, 2004 3:11 PM To: dso...@li... Subject: [Dsol-java] how to listen to fireEvent? Dear all, I've made a "crane" that delivers "containers" every 1..5 timeunits. These containers should be picked up by several "someVehicles". I would like to have my crane fire an event, CONTAINER_RELEASED_EVENT. The code for this I found in the tutorial, section 4.2: ... public class QuayCrane extends EventProducer { public static final EventType CONTAINER_RELEASED_EVENT = new EventType( "CONTAINER_RELEASED_EVENT"); ... private void releaseContainer () { ... this.fireEvent(CONTAINER_RELEASED_EVENT, this.simulator.getSimulatorTime()); ... } } // end class My question: How do I get an instance of my someVehicle to listen to this event? The events in the tutorial are (so it seems) only used by the Tallies. For this moment I;m not interested in the prioritization of my someVehicles; I just want them to respond. Is this the proper mechanism to create interaction between objects in the simulation?? Dirk Samson (PS My very-first-test-project can be found on the CVS Server: "SPM9322 - port") ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl _______________________________________________ Dsol-java mailing list Dso...@li... https://lists.sourceforge.net/lists/listinfo/dsol-java |