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

java.lang.Object
  extended by gov.nasa.arc.brahms.common.rt.BrahmsObjectCtx
      extended by gov.nasa.arc.brahms.common.rt.FrameCtx
          extended by gov.nasa.arc.brahms.vm.rt.VMFrameCtx
All Implemented Interfaces:
IBrahmsObjectCtx, IFrameCtx, IRuntimeConstants, gov.nasa.arc.brahms.vm.events.IDiscreteEventData, gov.nasa.arc.brahms.vm.events.IDiscreteEventHandler, java.io.Serializable
Direct Known Subclasses:
VMThoughtframeCtx, VMWorkframeCtx

public abstract class VMFrameCtx
extends FrameCtx
implements gov.nasa.arc.brahms.vm.events.IDiscreteEventData, gov.nasa.arc.brahms.vm.events.IDiscreteEventHandler

The VMFrameCtx maintains the general state information for a Brahms frame, workframe or thoughtframe and is a specialization of the FrameCtx to provide extensions for use in the virtual machine. 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:
1 April 2002
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
VMFrameCtx(BFrame frame)
          Constructor, creates a new context for the specified frame.
VMFrameCtx(BFrame frame, VMActiveInstanceCtx agent)
          Constructor, creates a new context for the specified frame setting the specified agent as the agent working on frame.
 
Method Summary
 void addFrameStatusListener(IFrameStatusListener listener)
          Registers the specified listener as a frame status listener with this frame context.
protected abstract  void doWork(long currentTime)
          Executes work up to the time higher then the time currently being executed.
protected  void fireStatusChanged(FrameStatusEvent evt)
          Distributes the specified status event to all registered frame status listeners.
 boolean handleDiscreteEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Process the specified discrete event.
 boolean handleDiscreteEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt, gov.nasa.arc.brahms.vm.events.IDiscreteEventHandlerFactory ehf)
          Handles the specified discrete event by selecting the appropriate event handler from the specified event handler factory.
 void onAvailable(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Called when the frame context is made available.
 void onEnd(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Called when a frame terminated under normal conditions meaning that there was nothing more to work on.
 void onStart(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Called when the frame context is started for the first time.
 void onUnavailable(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Called when the frame context is made unavailable.
 void removeFrameStatusListener(IFrameStatusListener listener)
          Unregisters the specified listener as a frame status listener with this frame context.
 void setStatus(int status)
          Sets the frame's current status.
 
Methods inherited from class gov.nasa.arc.brahms.common.rt.FrameCtx
addBinding, addFiredConsequence, getBinding, getBindings, getFiredConsequences, getPerformedBy, getPerformedIn, getPriority, getState, getStatus, getTimeAvailable, removeBinding, removeFiredConsequence, setPerformedBy, setPerformedIn, setPriority, setState, setState, setTimeAvailable, 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

VMFrameCtx

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

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

VMFrameCtx

public VMFrameCtx(BFrame frame,
                  VMActiveInstanceCtx 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

doWork

protected abstract void doWork(long currentTime)
Executes work up to the time higher then the time currently being executed.

Parameters:
currentTime - the time at which and for which work can be executed
Throws:
VMError - if an unexpected error occurs in executing the work

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
Overrides:
setStatus in class FrameCtx
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

addFrameStatusListener

public void addFrameStatusListener(IFrameStatusListener listener)
Registers the specified listener as a frame status listener with this frame context.

Parameters:
listener - the IFrameStatusListener registering for status events
See Also:
IFrameStatusListener

removeFrameStatusListener

public void removeFrameStatusListener(IFrameStatusListener listener)
Unregisters the specified listener as a frame status listener with this frame context.

Parameters:
listener - the IFrameStatusListener to be unregistered
See Also:
IFrameStatusListener

fireStatusChanged

protected void fireStatusChanged(FrameStatusEvent evt)
Distributes the specified status event to all registered frame status listeners.

Parameters:
evt - the FrameStatusEvent to be distributed to all frame status listeners.
See Also:
FrameStatusEvent, IFrameStatusListener

handleDiscreteEvent

public boolean handleDiscreteEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt,
                                   gov.nasa.arc.brahms.vm.events.IDiscreteEventHandlerFactory ehf)
Handles the specified discrete event by selecting the appropriate event handler from the specified event handler factory. The specified event contains as its data the object implementing this interface. The following should be the case: evt.getData() == this

Specified by:
handleDiscreteEvent in interface gov.nasa.arc.brahms.vm.events.IDiscreteEventData
Parameters:
evt - the DiscreteEvent to be handled
ehf - the EventHandlerFactory containing handlers from which this DiscreteEventData selects the appropriate handler
Returns:
boolean true if the event could be processed, false if not

handleDiscreteEvent

public boolean handleDiscreteEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Process the specified discrete event.

Specified by:
handleDiscreteEvent in interface gov.nasa.arc.brahms.vm.events.IDiscreteEventHandler
Parameters:
evt - the DiscreteEvent to be processed.
Returns:
boolean true if the event could be processed, false if not

onAvailable

public void onAvailable(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Called when the frame context is made available. Sets the status and notifies the event notifier of the availability.

Parameters:
evt - the DiscreteEvent that initiated the availability of the frame

onUnavailable

public void onUnavailable(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Called when the frame context is made unavailable. Sets the status and notifies the event notifier of the unavailability.

Parameters:
evt - the DiscreteEvent that initiated the unavailability of the frame

onStart

public void onStart(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Called when the frame context is started for the first time. Notifies the event notifier that the frame is started.

Parameters:
evt - the DiscreteEvent that initiated the start of the frame

onEnd

public void onEnd(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Called when a frame terminated under normal conditions meaning that there was nothing more to work on. Sets the status and notifies the event notifier that the frame ended.

Parameters:
evt - the DiscreteEvent that initiated the end of the frame


Copyright © 1997-2012 All Rights Reserved.