gov.nasa.arc.brahms.common.data
Class Detectable

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
All Implemented Interfaces:
gov.nasa.arc.brahms.common.IConstants, java.io.Serializable
Direct Known Subclasses:
VMDetectable

public class Detectable
extends Condition

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:
$Revision: 1.2 $ $Date: 2009/06/16 21:36:17 $ $Author: rvhoof $
Author:
Ron van Hoof
See Also:
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
Detectable()
          Constructor, creates a new detectable.
Detectable(java.lang.String name)
          Constructor, creates a new detectable with the specified name.
Detectable(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.
Detectable(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.
 int getAction()
          Returns the action to be performed when the detectable's condition exactly matches with an asserted belief (in case of an agent) or fact (in case of an object).
 int getCertainty()
          Returns the certainty that the detectable detects a fact.
 java.lang.String getFullyQualifiedName()
          Returns the fully qualified name of the detectable.
 java.lang.String getName()
          Returns the name of the detectable.
 int getWhen()
          Returns when the detectable is to be activated.
 void setAction(int action)
          Sets the action to be performed when the detectable's condition exactly matches with an asserted belief (in case of an agent) or fact (in case of an object).
 void setCertainty(int certainty)
          Sets the certainty that the detectable detects a fact.
protected  void setID()
          Sets the unique identifier.
 void setName(java.lang.String name)
          Sets the name of the detectable.
 void setWhen(int when)
          Sets when the detectable is to be activated.
 java.lang.String toString()
          Returns the string representation of the detectable
 
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

Detectable

public Detectable()
Constructor, creates a new detectable.


Detectable

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

Parameters:
name - the name for the detectable

Detectable

public Detectable(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

Detectable

public Detectable(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
Method Detail

setID

protected void setID()
Sets the unique identifier.

Overrides:
setID in class BrahmsObject

setName

public void setName(java.lang.String name)
Sets the name of the detectable.

Parameters:
name - the name of the detectable

getName

public java.lang.String getName()
Returns the name of the detectable.

Returns:
String the name of the detectable

setWhen

public void setWhen(int when)
Sets when the detectable is to be activated. 'Whenever' means that the detectable is immediately active as soon as the workframe or composite activity in which it is specified becomes active and it will detect facts as soon as the fact comes in. If not 'whenever' a time can be specified at which point the detectable is to be activated. Only after the specified time has passed since its parent workframe or composite activity has been activated will the detectable be able to detect facts and act on beliefs.

Parameters:
when - WHENEVER or a positive integer specifying the time passed before the detectable is to be activated
See Also:
IConstants.WHENEVER

getWhen

public int getWhen()
Returns when the detectable is to be activated. 'Whenever' means that the detectable is immediately active as soon as the workframe or composite activity in which it is specified becomes active and it will detect facts as soon as the fact comes in. If not 'whenever' a time can be specified at which point the detectable is to be activated. Only after the specified time has passed since its parent workframe or composite activity has been activated will the detectable be able to detect facts and act on beliefs.

Returns:
int WHENEVER or a positive integer specifying the time passed before the detectable is to be activated
See Also:
IConstants.WHENEVER

setCertainty

public void setCertainty(int certainty)
Sets the certainty that the detectable detects a fact. The certainty ranges from 0 to 100(%).

Parameters:
certainty - the certainty percentage

getCertainty

public int getCertainty()
Returns the certainty that the detectable detects a fact. The certainty ranges from 0 to 100(%).

Returns:
int the certainty percentage

setAction

public void setAction(int action)
Sets the action to be performed when the detectable's condition exactly matches with an asserted belief (in case of an agent) or fact (in case of an object). Continue makes the detectable detect a fact and just continue without causing any side effects. The impasse will cause the detection of a fact that matches with the detectable condition to impasse the workframe it is specified in until the value of the detected fact/belief changes. The complete action will cause the current activity to be aborted, all remaining activities in the workframe to be skipped but all consequences specified in the workframe after the aborted activity to be fired. The abort action aborts the current workframe immediately, aborting the current activity and skipping any remaining activities and consequences. The end-activity action is only used with composite activities to terminate a composite activity.

Parameters:
action - the detectable's action
See Also:
IConstants.CONTINUE, IConstants.IMPASSE, IConstants.COMPLETE, IConstants.ABORT, IConstants.ENDACTIVITY

getAction

public int getAction()
Returns the action to be performed when the detectable's condition exactly matches with an asserted belief (in case of an agent) or fact (in case of an object). Continue makes the detectable detect a fact and just continue without causing any side effects. The impasse will cause the detection of a fact that matches with the detectable condition to impasse the workframe it is specified in until the value of the detected fact/belief changes. The complete action will cause the current activity to be aborted, all remaining activities in the workframe to be skipped but all consequences specified in the workframe after the aborted activity to be fired. The abort action aborts the current workframe immediately, aborting the current activity and skipping any remaining activities and consequences. The end-activity action is only used with composite activities to terminate a composite activity.

Returns:
int the detectable's action
See Also:
IConstants.CONTINUE, IConstants.IMPASSE, IConstants.COMPLETE, IConstants.ABORT, IConstants.ENDACTIVITY

getFullyQualifiedName

public java.lang.String getFullyQualifiedName()
Returns the fully qualified name of the detectable. The fully qualified name of the detectable is the name of the detectable itself.

Returns:
String the fully qualified name

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.

Returns:
IDetectableCtx a context for the detectable

toString

public java.lang.String toString()
Returns the string representation of the detectable

Overrides:
toString in class Condition
Returns:
String the string representation


Copyright © 1997-2012 All Rights Reserved.