gov.nasa.arc.brahms.vm.data
Class VMDetectable

java.lang.Object
  extended by gov.nasa.arc.brahms.common.data.BrahmsObject
      extended by gov.nasa.arc.brahms.common.data.ModelElement
          extended by gov.nasa.arc.brahms.common.data.Condition
              extended by gov.nasa.arc.brahms.common.data.Detectable
                  extended by gov.nasa.arc.brahms.vm.data.VMDetectable
All Implemented Interfaces:
gov.nasa.arc.brahms.common.IConstants, java.io.Serializable

public class VMDetectable
extends Detectable

A VMDetectable is a Detectable with extensions for use in the Brahms virtual machine. A detectable is a declarative statement defining first which state changes an agent or object can detect and second what action results from detecting the state change.

Detecting facts is a two-step process. In the first step the agent or object detects the fact and the fact becomes a belief for the agent or object. No matter what the right hand side is in the form OA=V and OA=O the fact will become a belief for the agent or object. The second step is different for agents and objects. For agents in the second step the beliefs of the agent are matched with the detectable definition and if there is a positive match, the detectable action is executed. For objects in the second step the facts in the world are matched with the detectable definition and if there's a positive match, the detectable action is executed.

Note that these two steps are independent for agents, i.e. regardless of whether the fact is present in the world, the second step is performed. This means that if the agent has received a matching belief through a communication, the belief will trigger the action of the detectable. For objects this is irrelevant since it only performs the action based on the fact in the world which is also used in the first step.

Version:
8 August 2001
Author:
Ron van Hoof
See Also:
Detectable, Serialized Form

Field Summary
 
Fields inherited from interface gov.nasa.arc.brahms.common.IConstants
ABORT, ACTIVECLASS, ACTIVECONCEPT, ACTIVEINSTANCE, AGENT, ANONYMOUS, ANYAGENT, AREA, AREADEF, ASSIGNED, ATTRIBUTE, BASEAREADEF, BASECLASS, BASECONCEPTUALCLASS, BASEGROUP, BASELIBRARY, BOOLEAN, BROADCAST, BUILDING, BYTE, CCLOCK, CDATE, CHAR, CITY, CLASS, CLOCK, COLLECTALL, COMMUNICATE, COMPLETE, COMPOSITE, COMPUTER, CONCEPT, CONCEPTUALCLASS, CONCEPTUALCONCEPT, CONCEPTUALOBJECT, CONTINUE, COPY, CREATEAGENT, CREATEAREA, CREATEOBJECT, current, CURRENT, DATAFRAME, DATE, DB, DETECTABLE, DIV, DOUBLE, EMAIL, EMPTY_STRING, END, ENDACTIVITY, ENTAGENT, EQ, EXCEPTION, EXPR, FACE2FACE, FACTFRAME, FALSE, FAX, FLOAT, FOREACH, FORONE, G2, GE, GEOGRAPHYCONCEPT, GESTURE, GET, GROUP, GT, IMPASSE, INT, INVALID, JAVA, JAVA_TYPE, KNOWN_MODIFIER, KNOWNVAL_MODIFIER, LE, LOCAL, LONG, LT, MAP, MINUS, MOD, MOVE, MULT, NE, NEW, NONE, NOT_MODIFIER, NOWORK, O, OA, OBJECT, ONTOLOGY, PAGER, PARAMETER, PATH, PHONE, PLUS, PRIMITIVE, PRIVATE, PROAGENT, PROTECTED, PRSAGENT, PUBLIC, PUT, RECEIVE, RELATION, sACTIVECLASS, sACTIVECONCEPT, sACTIVEINSTANCE, sAGENT, sARCHIVE, sAREA, sAREADEF, sBOOLEAN, sBYTE, sBYTECODEEXT, sCHAR, sCLASS, sCOMPUTER, sCONCEPT, sCONCEPTUALCLASS, sCONCEPTUALCONCEPT, sCONCEPTUALOBJECT, sCOPY, sCURRENT, sDETECTABLE, sDOUBLE, sEMAIL, sEND, SEND, sFACE2FACE, sFAX, sFILEEXT, sFLOAT, sGEOGRAPHYCONCEPT, sGROUP, SHORT, SIMAGENT, sINT, sJAVA_TYPE, sLONG, sMAP, sNEW, sNONE, sNOWORK, sOBJECT, SOURCECODE, sPAGER, sPARAMETER, sPATH, sPHONE, sPRIVATE, sPROJECTEXT, sPROTECTED, sPUBLIC, sSHORT, sSTART, sSTRING, sSYMBOL, START, STRING, sUNKNOWN, sVOID, SYMBOL, TRUE, UDT, UML, UNASSIGNED, UNDEFINED, unknown, UNKNOWN, UNKNOWN_MODIFIER, V, VARIABLE, VOID, WHENEVER, WORKFRAME, WORLD, XML
 
Constructor Summary
VMDetectable()
          Constructor, creates a new detectable.
VMDetectable(java.lang.String name)
          Constructor, creates a new detectable with the specified name.
