public class BDIInterpreter
extends jadex.kernelbase.StatelessAbstractInterpreter
Modifier and Type | Field and Description |
---|---|
static Map |
interpreters
The interpreters, one per agent (ragent -> interpreter).
|
static jadex.rules.rulesystem.IRulebase |
RULEBASE
The (global) rulebase.
|
Constructor and Description |
---|
BDIInterpreter(IComponentDescription desc,
IComponentAdapterFactory factory,
jadex.rules.state.IOAVState state,
OAVAgentModel model,
String config,
Map<String,Object> arguments,
IExternalAccess parent,
RequiredServiceBinding[] bindings,
Map kernelprops,
boolean copy,
boolean realtime,
IIntermediateResultListener<Tuple2<String,Object>> resultlistener,
Future<Void> inited)
Create an agent interpreter for the given agent.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addArgument(String name,
Object value)
Add a default value for an argument (if not already present).
|
void |
addDefaultResult(String name,
Object value)
Add a default value for a result (if not already present).
|
void |
addExtension(String name,
IExtensionInstance ext)
Add an extension instance.
|
void |
addProperty(String name,
Object val)
Add a property value.
|
void |
afterBlock()
Called after unblocking the component thread.
|
void |
beforeBlock()
Called before blocking the component thread.
|
void |
cleanup()
Called when the agent is removed from the platform.
|
IFuture |
componentCreated(IComponentDescription desc,
IModelInfo model)
Called when a component has been created as a subcomponent of this component.
|
IFuture |
componentDestroyed(IComponentDescription desc)
Called when a subcomponent of this component has been destroyed.
|
IServiceContainer |
createServiceContainer()
Create the service container.
|
static Object |
createServiceImplementation(IBDIInternalAccess agent,
Class<?> type,
String[] methodnames,
String[] goalnames)
Create a wrapper service implementation based on
|
void |
endAtomic()
End an atomic transaction.
|
void |
endMonitorConsequences()
Checks if consequences have been produced and
interrupts the executing plan accordingly.
|
boolean |
executeStep()
Main method to perform agent execution.
|
String |
findServicePrefix(Object scope)
The prefix is the name of the capability starting from the agent.
|
boolean |
findSubcapability(Object rcapa,
Object targetcapa,
List path)
Find the path to a subcapability.
|
Object |
getAgent()
Get the agent instance reference.
|
IComponentAdapter |
getAgentAdapter()
Get the adapter agent.
|
Map<String,Object> |
getArguments()
Get the arguments.
|
RequiredServiceBinding[] |
getBindings()
Get the bindings.
|
ClassLoader |
getClassLoader()
Get the class loader of the agent.
|
IClockService |
getClockService()
Get the cached clock service.
|
IComponentManagementService |
getCMS()
Get the cached component management service.
|
IComponentAdapter |
getComponentAdapter()
Get the component adapter.
|
String |
getConfiguration()
Get the configuration.
|
Object |
getCurrentPlan()
Get the currently executed plan.
|
List<IMonitoringEvent> |
getCurrentStateEvents()
Generate added events for the current goals
|
void |
getCurrentStateEvents(IInternalAccess ia,
jadex.rules.state.IOAVState state,
Object capa,
List<IMonitoringEvent> events)
Generate added events for the current goals
|
EventReificator |
getEventReificator()
Get the event reificator for generating change events.
|
IExtensionInstance |
getExtension(String name)
Get a space of the application.
|
IExtensionInstance[] |
getExtensions()
Get a space of the application.
|
IExternalAccess |
getExternalAccess()
Get the external access for this agent.
|
IValueFetcher |
getFetcher()
Get the value fetcher.
|
Object |
getFlyweightCache(Class type,
Object key)
Get an element from the cache.
|
IInternalAccess |
getInternalAccess()
Get the internal access.
|
IInternalAccess |
getInternalAccess(Object scope)
Get the internal access.
|
static BDIInterpreter |
getInterpreter(jadex.rules.state.IOAVState state)
Get the interpreter for an agent object.
|
Map |
getKernelProperties()
Get the kernel properties.
|
Logger |
getLogger(Object rcapa)
Get the logger.
|
IMessageService |
getMessageService()
Get the cached message service.
|
IModelInfo |
getModel()
Get the model info.
|
IModelInfo |
getModel(Object rcapa)
Get the model info of a capability
|
ServiceGetter<IMonitoringService> |
getMonitoringServiceGetter()
Get the monitoring service getter.
|
IExternalAccess |
getParent()
Get the parent of the agent.
|
IPlanExecutor |
getPlanExecutor(Object rplan)
Get a plan executor by name.
|
Map |
getProperties()
Get the properties.
|
Map |
getProperties(Object rcapa)
Get the properties for a subcapability.
|
IMonitoringService.PublishEventLevel |
getPublishEmitLevelMonitoring()
Get the monitoring event emit level.
|
IMonitoringService.PublishEventLevel |
getPublishEmitLevelSubscriptions()
Get the monitoring event emit level for subscriptions.
|
INFMixedPropertyProvider |
getRequiredServicePropertyProvider(IServiceIdentifier sid)
Get the required service property provider for a service.
|
Map<String,Object> |
getResults()
Get the results of the component (considering it as a functionality).
|
jadex.rules.rulesystem.RuleSystem |
getRuleSystem()
Get the rule system.
|
IServiceContainer |
getServiceContainer()
Create the service container.
|
String |
getServicePrefix()
Get the service prefix.
|
jadex.rules.state.IOAVState |
getState()
Get the agent state.
|
boolean |
hasEventTargets(IMonitoringService.PublishTarget pt,
IMonitoringService.PublishEventLevel pi)
Check if event targets exist.
|
boolean |
hasRequiredServicePropertyProvider(IServiceIdentifier sid)
Has the service a property provider.
|
IFuture |
init(IModelInfo model,
String config)
Extended init procedure including subcapabilities.
|
IFuture |
initArguments(IModelInfo model,
String config,
Map arguments)
Init the arguments and results.
|
IFuture |
initProvidedServices(IModelInfo model,
String config)
Overridden to init BDI internals before services.
|
void |
invokeSynchronized(Runnable code)
Invoke some code with agent behaviour synchronized on the agent.
|
boolean |
isAtBreakpoint(String[] breakpoints)
Test if the component's execution is currently at one of the
given breakpoints.
|
boolean |
isAtomic()
Check if atomic state is enabled.
|
boolean |
isCopy()
Get the copy.
|
boolean |
isExternalThread()
Check if the external thread is accessing.
|
boolean |
isPlanThread()
Check if the agent thread is accessing.
|
boolean |
isRealtime()
Get the realtime.
|
void |
messageArrived(IMessageAdapter message)
Inform the agent that a message has arrived.
|
void |
publishLocalEvent(IMonitoringEvent event)
Forward event to all currently registered subscribers.
|
void |
putFlyweightCache(Class type,
Object key,
Object flyweight)
Put an element into the cache.
|
IFuture |
scheduleImmediate(IComponentStep step,
Object scope)
Execute some code on the component's thread.
|
<T> IFuture<T> |
scheduleStep(IComponentStep<T> step)
Schedule a step of the component.
|
<T> IFuture<T> |
scheduleStep(Object step,
Object scope)
Schedule a step of the agent.
|
void |
setPlanThread(Thread planthread)
Set the current plan thread.
|
void |
setResultValue(String name,
Object value)
Set a result value.
|
void |
startAtomic()
Start an atomic transaction.
|
void |
startBehavior()
Start the component behavior.
|
IFuture<Void> |
startEndSteps()
Request agent to kill itself.
|
void |
startMonitorConsequences()
Start monitoring the consequences.
|
IFuture |
startServiceContainer()
Start the services.
|
void |
streamArrived(IConnection con)
Inform the agent that a message has arrived.
|
ISubscriptionIntermediateFuture<IMonitoringEvent> |
subscribeToEvents(IFilter<IMonitoringEvent> filter,
boolean initial,
IMonitoringService.PublishEventLevel emitlevel)
Subscribe to monitoring events.
|
addService, cleanupComponent, createChild, createComponent, createInternalService, createResultListener, createResultListener, getArguments, getChildren, getComponentDescription, getComponentFilename, getComponentIdentifier, getLocalType, getLogger, getName, getName, getNumber, getProperty, getRawService, getRawService, getRawServices, getServiceProvider, init, initComponents, initExtension, initExtensions, initFutureProperties, initRequiredServices, isComponentThread, killComponent, publishEvent, publishEvent, startInitialSteps, terminateExtensions, terminateServiceContainer, toString, waitForDelay, waitForDelay, waitForDelay, waitForDelay
addNFProperty, getNFAllPropertyNames, getNFPropertyMetaInfo, getNFPropertyMetaInfos, getNFPropertyNames, getNFPropertyValue, getNFPropertyValue, removeNFProperty, setParent, shutdownNFPropertyProvider
public static final Map interpreters
public static final jadex.rules.rulesystem.IRulebase RULEBASE
public BDIInterpreter(IComponentDescription desc, IComponentAdapterFactory factory, jadex.rules.state.IOAVState state, OAVAgentModel model, String config, Map<String,Object> arguments, IExternalAccess parent, RequiredServiceBinding[] bindings, Map kernelprops, boolean copy, boolean realtime, IIntermediateResultListener<Tuple2<String,Object>> resultlistener, Future<Void> inited)
state
- The state.magent
- The reference to the agent model in the state.config
- The name of the configuration (or null for default configuration)arguments
- The arguments for the agent as name/value pairs.public void startBehavior()
startBehavior
in interface IComponentInstance
startBehavior
in class jadex.kernelbase.StatelessAbstractInterpreter
public void beforeBlock()
public void afterBlock()
public IFuture init(IModelInfo model, String config)
public IFuture initProvidedServices(IModelInfo model, String config)
initProvidedServices
in class jadex.kernelbase.StatelessAbstractInterpreter
public IFuture startServiceContainer()
startServiceContainer
in class jadex.kernelbase.StatelessAbstractInterpreter
public boolean executeStep()
executeStep
in interface IComponentInstance
executeStep
in class jadex.kernelbase.StatelessAbstractInterpreter
public void messageArrived(IMessageAdapter message)
messageArrived
in interface IComponentInstance
messageArrived
in class jadex.kernelbase.StatelessAbstractInterpreter
message
- The message that arrived.public void streamArrived(IConnection con)
streamArrived
in interface IComponentInstance
streamArrived
in class jadex.kernelbase.StatelessAbstractInterpreter
message
- The message that arrived.public IFuture<Void> startEndSteps()
startEndSteps
in class jadex.kernelbase.StatelessAbstractInterpreter
public IExternalAccess getExternalAccess()
getExternalAccess
in interface IComponentInstance
getExternalAccess
in class jadex.kernelbase.StatelessAbstractInterpreter
listener
- When cleanup of the agent is finished, the listener must be notified.public ClassLoader getClassLoader()
getClassLoader
in interface IComponentInstance
getClassLoader
in class jadex.kernelbase.StatelessAbstractInterpreter
public void cleanup()
public IFuture componentCreated(IComponentDescription desc, IModelInfo model)
componentCreated
in interface IComponentInstance
componentCreated
in class jadex.kernelbase.StatelessAbstractInterpreter
comp
- The newly created component.public IFuture componentDestroyed(IComponentDescription desc)
componentDestroyed
in interface IComponentInstance
componentDestroyed
in class jadex.kernelbase.StatelessAbstractInterpreter
comp
- The destroyed component.public boolean isAtBreakpoint(String[] breakpoints)
isAtBreakpoint
in interface IComponentInstance
isAtBreakpoint
in class jadex.kernelbase.StatelessAbstractInterpreter
breakpoints
- An array of breakpoints.public boolean findSubcapability(Object rcapa, Object targetcapa, List path)
rcapa
- The start capability.targetcapa
- The target capability.path
- The result path as list of capas.public Object getAgent()
public jadex.rules.rulesystem.RuleSystem getRuleSystem()
public IPlanExecutor getPlanExecutor(Object rplan)
rplan
- The rplan.public IComponentAdapter getAgentAdapter()
public jadex.rules.state.IOAVState getState()
public IClockService getClockService()
public IComponentManagementService getCMS()
public IMessageService getMessageService()
public void invokeSynchronized(Runnable code)
code
- The code to execute.
The method will block the externally calling thread until the
action has been executed on the agent thread.
If the agent does not accept external actions (because of termination)
the method will directly fail with a runtime exception.
Note: 1.4 compliant code.
Problem: Deadlocks cannot be detected and no exception is thrown.public <T> IFuture<T> scheduleStep(IComponentStep<T> step)
scheduleStep
in class jadex.kernelbase.StatelessAbstractInterpreter
step
- Code to be executed as a step of the component.public <T> IFuture<T> scheduleStep(Object step, Object scope)
step
- Code to be executed as a step of the agent.public IFuture scheduleImmediate(IComponentStep step, Object scope)
action
- Code to be executed on the component's thread.public void setPlanThread(Thread planthread)
planthread
- The planthread.public boolean isPlanThread()
public boolean isExternalThread()
isExternalThread
in interface IComponentInstance
isExternalThread
in class jadex.kernelbase.StatelessAbstractInterpreter
public Object getCurrentPlan()
public EventReificator getEventReificator()
public void startMonitorConsequences()
public void endMonitorConsequences()
public void startAtomic()
endAtomic()
public void endAtomic()
startAtomic()
public boolean isAtomic()
public Map getKernelProperties()
public void putFlyweightCache(Class type, Object key, Object flyweight)
public Object getFlyweightCache(Class type, Object key)
public IExternalAccess getParent()
getParent
in class jadex.kernelbase.StatelessAbstractInterpreter
public IServiceContainer getServiceContainer()
getServiceContainer
in interface IComponentInstance
getServiceContainer
in class jadex.kernelbase.StatelessAbstractInterpreter
public static BDIInterpreter getInterpreter(jadex.rules.state.IOAVState state)
public IComponentAdapter getComponentAdapter()
getComponentAdapter
in class jadex.kernelbase.StatelessAbstractInterpreter
public IModelInfo getModel()
getModel
in class jadex.kernelbase.StatelessAbstractInterpreter
public String getConfiguration()
getConfiguration
in class jadex.kernelbase.StatelessAbstractInterpreter
public IModelInfo getModel(Object rcapa)
rcapa
- The capability.public IValueFetcher getFetcher()
getFetcher
in class jadex.kernelbase.StatelessAbstractInterpreter
public IFuture initArguments(IModelInfo model, String config, Map arguments)
initArguments
in class jadex.kernelbase.StatelessAbstractInterpreter
public boolean addArgument(String name, Object value)
addArgument
in class jadex.kernelbase.StatelessAbstractInterpreter
name
- The argument name.value
- The argument value.public void addDefaultResult(String name, Object value)
addDefaultResult
in class jadex.kernelbase.StatelessAbstractInterpreter
name
- The result name.value
- The result value.public IInternalAccess getInternalAccess()
getInternalAccess
in class jadex.kernelbase.StatelessAbstractInterpreter
public IInternalAccess getInternalAccess(Object scope)
public void addExtension(String name, IExtensionInstance ext)
addExtension
in class jadex.kernelbase.StatelessAbstractInterpreter
extension
- The extension instance.public IExtensionInstance getExtension(String name)
getExtension
in class jadex.kernelbase.StatelessAbstractInterpreter
name
- The name of the space.public IExtensionInstance[] getExtensions()
getExtensions
in class jadex.kernelbase.StatelessAbstractInterpreter
name
- The name of the space.public Map getProperties()
getProperties
in class jadex.kernelbase.StatelessAbstractInterpreter
public Map getProperties(Object rcapa)
public void addProperty(String name, Object val)
addProperty
in class jadex.kernelbase.StatelessAbstractInterpreter
name
- The name.val
- The value.public Map<String,Object> getArguments()
getArguments
in class jadex.kernelbase.StatelessAbstractInterpreter
public String getServicePrefix()
getServicePrefix
in class jadex.kernelbase.StatelessAbstractInterpreter
public RequiredServiceBinding[] getBindings()
getBindings
in class jadex.kernelbase.StatelessAbstractInterpreter
public String findServicePrefix(Object scope)
public boolean isCopy()
isCopy
in class jadex.kernelbase.StatelessAbstractInterpreter
public IServiceContainer createServiceContainer()
createServiceContainer
in class jadex.kernelbase.StatelessAbstractInterpreter
public Map<String,Object> getResults()
getResults
in interface IComponentInstance
getResults
in class jadex.kernelbase.StatelessAbstractInterpreter
public void setResultValue(String name, Object value)
setResultValue
in class jadex.kernelbase.StatelessAbstractInterpreter
name
- The result name.value
- The result value.public boolean isRealtime()
isRealtime
in class jadex.kernelbase.StatelessAbstractInterpreter
public static Object createServiceImplementation(IBDIInternalAccess agent, Class<?> type, String[] methodnames, String[] goalnames)
public ServiceGetter<IMonitoringService> getMonitoringServiceGetter()
getMonitoringServiceGetter
in class jadex.kernelbase.StatelessAbstractInterpreter
public ISubscriptionIntermediateFuture<IMonitoringEvent> subscribeToEvents(IFilter<IMonitoringEvent> filter, boolean initial, IMonitoringService.PublishEventLevel emitlevel)
subscribeToEvents
in class jadex.kernelbase.StatelessAbstractInterpreter
filter
- An optional filter.public void publishLocalEvent(IMonitoringEvent event)
publishLocalEvent
in class jadex.kernelbase.StatelessAbstractInterpreter
public List<IMonitoringEvent> getCurrentStateEvents()
getCurrentStateEvents
in class jadex.kernelbase.StatelessAbstractInterpreter
public void getCurrentStateEvents(IInternalAccess ia, jadex.rules.state.IOAVState state, Object capa, List<IMonitoringEvent> events)
public INFMixedPropertyProvider getRequiredServicePropertyProvider(IServiceIdentifier sid)
public boolean hasRequiredServicePropertyProvider(IServiceIdentifier sid)
public boolean hasEventTargets(IMonitoringService.PublishTarget pt, IMonitoringService.PublishEventLevel pi)
hasEventTargets
in class jadex.kernelbase.StatelessAbstractInterpreter
public IMonitoringService.PublishEventLevel getPublishEmitLevelSubscriptions()
public IMonitoringService.PublishEventLevel getPublishEmitLevelMonitoring()
getPublishEmitLevelMonitoring
in class jadex.kernelbase.StatelessAbstractInterpreter
Copyright © 2013. All Rights Reserved.