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

java.lang.Object
  extended by gov.nasa.arc.brahms.common.rt.BrahmsObjectCtx
      extended by gov.nasa.arc.brahms.common.rt.FrameCtx
All Implemented Interfaces:
IBrahmsObjectCtx, IFrameCtx, IRuntimeConstants, java.io.Serializable
Direct Known Subclasses:
ThoughtframeCtx, VMFrameCtx, WorkframeCtx

public class FrameCtx
extends BrahmsObjectCtx
implements IFrameCtx

The FrameCtx maintains the general state information for a Brahms frame, workframe or thoughtframe. The frame context maintains the status of the frame, the state of the frame, the executing active instance, and the contexts of the variables in the frame, preconditions that evaluated to true making the frame available and consequences fired in the frame. A modeled Brahms frame can have multiple contexts due to the possible different bindings of its variables.

Version:
13 March 2003
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
FrameCtx(BFrame frame)
          Constructor, creates a new context for the specified frame.
FrameCtx(BFrame frame, IActiveInstanceCtx agent)
          Constructor, creates a new context for the specified frame setting the specified agent as the agent working on frame.
 
Method Summary
 void addBinding(VariableCtx var)
          Adds the specified variable binding to this frame context.
 void addFiredConsequence(ConsequenceCtx consequence)
          Adds the specified consequence as a fired consequence to the list of fired consequences.
 VariableCtx getBinding(Variable var)
          Returns the binding for the specified variable.
 java.util.Enumeration getBindings()
          Returns the frame context's variable bindings.
 java.util.ListIterator getFiredConsequences()
          Returns the list of fired consequences.
 IActiveInstanceCtx getPerformedBy()
          Returns the active instance executing the frame.
 ICompositeActivityCtx getPerformedIn()
          If the frame is performed as part of a composite activity this method returns the context of the composite activity in which the frame is performed.
 int getPriority()
          Returns the priority of the frame context.
 FrameStateCtx getState()
          Returns the current state of the frame context.
 int getStatus()
          Returns the frame's current status.
 long getTimeAvailable()
          Returns the time the frame became available to work on.
 void removeBinding(VariableCtx var)
          Removes the specified variable binding from this frame context.
 void removeFiredConsequence(ConsequenceCtx consequence)
          Removes the specified consequence as a fired consequence from the list of fired consequences.
 void setPerformedBy(IActiveInstanceCtx ai)
          Sets the active instance executing the frame.
 void setPerformedIn(ICompositeActivityCtx act)
          If the frame is performed as part of a composite activity this method sets the context of the composite activity in which the frame is performed.
 void setPriority(int priority)
          Sets the priority of the frame context.
 void setState(FrameStateCtx state)
          Sets the current state of the frame context.
 void setState(FrameStateCtx state, boolean maintainHistory)
          Sets the current state of the frame context.
 void setStatus(int status)
          Sets the frame's current status.
 void setTimeAvailable(long time)
          Sets the time the frame became available to work on.
 java.lang.String toString()
          Returns the fully qualified name of the frame this is a context for.
 
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

FrameCtx

public FrameCtx(BFrame frame)
Constructor, creates a new context for the specified frame.

Parameters:
frame - the BFrame for which this frame context is a context

FrameCtx

public FrameCtx(BFrame frame,
                IActiveInstanceCtx agent)
Constructor, creates a new context for the specified frame setting the specified agent as the agent working on frame.

Parameters:
frame - the BFrame for which this frame context is a context
agent - the agent working on the frame
Method Detail

setPriority

public void setPriority(int priority)
                 throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Sets the priority of the frame context. The priority is calculated by the virtual machine based on the priorities of its activities.

Specified by:
setPriority in interface IFrameCtx
Parameters:
priority - the frame context's priority
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an invalid priority is specified (< 0)

getPriority

public int getPriority()
                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the priority of the frame context. The priority is calculated by the virtual machine based on the priorities of its activities.

Specified by:
getPriority in interface IFrameCtx
Returns:
int the frame context's priority
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no priority is set

setPerformedBy

public void setPerformedBy(IActiveInstanceCtx ai)
                    throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Sets the active instance executing the frame.

Specified by:
setPerformedBy in interface IFrameCtx
Parameters:
ai - the active instance executing the frame.
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if a null active instance is specified

getPerformedBy

public IActiveInstanceCtx getPerformedBy()
                                  throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the active instance executing the frame.

Specified by:
getPerformedBy in interface IFrameCtx
Returns:
IActiveInstanceCtx the active instance executing the frame.
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no active instance is specified

setPerformedIn

public void setPerformedIn(ICompositeActivityCtx act)
                    throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
If the frame is performed as part of a composite activity this method sets the context of the composite activity in which the frame is performed.

Specified by:
setPerformedIn in interface IFrameCtx
Parameters:
act - the ICompositeActivityCtx of the composite activity in which the frame is performed.
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if a null composite activity is specified.

getPerformedIn

public ICompositeActivityCtx getPerformedIn()
                                     throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
If the frame is performed as part of a composite activity this method returns the context of the composite activity in which the frame is performed.

Specified by:
getPerformedIn in interface IFrameCtx
Returns:
ICompositeActivityCtx the composite activity in which the frame is performed or null if the frame is not performed in a composite activity.
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs.

