gov.nasa.arc.brahms.common.rt
Class BrahmsObjectCtx

java.lang.Object
  extended by gov.nasa.arc.brahms.common.rt.BrahmsObjectCtx
All Implemented Interfaces:
IBrahmsObjectCtx, IRuntimeConstants, java.io.Serializable
Direct Known Subclasses:
ActivityCtx, ActivityStateCtx, AssignmentCtx, ConceptCtx, ConditionCtx, ContainedInstanceCtx, DeleteCtx, DetectCtx, FrameCtx, FrameStateCtx, MethodInvocationCtx, ModelCtx, ParameterCtx, PartCtx, StatementCtx, TriggerCtx, VariableCtx

public class BrahmsObjectCtx
extends java.lang.Object
implements IBrahmsObjectCtx, IRuntimeConstants, java.io.Serializable

The BrahmsObjectCtx class defines the base class for all contexts in the Brahms system as part of the dynamic model. The BrahmsObject context class manages the start and end times of the contexts or depending on the type of object the creation and deletion time of an object. Every context allows for additional notes to capture additional information for explanation purposes. The contexts in the dynamic model are generally used to maintain the state information for the elements defined in a Brahms model in a simulation or when running intelligent agents.

Version:
1.0
Author:
Ron van Hoof
See Also:
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
BrahmsObjectCtx()
          Constructor, creates a new context that has no relationship with a BrahmsObject.
BrahmsObjectCtx(BrahmsObject obj)
          Constructor, creates a new context for the specified BrahmsObject.
 
Method Summary
 void addNote(Note note)
          Adds a note to the context.
 BrahmsObject getContextFor()
          Returns the BrahmsObject this context is a context for.
 long getEndTime()
          Returns the end time.
 java.lang.String getID()
          Returns the unique identifier for the context.
 Note getNote(int index)
          Returns the note defined at the given index.
 java.util.Enumeration getNotes()
          Returns a list of all the notes for the context.
 long getStartTime()
          Returns the start time.
 void removeNote(Note note)
          Removes a note from the context.
 void setContextFor(BrahmsObject obj)
          Sets the BrahmsObject for which this context is a context.
 void setEndTime(long endTime)
          Sets the end time.
 void setID(java.lang.String id)
          Sets a unique identifier for the context.
 void setStartTime(long startTime)
          Sets the start time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BrahmsObjectCtx

public BrahmsObjectCtx()
Constructor, creates a new context that has no relationship with a BrahmsObject.


BrahmsObjectCtx

public BrahmsObjectCtx(BrahmsObject obj)
Constructor, creates a new context for the specified BrahmsObject.

Parameters:
obj - the BrahmsObject for which to create a context
Method Detail

setID

public void setID(java.lang.String id)
Sets a unique identifier for the context. Not all contexts are required to have a unique identifier.

Specified by:
setID in interface IBrahmsObjectCtx
Parameters:
id - the unique identifier for the context

getID

public java.lang.String getID()
Returns the unique identifier for the context. Not all contexts are required to have a unique identifier.

Specified by:
getID in interface IBrahmsObjectCtx
Returns:
String the unique identifier for the context, empty string if no id is specified

setStartTime

public void setStartTime(long startTime)
                  throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Sets the start time. The start time represents either the time a object was started or the time an object was created. The time is represented in simulation units when used in a simulation run and the time is represented in milliseconds when used in an intelligent agent mode.

Specified by:
setStartTime in interface IBrahmsObjectCtx
Parameters:
startTime - the time the object was started or created.
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if the start time is <= 0

getStartTime

public long getStartTime()
Returns the start time. The start time represents either the time an object was started or the time an object was created. The time is represented in simulation units when used in a simulation run and the time is represented in milliseconds when used in an intelligent agent mode.

Specified by:
getStartTime in interface IBrahmsObjectCtx
Returns:
long the time the object was started or created.

setEndTime

public void setEndTime(long endTime)
                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Sets the end time. The end time represents either the time an object was ended or the time an object was deleted. The time is represented in simulation units when used in a simulation run and the time is represented in milliseconds when used in an intelligent agent mode.

Specified by:
setEndTime in interface IBrahmsObjectCtx
Parameters:
endTime - the time the object was ended or deleted.
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if the end time is <= 0 && end time < start time

getEndTime

public long getEndTime()
Returns the end time. The end time represents either the time an object was ended or the time an object was deleted. The time is represented in simulation units when used in a simulation run and the time is represented in milliseconds when used in an intelligent agent mode.

Specified by:
getEndTime in interface IBrahmsObjectCtx
Returns:
long the time the object was ended or deleted.

addNote

public void addNote(Note note)
             throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds a note to the context. A note provides additional information relevant for the context that can be used to further explain the use of a specific context. Notes are generally used in the Brahms explanation facility.

Specified by:
addNote in interface IBrahmsObjectCtx
Parameters:
note - the Note to be added to the context.
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if note is null

removeNote

public void removeNote(Note note)
                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Removes a note from the context.

Specified by:
removeNote in interface IBrahmsObjectCtx
Parameters:
note - the Note to be removed from the context
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if note is null, no notes present or note not present

getNotes

public java.util.Enumeration getNotes()
                               throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns a list of all the notes for the context.

Specified by:
getNotes in interface IBrahmsObjectCtx
Returns:
Enumeration the list of notes.
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no notes are present

getNote

public Note getNote(int index)
             throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the note defined at the given index.

Specified by:
getNote in interface IBrahmsObjectCtx
Parameters:
index - the index of the requested Note
Returns:
Note the note at the given index
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no notes are registered or an invalid index is given.

setContextFor

public void setContextFor(BrahmsObject obj)
Sets the BrahmsObject for which this context is a context.

Parameters:
obj - the BrahmsObject for which this context is a context

getContextFor

public BrahmsObject getContextFor()
                           throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the BrahmsObject this context is a context for.

Specified by:
getContextFor in interface IBrahmsObjectCtx
Returns:
BrahmsObject the brahms object this context is a context for.
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no BrahmsObject is defined for the context


Copyright © 1997-2012 All Rights Reserved.