VMDetectable(java.lang.String name, Comparison c)
          Constructor, create a new detectable with the specified name and the specified comparison specifying the condition to be detected.
VMDetectable(java.lang.String name, Comparison c, int truth)
          Constructor, create a new detectable with the specified name and the specified comparison and truth value specifying the condition to be detected.
 
Method Summary
 IDetectableCtx createContext()
          Creates a new context for this detectable.
 java.util.Enumeration getMatchingFacts(VMActiveInstanceCtx agent, VMFrameCtx frame)
          Returns a list of all the facts that match with the detectable's condition by just comparing the facts with the left hand side of the detectable condition.
 VMBeliefCtx matchesBelief(VMActiveInstanceCtx agent, VMFrameCtx frame)
          Checks whether any of the beliefs in the specified agent's belief set match with this detectable.
 boolean matchesBelief(VMBeliefCtx belief, VMActiveInstanceCtx agent, VMFrameCtx frame)
          Checks whether the specified belief matches with this detectable.
 boolean matchesFact(VMFactCtx fact, VMActiveInstanceCtx agent, VMFrameCtx frame)
          Checks whether the specified fact matches the detectable condition by only considering the left hand side of the detectable condition.
 
Methods inherited from class gov.nasa.arc.brahms.common.data.Detectable
getAction, getCertainty, getFullyQualifiedName, getName, getWhen, setAction, setCertainty, setID, setName, setWhen, toString
 
Methods inherited from class gov.nasa.arc.brahms.common.data.Condition
getComparison, getOwner, getParameters, getTruthValue, getTruthValueAsString, getVariables, setComparison, setOwner, setOwner, setOwner, setTruthValue, toSource
 
Methods inherited from class gov.nasa.arc.brahms.common.data.BrahmsObject
delete, export, getFile, getID, getLine, getSerialNumber, isBCC, isDynamic, isLoaded, isResolved, setBCC, setDynamic, setFile, setID, setLine, setLoaded, setResolved, setSerialNumber
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VMDetectable

public VMDetectable()
Constructor, creates a new detectable.


VMDetectable

public VMDetectable(java.lang.String name)
Constructor, creates a new detectable with the specified name.

Parameters:
name - the name for the detectable

VMDetectable

public VMDetectable(java.lang.String name,
                    Comparison c)
Constructor, create a new detectable with the specified name and the specified comparison specifying the condition to be detected.

Parameters:
name - the name for the detectable
c - the Comparison

VMDetectable

public VMDetectable(java.lang.String name,
                    Comparison c,
                    int truth)
Constructor, create a new detectable with the specified name and the specified comparison and truth value specifying the condition to be detected.

Parameters:
name - the name for the detectable
c - the Comparison
truth - the truth-value of the condition (TRUE, FALSE, UNKNOWN)
See Also:
IConstants.TRUE, IConstants.FALSE, IConstants.UNKNOWN
Method Detail

getMatchingFacts

public java.util.Enumeration getMatchingFacts(VMActiveInstanceCtx agent,
                                              VMFrameCtx frame)
Returns a list of all the facts that match with the detectable's condition by just comparing the facts with the left hand side of the detectable condition. If no facts match the enumeration will have no elements.

Parameters:
agent - the agent for whom the detectable is checked
frame - the frame in which the detectable is fired and containing the variable contexts
Returns:
Enumeration a list of VMFactCtx with the matching facts, an empty enumeration if there are no matching facts

matchesFact

public boolean matchesFact(VMFactCtx fact,
                           VMActiveInstanceCtx agent,
                           VMFrameCtx frame)
Checks whether the specified fact matches the detectable condition by only considering the left hand side of the detectable condition.

Parameters:
fact - the fact to be tested
agent - the agent for whom the detectable is checked
frame - the frame in which the detectable is fired and containing the variable contexts
Returns:
boolean true of the fact matched, false otherwise

matchesBelief

public VMBeliefCtx matchesBelief(VMActiveInstanceCtx agent,
                                 VMFrameCtx frame)
Checks whether any of the beliefs in the specified agent's belief set match with this detectable. If so it will return true, if no beliefs match false is returned. A belief must match the complete detectable condition.

Parameters:
agent - the agent for whom the detectable is checked and whom's belief set is to be checked against detectable condition
frame - the frame in which the detectable is fired and containing the variable contexts
Returns:
VMBeliefCtx the belief from the belief set that matches the detectable condition, null if no belief matches the detectable condition

matchesBelief

public boolean matchesBelief(VMBeliefCtx belief,
                             VMActiveInstanceCtx agent,
                             VMFrameCtx frame)
Checks whether the specified belief matches with this detectable. If so it will return true, if the belief does not match false is returned. The belief must match the complete detectable condition.

Parameters:
belief - the belief to be tested
agent - the agent for whom the detectable is checked
frame - the frame in which the detectable is fired and containing the variable contexts
Returns:
true if a belief from the belief set matches the detectable condition, false otherwise

createContext

public IDetectableCtx createContext()
Creates a new context for this detectable.

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

Overrides:
createContext in class Detectable
Returns:
IDetectableCtx a context for the detectable


Copyright © 1997-2012 All Rights Reserved.