Interface Agent
- All Superinterfaces:
ModelEntity
- All Known Subinterfaces:
Visitor
- All Known Implementing Classes:
BasicAgent
,Cell
,DynamicElevator
,DynamicVisitor
,InstrumentationDecorator
,RoutingAgent
,SimpleAgent
,StaticElevator
,StaticVisitor
Agents should implement a strategy within their doEvent
method and
provide the scheduler with the time of next event (tone). Data
should be stored separately within the agent's state. Agents are always
embedded within a Domain
for compartmentalization of the model.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic final class
Exception to be thrown if the current event is unknown.Nested classes/interfaces inherited from interface org.simplesim.model.ModelEntity
ModelEntity.PortConnectionException, ModelEntity.PortOperationException, ModelEntity.UniqueConstraintViolationException
-
Field Summary
Fields inherited from interface org.simplesim.model.ModelEntity
ROOT_LEVEL
-
Method Summary
Modifier and TypeMethodDescriptionCalculates new outputs from the available inputs and implements the agent's strategy.<S extends State>
SgetState()
Returns the agent's state containing all internal variablesReturns the time of the next event (tone).default void
log
(PrintStream stream, String msg) Provides simple logging functionality to a stream - only message output.default void
log
(PrintStream stream, Time time, String msg) Provides simple logging functionality to a stream with time stamp, entity name and message output.default void
Provides simple logging functionality to System.out - only message output.default void
Provides simple logging functionality to System.out with time stamp, entity name and message output.Methods inherited from interface org.simplesim.model.ModelEntity
addToDomain, getAddress, getFullName, getInport, getLevel, getName, getOutport, getParent, removeFromDomain
-
Method Details
-
getState
Returns the agent's state containing all internal variables- Returns:
- the agent's internal state
-
getTimeOfNextEvent
Time getTimeOfNextEvent()Returns the time of the next event (tone).This method is called by the simulator to update the global event queue.
- Returns:
- time of the next event
-
doEvent
Calculates new outputs from the available inputs and implements the agent's strategy.This method is called by the simulator every time this agent is scheduled as an event in the global event queue. Outputs are basically massages that have to be put onto the outport of this agent. It should implement the general strategy of the agent and will acquire the actual simulation time from the simulator.
This method is supposed to do the following steps:
- read the messages from the inports
- modify the agent's state
- compute output and write messages to other entities to the outports
- add events to the internal event queue if necessary
- return the time of the next local event (=next time to call this method)
Do not invoke from outside the simulation loop!
- Parameters:
time
- current simulation time- Returns:
- tone - time of next event
-
log
Provides simple logging functionality to a stream with time stamp, entity name and message output.Can be used to redirect output to a log file. May be overloaded by a more sophisticated implementation.
- Parameters:
stream
- stream to be used as outputtime
- current time stampmsg
- message to print
-
log
Provides simple logging functionality to a stream - only message output.Can be used to redirect output to a log file. May be overloaded by a more sophisticated implementation.
- Parameters:
stream
- stream to be used as outputmsg
- message to print
-
log
Provides simple logging functionality to System.out with time stamp, entity name and message output.Can be used to redirect output to a log file. May be overloaded by a more sophisticated implementation.
- Parameters:
time
- current time stampmsg
- message to print
-
log
Provides simple logging functionality to System.out - only message output.Can be used to redirect output to a log file. May be overloaded by a more sophisticated implementation.
- Parameters:
msg
- message to print
-