gov.nasa.arc.brahms.vm.rt
Class VMActiveInstanceCtx

java.lang.Object
  extended by gov.nasa.arc.brahms.common.rt.BrahmsObjectCtx
      extended by gov.nasa.arc.brahms.common.rt.ConceptCtx
          extended by gov.nasa.arc.brahms.common.rt.ActiveInstanceCtx
              extended by gov.nasa.arc.brahms.vm.rt.VMActiveInstanceCtx
All Implemented Interfaces:
IActiveInstanceCtx, IBrahmsObjectCtx, IConceptCtx, IRuntimeConstants, gov.nasa.arc.brahms.vm.engine.IPriorityWorkManager, gov.nasa.arc.brahms.vm.engine.IWorkManager, gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement, gov.nasa.arc.brahms.vm.monitoring.IMonitoredAgent, IFrameStatusListener, IRuntimeConceptCtx, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener
Direct Known Subclasses:
VMAgentCtx, VMObjectInstanceCtx

public abstract class VMActiveInstanceCtx
extends ActiveInstanceCtx
implements IRuntimeConceptCtx, gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement, IFrameStatusListener, gov.nasa.arc.brahms.vm.engine.IPriorityWorkManager, gov.nasa.arc.brahms.vm.monitoring.IMonitoredAgent, java.beans.PropertyChangeListener

The VMActiveInstanceCtx is the runtime class for active instances (agents and object instances) with extensions for it to function in the Brahms virtual machine. It manages the belief set, location, frame contexts with their various states and containment. The virtual machine maintains the active instances states through the active instance contexts.

Version:
$Revision: 1.12 $ $Date: 2009/11/29 21:50:07 $ $Author: rnado $
Author:
Ron van Hoof
See Also:
ActiveInstanceCtx, Serialized Form

Field Summary
protected  boolean m_bInitialized
          Indicates whether the agent has been initialized, used to see whether the agent accepts incoming messages in a distributed environment.
protected  java.util.LinkedList<gov.nasa.arc.brahms.vm.events.DiscreteEvent> m_llCIMessageQueue
          The queue used to temporarily store incoming KAoS messages while not initialized
protected  java.util.LinkedList<java.lang.String> m_llReceivedMessageConversationIds
          The conversation ids of the messages already received
protected  IStatementSet m_oBeliefSet
          The belief set of the active instance
protected  gov.nasa.arc.brahms.vm.engine.IEngine m_oEngine
          The active instance's reasoning engine
protected  int[] m_oIncomingMessageLock
          This lock is used to handle an incoming message from a remote agent and to ensure that no race conditions occur while posting an event on the agent's event queue for processing.
 
Fields inherited from interface gov.nasa.arc.brahms.common.rt.IRuntimeConstants
ABORTED, ACTIVE, ACTIVITY, AVAILABLE, COMPLETED, CONSEQUENCE, DETECTABLE, ENDED, ENGINE, EXTERNAL_AGENT, FROM, IMPASSED, INITIAL, INTERRUPTED, JAVA_PROPERTY, sABORTED, sACTIVE, sAVAILABLE, sCOMPLETED, sENDED, sIMPASSED, sINTERRUPTED, sUNAVAILABLE, TO, TRANSFER, UNAVAILABLE
 
Constructor Summary
VMActiveInstanceCtx(ActiveInstance ai)
          Constructor, creates a new context for the specified active instance.
 
