neosim.implementation
Class EntityImpl

java.lang.Object
  |
  +--neosim.implementation.EntityImpl
Direct Known Subclasses:
Entity3D

public class EntityImpl
extends java.lang.Object
implements Entity

See Also:
Serialized Form

Constructor Summary
EntityImpl(EntityClass ec, Population p, int index)
          Make an entity of population p, class ec
 
Method Summary
 ConnectionID addInConnection(Connection c)
          Add an input connection
 PortID addInPort(EventClass ec)
          Add an input port
 PortID addInPort(java.util.Vector vec)
          Add an input port
 void addOutConnection(PortID outport, Time delay, EntityID dest, PortID destinport)
          Add an output connection from an output port to a given dest
 PortID addOutPort(EventClass ec)
          Add an output port
 PortID addOutPort(java.util.Vector vec)
          Add an output port
 int compareTo(java.lang.Object o)
          Compare two "Entity" objects based on Right Window Times
 void connect(Time t, Projection p, Callback c)
          Make connections at a given time
 void construct(Time t, PopulationBuilder p, Callback c)
          Build a population at a given time
 void defaultEventHandler(Event e)
          This method deals with built in events, used for querying and updating entity state.
 void deleteInConnection(ConnectionID cid)
          Delete an input connection
 void deleteInPort(PortID inport)
          Delete an input port
 void deleteOutConnection(PortID outport, EntityID dest, PortID destinport)
           
 void deleteOutPort(PortID outport)
          Delete an output port
 void destroy()
          This method is called when the entity is deleted.
 void destroy(Time t, Population p, Callback c)
          Destroy a population at a given time.
 void disconnect(Time t, Projection p, Callback c)
          Delete connections at a given time
 java.util.Vector getClassesOfInPort(PortID pid)
          Return the classes of events accepted by an input port
 java.util.Vector getClassesOfOutPort(PortID pid)
          Return the classes of events produced by an output port
 EntityClass getEntityClass()
           
 EventList getEventList()
          Get EventList
 EntityID getID()
           
 java.util.Vector getInConnections(PortID inport)
          Return the input connections to a port
 int getIndex()
           
 Time getLocalTime()
          Get the current local time
 Time getMinOutputDelay()
          Get the minimum output delay
 java.lang.String getName()
           
 NeosimClasses getNeosimClasses()
          Return the set of user defined classes.
 int getNumInConnections(PortID inport)
          Return the number of input connections on a port
 int getNumInPorts()
           
 int getNumOutConnections(PortID outport)
          Return the number of output connections from a port
 int getNumOutPorts()
           
 neosim.kernel.OutPortTable getOutConnection(PortID outport)
           
 Population getPopulation()
           
 PopulationTree getPopulationTree(Time t)
          Return the top level population tree.
 Time getRightWindowTime()
          Get the right window time
 Time handleEvents(EventList el, Time t)
          User entities MUST extend this method : deal with events in el up to time t, and advance the entity's time to at least t and return the time actually advanced to (which may be later than t, as long as the state can be rewound back to t and no new events are generated after t).
 void init(Population p, int index)
          User entities can extend this method
 EntityClass lookupEntityClass(java.lang.String name)
          Look up an EntityClass object given a name, e.g.
 EntityID lookupEntityID(Time t, java.lang.String name)
          Look up an Entity handle given a name, e.g.
 Population lookupPopulation(Time t, java.lang.String name)
          Look up a Population given a name, e.g.
 void postEvent(Event e)
          Post event, connection id is coded in event.
 void queryEntity(Time t, EntityID e, EntityQuery eq, Callback c)
          Query another entity at a given time
 void queryOutputConnections(Time t, PortID p, ConnectionQuery cq, Callback cb)
          Query output connections of a port
 void queryPopulation(Time t, Population p, EntityQuery eq, Callback c)
          Query a population of entities at a given time
 void reset()
          This method is called when simulation time is rest to zero.
 void resetOutputDelay()
          Set output delay to its previous value
 void sendEvent(EntityID deste, PortID destp, Event e)
          This method sends an event to input port p of entity e.
 void sendEvent(PortID c, Event e)
          This method sends an event on output port c.
 void setDstConnectionParams(Connection c, ConnectionID destcid, java.util.Hashtable params)
          Set additional connection parameters at dst end Called by ParamConnectionSpec.setDstParams User entities should override this to set their connection params
 void setID(EntityID h)
          Sets the handle of this entity.
 void setLocalTime(Time t)
          Set the current local time
 void setMinOutputDelay(Time t)
          Set the minimum output delay
 void setProvLocalTime(Time t)
          Set the provisional local time
 void setSrcConnectionParams(Connection c, PortID srcpid, java.util.Hashtable params)
          Set additional connection parameters at src end Called by ParamConnectionSpec.setSrcParams User entities should override this to set their connection params
 void trace(java.lang.String msg)
          Write a trace message
 void updateEntity(Time t, EntityID e, EntityUpdate eu, Callback c)
          Update another entity at a given time
 void updatePopulation(Time t, Population p, EntityUpdate eu, Callback c)
          Update a population of entities at a given time
 void zeroOutputDelay()
          Zero delay on system output port
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntityImpl

