Events arrive at an entity in a call to the entity's Time handleEvents(EventList el, Time t) method. The event list is a vector of events in increasing time order, and may include events later than the time t to advance to. Example code to traverse this list is:-
Time handleEvents(EventList el, Time t) { for (int i=0; i < el.size(); i++) { Event ev = el.elementAt(i); Time evtime = ev.getTime(); ClassID evclass = ev.getClassID(); Connection c = ev.getConnection(); } }
The basic event includes a timestamp, a class identifier and the connection it arrived on. The connection includes which input port, source entity handle and output port, and also a connection id which is unique for this entity.
Connection c = ev.getConnection(); EntityID deste = c.getDstEntityID(); PortID destport = c.getDstPortID(); ConnectionID destc = c.getConnectionID(); EntityID srce = c.getSrcEntityID(); PortID srcport = c.getSrcPortID(); Time delay = c.getDelay();
Some events (e.g. spikes) are binary affairs - it is just necessary to know the time that an event occurred. The code to handle one could look like:
Event ev = el.elementAt(i); PortID p = ev.getConnection().getDstPortID(); Time evtime = ev.getTime(); // deal with an event on p at evtime
Other events may include complex information, e.g. a Morphology. The integer class identifier of the event is available by calling the getClassID() method, e.g. an entity which receives morphologies and spikes:
ClassID morphologyEventID = NeosimClasses.getClassFromName("MorphologyEvent"); ClassID spikeEventID = NeosimClasses.getClassFromName("SpikeEvent"); ClassID evclass = ev.getClassID(); switch (evclass) { case morphologyEventID : // got a morphology event case spikeEventID : // got a spike event // ... }