Method Summary
 void activateCompositeActivity(VMCompositeActivityCtx act)
          Activates the composite activity, activating its frames.
 void addActiveDetectable(IDetectableCtx detectable)
          Adds the specified detectable as an active detectable to the list of active detectables.
 void addBelief(IBeliefCtx belief, long time)
          Add a new belief to the belief set of the active instance.
 void addDeletedListener(gov.nasa.arc.brahms.vm.memory.IDeletedListener listener)
          Registers the specified listener to be notified when this element was deleted.
 void addEventReference(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Adds the specified DiscreteEvent as an event in which this element is referenced.
 void addFrameBindingReference(ActiveInstance refHolder, gov.nasa.arc.brahms.vm.engine.rsn.RSNFrameNode frame, gov.nasa.arc.brahms.vm.engine.rsn.RSNFrameNode.FrameBinding binding)
          Adds the specified FrameBinding as a binding in which this element was used in a variable in the completed execution of the frame defined by the RSNFrameNode executed by the specified ActiveInstance.
 gov.nasa.arc.brahms.vm.memory.HardReference addHardReference(ActiveInstance refHolder, long time)
          Adds the specified refHolder as an ActiveInstance holding a hard reference to this concept.
protected  void addKnowsLocationOf(VMActiveInstanceCtx containedInstance)
          Adds the specified contained instance as a contained instance we know the location of.
 gov.nasa.arc.brahms.vm.memory.SoftReference addSoftReference(ActiveInstance refHolder, long time)
          Adds the specified refHolder as an ActiveInstance holding a soft reference to this concept.
 void addStatementReference(ActiveInstance refHolder, VMStatementCtx statement, long time)
          Adds the specified VMStatementCtx as a statement in which this element is referenced, either on the left or right hand side asserted by the specified ActiveInstance.
 void addStatusListener(gov.nasa.arc.brahms.vm.monitoring.IAgentStatusListener listener)
          Adds the specified IAgentStatusListener as the listener to be notified of the agent's status and status changes.
protected  void clearKnowsLocationOf()
          Clears the list of contained instances we know the location of.
 boolean containsBelief(Statement statement)
          Checks if a belief with the same contents as the specified contents exists in the belief set.
protected abstract  gov.nasa.arc.brahms.vm.engine.IEngine createEngine(gov.nasa.arc.brahms.vm.controller.VMController vmc)
          Creates a new engine for this active concept for use in a virtual machine
protected  gov.nasa.arc.brahms.vm.engine.IWorkSelector createWorkSelector()
          Creates a new work selector for this active concept to be used to select the work to be worked on when the engine asks for it.
 void deactivateCompositeActivity(VMCompositeActivityCtx act)
          Deactivates the composite activity, deactivating its frames.
 void deregisterForMonitoring()
          Registers this agent to be monitored by the agent monitor.
 void deregisterThreadListener()
          Deregisters the thread listener to detect when this agent's thread of execution is terminated and under what circumstances.
 void detect(long time, VMFactCtx fact)
          Checks the detectables to see if the specified fact can be detected.
 void doWork(long currentTime)
          Makes the agent select its current work and execute the current work using the current time as the base time.
 void finalizeDelete(long time)
          Finalizes the deletes of this element from memory, cleaning up any internal structures kept for this element and marking the element as deleted.
 java.util.ListIterator<IDetectableCtx> getActiveDetectables()
          Returns the list of active detectables.
 IBeliefCtx getBelief(Concept lhsConcept, Relation relation, java.lang.Object rhsConcept, int truthValue)
          Find the belief using the specified parameters and return the belief if found, null if the belief was not found.
 IBeliefCtx getBelief(java.lang.Object lhsObject, Attribute lhsAttribute, int lhsCollectionIndex, int relation)
          Find the belief using the specified parameters and return the belief if found, null if the belief was not found.
 IBeliefCtx getBelief(java.lang.Object lhsObject, Attribute lhsAttribute, int lhsCollectionIndex, int relation, java.lang.Object value)
          Find the belief using the specified parameters and return the belief if found, null if the belief was not found.
 IBeliefCtx getBelief(java.lang.Object lhsObject, Attribute lhsAttribute, int relation, java.lang.Object value)
          Find the belief using the specified parameters and return the belief if found, null if the belief was not found.
 VMBeliefCtx getBelief(java.lang.Object lhsObject, Attribute lhsAttribute, java.lang.String lhsCollectionIndex, int relation)
          Find the belief using the specified parameters and return the belief if found, null if the belief was not found.
 IBeliefCtx getBelief(java.lang.Object lhsObject, Attribute lhsAttribute, java.lang.String lhsCollectionIndex, int relation, java.lang.Object value)
          Find the belief using the specified parameters and return the belief if found, null if the belief was not found.
 int getBeliefChangeSupport(java.lang.Object object)
          Returns the current level of belief change support for a given Java object.
 IBeliefCtx getBeliefForIndex(java.lang.Object lhsObject, Attribute lhsAttribute, int lhsCollectionIndex)
          Find the belief using the specified parameters and return the belief if found, null if the belief was not found.
 IBeliefCtx getBeliefForIndex(java.lang.Object lhsObject, Attribute lhsAttribute, java.lang.String lhsCollectionIndex)
          Find the belief using the specified parameters and return the belief if found, null if the belief was not found.
 gov.nasa.arc.brahms.vm.engine.rsn.ReasoningStateNetwork getBeliefRSN()
          Returns the active instance's belief based reasoning state network.
 java.util.Enumeration<IBeliefCtx> getBeliefs()
          Returns the active instance's belief set.
 java.util.Enumeration<IBeliefCtx> getBeliefs(Attribute lhsAttribute)
          Returns a list of all the beliefs that have the specified attribute regardless of their left and right hand side values.
 java.util.Enumeration<IBeliefCtx> getBeliefs(Concept lhsConcept, Relation relation)
          Returns a list of all the beliefs that have the specified left hand side concept and relation regardless of their right hand side concept.
 java.util.Enumeration<IBeliefCtx> getBeliefs(Concept lhsConcept, Relation relation, int truthvalue)
          Returns a list of all the beliefs that have the specified left hand side concept, relation and truth value regardless of their right hand side concept.
 java.util.Enumeration<IBeliefCtx> getBeliefs(Concept lhsConcept, Relation relation, java.lang.Object rhsConcept, int truthvalue)
          Returns a list of all the beliefs that have the specified left hand side concept, relation, right-hand side concept and truth value.
 java.util.Enumeration<IBeliefCtx> getBeliefs(java.lang.Object object)
          Returns a list of all the beliefs that have the specified concept in either their left or right hand side.
 java.util.Enumeration<IBeliefCtx> getBeliefs(java.lang.Object lhsObject, Attribute lhsAttribute)
          Returns a list of all the beliefs that have the specified concept and attribute on their left hand side regardless of their relational operator or value.
 java.util.Enumeration<IBeliefCtx> getBeliefs(java.lang.Object lhsObject, Attribute lhsAttribute, int relation)
          Returns a list of all the beliefs that have the specified concept and attribute on their left hand side and that use the specified relational operator.
 java.util.Enumeration<IBeliefCtx> getBeliefs(java.lang.Object lhsObject, Attribute lhsAttribute, int lhsCollectionIndex, int relation)
          Find and return the beliefs using the specified parameters.
 java.util.Enumeration<IBeliefCtx> getBeliefs(java.lang.Object lhsObject, Attribute lhsAttribute, int lhsCollectionIndex, int relation, java.lang.Object value)
          Find and return the beliefs using the specified parameters.
 java.util.Enumeration<IBeliefCtx> getBeliefs(java.lang.Object lhsObject, Attribute lhsAttribute, int relation, java.lang.Object value)
          Find the belief(s) using the specified parameters and return the belief(s) if found.
 java.util.Enumeration<IBeliefCtx> getBeliefs(java.lang.Object lhsObject, Attribute lhsAttribute, java.lang.String lhsCollectionIndex, int relation)
          Find and return the beliefs using the specified parameters.
 java.util.Enumeration<IBeliefCtx> getBeliefs(java.lang.Object lhsObject, Attribute lhsAttribute, java.lang.String lhsCollectionIndex, int relation, java.lang.Object value)
          Find and return the beliefs using the specified parameters.
 java.util.Enumeration<IBeliefCtx> getBeliefs(Relation relation)
          Returns a list of all the beliefs that have the specified relation regardless of their left and right hand side concept.
 java.util.Enumeration<IBeliefCtx> getBeliefs(Relation relation, java.lang.Object rhsConcept, int truthvalue)
          Returns a list of all the beliefs that have the specified relation and right hand side concept, and truth value regardless of their left hand side concept.
 java.util.Enumeration<IBeliefCtx> getBeliefsForIndex(java.lang.Object lhsObject, Attribute lhsAttribute, int lhsCollectionIndex)
          Find and return the beliefs using the specified parameters.
 java.util.Enumeration<IBeliefCtx> getBeliefsForIndex(java.lang.Object lhsObject, Attribute lhsAttribute, java.lang.String lhsCollectionIndex)
          Find and return the beliefs using the specified parameters.
 java.util.LinkedList<Concept> getContainedInstances()
          Returns a list of the active instances contained by this active instance.
 Relation getContainsRelation()
          Returns the relation used in facts and beliefs to specify the agents/ objects contained by this active instance.
 IConceptCtx getContext()
          Returns the agent's context used in a virtual machine.
 gov.nasa.arc.brahms.vm.controller.VMController getController()
          Returns the controller managing the active instance
 ModelElement getElement()
          Returns the model element for which its memory is being managed.
 int getFactChangeSupport(java.lang.Object object)
          Returns the current level of fact change support for a given Java object.
 gov.nasa.arc.brahms.vm.engine.rsn.ReasoningStateNetwork getFactRSN()
          Returns the active instance's fact based reasoning state network.
protected  java.util.ListIterator<VMActiveInstanceCtx> getKnowsLocationOf()
          Returns a list of contained instances we know the location of.
 Attribute getLocationAttribute()
          Returns the attribute used to specify the location of the active instance in facts and beliefs about the active instance's location.
abstract  int getMatchingStrategy(VMFrameCtx frame)
          Determines whether the active instance attempts to match facts or beliefs when evaluating OA operands that occur in expressions in the body of the given frame context.
 IThoughtframeCtx getPriorityAvailableThoughtframe()
          Returns the highest priority available thoughtframe in the hierarchy of workframe contexts if a hierarchy exists due to the use of composite activities.
 IWorkframeCtx getPriorityAvailableWorkframe()
          Returns the highest priority available workframe in the hierarchy of workframe contexts if a hierarchy exists due to the use of composite activities.
 IWorkframeCtx getPriorityInterruptedFrame()
          Returns the highest priority interrupted workframe in the hierarchy of workframe contexts if a hierarchy exists due to the use of composite activities.
 java.util.Enumeration<IBeliefCtx> getRemoteBeliefs(ActiveInstance requestor)
          Requests from this remote agent the set of beliefs matching the specified pattern.
 java.util.ListIterator<VMBeliefCtx> getRemovedBeliefs()
          Returns the belief removed from the belief set as a result of an addBelief or removeBelief.
 java.util.List<gov.nasa.arc.brahms.vm.memory.SoftReference> getSoftReferences()
          Returns a list of all the actors holding a soft reference to this element.
 java.util.List<gov.nasa.arc.brahms.vm.monitoring.IAgentStatusListener> getStatusListeners()
          Returns a list of all of the registered IAgentStatusListeners.
 boolean hasAddedBelief()
          Returns whether or not the active instance has added a belief after an addBelief.
 boolean hasEventReferences()
          Indicates whether any events hold references to this element.
 boolean hasFrames()
          Indicates whether this actor has any top-level frames (thought or work) indicating behavior.
 boolean hasRemovedBelief()
          Returns whether or not the active instance has removed a belief after an addBelief or removeBelief.
 boolean hasSoftReferences()
          Indicates whether there are any actors that hold a soft reference to this element.
 void initialize(gov.nasa.arc.brahms.vm.controller.VMController vmc, long time)
          Initializes the concept for use in a virtual machine controller by the specified virtual machine controller.
protected  void initializeMemoryManagement(ActiveInstance concept)
          Initializes the state used for managing the memory for this element.
 void initiateDelete(long time)
          Initiates the deletion of this element from memory causing the element to be marked as in the process of being deleted and causing the retraction of the facts referencing the element.
 boolean isAcceptingFacts()
          Indicates whether this actor is interested in being notified of fact assertions/retractions.
 boolean isDeleted()
          Indicates whether the element was deleted.
 boolean isDeleteInitiated()
          Indicates whether the process to start the deletion of the element was started.
 boolean isMarkedForGC()
          Indicates whether the element is marked for garbage collection.
 boolean isSynchronizationRequired()
          Tests if the active instance needs to sync with the Scheduler first before performing a work selection.
protected  boolean knowsLocationOf(VMActiveInstanceCtx containedInstance)
          Checks if the active instance knows the location of the specified contained instance.
 void pause()
          Pauses the active instance, pausing the processing of new facts, beliefs and the execution of activities.
 void postEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Posts the specified event on the active instance's discrete event queue for processing.
 void process(long time)
          In simulation mode the Scheduler determines when an agent can process events up to what time.
 void processMessage(gov.nasa.ci.api.communication.ICommunicativeAct message)
          Invoked when a new ICommunicativeAct was received intended for this actor.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          The property change method required of a PropertyChangeListener.
 void registerForMonitoring()
          Registers this agent to be monitored by the agent monitor.
 void registerJavaObject(java.lang.Object object, int beliefSupport, int factSupport)
          Registers a Java object that may have property change support with given levels of belief support and fact support.
 void registerThreadListener()
          Registers a thread listener to detect when this agent's thread of execution is terminated and under what circumstances.
 void removeActiveDetectable(IDetectableCtx detectable)
          Removes the specified detectable as an active detectable from the list of active detectables.
 void removeAllBeliefs()
          Clears the active instance's belief set.
 void removeBelief(IBeliefCtx belief, long time)
          Removes the specified belief from the belief set of the active instance.
 void removeEventReference(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Removes the specified DiscreteEvent as an event in which this element is referenced.
 void removeFrameBindingReference(ActiveInstance refHolder, gov.nasa.arc.brahms.vm.engine.rsn.RSNFrameNode frame, gov.nasa.arc.brahms.vm.engine.rsn.RSNFrameNode.FrameBinding binding)
          Removes the specified FrameBinding as a binding in which this element was used in a variable in the completed execution of the frame defined by the RSNFrameNode executed by the specified ActiveInstance.
 void removeHardReference(ActiveInstance refHolder, long time)
          Removes the specified refHolder as an ActiveInstance holding a hard reference to this concept.
protected  void removeKnowsLocationOf(VMActiveInstanceCtx containedInstance)
          Removes the specified contained instance as a contained instance we know the location of.
 void removeSoftReference(ActiveInstance refHolder, long time)
          Removes the specified refHolder as an ActiveInstance holding a soft reference to this concept.
 void removeStatementReference(ActiveInstance refHolder, VMStatementCtx statement, long time)
          Removes the specified VMStatementCtx as a statement in which the element is referenced, either on the left or right hand side retracted by the specified ActiveInstance.
 void removeStatusListener(gov.nasa.arc.brahms.vm.monitoring.IAgentStatusListener listener)
          Removes the specified IAgentStatusListener as the listener to be notified of the agent's status and status changes.
 void reset()
          Resets the concept removing its context and any references and additional components created to use this concept in a virtual machine.
 void resume()
          Resumes the active instance from its state when it is paused, resuming the processing of new facts, beliefs and the execution of activities.
 void retractEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Retracts the specified event from the active instance's discrete event queue to prevent processing.
 void setBeliefChangeSupport(java.lang.Object object, int beliefSupport)
          Sets the level of belief change support for a given Java object.
protected  void setController(gov.nasa.arc.brahms.vm.controller.VMController vmc)
          Sets the virtual machine's controller for the virtual machine in which this active instance context is loaded.
 void setFactChangeSupport(java.lang.Object object, int factSupport)
          Sets the level of fact change support for a given Java object.
 void setMarkedForGC(boolean marked)
          Sets whether the element is marked for garbage collection.
 void setSynchronizationRequired(boolean sync)
          Sets the flag indicating whether the agent needs to synchronize itself with the scheduler before performing a work selection.
 void start()
          Starts the active instance, starting the processing of new facts, beliefs and the execution of activities.
 void statusChanged(FrameStatusEvent evt)
          Fired when the status of a frame context changes.
 void stop()
          Stops and resets the active instance, stops all processing of facts, beliefs and execution of activities.
 void trigger(long time, VMBeliefCtx belief)
          Checks the triggers to see if the specified belief causes a trigger to be activated.
 void triggerImpasseResolution(long time, VMBeliefCtx belief)
          Checks the triggers of the detectables that caused an impasse to see if the specified belief can cause the impasse to be lifted.
 void unregisterJavaObject(java.lang.Object object)
          Unregisters a Java object for monitoring by this active instance.
 
Methods inherited from class gov.nasa.arc.brahms.common.rt.ActiveInstanceCtx
addAvailableFrame, addBelief, addCompletedFrame, addContainedElement, addImpasseDetectable, addImpassedFrame, addInterruptedFrame, addPastLocation, getAvailableThoughtframes, getAvailableWorkframes, getBelievedTime, getCompletedThoughtframeNames, getCompletedThoughtframes, getCompletedWorkframeNames, getCompletedWorkframes, getContainedElements, getCurrentWork, getImpasseDetectables, getImpassedFrames, getInterruptedFrames, getLocation, getPastLocations, hasAvailableThoughtframes, hasAvailableWorkframes, hasCompletedThoughtframes, hasCompletedWorkframes, hasImpassedFrames, hasInterruptedFrames, removeAllAvailableFrames, removeAllCompletedFrames, removeAllContainedElements, removeAllImpasseDetectables, removeAllImpassedFrames, removeAllInterruptedFrames, removeAllPastLocations, removeAvailableFrame, removeBelief, removeCompletedFrame, removeContainedElement, removeImpasseDetectable, removeImpassedFrame, removeInterruptedFrame, removePastLocation, setBelievedTime, setCurrentWork, setLocation
 
Methods inherited from class gov.nasa.arc.brahms.common.rt.ConceptCtx
addAttribute, addRelation, getAttribute, getRelation, initAttributeRelationCache, removeAttribute, removeRelation, resetAttributeRelationCache, toString
 
Methods inherited from class gov.nasa.arc.brahms.common.rt.BrahmsObjectCtx
addNote, getContextFor, getEndTime, getID, getNote, getNotes, getStartTime, removeNote, setContextFor, setEndTime, setID, setStartTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.nasa.arc.brahms.vm.engine.IPriorityWorkManager
getCurrentWork
 
Methods inherited from interface gov.nasa.arc.brahms.common.rt.IBrahmsObjectCtx
addNote, getContextFor, getEndTime, getID, getNote, getNotes, getStartTime, removeNote, setEndTime, setID, setStartTime
 

Field Detail

m_oEngine

protected gov.nasa.arc.brahms.vm.engine.IEngine m_oEngine
The active instance's reasoning engine


m_oBeliefSet

protected IStatementSet m_oBeliefSet
The belief set of the active instance


m_oIncomingMessageLock

protected int[] m_oIncomingMessageLock
This lock is used to handle an incoming message from a remote agent and to ensure that no race conditions occur while posting an event on the agent's event queue for processing.


m_bInitialized

protected boolean m_bInitialized
Indicates whether the agent has been initialized, used to see whether the agent accepts incoming messages in a distributed environment.


m_llCIMessageQueue

protected java.util.LinkedList<gov.nasa.arc.brahms.vm.events.DiscreteEvent> m_llCIMessageQueue
The queue used to temporarily store incoming KAoS messages while not initialized


m_llReceivedMessageConversationIds

protected java.util.LinkedList<java.lang.String> m_llReceivedMessageConversationIds
The conversation ids of the messages already received

Constructor Detail

VMActiveInstanceCtx

public VMActiveInstanceCtx(ActiveInstance ai)
Constructor, creates a new context for the specified active instance.

Parameters:
ai - the ActiveInstance for which to create a context
Method Detail

setController

protected final void setController(gov.nasa.arc.brahms.vm.controller.VMController vmc)
Sets the virtual machine's controller for the virtual machine in which this active instance context is loaded.

Parameters:
vmc - the VMController

hasFrames

public final boolean hasFrames()
Indicates whether this actor has any top-level frames (thought or work) indicating behavior.

Returns:
boolean true if it has top-level frames, false if not

isAcceptingFacts

public boolean isAcceptingFacts()
Indicates whether this actor is interested in being notified of fact assertions/retractions.

Returns:
boolean true to accept facts, false if not

getMatchingStrategy

public abstract int getMatchingStrategy(VMFrameCtx frame)
                                 throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Determines whether the active instance attempts to match facts or beliefs when evaluating OA operands that occur in expressions in the body of the given frame context.

Parameters:
frame - a VMFrameCtx where an expression is being evaluated
Returns:
int a code indicating the matching strategy
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an error occurs in determining the strategy
See Also:
gov.nasa.arc.brahms.vm.data.FACTS, gov.nasa.arc.brahms.vm.data.BELIEFS

initialize

public void initialize(gov.nasa.arc.brahms.vm.controller.VMController vmc,
                       long time)
                throws VMException
Initializes the concept for use in a virtual machine controller by the specified virtual machine controller. The initialization sets up any additional components required for the concept to be used in the virtual machine.

Specified by:
initialize in interface IRuntimeConceptCtx
Parameters:
vmc - the VMController controlling the virtual machine in which this concept is to be used.
time - the time at which the initialization is performed
Throws:
VMException - if an error occurs in initializing the concept

initializeMemoryManagement

protected void initializeMemoryManagement(ActiveInstance concept)
Initializes the state used for managing the memory for this element.

Parameters:
concept - the concept for which this is the context

getElement

public ModelElement getElement()
                        throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the model element for which its memory is being managed.

Specified by:
getElement in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Returns:
ModelElement the model element
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if there is an error obtaining the element

addHardReference

public gov.nasa.arc.brahms.vm.memory.HardReference addHardReference(ActiveInstance refHolder,
                                                                    long time)
Adds the specified refHolder as an ActiveInstance holding a hard reference to this concept. A hard reference is a reference held by an ActiveInstance that has behavior (frames) as a result of either creating the concept or as a result of a belief assertion in which the belief references this concept.

Specified by:
addHardReference in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Parameters:
refHolder - the ActiveInstance holding a reference to this concept
time - the event time at which the reference is added
Returns:
HardReference the HardReference created for the ActiveInstance

removeHardReference

public void removeHardReference(ActiveInstance refHolder,
                                long time)
Removes the specified refHolder as an ActiveInstance holding a hard reference to this concept. A hard reference is a reference held by an ActiveInstance that has behavior (frames) as a result of either creating the concept or as a result of a belief assertion in which the belief references this concept.

If the specified refHolder is not listed as a concept holding a reference to this concept then this method is a no-op.

Specified by:
removeHardReference in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Parameters:
refHolder - the ActiveInstance that no longer holds any references to this concept
time - the event time at which the reference is removed

addSoftReference

public gov.nasa.arc.brahms.vm.memory.SoftReference addSoftReference(ActiveInstance refHolder,
                                                                    long time)
Adds the specified refHolder as an ActiveInstance holding a soft reference to this concept. A soft reference is a reference held by an ActiveInstance that has no behavior (no frames) as a result of a belief assertion in which the belief references this concept.

Specified by:
addSoftReference in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Parameters:
refHolder - the ActiveInstance holding a reference to this concept
time - the event time at which the reference is added
Returns:
SoftReference the SoftReference created for the ActiveInstance

removeSoftReference

public void removeSoftReference(ActiveInstance refHolder,
                                long time)
Removes the specified refHolder as an ActiveInstance holding a soft reference to this concept. A soft reference is a reference held by an ActiveInstance that has no behavior (no frames) as a result of a belief assertion in which the belief references this concept.

If the specified refHolder is not listed as a concept holding a reference to this concept then this method is a no-op.

Specified by:
removeSoftReference in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Parameters:
refHolder - the ActiveInstance that no longers holds any references to this concept
time - the event time at which the reference is removed

hasSoftReferences

public boolean hasSoftReferences()
Indicates whether there are any actors that hold a soft reference to this element.

Specified by:
hasSoftReferences in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Returns:
boolean true if there are soft references, false otherwise

getSoftReferences

public java.util.List<gov.nasa.arc.brahms.vm.memory.SoftReference> getSoftReferences()
Returns a list of all the actors holding a soft reference to this element.

Specified by:
getSoftReferences in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Returns:
List the list of SoftReferences

addEventReference

public void addEventReference(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Adds the specified DiscreteEvent as an event in which this element is referenced. These references need to maintained to ensure that during the transfer of beliefs these beliefs can be asserted by the recipient before the element is actually deleted. An element could otherwise be deleted before the recipient has had a chance to assert beliefs about it and to claim ownership of a reference to the element.

Specified by:
addEventReference in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Parameters:
evt - the DiscreteEvent in which the element is referenced

removeEventReference

public void removeEventReference(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Removes the specified DiscreteEvent as an event in which this element is referenced. These references need to maintained to ensure that during the transfer of beliefs these beliefs can be asserted by the recipient before the element is actually deleted. An element could otherwise be deleted before the recipient has had a chance to assert beliefs about it and to claim ownership of a reference to the element.

Specified by:
removeEventReference in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Parameters:
evt - the DiscreteEvent in which the element is referenced

hasEventReferences

public boolean hasEventReferences()
Indicates whether any events hold references to this element.

Specified by:
hasEventReferences in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Returns:
boolean true if there are event references, false otherwise

addStatementReference

public void addStatementReference(ActiveInstance refHolder,
                                  VMStatementCtx statement,
                                  long time)
Adds the specified VMStatementCtx as a statement in which this element is referenced, either on the left or right hand side asserted by the specified ActiveInstance.

Specified by:
addStatementReference in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Parameters:
refHolder - the ActiveInstance that asserted the statement referencing this element
statement - the VMStatementCtx to be added
time - the time at which the statement reference is added

removeStatementReference

public void removeStatementReference(ActiveInstance refHolder,
                                     VMStatementCtx statement,
                                     long time)
Removes the specified VMStatementCtx as a statement in which the element is referenced, either on the left or right hand side retracted by the specified ActiveInstance.

Specified by:
removeStatementReference in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Parameters:
refHolder - the ActiveInstance that retracted the statement referencing this element
statement - the VMStatementCtx to be removed
time - the time at which the statement reference is removed

addFrameBindingReference

public void addFrameBindingReference(ActiveInstance refHolder,
                                     gov.nasa.arc.brahms.vm.engine.rsn.RSNFrameNode frame,
                                     gov.nasa.arc.brahms.vm.engine.rsn.RSNFrameNode.FrameBinding binding)
Adds the specified FrameBinding as a binding in which this element was used in a variable in the completed execution of the frame defined by the RSNFrameNode executed by the specified ActiveInstance. This binding only exists if the frame's repeat property is set to false.

Specified by:
addFrameBindingReference in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Parameters:
refHolder - the ActiveInstance that executed the frame
frame - the RSNFrameNode in which the used binding is maintained
binding - the FrameBinding in which the element is referenced

removeFrameBindingReference

public void removeFrameBindingReference(ActiveInstance refHolder,
                                        gov.nasa.arc.brahms.vm.engine.rsn.RSNFrameNode frame,
                                        gov.nasa.arc.brahms.vm.engine.rsn.RSNFrameNode.FrameBinding binding)
Removes the specified FrameBinding as a binding in which this element was used in a variable in the completed execution of the frame defined by the RSNFrameNode executed by the specified ActiveInstance. This binding only exists if the frame's repeat property is set to false.

Specified by:
removeFrameBindingReference in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Parameters:
refHolder - the ActiveInstance that executed the frame
frame - the RSNFrameNode in which the used binding is maintained
binding - the FrameBinding in which the element is referenced

setMarkedForGC

public void setMarkedForGC(boolean marked)
Sets whether the element is marked for garbage collection. True when the element was added to the garbage collector, false if the element is not yet added to the garbage collector.

Specified by:
setMarkedForGC in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Parameters:
marked - true if marked, false if not

isMarkedForGC

public boolean isMarkedForGC()
Indicates whether the element is marked for garbage collection. True when the element was added to the garbage collector, false if the element is not yet added to the garbage collector.

Specified by:
isMarkedForGC in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Returns:
boolean true if marked, false if not

initiateDelete

public void initiateDelete(long time)
Initiates the deletion of this element from memory causing the element to be marked as in the process of being deleted and causing the retraction of the facts referencing the element.

Specified by:
initiateDelete in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Parameters:
time - the event time at which the element's deletion is initiated

isDeleteInitiated

public boolean isDeleteInitiated()
Indicates whether the process to start the deletion of the element was started.

Specified by:
isDeleteInitiated in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Returns:
boolean true if the element is in the process of being deleted, false otherwise

finalizeDelete

public void finalizeDelete(long time)
Finalizes the deletes of this element from memory, cleaning up any internal structures kept for this element and marking the element as deleted.

Specified by:
finalizeDelete in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Parameters:
time - the event time at which the element's deletion is finalized

addDeletedListener

public void addDeletedListener(gov.nasa.arc.brahms.vm.memory.IDeletedListener listener)
Registers the specified listener to be notified when this element was deleted. This listener is automatically deregistered after the listener was notified of the deletion.

Specified by:
addDeletedListener in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Parameters:
listener - the IDeletedListener to be added

isDeleted

public boolean isDeleted()
Indicates whether the element was deleted.

Specified by:
isDeleted in interface gov.nasa.arc.brahms.vm.memory.IMemoryManagedElement
Returns:
boolean true if the element was deleted, false otherwise

processMessage

public void processMessage(gov.nasa.ci.api.communication.ICommunicativeAct message)
Invoked when a new ICommunicativeAct was received intended for this actor.

Parameters:
message - the ICommunicativeAct intended for this actor

createEngine

protected abstract gov.nasa.arc.brahms.vm.engine.IEngine createEngine(gov.nasa.arc.brahms.vm.controller.VMController vmc)
                                                               throws VMException
Creates a new engine for this active concept for use in a virtual machine

Note: This method always returns a new instance and does not verify whether one is already created.

Parameters:
vmc - the virtual machine controller controlling the active instance
Returns:
IEngine a new engine
Throws:
VMException - if an error occurs in creating the engine

getFactRSN

public gov.nasa.arc.brahms.vm.engine.rsn.ReasoningStateNetwork getFactRSN()
Returns the active instance's fact based reasoning state network.

Note that this method is public because the ReasoningStateNetwork requires access to it. No other component should use this method.

Returns:
ReasoningStateNetwork the active instance's fact based ReasoningStateNetwork.

getBeliefRSN

public final gov.nasa.arc.brahms.vm.engine.rsn.ReasoningStateNetwork getBeliefRSN()
Returns the active instance's belief based reasoning state network.

Note that this method is public because the ReasoningStateNetwork requires access to it. No other component should use this method.

Returns:
ReasoningStateNetwork the active instance's belief based ReasoningStateNetwork.

createWorkSelector

protected gov.nasa.arc.brahms.vm.engine.IWorkSelector createWorkSelector()
                                                                  throws VMException
Creates a new work selector for this active concept to be used to select the work to be worked on when the engine asks for it.

Note: This method always returns a new instance and does not verify whether one is already created.

Returns:
IWorkSelector the active instance's work selector
Throws:
VMException - if an error occurs in creating the work selector

doWork

public void doWork(long currentTime)
Makes the agent select its current work and execute the current work using the current time as the base time. It executes work until it reaches a point where it either completes the work or until it reaches a point where the next work would be at a time later then the current time.

Parameters:
currentTime - the time at which and for which work can be executed throws VMError if an unexpected error occurs in executing the work

setSynchronizationRequired

public void setSynchronizationRequired(boolean sync)
Sets the flag indicating whether the agent needs to synchronize itself with the scheduler before performing a work selection. It is possible that after a frame completes new facts or beliefs are listed on the scheduler's queue for the same time that could potentially change the state of available frames. A sync is therefor required before we start a new frame after a frame completes.

Parameters:
sync - true if synchronization is required, false otherwise.

isSynchronizationRequired

public boolean isSynchronizationRequired()
Tests if the active instance needs to sync with the Scheduler first before performing a work selection. It is possible that after a frame completes new facts or beliefs are listed on the scheduler's queue for the same time that could potentially change the state of available frames. A sync is therefor required before we start a new frame after a frame completes.

Returns:
boolean true if required, false if not

activateCompositeActivity

public void activateCompositeActivity(VMCompositeActivityCtx act)
Activates the composite activity, activating its frames.

Parameters:
act - the context of the composite activity to be activated

deactivateCompositeActivity

public void deactivateCompositeActivity(VMCompositeActivityCtx act)
Deactivates the composite activity, deactivating its frames.

Parameters:
act - the context of the composite activity to be deactivated

detect

public void detect(long time,
                   VMFactCtx fact)
Checks the detectables to see if the specified fact can be detected.

Parameters:
time - the time at which the detection is to take place
fact - the fact to be checked for detection

trigger

public void trigger(long time,
                    VMBeliefCtx belief)
Checks the triggers to see if the specified belief causes a trigger to be activated.

Parameters:
time - the time at which the trigger is to be activated
belief - the belief to be checked

triggerImpasseResolution

public void triggerImpasseResolution(long time,
                                     VMBeliefCtx belief)
Checks the triggers of the detectables that caused an impasse to see if the specified belief can cause the impasse to be lifted.

Parameters:
time - the time at which the trigger is to be activated
belief - the retracted belief to be checked

statusChanged

public void statusChanged(FrameStatusEvent evt)
Fired when the status of a frame context changes. The frame contect that changed status and the old and new status are captured by the event.

Specified by:
statusChanged in interface IFrameStatusListener
Parameters:
evt - the FrameStatusEvent
See Also:
FrameStatusEvent

getController

public final gov.nasa.arc.brahms.vm.controller.VMController getController()
Returns the controller managing the active instance

Returns:
VMController the agent's ontroller

start

public void start()
           throws VMException
Starts the active instance, starting the processing of new facts, beliefs and the execution of activities.

Throws:
VMException - if an error occurs in starting the active instance

pause

public void pause()
           throws VMException
Pauses the active instance, pausing the processing of new facts, beliefs and the execution of activities.

Throws:
VMException - if an error occurs in pausing the active instance

resume

public void resume()
            throws VMException
Resumes the active instance from its state when it is paused, resuming the processing of new facts, beliefs and the execution of activities.

Throws:
VMException - if an error occurs in resuming the active instance

stop

public void stop()
          throws VMException
Stops and resets the active instance, stops all processing of facts, beliefs and execution of activities.

Throws:
VMException - if an error occurs in stopping the active instance

postEvent

public void postEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
               throws VMException
Posts the specified event on the active instance's discrete event queue for processing.

Parameters:
evt - the DiscreteEvent to be added to the event queue
Throws:
VMException - if an error occurs in adding the event to the queue

retractEvent

public void retractEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
                  throws VMException
Retracts the specified event from the active instance's discrete event queue to prevent processing.

Parameters:
evt - the DiscreteEvent to be removed from the event queue
Throws:
VMException - if an error occurs in removing the event from the queue

process

public void process(long time)
             throws VMException
In simulation mode the Scheduler determines when an agent can process events up to what time. When the Scheduler calls the process method it specifies the time up to where the active instance can process events. The active instance can process events marked for a time of up to and including the specified time.

Note: In real time mode the active instance processes any events as fast as possible without waiting for approval from the Scheduler. This method is considered irrelevant for the real time mode.

Parameters:
time - the time of the events that can be processed, up to and including the specified time
Throws:
VMException - if an error occurs in the continuation of the processing

reset

public void reset()
           throws VMException
Resets the concept removing its context and any references and additional components created to use this concept in a virtual machine.

Specified by:
reset in interface IRuntimeConceptCtx
Throws:
VMException - if in error occurs in resetting the active instance

addBelief

public void addBelief(IBeliefCtx belief,
                      long time)
               throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Add a new belief to the belief set of the active instance.

Parameters:
belief - the IBeliefCtx to be added to the belief set.
time - the discrete event time at which the belief is added
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if a null belief is passed or of event notification fails

removeBelief

public void removeBelief(IBeliefCtx belief,
                         long time)
                  throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Removes the specified belief from the belief set of the active instance.

Parameters:
belief - the IBeliefCtx to be removed from the belief set.
time - the discrete event time at which the belief is removed
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if a null belief is passed, the specified belief is not present, ot if event notification failed

getBelief

public IBeliefCtx getBelief(java.lang.Object lhsObject,
                            Attribute lhsAttribute,
                            int relation,
                            java.lang.Object value)
                     throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Find the belief using the specified parameters and return the belief if found, null if the belief was not found.

Parameters:
lhsObject - the left hand side Object in the requested belief
lhsAttribute - the left hand side Attribute in the requested belief
relation - the relational operator in the requested belief
value - the right hand side value to match
Returns:
VMBeliefCtx if the matching belief is found, null otherwise
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs
See Also:
IConstants.EQ, IConstants.NE, IConstants.GT, IConstants.GE, IConstants.LT, IConstants.LE

getBelief

public IBeliefCtx getBelief(java.lang.Object lhsObject,
                            Attribute lhsAttribute,
                            int lhsCollectionIndex,
                            int relation,
                            java.lang.Object value)
                     throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Find the belief using the specified parameters and return the belief if found, null if the belief was not found.

Parameters:
lhsObject - the left hand side Object in the requested belief
lhsAttribute - the left hand side Attribute in the requested belief
lhsCollectionIndex - the integer index/key if the attribute's type is a collection
relation - the relational operator in the requested statement
value - the right hand side value to match
Returns:
VMBeliefCtx if the matching belief is found, null otherwise
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs
See Also:
IConstants.EQ, IConstants.NE, IConstants.GT, IConstants.GE, IConstants.LT, IConstants.LE

getBelief

public IBeliefCtx getBelief(java.lang.Object lhsObject,
                            Attribute lhsAttribute,
                            java.lang.String lhsCollectionIndex,
                            int relation,
                            java.lang.Object value)
                     throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Find the belief using the specified parameters and return the belief if found, null if the belief was not found.

Parameters:
lhsObject - the left hand side Object in the requested belief
lhsAttribute - the left hand side Attribute in the requested belief
lhsCollectionIndex - the String index/key if the attribute's type is a collection
relation - the relational operator in the requested statement
value - the right hand side value to match
Returns:
VMBeliefCtx if the matching belief is found, null otherwise
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs
See Also:
IConstants.EQ, IConstants.NE, IConstants.GT, IConstants.GE, IConstants.LT, IConstants.LE

getBelief

public IBeliefCtx getBelief(java.lang.Object lhsObject,
                            Attribute lhsAttribute,
                            int lhsCollectionIndex,
                            int relation)
                     throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Find the belief using the specified parameters and return the belief if found, null if the belief was not found.

Parameters:
lhsObject - the left hand side Object in the requested belief
lhsAttribute - the left hand side Attribute in the requested belief
lhsCollectionIndex - the integer index/key if the attribute's type is a collection
relation - the relational operator in the requested belief
Returns:
VMStatementCtx if the matching belief is found, null otherwise
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs
See Also:
IConstants.EQ, IConstants.NE, IConstants.GT, IConstants.GE, IConstants.LT, IConstants.LE

getBelief

public VMBeliefCtx getBelief(java.lang.Object lhsObject,
                             Attribute lhsAttribute,
                             java.lang.String lhsCollectionIndex,
                             int relation)
                      throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Find the belief using the specified parameters and return the belief if found, null if the belief was not found.

Parameters:
lhsObject - the left hand side Object in the requested belief
lhsAttribute - the left hand side Attribute in the requested belief
lhsCollectionIndex - the String index/key if the attribute's type is a collection
relation - the relational operator in the requested belief
Returns:
VMStatementCtx if the matching belief is found, null otherwise
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs
See Also:
IConstants.EQ, IConstants.NE, IConstants.GT, IConstants.GE, IConstants.LT, IConstants.LE

getBeliefForIndex

public IBeliefCtx getBeliefForIndex(java.lang.Object lhsObject,
                                    Attribute lhsAttribute,
                                    int lhsCollectionIndex)
                             throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Find the belief using the specified parameters and return the belief if found, null if the belief was not found.

Parameters:
lhsObject - the left hand side Object in the requested belief
lhsAttribute - the left hand side Attribute in the requested belief
lhsCollectionIndex - the integer index/key if the attribute's type is a collection
Returns:
VMStatementCtx if the matching belief is found, null otherwise
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs
See Also:
IConstants.EQ, IConstants.NE, IConstants.GT, IConstants.GE, IConstants.LT, IConstants.LE

getBeliefForIndex

public IBeliefCtx getBeliefForIndex(java.lang.Object lhsObject,
                                    Attribute lhsAttribute,
                                    java.lang.String lhsCollectionIndex)
                             throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Find the belief using the specified parameters and return the belief if found, null if the belief was not found.

Parameters:
lhsObject - the left hand side Object in the requested belief
lhsAttribute - the left hand side Attribute in the requested belief
lhsCollectionIndex - the String index/key if the attribute's type is a collection
Returns:
VMStatementCtx if the matching belief is found, null otherwise
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs
See Also:
IConstants.EQ, IConstants.NE, IConstants.GT, IConstants.GE, IConstants.LT, IConstants.LE

getBelief

public IBeliefCtx getBelief(Concept lhsConcept,
                            Relation relation,
                            java.lang.Object rhsConcept,
                            int truthValue)
                     throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Find the belief using the specified parameters and return the belief if found, null if the belief was not found.

Parameters:
lhsConcept - the left hand side Concept in the requested belief
relation - the Relation in the requested belief
rhsConcept - the right hand side Concept in the requested belief or the value unknown
truthValue - the truth value in the requested belief (TRUE, FALSE, UNKNOWN)
Returns:
VMBeliefCtx if the matching belief is found, null otherwise
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs
See Also:
IConstants.TRUE, IConstants.FALSE, IConstants.UNKNOWN, IConstants.unknown

getBeliefs

public java.util.Enumeration<IBeliefCtx> getBeliefs()
                                             throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the active instance's belief set.

Specified by:
getBeliefs in interface IActiveInstanceCtx
Overrides:
getBeliefs in class ActiveInstanceCtx
Returns:
Enumeration an enumeration of BeliefCtx's
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs

getBeliefs

public java.util.Enumeration<IBeliefCtx> getBeliefs(Attribute lhsAttribute)
                                             throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns a list of all the beliefs that have the specified attribute regardless of their left and right hand side values.

Parameters:
lhsAttribute - the left hand side Attribute in the requested belief(s)
Returns:
Enumeration an enumeration of BeliefCtx's
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs

getBeliefs

public java.util.Enumeration<IBeliefCtx> getBeliefs(java.lang.Object object)
                                             throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns a list of all the beliefs that have the specified concept in either their left or right hand side.

Parameters:
concept - the Concept in the requested belief(s)
Returns:
Enumeration an enumeration of BeliefCtx's
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs

getBeliefs

public java.util.Enumeration<IBeliefCtx> getBeliefs(java.lang.Object lhsObject,
                                                    Attribute lhsAttribute)
                                             throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns a list of all the beliefs that have the specified concept and attribute on their left hand side regardless of their relational operator or value. If the lhs concept is a class type concept the method will return all statements for the concepts instances that are instances of the specified lhs concept.

Parameters:
lhsConcept - the left hand side Concept in the requested belief(s)
lhsAttribute - the left hand side Attribute in the requested belief(s)
Returns:
Enumeration a list of VMBeliefCtx's
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs

getBeliefs

public java.util.Enumeration<IBeliefCtx> getBeliefs(java.lang.Object lhsObject,
                                                    Attribute lhsAttribute,
                                                    int relation)
                                             throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns a list of all the beliefs that have the specified concept and attribute on their left hand side and that use the specified relational operator. If the lhs concept is a class type concept the method will return all statements for the concepts instances that are instances of the specified lhs concept.

Parameters:
lhsConcept - the left hand side Concept in the requested belief(s)
lhsAttribute - the left hand side Attribute in the requested belief(s)
relation - the relational operator in the requested belief(s)
Returns:
Enumeration a list of VMBeliefCtx's
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs
See Also:
IConstants.EQ, IConstants.NE, IConstants.GT, IConstants.GE, IConstants.LT, IConstants.LE

getBeliefs

public java.util.Enumeration<IBeliefCtx> getBeliefs(java.lang.Object lhsObject,
                                                    Attribute lhsAttribute,
                                                    int lhsCollectionIndex,
                                                    int relation,
                                                    java.lang.Object value)
Find and return the beliefs using the specified parameters. Multiple beliefs can be found if the lhsConcept is of a class type. If the lhsConcept is of a class type then all beliefs of which the lhs concept matches the type of the specified lhsConcept will be returned provided the the other parameters match.

Parameters:
lhsConcept - the left hand side Concept in the requested belief
lhsAttribute - the left hand side Attribute in the requested belief
lhsCollectionIndex - the integer index/key if the attribute's type is a collection
relation - the relational operator in the requested fact
value - the right hand side value to match
Returns:
Enumeration the list of matching VMBeliefCtx's
See Also:
IConstants.EQ, IConstants.NE, IConstants.GT, IConstants.GE, IConstants.LT, IConstants.LE

getBeliefs

public java.util.Enumeration<IBeliefCtx> getBeliefs(java.lang.Object lhsObject,
                                                    Attribute lhsAttribute,
                                                    java.lang.String lhsCollectionIndex,
                                                    int relation,
                                                    java.lang.Object value)
Find and return the beliefs using the specified parameters. Multiple beliefs can be found if the lhsConcept is of a class type. If the lhsConcept is of a class type then all beliefs of which the lhs concept matches the type of the specified lhsConcept will be returned provided the the other parameters match.

Parameters:
lhsConcept - the left hand side Concept in the requested belief
lhsAttribute - the left hand side Attribute in the requested belief
lhsCollectionIndex - the String index/key if the attribute's type is a collection
relation - the relational operator in the requested fact
value - the right hand side value to match
Returns:
Enumeration the list of matching VMBeliefCtx's
See Also:
IConstants.EQ, IConstants.NE, IConstants.GT, IConstants.GE, IConstants.LT, IConstants.LE

getBeliefs

public java.util.Enumeration<IBeliefCtx> getBeliefs(java.lang.Object lhsObject,
                                                    Attribute lhsAttribute,
                                                    int relation,
                                                    java.lang.Object value)
                                             throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Find the belief(s) using the specified parameters and return the belief(s) if found. Multiple beliefs can be found if the lhsConcept is of a class type. If the lhsConcept is of a class type then all beliefs of which the lhs concept matches the type of the specified lhsConcept will be returned provided the the other parameters match.

Parameters:
lhsConcept - the left hand side Concept in the requested belief
lhsAttribute - the left hand side Attribute in the requested belief
relation - the relational operator in the requested belief
value - the right hand side value to match
Returns:
Enumeration a list of VMBeliefCtx's
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs
See Also:
IConstants.EQ, IConstants.NE, IConstants.GT, IConstants.GE, IConstants.LT, IConstants.LE

getBeliefs

public java.util.Enumeration<IBeliefCtx> getBeliefs(java.lang.Object lhsObject,
                                                    Attribute lhsAttribute,
                                                    int lhsCollectionIndex,
                                                    int relation)
Find and return the beliefs using the specified parameters. Multiple beliefs can be found if the lhsConcept is of a class type. If the lhsConcept is of a class type then all beliefs of which the lhs concept matches the type of the specified lhsConcept will be returned provided the other parameters match.

Parameters:
lhsConcept - the left hand side Concept in the requested belief
lhsAttribute - the left hand side Attribute in the requested belief
lhsCollectionIndex - the integer index/key if the attribute's type is a collection
relation - the relational operator in the requested fact
Returns:
Enumeration a list of VMBeliefCtx's
See Also:
IConstants.EQ, IConstants.NE, IConstants.GT, IConstants.GE, IConstants.LT, IConstants.LE

getBeliefs

public java.util.Enumeration<IBeliefCtx> getBeliefs(java.lang.Object lhsObject,
                                                    Attribute lhsAttribute,
                                                    java.lang.String lhsCollectionIndex,
                                                    int relation)
Find and return the beliefs using the specified parameters. Multiple beliefs can be found if the lhsConcept is of a class type. If the lhsConcept is of a class type then all beliefs of which the lhs concept matches the type of the specified lhsConcept will be returned provided the the other parameters match.

Parameters:
lhsConcept - the left hand side Concept in the requested belief
lhsAttribute - the left hand side Attribute in the requested belief
lhsCollectionIndex - the String index/key if the attribute's type is a collection
relation - the relational operator in the requested fact
Returns:
Enumeration a list of VMBeliefCtx's
See Also:
IConstants.EQ, IConstants.NE, IConstants.GT, IConstants.GE, IConstants.LT, IConstants.LE

getBeliefsForIndex

public java.util.Enumeration<IBeliefCtx> getBeliefsForIndex(java.lang.Object lhsObject,
                                                            Attribute lhsAttribute,
                                                            int lhsCollectionIndex)
Find and return the beliefs using the specified parameters. Multiple beliefs can be found if the lhsConcept is of a class type. If the lhsConcept is of a class type then all beliefs of which the lhs concept matches the type of the specified lhsConcept will be returned provided the the other parameters match.

Parameters:
lhsConcept - the left hand side Concept in the requested belief
lhsAttribute - the left hand side Attribute in the requested belief
lhsCollectionIndex - the integer index/key if the attribute's type is a collection
Returns:
Enumeration a list of VMBeliefCtx's
See Also:
IConstants.EQ, IConstants.NE, IConstants.GT, IConstants.GE, IConstants.LT, IConstants.LE

getBeliefsForIndex

public java.util.Enumeration<IBeliefCtx> getBeliefsForIndex(java.lang.Object lhsObject,
                                                            Attribute lhsAttribute,
                                                            java.lang.String lhsCollectionIndex)
Find and return the beliefs using the specified parameters. Multiple beliefs can be found if the lhsConcept is of a class type. If the lhsConcept is of a class type then all beliefs of which the lhs concept matches the type of the specified lhsConcept will be returned provided the the other parameters match.

Parameters:
lhsConcept - the left hand side Concept in the requested belief
lhsAttribute - the left hand side Attribute in the requested belief
lhsCollectionIndex - the String index/key if the attribute's type is a collection
Returns:
Enumeration a list of VMBeliefCtx's
See Also:
IConstants.EQ, IConstants.NE, IConstants.GT, IConstants.GE, IConstants.LT, IConstants.LE

getBeliefs

public java.util.Enumeration<IBeliefCtx> getBeliefs(Relation relation)
Returns a list of all the beliefs that have the specified relation regardless of their left and right hand side concept.

Parameters:
relation - the Relation in the requested belief(s)
Returns:
Enumeration a list of VMBeliefCtx's

getBeliefs

public java.util.Enumeration<IBeliefCtx> getBeliefs(Concept lhsConcept,
                                                    Relation relation)
Returns a list of all the beliefs that have the specified left hand side concept and relation regardless of their right hand side concept. If the lhs concept is a class type concept the method will return all beliefs for the concepts instances that are instances of the specified lhs concept.

Parameters:
lhsConcept - the left hand side Concept in the requested belief(s)
relation - the Relation in the requested belief(s)
Returns:
Enumeration a list of VMBeliefCtx's

getBeliefs

public java.util.Enumeration<IBeliefCtx> getBeliefs(Concept lhsConcept,
                                                    Relation relation,
                                                    int truthvalue)
Returns a list of all the beliefs that have the specified left hand side concept, relation and truth value regardless of their right hand side concept. If the lhs concept is a class type concept the method will return all beliefs for the concepts instances that are instances of the specified lhs concept.

Parameters:
lhsConcept - the left hand side Concept in the requested belief(s)
relation - the Relation in the requested belief(s)
truthvalue - the truth value in the requested belief(s) (TRUE, FALSE, UNKNOWN)
Returns:
Enumeration a list of VMBeliefCtx's
See Also:
IConstants.TRUE, IConstants.FALSE, IConstants.UNKNOWN

getBeliefs

public java.util.Enumeration<IBeliefCtx> getBeliefs(Relation relation,
                                                    java.lang.Object rhsConcept,
                                                    int truthvalue)
Returns a list of all the beliefs that have the specified relation and right hand side concept, and truth value regardless of their left hand side concept. If the rhs concept is a class type concept the method will return all beliefs for the concepts instances that are instances of the specified rrs concept.

Parameters:
relation - the Relation in the requested belief(s)
rhsConcept - the right hand side Concept in the requested belief(s) or the value unknown
truthvalue - the truth value in the requested belief(s) (TRUE, FALSE, UNKNOWN)
Returns:
Enumeration a list of VMBeliefCtx's
See Also:
IConstants.TRUE, IConstants.FALSE, IConstants.UNKNOWN, IConstants.unknown

getBeliefs

public java.util.Enumeration<IBeliefCtx> getBeliefs(Concept lhsConcept,
                                                    Relation relation,
                                                    java.lang.Object rhsConcept,
                                                    int truthvalue)
Returns a list of all the beliefs that have the specified left hand side concept, relation, right-hand side concept and truth value. If either the lhs concept or rhs concept is a class type concept the method will return all beliefs for the concepts that are instances of the specified lhs or rhs concept.

Parameters:
lhsConcept - the left hand side Concept in the requested belief(s)
relation - the Relation in the requested belief(s)
rhsConcept - the right hand side Concept in the requested belief(s) or the value unknown
truthvalue - the truth value in the requested belief(s) (TRUE, FALSE, UNKNOWN)
Returns:
Enumeration a list of VMBeliefCtx's
See Also:
IConstants.TRUE, IConstants.FALSE, IConstants.UNKNOWN

getRemoteBeliefs

public java.util.Enumeration<IBeliefCtx> getRemoteBeliefs(ActiveInstance requestor)
                                                   throws VMException
Requests from this remote agent the set of beliefs matching the specified pattern.

Parameters:
requestor - the ActiveInstance requesting the beliefs
Returns:
Enumeration the list of a list of VMBeliefCtx's
Throws:
VMException - if an error occurred during the belief retrieval

removeAllBeliefs

public void removeAllBeliefs()
Clears the active instance's belief set.

Specified by:
removeAllBeliefs in interface IActiveInstanceCtx
Overrides:
removeAllBeliefs in class ActiveInstanceCtx

hasAddedBelief

public boolean hasAddedBelief()
Returns whether or not the active instance has added a belief after an addBelief.

Returns:
boolean true if the active instance successfully added a belief after an addBelief

hasRemovedBelief

public boolean hasRemovedBelief()
Returns whether or not the active instance has removed a belief after an addBelief or removeBelief.

Returns:
boolean true if the active instance removed a belief after an addBelief or removeBelief

getRemovedBeliefs

public java.util.ListIterator<VMBeliefCtx> getRemovedBeliefs()
Returns the belief removed from the belief set as a result of an addBelief or removeBelief.

Returns:
ListIterator the list of belief contexts for the removed beliefs, an empty list if no beliefs were removed.
See Also:
hasRemovedBelief()

containsBelief

public boolean containsBelief(Statement statement)
Checks if a belief with the same contents as the specified contents exists in the belief set. If so true will be returned, if not false will be returned.

Note that this method does not check whether the belief set contains the same statement reference as specified for this method, it only compares the contents of the statement to the beliefs in this belief set.

Parameters:
statement - the belieft to be checked
Returns:
boolean true if the belief set contains a belief with the same contents, false otherwise

getContainedInstances

public java.util.LinkedList<Concept> getContainedInstances()
Returns a list of the active instances contained by this active instance.

Returns:
LinkedList a list of ActiveInstance

addKnowsLocationOf

protected void addKnowsLocationOf(VMActiveInstanceCtx containedInstance)
Adds the specified contained instance as a contained instance we know the location of.

Note: This method is only used by VMAreaCtx to keep track of what location beliefs about a contained instance we need to re-assert when arriving in a location.

Parameters:
containedInstance - the VMActiveInstanceCtx to be added

removeKnowsLocationOf

protected void removeKnowsLocationOf(VMActiveInstanceCtx containedInstance)
Removes the specified contained instance as a contained instance we know the location of.

Note: This method is only used by VMAreaCtx to keep track of what location beliefs about a contained instance we need to re-assert when arriving in a location.

Parameters:
containedInstance - the VMActiveInstanceCtx to be removed

getKnowsLocationOf

protected java.util.ListIterator<VMActiveInstanceCtx> getKnowsLocationOf()
Returns a list of contained instances we know the location of.

Note: This method is only used by VMAreaCtx to keep track of what location beliefs about a contained instance we need to re-assert when arriving in a location.

Returns:
ListIterator a list of VMActiveInstanceCtx being the contained instances we know the location of

knowsLocationOf

protected boolean knowsLocationOf(VMActiveInstanceCtx containedInstance)
Checks if the active instance knows the location of the specified contained instance.

Note: This method is only used by VMAreaCtx to keep track of what location beliefs about a contained instance we need to re-assert when arriving in a location.

Parameters:
containedInstance - the VMActiveInstanceCtx to be checked
Returns:
boolean true if the active instance knows about the location, false otherwise

clearKnowsLocationOf

protected void clearKnowsLocationOf()
Clears the list of contained instances we know the location of.


getLocationAttribute

public final Attribute getLocationAttribute()
Returns the attribute used to specify the location of the active instance in facts and beliefs about the active instance's location.

Returns:
Attribute the location Attribute, null if it could not be found

getContainsRelation

public final Relation getContainsRelation()
Returns the relation used in facts and beliefs to specify the agents/ objects contained by this active instance.

Returns:
Relation the contains Relation, null if it could not be found

getPriorityAvailableWorkframe

public IWorkframeCtx getPriorityAvailableWorkframe()
Returns the highest priority available workframe in the hierarchy of workframe contexts if a hierarchy exists due to the use of composite activities.

Specified by:
getPriorityAvailableWorkframe in interface gov.nasa.arc.brahms.vm.engine.IPriorityWorkManager
Overrides:
getPriorityAvailableWorkframe in class ActiveInstanceCtx
Returns:
IWorkframeCtx the context of the highest priority available workframe, null if there are no available workframes.

getPriorityAvailableThoughtframe

public IThoughtframeCtx getPriorityAvailableThoughtframe()
Returns the highest priority available thoughtframe in the hierarchy of workframe contexts if a hierarchy exists due to the use of composite activities.

Specified by:
getPriorityAvailableThoughtframe in interface gov.nasa.arc.brahms.vm.engine.IPriorityWorkManager
Overrides:
getPriorityAvailableThoughtframe in class ActiveInstanceCtx
Returns:
IThoughtframeCtx the context of the highest priority available thoughtframe, null if there are no available thoughtframes.

getPriorityInterruptedFrame

public IWorkframeCtx getPriorityInterruptedFrame()
Returns the highest priority interrupted workframe in the hierarchy of workframe contexts if a hierarchy exists due to the use of composite activities.

Specified by:
getPriorityInterruptedFrame in interface gov.nasa.arc.brahms.vm.engine.IPriorityWorkManager
Overrides:
getPriorityInterruptedFrame in class ActiveInstanceCtx
Returns:
IWorkframeCtx the context of the highest priority interrupted workframe, null if there are no interrupted workframes.

addActiveDetectable

public void addActiveDetectable(IDetectableCtx detectable)
                         throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified detectable as an active detectable to the list of active detectables. An active detectable is actively checked for fact detection and actions on beliefs.

Parameters:
detectable - the IDetectableCtx for the detectable active in the workframe
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if the detectable is null

removeActiveDetectable

public void removeActiveDetectable(IDetectableCtx detectable)
                            throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Removes the specified detectable as an active detectable from the list of active detectables.

Parameters:
detectable - the IDetectableCtx for the detectable to be removed as an active detectable
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if the detectable is null or no active detectables exist or the specified detectable is not found

getActiveDetectables

public java.util.ListIterator<IDetectableCtx> getActiveDetectables()
                                                            throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the list of active detectables.

Returns:
ListIterator the list of active detectables (IDetectableCtx)
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no active detectables exist

registerForMonitoring

public void registerForMonitoring()
Registers this agent to be monitored by the agent monitor.


deregisterForMonitoring

public void deregisterForMonitoring()
Registers this agent to be monitored by the agent monitor.


registerThreadListener

public void registerThreadListener()
Registers a thread listener to detect when this agent's thread of execution is terminated and under what circumstances.


deregisterThreadListener

public void deregisterThreadListener()
Deregisters the thread listener to detect when this agent's thread of execution is terminated and under what circumstances.


getStatusListeners

public java.util.List<gov.nasa.arc.brahms.vm.monitoring.IAgentStatusListener> getStatusListeners()
Returns a list of all of the registered IAgentStatusListeners.

Returns:
List the list of status listeners

addStatusListener

public void addStatusListener(gov.nasa.arc.brahms.vm.monitoring.IAgentStatusListener listener)
Adds the specified IAgentStatusListener as the listener to be notified of the agent's status and status changes.

Specified by:
addStatusListener in interface gov.nasa.arc.brahms.vm.monitoring.IMonitoredAgent
Parameters:
listener - the IAgentStatusListener to be registered

removeStatusListener

public void removeStatusListener(gov.nasa.arc.brahms.vm.monitoring.IAgentStatusListener listener)
Removes the specified IAgentStatusListener as the listener to be notified of the agent's status and status changes.

Specified by:
removeStatusListener in interface gov.nasa.arc.brahms.vm.monitoring.IMonitoredAgent
Parameters:
listener - the IAgentStatusListener to be deregistered

getContext

public IConceptCtx getContext()
Returns the agent's context used in a virtual machine.

Specified by:
getContext in interface gov.nasa.arc.brahms.vm.monitoring.IMonitoredAgent
Returns:
IConceptCtx the concept's context

getBeliefChangeSupport

public int getBeliefChangeSupport(java.lang.Object object)
Returns the current level of belief change support for a given Java object. This number will be used to determine the likelihood that a belief will be created when the Java object calls the propertyChange listener

Parameters:
object - the Java object that may have property change support
Returns:
int the value between 0 and 100 used for the likelihood

setBeliefChangeSupport

public void setBeliefChangeSupport(java.lang.Object object,
                                   int beliefSupport)
Sets the level of belief change support for a given Java object. This number will be used to determine the likelihood that a belief will be created when the Java object calls the propertyChange listener

Parameters:
object - the Java object that may have property change support
beliefSupport - the int between 0 and 100 representing the likelihood

getFactChangeSupport

public int getFactChangeSupport(java.lang.Object object)
Returns the current level of fact change support for a given Java object. This number will be used to determine the likelihood that a fact will be created when the Java object calls the propertyChange listener

Parameters:
object - the Java object that may have property change support
Returns:
int the value between 0 and 100 used for the likelihood

setFactChangeSupport

public void setFactChangeSupport(java.lang.Object object,
                                 int factSupport)
Sets the level of fact change support for a given Java object. This number will be used to determine the likelihood that a fact will be created when the Java object calls the propertyChange listener

Parameters:
object - the Java object that may have property change support
factSupport - the int between 0 and 100 representing the likelihood

registerJavaObject

public void registerJavaObject(java.lang.Object object,
                               int beliefSupport,
                               int factSupport)
Registers a Java object that may have property change support with given levels of belief support and fact support. Trys to add the active instance as a PropertyChangeListener with the Java object if the object is given a non-zero level of either belief support or fact support. Tries to remove the active instance as a PropertyChangeListener with the Java object if the belief support and fact support are both changed to 0.

Parameters:
object -
beliefSupport -
factSupport -

unregisterJavaObject

public void unregisterJavaObject(java.lang.Object object)
Unregisters a Java object for monitoring by this active instance. Tries to remove this active instance as a PropertyChangeListener on the Java object. Removes entries for the belief support and fact support levels maintained by this active instance for the object.

Parameters:
object - the Java object to be unregistered

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
The property change method required of a PropertyChangeListener. This method will be called by the PropertyChangeSupport mechanism of a Java bean with property change support when one of the bean properties gets a new value.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
evt - a JavaBean PropertyChangeEvent passed from the Java bean's PropertyChangeSupport
See Also:
PropertyChangeListener, PropertyChangeSupport, PropertyChangeEvent


Copyright © 1997-2012 All Rights Reserved.