public EntityImpl(EntityClass ec,
                  Population p,
                  int index)
Make an entity of population p, class ec
Method Detail

init

public void init(Population p,
                 int index)
User entities can extend this method
Specified by:
init in interface Entity

getIndex

public int getIndex()
Specified by:
getIndex in interface Entity
Returns:
the index of this entity in its population/

handleEvents

public Time handleEvents(EventList el,
                         Time t)
User entities MUST extend this method : deal with events in el up to time t, and advance the entity's time to at least t and return the time actually advanced to (which may be later than t, as long as the state can be rewound back to t and no new events are generated after t). If the event type of incoming events is not recognised, the method defaultEventIDr() should be called.
Specified by:
handleEvents in interface Entity
Parameters:
el - The (possible empty) event list in time stamp order
t - The time to advance to
Returns:
the time actually advanced to (must be >= t)
See Also:
defaultEventHandler(neosim.iface.Event)

reset

public void reset()
This method is called when simulation time is rest to zero. User entities can extend this method to perform a local reset.
Specified by:
reset in interface Entity

destroy

public void destroy()
This method is called when the entity is deleted. User entities can extend this to remove any locally allocated storage.
Specified by:
destroy in interface Entity

sendEvent

public final void sendEvent(PortID c,
                            Event e)
This method sends an event on output port c.
Specified by:
sendEvent in interface Entity
Parameters:
c - The output port to send the event to.
e - The event to send. Its timestamp should be the sending time

sendEvent

public final void sendEvent(EntityID deste,
                            PortID destp,
                            Event e)
This method sends an event to input port p of entity e.
Specified by:
sendEvent in interface Entity
Parameters:
c - The output port to send the event from.
deste - The destination entity
destp - The destination input port
e - The event to send. Its timestamp should be the sending time

defaultEventHandler

public final void defaultEventHandler(Event e)
This method deals with built in events, used for querying and updating entity state.
Specified by:
defaultEventHandler in interface Entity
Parameters:
e - The event to handle

getPopulation

public final Population getPopulation()
Specified by:
getPopulation in interface Entity
Returns:
the population this entity was created in.

getEntityClass

public final EntityClass getEntityClass()
Specified by:
getEntityClass in interface Entity
Returns:
the class of this entity.

getID

public final EntityID getID()
Specified by:
getID in interface Entity
Returns:
the handle of this entity.

setID

public final void setID(EntityID h)
Sets the handle of this entity.
Parameters:
h - the new handle

getName

public final java.lang.String getName()
Specified by:
getName in interface Entity
Tags copied from interface: Entity
Returns:
the name pf this entity.

getPopulationTree

public final PopulationTree getPopulationTree(Time t)
Return the top level population tree.
Specified by:
getPopulationTree in interface Entity
Parameters:
t - the time of the request (needed as the population tree changes with time)
Returns:
the top level population tree

getNeosimClasses

public final NeosimClasses getNeosimClasses()
Return the set of user defined classes.
Specified by:
getNeosimClasses in interface Entity
Returns:
the set of user classes.

lookupEntityClass

public final EntityClass lookupEntityClass(java.lang.String name)
Look up an EntityClass object given a name, e.g. "CompartmentalEntity"
Specified by:
lookupEntityClass in interface Entity
Parameters:
name - The fully qualified name of the class
Returns:
the entity class, if found, or null if not.

lookupEntityID

public final EntityID lookupEntityID(Time t,
                                     java.lang.String name)
Look up an Entity handle given a name, e.g. "cortex.layer1.pyramidal1234"
Specified by:
lookupEntityID in interface Entity
Parameters:
t - The time of the request
name - The fully qualified name of the entity
Returns:
the entity handle, if found, or null if not.

lookupPopulation

public final Population lookupPopulation(Time t,
                                         java.lang.String name)
