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

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.AreaCtx
              extended by gov.nasa.arc.brahms.vm.rt.VMAreaCtx
All Implemented Interfaces:
IAreaCtx, IBrahmsObjectCtx, IConceptCtx, IRuntimeConstants, IRuntimeConceptCtx, java.io.Serializable

public class VMAreaCtx
extends AreaCtx
implements IRuntimeConceptCtx

The VMAreaCtx is the runtime representation of areas defined in a Brahms model with extensions for use in the virtual machine. The area context manages the creation and deletion time of the areas. Area contexts are also used to trace the traveled path of an active instance. In the case an area context is used to define a traveled path the start and end time represent the time the active instance arrived in the area and when the active instance left the area. The area context also manages a list of the active instances present in the location.

Version:
$Revision: 1.2 $ $Date: 2008/02/28 18:33:05 $ $Author: rvhoof $
Author:
Ron van Hoof
See Also:
AreaCtx, Serialized Form

Field Summary
 
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
VMAreaCtx(Area area)
          Constructor, creates a new context for the specified area.
 
Method Summary
 void addInhabitant(VMActiveInstanceCtx inhabitant, long time, int sourceType, BrahmsObjectCtx source)
          Adds the specified active instance to this location as an inhabitant.
protected  java.util.Enumeration getInhabitantsDetectingArrival(BrahmsObjectCtx source)
          Returns a list of all the inhabitants that can detect the arrival of an agent or object.
protected  java.util.Enumeration getInhabitantsDetectingDeparture(BrahmsObjectCtx source)
          Returns a list of all the inhabitants that can detect the departure of an agent or object.
protected  int getNodeIndex()
          Returns the node index used in Dijkstra's shortest path algorithm to determine the shortest duration from one area to another.
 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.
 void removeInhabitant(VMActiveInstanceCtx inhabitant, long time, int sourceType, BrahmsObjectCtx source)
          Removes the specified active instance from this location as an inhabitant It retracts the location fact and beliefs for the inhabitant and makes sure that the agents in the location will detect the agent leaving by retracting the location beliefs for the inhabitant.
 void removeInhabitant(VMActiveInstanceCtx inhabitant, long time, int sourceType, BrahmsObjectCtx source, java.util.LinkedList llCheckedInstances)
          Removes the specified active instance from this location as an inhabitant It retracts the location fact and beliefs for the inhabitant and makes sure that the agents in the location will detect the agent leaving by retracting the location beliefs for the inhabitant.
 void reset()
          Resets the area context, removing all inhabitants.
protected  void setNodeIndex(int index)
          Sets the node index used in Dijkstra's shortest path algorithm to determine the shortest duration from one area to another.
 
Methods inherited from class gov.nasa.arc.brahms.common.rt.AreaCtx
addInhabitant, getInhabitants, isInhabitant, removeAllInhabitants, removeInhabitant
 
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.common.rt.IBrahmsObjectCtx
addNote, getContextFor, getEndTime, getID, getNote, getNotes, getStartTime, removeNote, setEndTime, setID, setStartTime
 

Constructor Detail

VMAreaCtx

public VMAreaCtx(Area area)
Constructor, creates a new context for the specified area.

Parameters:
area - the Area for which to create a context
Method Detail

setNodeIndex

protected final void setNodeIndex(int index)
Sets the node index used in Dijkstra's shortest path algorithm to determine the shortest duration from one area to another. The index points to the location in the array of nodes for all the areas in the model.

Parameters:
index - the unique node index

getNodeIndex

protected final int getNodeIndex()
Returns the node index used in Dijkstra's shortest path algorithm to determine the shortest duration from one area to another. The index points to the location in the array of nodes for all the areas in the model.

Returns:
int the unique node index

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

reset

public void reset()
           throws VMException
Resets the area context, removing all inhabitants.

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

getInhabitantsDetectingArrival

protected java.util.Enumeration getInhabitantsDetectingArrival(BrahmsObjectCtx source)
                                                        throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns a list of all the inhabitants that can detect the arrival of an agent or object. If the source is a move activity then the detection areas are determined by that activity, otherwise the detection assumes this area as the location.

Parameters:
source - the source that caused the inhabitant to be added
Returns:
Enumeration a list of agents that can detect the arrival
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException

getInhabitantsDetectingDeparture

protected java.util.Enumeration getInhabitantsDetectingDeparture(BrahmsObjectCtx source)
                                                          throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns a list of all the inhabitants that can detect the departure of an agent or object. If the source is a move activity then the detection areas are determined by that activity, otherwise the detection assumes this area as the location.

Parameters:
source - the source that caused the inhabitant to be added
Returns:
Enumeration a list of agents that can detect the arrival
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException

addInhabitant

public void addInhabitant(VMActiveInstanceCtx inhabitant,
                          long time,
                          int sourceType,
                          BrahmsObjectCtx source)
                   throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified active instance to this location as an inhabitant. It creates the appropriate fact and beliefs for the inhabitant and makes sure that the environment in the location(s) specified by the move activity gets detected by the inhabitant. Agents in those location will detect the arriving inhabitant.

Parameters:
inhabitant - the active instance to be added
time - the time at which the inhabitant is added
sourceType - the type of the source
source - the source that caused the inhabitant to be added
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if a null inhabitant is specified

removeInhabitant

public void removeInhabitant(VMActiveInstanceCtx inhabitant,
                             long time,
                             int sourceType,
                             BrahmsObjectCtx source)
                      throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Removes the specified active instance from this location as an inhabitant It retracts the location fact and beliefs for the inhabitant and makes sure that the agents in the location will detect the agent leaving by retracting the location beliefs for the inhabitant.

Parameters:
inhabitant - the active instance to be removed
time - the time at which the inhabitant is removed
sourceType - the type of the source
source - the source that caused the inhabitant to be removed
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if a null inhabitant is specified, if no inhabitants are present in the location or if the inhabitant is not found

removeInhabitant

public void removeInhabitant(VMActiveInstanceCtx inhabitant,
                             long time,
                             int sourceType,
                             BrahmsObjectCtx source,
                             java.util.LinkedList llCheckedInstances)
                      throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Removes the specified active instance from this location as an inhabitant It retracts the location fact and beliefs for the inhabitant and makes sure that the agents in the location will detect the agent leaving by retracting the location beliefs for the inhabitant.

Parameters:
inhabitant - the active instance to be removed
time - the time at which the inhabitant is removed
sourceType - the type of the source
source - the source that caused the inhabitant to be removed
llCheckedInstances - the instances that were already removed from the location as a contained instance
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if a null inhabitant is specified, if no inhabitants are present in the location or if the inhabitant is not found


Copyright © 1997-2012 All Rights Reserved.