Class InstrumentationDecorator<S extends State,E>
- All Implemented Interfaces:
Agent,ModelEntity
The decorator adds listeners to the doEvent method, so that the
agent's state can be queried before and after the execution of the agent's
strategy. This enables snapshots for data time series and debugging.
The agent's state should considered as read only.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.simplesim.model.Agent
Agent.UnknownEventTypeNested 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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToDomain(BasicDomain domain) Adds this entity to a domain.Calculates new outputs from the available inputs and implements the agent's strategy.int[]Gets the entity address.Returns the full name of a model, concatenating the names of the parent entities.intgetLevel()Returns the level of the entity within the model hierarchygetName()Returns the name of this model entityReturns the parent domain of this model entity.getState()Returns the agent's state containing all internal variablesReturns the time of the next internal event.voidregisterAfterExecutionListener(Listener<BasicAgent<?, ?>> listener) voidregisterBeforeExecutionListener(Listener<BasicAgent<?, ?>> listener) voidRemoves this entity form its parent domain.voidunregisterAfterExecutionListener(Listener<BasicAgent<?, ?>> listener) voidunregisterBeforeExecutionListener(Listener<BasicAgent<?, ?>> listener) Methods inherited from class org.simplesim.model.BasicAgent
isSimulationRunning, pollModelChangeRequest, toggleSimulationIsRunningMethods inherited from class org.simplesim.model.BasicModelEntity
equals, toString
-
Constructor Details
-
InstrumentationDecorator
-
-
Method Details
-
registerBeforeExecutionListener
-
unregisterBeforeExecutionListener
-
registerAfterExecutionListener
-
unregisterAfterExecutionListener
-
addToDomain
Description copied from interface:ModelEntityAdds this entity to a domain.The domain becomes the parent of this entity.
Note: Connection management has to be done externally by the caller!
- Specified by:
addToDomainin interfaceModelEntity- Overrides:
addToDomainin classBasicModelEntity
-
removeFromDomain
public void removeFromDomain()Description copied from interface:ModelEntityRemoves this entity form its parent domain.This method should never be called during a simulation cycle. If the entity could be removed from the domain, the entity's parent is set to null.
Note: Connection management has to be done externally by the caller.
- Specified by:
removeFromDomainin interfaceModelEntity- Overrides:
removeFromDomainin classBasicModelEntity
-
doEvent
Description copied from interface:AgentCalculates 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
-
getState
Description copied from interface:AgentReturns the agent's state containing all internal variables -
getTimeOfNextEvent
Description copied from class:BasicAgentReturns the time of the next internal event.This method is called by the simulator to update the global event queue.
- Specified by:
getTimeOfNextEventin interfaceAgent- Overrides:
getTimeOfNextEventin classBasicAgent<S extends State,E> - Returns:
- time of the next internal event
-
getName
Description copied from interface:ModelEntityReturns the name of this model entityReturns an empty string as default, may be overridden in derived classes.
- Specified by:
getNamein interfaceModelEntity- Overrides:
getNamein classBasicModelEntity- Returns:
- the name of this model entity, may be an empty string but not null
-
getFullName
Description copied from interface:ModelEntityReturns the full name of a model, concatenating the names of the parent entities.Example: If A and B are parents of this entity and this entity is named C, then the full name is A.B.C
- Specified by:
getFullNamein interfaceModelEntity- Overrides:
getFullNamein classBasicModelEntity- Returns:
- the full name of this entity
-
getParent
Description copied from interface:ModelEntityReturns the parent domain of this model entity.- Specified by:
getParentin interfaceModelEntity- Overrides:
getParentin classBasicModelEntity- Returns:
- the parent of this model
-
getAddress
public int[] getAddress()Description copied from interface:ModelEntityGets the entity address. Can be null.Note: The address of the root domain is
int[0]. Another dimension is added per model level. The value of each dimension is the index within the corresponding level.- Specified by:
getAddressin interfaceModelEntity- Overrides:
getAddressin classBasicModelEntity- Returns:
- the address
-
getInport
- Specified by:
getInportin interfaceModelEntity- Overrides:
getInportin classBasicModelEntity
-
getOutport
- Specified by:
getOutportin interfaceModelEntity- Overrides:
getOutportin classBasicModelEntity
-
getLevel
public int getLevel()Description copied from interface:ModelEntityReturns the level of the entity within the model hierarchyModels may be organized in a hierarchy, so that each entity resides in a definite domain level of the model tree. The level information is generated when the getLevel() method is called first. The level of the root node is always 0.
- Specified by:
getLevelin interfaceModelEntity- Overrides:
getLevelin classBasicModelEntity- Returns:
- the level of this entity in the model hierarchy
-