setStatus

public void setStatus(int status)
               throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Sets the frame's current status.

Specified by:
setStatus in interface IFrameCtx
Parameters:
status - the status of the frame context
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if status is an invalid status
See Also:
IRuntimeConstants.UNAVAILABLE, IRuntimeConstants.AVAILABLE, IRuntimeConstants.ACTIVE, IRuntimeConstants.INTERRUPTED, IRuntimeConstants.IMPASSED, IRuntimeConstants.ABORTED, IRuntimeConstants.COMPLETED, IRuntimeConstants.ENDED

getStatus

public int getStatus()
              throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the frame's current status.

Specified by:
getStatus in interface IFrameCtx
Returns:
int the status of the frame context
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if frame context has no status or invalid status
See Also:
IRuntimeConstants.UNAVAILABLE, IRuntimeConstants.AVAILABLE, IRuntimeConstants.ACTIVE, IRuntimeConstants.INTERRUPTED, IRuntimeConstants.IMPASSED, IRuntimeConstants.ABORTED, IRuntimeConstants.COMPLETED, IRuntimeConstants.ENDED

setState

public void setState(FrameStateCtx state)
Sets the current state of the frame context. No state history is maintained. Any previous state information is discarded.

Specified by:
setState in interface IFrameCtx
Parameters:
state - the FrameStateCtx with the state information
See Also:
ActiveCtx, AvailableCtx, UnavailableCtx, InterruptCtx, ImpasseCtx, CompleteCtx

setState

public void setState(FrameStateCtx state,
                     boolean maintainHistory)
Sets the current state of the frame context. Depending on the maintainHistory indicator a history of the states is maintained by linking the states in a list (maintainHistory == true). If maintainHistory is false no history is maintained and any previous state information is discarded.

Specified by:
setState in interface IFrameCtx
Parameters:
state - the FrameStateCtx with the state information
maintainHistory - true if history must be maintained, false otherwise
See Also:
ActiveCtx, AvailableCtx, UnavailableCtx, InterruptCtx, ImpasseCtx, CompleteCtx

getState

public FrameStateCtx getState()
Returns the current state of the frame context. If a history was maintained the history can be traversed using the states getPreviousFrameState and getNextFrameState methods.

Specified by:
getState in interface IFrameCtx
Returns:
FrameStateCtx the current state of the frame context, null if no state is set
See Also:
ActiveCtx, AvailableCtx, UnavailableCtx, InterruptCtx, ImpasseCtx, CompleteCtx

setTimeAvailable

public void setTimeAvailable(long time)
Sets the time the frame became available to work on.

Specified by:
setTimeAvailable in interface IFrameCtx
Parameters:
time - the time the frame became available in simulation units

getTimeAvailable

public long getTimeAvailable()
Returns the time the frame became available to work on.

Specified by:
getTimeAvailable in interface IFrameCtx
Returns:
long the time the frame became available in simulation units

addBinding

public void addBinding(VariableCtx var)
                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified variable binding to this frame context.

Specified by:
addBinding in interface IFrameCtx
Parameters:
var - the VariableCtx to be added
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if the specified variable is null.

removeBinding

public void removeBinding(VariableCtx var)
                   throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Removes the specified variable binding from this frame context.

Specified by:
removeBinding in interface IFrameCtx
Parameters:
var - the VariableCtx to be removed
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if a null variable is specified, no bindings are present or the specified variable is not present

getBinding

public VariableCtx getBinding(Variable var)
                       throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the binding for the specified variable.

Specified by:
getBinding in interface IFrameCtx
Parameters:
var - the variable for which the binding is requested
Returns:
VariableCtx the binding for the specified variable
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no binding for the specified variable exists

getBindings

public java.util.Enumeration getBindings()
                                  throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the frame context's variable bindings.

Specified by:
getBindings in interface IFrameCtx
Returns:
Enumeration an enumeration of VariableCtx's
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if frame context has no bindings

addFiredConsequence

public void addFiredConsequence(ConsequenceCtx consequence)
                         throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified consequence as a fired consequence to the list of fired consequences.

Specified by:
addFiredConsequence in interface IFrameCtx
Parameters:
consequence - the ConsequenceCtx for the consequence fired in the frame
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if the consequence is null

removeFiredConsequence

public void removeFiredConsequence(ConsequenceCtx consequence)
                            throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Removes the specified consequence as a fired consequence from the list of fired consequences.

Specified by:
removeFiredConsequence in interface IFrameCtx
Parameters:
consequence - the ConsequenceCtx for the consequence fired in the frame
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if the consequence is null or no fired consequences exist or the specified consequence is not found

getFiredConsequences

public java.util.ListIterator getFiredConsequences()
                                            throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the list of fired consequences.

Specified by:
getFiredConsequences in interface IFrameCtx
Returns:
ListIterator the list of fired consequences (ConsequenceCtx)
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no fired consequences exist

toString

public java.lang.String toString()
Returns the fully qualified name of the frame this is a context for.

Overrides:
toString in class java.lang.Object
Returns:
String string representation of this context


Copyright © 1997-2012 All Rights Reserved.