Look up a Population given a name, e.g. "cortex.layer1"
Specified by:
lookupPopulation in interface Entity
Parameters:
t - The time of the request
name - The fully qualified name of the population
Returns:
the population if found, or null if not.

construct

public final void construct(Time t,
                            PopulationBuilder p,
                            Callback c)
Build a population at a given time
Specified by:
construct in interface Entity
Parameters:
t - the time to build the population ( must be >= localTime() + getMinOutputDelay())
p - the population to build
c - the callback to call when the population has been built.

destroy

public final void destroy(Time t,
                          Population p,
                          Callback c)
Destroy a population at a given time. Calls every member's destroy() method.
Specified by:
destroy in interface Entity
Parameters:
t - the time to build the population ( must be >= localTime() + getMinOutputDelay())
p - the population to destroy
c - the callback to call when the population has been destroyed

connect

public final void connect(Time t,
                          Projection p,
                          Callback c)
Make connections at a given time
Specified by:
connect in interface Entity
Parameters:
t - the time to make the connections ( must be >= localTime() + getMinOutputDelay())
p - the projection to make
c - the callback to call when the connections have been made

disconnect

public final void disconnect(Time t,
                             Projection p,
                             Callback c)
Delete connections at a given time
Specified by:
disconnect in interface Entity
Parameters:
t - the time to delete the connections ( must be >= localTime() + getMinOutputDelay())
p - the population to destroy
c - the callback to call when the population has been destroyed

updateEntity

public final void updateEntity(Time t,
                               EntityID e,
                               EntityUpdate eu,
                               Callback c)
Update another entity at a given time
Specified by:
updateEntity in interface Entity
Parameters:
t - the time to update the entity ( must be >= localTime() + getMinOutputDelay())
e - the handle of the entity to update
eu - the update to perform
c - the callback to call when the update has been done

queryEntity

public final void queryEntity(Time t,
                              EntityID e,
                              EntityQuery eq,
                              Callback c)
Query another entity at a given time
Specified by:
queryEntity in interface Entity
Parameters:
t - the time to query the entity ( must be >= localTime() + getMinOutputDelay())
e - the handle of the entity to query
eq - the query to perform
c - the callback to call with the results of the query

updatePopulation

public final void updatePopulation(Time t,
                                   Population p,
                                   EntityUpdate eu,
                                   Callback c)
Update a population of entities at a given time
Specified by:
updatePopulation in interface Entity
Parameters:
t - the time to update the entity ( must be >= localTime() + getMinOutputDelay())
p - the population to update
eu - the update to perform
c - the callback to call when the update has been done

queryPopulation

public final void queryPopulation(Time t,
                                  Population p,
                                  EntityQuery eq,
                                  Callback c)
Query a population of entities at a given time
Specified by:
queryPopulation in interface Entity
Parameters:
t - the time to query the population( must be >= localTime() + getMinOutputDelay())
p - the population to query
eq - the query to perform
c - the callback to call with the results of the query. The results will be in the form of a vector of objects, indexed by entties' index in the population.

queryOutputConnections

public final void queryOutputConnections(Time t,
                                         PortID p,
                                         ConnectionQuery cq,
                                         Callback cb)
Description copied from interface: Entity
Query output connections of a port
Specified by:
queryOutputConnections in interface Entity
Tags copied from interface: Entity
Parameters:
t - the time to query the connections( must be >= localTime() + getMinOutputDelay())
p - the output port
cq - the query to run on each output connection
c - the callback to call with the results of the query. The results will be in the form of a vector of objects, ordered by entity handle/input connection id.

addOutPort

