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.UnknownEventType
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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addToDomain
(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.int
getLevel()
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.void
registerAfterExecutionListener
(Listener<BasicAgent<?, ?>> listener) void
registerBeforeExecutionListener
(Listener<BasicAgent<?, ?>> listener) void
Removes this entity form its parent domain.void
unregisterAfterExecutionListener
(Listener<BasicAgent<?, ?>> listener) void
unregisterBeforeExecutionListener
(Listener<BasicAgent<?, ?>> listener) Methods inherited from class org.simplesim.model.BasicAgent
isSimulationRunning, pollModelChangeRequest, toggleSimulationIsRunning
Methods inherited from class org.simplesim.model.BasicModelEntity
equals, toString
-
Constructor Details
-
InstrumentationDecorator
-
-
Method Details
-
registerBeforeExecutionListener
-
unregisterBeforeExecutionListener
-
registerAfterExecutionListener
-
unregisterAfterExecutionListener
-
addToDomain
Description copied from interface:ModelEntity
Adds 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:
addToDomain
in interfaceModelEntity
- Overrides:
addToDomain
in classBasicModelEntity
-
removeFromDomain
public void removeFromDomain()Description copied from interface:ModelEntity
Removes 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:
removeFromDomain
in interfaceModelEntity
- Overrides:
removeFromDomain
in classBasicModelEntity
-
doEvent
Description copied from interface:Agent
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
-
getState
Description copied from interface:Agent
Returns the agent's state containing all internal variables -
getTimeOfNextEvent
Description copied from class:BasicAgent
Returns the time of the next internal event.This method is called by the simulator to update the global event queue.
- Specified by:
getTimeOfNextEvent
in interfaceAgent
- Overrides:
getTimeOfNextEvent
in classBasicAgent<S extends State,
E> - Returns:
- time of the next internal event
-
getName
Description copied from interface:ModelEntity
Returns the name of this model entityReturns an empty string as default, may be overridden in derived classes.
- Specified by:
getName
in interfaceModelEntity
- Overrides:
getName
in classBasicModelEntity
- Returns:
- the name of this model entity, may be an empty string but not null
-
getFullName
Description copied from interface:ModelEntity
Returns 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:
getFullName
in interfaceModelEntity
- Overrides:
getFullName
in classBasicModelEntity
- Returns:
- the full name of this entity
-
getParent
Description copied from interface:ModelEntity
Returns the parent domain of this model entity.- Specified by:
getParent
in interfaceModelEntity
- Overrides:
getParent
in classBasicModelEntity
- Returns:
- the parent of this model
-
getAddress
public int[] getAddress()Description copied from interface:ModelEntity
Gets 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:
getAddress
in interfaceModelEntity
- Overrides:
getAddress
in classBasicModelEntity
- Returns:
- the address
-
getInport
- Specified by:
getInport
in interfaceModelEntity
- Overrides:
getInport
in classBasicModelEntity
-
getOutport
- Specified by:
getOutport
in interfaceModelEntity
- Overrides:
getOutport
in classBasicModelEntity
-
getLevel
public int getLevel()Description copied from interface:ModelEntity
Returns 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:
getLevel
in interfaceModelEntity
- Overrides:
getLevel
in classBasicModelEntity
- Returns:
- the level of this entity in the model hierarchy
-