public final PortID addOutPort(EventClass ec)
Add an output port
Specified by:
addOutPort in interface Entity
Parameters:
ec - the class of events the port generates
Returns:
the id of the output port (from 1..#output ports).

addOutPort

public final PortID addOutPort(java.util.Vector vec)
Add an output port
Specified by:
addOutPort in interface Entity
Parameters:
ec - the class of events the port generates
Returns:
the id of the output port (from 1..#output ports).

addInPort

public final PortID addInPort(EventClass ec)
Add an input port
Specified by:
addInPort in interface Entity
Parameters:
ec - the class of events the port accepts
Returns:
the id of the input port (from 1..#input ports).

addInPort

public final PortID addInPort(java.util.Vector vec)
Add an input port
Specified by:
addInPort in interface Entity
Parameters:
ec - the class of events the port accepts
Returns:
the id of the input port (from 1..#input ports).

getClassesOfInPort

public final java.util.Vector getClassesOfInPort(PortID pid)
Return the classes of events accepted by an input port
Specified by:
getClassesOfInPort in interface Entity
Parameters:
pid - the input port id
Returns:
the classes of events

getClassesOfOutPort

public final java.util.Vector getClassesOfOutPort(PortID pid)
Return the classes of events produced by an output port
Specified by:
getClassesOfOutPort in interface Entity
Parameters:
pid - the output port id
Returns:
the classes of events

getNumInConnections

public final int getNumInConnections(PortID inport)
Return the number of input connections on a port
Specified by:
getNumInConnections in interface Entity
Parameters:
inport - the input port id
Returns:
the number of connections

getNumOutConnections

public final int getNumOutConnections(PortID outport)
Return the number of output connections from a port
Specified by:
getNumOutConnections in interface Entity
Parameters:
outport - the output port id
Returns:
the number of connections

getOutConnection

public final neosim.kernel.OutPortTable getOutConnection(PortID outport)

getNumOutPorts

public final int getNumOutPorts()

getNumInPorts

public final int getNumInPorts()

getInConnections

public final java.util.Vector getInConnections(PortID inport)
Return the input connections to a port
Specified by:
getInConnections in interface Entity
Parameters:
outport - the output port id
Returns:
the number of connections

addOutConnection

public final void addOutConnection(PortID outport,
                                   Time delay,
                                   EntityID dest,
                                   PortID destinport)
Add an output connection from an output port to a given dest
Specified by:
addOutConnection in interface Entity
Parameters:
outport - the output port id
delay - the delay on the connection
dest - the destination entity
destinport - the destination port id

deleteOutConnection

public final void deleteOutConnection(PortID outport,
                                      EntityID dest,
                                      PortID destinport)
Specified by:
deleteOutConnection in interface Entity

addInConnection

public final ConnectionID addInConnection(Connection c)
Add an input connection
Specified by:
addInConnection in interface Entity
Parameters:
c - the input connection to add
Returns:
the connection id

deleteInConnection

public final void deleteInConnection(ConnectionID cid)
Delete an input connection
Specified by:
deleteInConnection in interface Entity
Parameters:
cid - the input connection to delete

setSrcConnectionParams

public void setSrcConnectionParams(Connection c,
                                   PortID srcpid,
                                   java.util.Hashtable params)
Set additional connection parameters at src end Called by ParamConnectionSpec.setSrcParams User entities should override this to set their connection params
Specified by:
setSrcConnectionParams in interface Entity
Parameters:
params - the table of name/value (strings)

setDstConnectionParams

public void setDstConnectionParams(Connection c,
                                   ConnectionID destcid,
                                   java.util.Hashtable params)
Set additional connection parameters at dst end Called by ParamConnectionSpec.setDstParams User entities should override this to set their connection params
Specified by:
setDstConnectionParams in interface Entity
Parameters:
params - the table of name/value (strings)

deleteInPort

public final void deleteInPort(PortID inport)
Delete an input port
Specified by:
deleteInPort in interface Entity
Parameters:
inport - the input port id

deleteOutPort

public final void deleteOutPort(PortID outport)
Delete an output port
Specified by:
deleteOutPort in interface Entity
Parameters:
inport - the input port id

zeroOutputDelay

public final void zeroOutputDelay()
Zero delay on system output port
Specified by:
zeroOutputDelay in interface Entity

resetOutputDelay

public void resetOutputDelay()
Set output delay to its previous value
Specified by:
resetOutputDelay in interface Entity

getMinOutputDelay

public Time getMinOutputDelay()
Get the minimum output delay
Specified by:
getMinOutputDelay in interface Entity

setMinOutputDelay

public void setMinOutputDelay(Time t)
Set the minimum output delay
Specified by:
setMinOutputDelay in interface Entity

getLocalTime

public Time getLocalTime()
Get the current local time
Specified by:
getLocalTime in interface Entity

setLocalTime

public void setLocalTime(Time t)
Set the current local time

setProvLocalTime

public void setProvLocalTime(Time t)
Set the provisional local time

getRightWindowTime

public Time getRightWindowTime()
Get the right window time
Specified by:
getRightWindowTime in interface Entity

getEventList

public EventList getEventList()
Get EventList
Specified by:
getEventList in interface Entity

postEvent

public void postEvent(Event e)
Post event, connection id is coded in event.

trace

public void trace(java.lang.String msg)
Description copied from interface: Entity
Write a trace message
Specified by:
trace in interface Entity

compareTo

public int compareTo(java.lang.Object o)
              throws java.lang.ClassCastException
Compare two "Entity" objects based on Right Window Times