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

java.lang.Object
  extended by gov.nasa.arc.brahms.common.rt.BrahmsObjectCtx
      extended by gov.nasa.arc.brahms.common.rt.ActivityCtx
          extended by gov.nasa.arc.brahms.vm.rt.VMActivityCtx
              extended by gov.nasa.arc.brahms.vm.rt.VMPrimitiveActivityCtx
                  extended by gov.nasa.arc.brahms.vm.rt.VMBroadcastActivityCtx
All Implemented Interfaces:
IActivityCtx, IBrahmsObjectCtx, IBroadcastActivityCtx, IPrimitiveActivityCtx, IRuntimeConstants, gov.nasa.arc.brahms.vm.events.IDiscreteEventData, gov.nasa.arc.brahms.vm.events.IDiscreteEventHandler, java.io.Serializable
Direct Known Subclasses:
VMCommunicateActivityCtx

public class VMBroadcastActivityCtx
extends VMPrimitiveActivityCtx
implements IBroadcastActivityCtx

The VMBroadcastActivityCtx is a broadcast activity context with extensions for use in the virtual machine that maintains the context of a broadcast activity being or to be executed by an active instance. The context maintains the start and end times for an activity, the duration, priority, status, randomness, duration, resources, with whom or what the broadcast is with, what the communication is about, the type of communication and when the communication is to occur during the activity. The virtual machine determines with whom or what the communication of the broadcast is with.

Version:
$Revision: 1.5 $ $Date: 2009/11/23 23:54:10 $ $Author: rnado $
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
  VMBroadcastActivityCtx(BroadcastActivity act)
          Constructor, creates a new context for the specified VMBroadcastActivity.
protected VMBroadcastActivityCtx(BroadcastActivity act, java.lang.String id)
          Constructor, creates a new context for the specified VMBroadcastActivity.
 
Method Summary
 void addAbout(TransferDefinitionCtx about)
          Adds the transfer definition specifying a piece of information that was communicated in the activity.
 void addWith(ParameterCtx with)
          Adds the specified element as an active instance to be communicated with in this activity.
protected  void communicate(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Communicates the beliefs specified by the transfer definitions with the active instances specified in the communication with attribute.
 java.util.Enumeration<TransferDefinitionCtx> getAbout()
          Returns the transfer definitions specifying the information that was communicated in the activity.
 java.util.Enumeration<ParameterCtx> getAreasToBroadcastTo()
          Returns a list of all the areas (ParameterCtx) to which we need to broadcast to.
protected  java.util.Enumeration<ParameterCtx> getCommunicationWith()
          Returns the elements to be communicated with as found by calling getWith.
 ParameterCtx getToSubAreas()
          Returns whether we need to include the sub areas when returning the list of areas to which to broadcast to.
 ParameterCtx getType()
          Returns the communication type (face 2 face, e-mail, etc).
 ParameterCtx getWhen()
          Returns when the communication is to take place (start or end).
 java.util.Enumeration<ParameterCtx> getWith()
          Returns the active instances with which is to be communicated.
 boolean hasWith()
          Returns whether the activity has active instances specified to be communicated with.
protected  void onEnd(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Ends the activity, handling any completion initializations and executing any actions that are to be executed at the end of the activity as specified for the activity.
protected  boolean onStart(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Starts the activity, handling any startup initialization and executing any actions that are to be executed at the start of the activity as specified for the activity.
 void removeAbout(TransferDefinitionCtx about)
          Removes the transfer definition specifying a piece of information that was communicated in the activity.
 void removeWith(ParameterCtx with)
          Removes the specified element as an active instance to be communicated with in this activity.
protected  void send(java.util.Enumeration<VMTransferDefinition> tdfs, long time)
          Sends all the beliefs held by the communicating active instance and matching the specified transfer definitions to all active instances communicated with.
protected  void send(VMTransferDefinition tdf, long time)
          Sends all the beliefs held by the communicating active instance and matching the specified transfer definition to all active instances communicated with.
protected  void sendAbortEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Sends an abort event to the event notifier.
protected  void sendCompleteEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Sends a complete event to the event notifier.
protected  void sendContinueEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Sends a continue event to the event notifier.
protected  void sendContinueFromImpasseEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Sends a continue from impasse event to the event notifier.
protected  void sendEndEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Sends an end event to the event notifier.
protected  void sendImpasseEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Sends an impasse event to the event notifier.
protected  void sendInterruptEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Sends an interrupt event to the event notifier.
protected  void sendStartEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Sends a start event to the event notifier.
 
Methods inherited from class gov.nasa.arc.brahms.vm.rt.VMPrimitiveActivityCtx
addResource, getDuration, getElapsedTime, getMaxDuration, getMinDuration, getRandom, getResourceCount, getResources, removeResource, setElapsedTime
 
Methods inherited from class gov.nasa.arc.brahms.vm.rt.VMActivityCtx
getDisplayText, getParameterCtx, getPriority, handleDiscreteEvent, handleDiscreteEvent, onAbort, onComplete, onContinue, onContinueFromImpasse, onImpasse, onInterrupt, resolveParameters
 
Methods inherited from class gov.nasa.arc.brahms.common.rt.ActivityCtx
getCompletionCause, getParentFrame, getPerformedBy, getReferencedBy, getState, getStatus, setCompletionCause, setDisplayText, setParentFrame, setPerformedBy, setPriority, setReferencedBy, setState, setState, setStatus, 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.IPrimitiveActivityCtx
addResource, getDuration, getElapsedTime, getMaxDuration, getMinDuration, getRandom, getResourceCount, getResources, removeResource, setElapsedTime
 
Methods inherited from interface gov.nasa.arc.brahms.common.rt.IActivityCtx
getCompletionCause, getDisplayText, getParentFrame, getPerformedBy, getPriority, getReferencedBy, getStatus, setCompletionCause, setDisplayText, setParentFrame, setPerformedBy, setReferencedBy, setStatus
 
Methods inherited from interface gov.nasa.arc.brahms.common.rt.IBrahmsObjectCtx
addNote, getContextFor, getEndTime, getID, getNote, getNotes, getStartTime, removeNote, setEndTime, setID, setStartTime
 

Constructor Detail

VMBroadcastActivityCtx

public VMBroadcastActivityCtx(BroadcastActivity act)
Constructor, creates a new context for the specified VMBroadcastActivity.

Parameters:
act - the VMBroadcastActivity for which to create a context

VMBroadcastActivityCtx

protected VMBroadcastActivityCtx(BroadcastActivity act,
                                 java.lang.String id)
Constructor, creates a new context for the specified VMBroadcastActivity.

Parameters:
act - the VMBroadcastActivity for which to create a context
id - the unique identifier for the activity context
Method Detail

getType

public ParameterCtx getType()
                     throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the communication type (face 2 face, e-mail, etc). The type is set through a parameter context containing either the actual value or a reference to a variable containing the type value.

Specified by:
getType in interface IBroadcastActivityCtx
Returns:
ParameterCtx the communication type
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no type is defined

getToSubAreas

public ParameterCtx getToSubAreas()
                           throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns whether we need to include the sub areas when returning the list of areas to which to broadcast to. The toSubAreas indicator is set through a parameter context containing either the actual value or a reference to a variable containing the value.

Returns:
ParameterCtx containing a boolean value defining whether we need to include sub areas.
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no toSubAreas indicator is specified

getWhen

public ParameterCtx getWhen()
                     throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns when the communication is to take place (start or end). The when value is set through a parameter context containing either the actual value or a reference to a variable containing the when value.

Specified by:
getWhen in interface IBroadcastActivityCtx
Returns:
ParameterCtx the when value defining when the communication is to occur
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if the when value is not defined

getAreasToBroadcastTo

public java.util.Enumeration<ParameterCtx> getAreasToBroadcastTo()
                                                          throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns a list of all the areas (ParameterCtx) to which we need to broadcast to. This values in this list depend on whether values are specified for the 'to' property of the activity and the value specified for the 'toSubAreas' property of the activity. If no areas are specified for the to-property then the current location of the agent is used. If toSubAreas is true then also all the sub areas of the specified areas are returned.

Returns:
Enumeration an enumeration of ParameterCtx
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if there are no areas

addWith

public void addWith(ParameterCtx with)
             throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified element as an active instance to be communicated with in this activity. The actual communication with is the concept referenced by the parameter context where the parameter context specifies when the communication with was associated with the activity.

Parameters:
with - the active instance (ParameterCtx) to be added
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if with is null

removeWith

public void removeWith(ParameterCtx with)
                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Removes the specified element as an active instance to be communicated with in this activity. The actual communication with is the concept referenced by the parameter context where the parameter context specifies when the communication with was (dis)associated with the activity.

Parameters:
with - the active instance (ParameterCtx) to be removed
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if with is null, no communication with are available, or the specified with is not found

getWith

public java.util.Enumeration<ParameterCtx> getWith()
                                            throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the active instances with which is to be communicated. It returns the agents (not the objects) that are in the locations specified by getAreasToBroadcastTo. If no areas are specified it returns all agents in the system except for the broadcasting agent.

Specified by:
getWith in interface IBroadcastActivityCtx
Returns:
Enumeration the list of ParameterCtx referencing active instances to communicate with
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no active instances are specified

getCommunicationWith

protected java.util.Enumeration<ParameterCtx> getCommunicationWith()
                                                            throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the elements to be communicated with as found by calling getWith.

Returns:
Enumeration a list of ParameterCtx with the active instances to be communicated with
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if there are no active instances to be communicated with

hasWith

public boolean hasWith()
Returns whether the activity has active instances specified to be communicated with.

Returns:
boolean true if the communication with is specified, false otherwise

addAbout

public void addAbout(TransferDefinitionCtx about)
              throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the transfer definition specifying a piece of information that was communicated in the activity.

Parameters:
about - the communicated transfer definition
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if a null transfer definition is specified

removeAbout

public void removeAbout(TransferDefinitionCtx about)
                 throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Removes the transfer definition specifying a piece of information that was communicated in the activity.

Parameters:
about - the communicated transfer definition
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if a null transfer definition is specified, or no transfer definitions are specified or the transfer definition is not found

getAbout

public java.util.Enumeration<TransferDefinitionCtx> getAbout()
                                                      throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the transfer definitions specifying the information that was communicated in the activity.

Specified by:
getAbout in interface IBroadcastActivityCtx
Returns:
Enumeration the communicated TransferDefinitionCtx
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no transfer definitions are specified

communicate

protected void communicate(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
                    throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Communicates the beliefs specified by the transfer definitions with the active instances specified in the communication with attribute.

Parameters:
evt - the event that triggered the communication
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs

send

protected void send(VMTransferDefinition tdf,
                    long time)
             throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Sends all the beliefs held by the communicating active instance and matching the specified transfer definition to all active instances communicated with.

Parameters:
tdf - the VMTransferDefinition specifying what needs to be send
time - the time at which the sending is to occur
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs

send

protected void send(java.util.Enumeration<VMTransferDefinition> tdfs,
                    long time)
             throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Sends all the beliefs held by the communicating active instance and matching the specified transfer definitions to all active instances communicated with. This method is only to be used for non-simulation purposes and allows for communication across Brahms virtual machines.

Parameters:
tdfs - the VMTransferDefinitions specifying what needs to be send
time - the time at which the sending is to occur
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs

onStart

protected boolean onStart(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Starts the activity, handling any startup initialization and executing any actions that are to be executed at the start of the activity as specified for the activity. If the activity specifies that the broadcast is to occur at the start, it will start the broadcast.

Overrides:
onStart in class VMActivityCtx
Parameters:
evt - the DiscreteEvent that initiated the start of the activity
Returns:
boolean true if the activity was started, false if not

onEnd

protected void onEnd(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Ends the activity, handling any completion initializations and executing any actions that are to be executed at the end of the activity as specified for the activity. If the activity specifies that the broadcast is to occur at the end, it will start the broadcast.

Overrides:
onEnd in class VMActivityCtx
Parameters:
evt - the DiscreteEvent that initiated the end of the activity

sendStartEvent

protected void sendStartEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Sends a start event to the event notifier.

Note that this method is created for the different implementations by the sub classes of VMActivityCtx.

Overrides:
sendStartEvent in class VMPrimitiveActivityCtx
Parameters:
evt - the DiscreteEvent that triggered the state change

sendEndEvent

protected void sendEndEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Sends an end event to the event notifier.

Note that this method is created for the different implementations by the sub classes of VMActivityCtx.

Overrides:
sendEndEvent in class VMPrimitiveActivityCtx
Parameters:
evt - the DiscreteEvent that triggered the state change

sendInterruptEvent

protected void sendInterruptEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Sends an interrupt event to the event notifier.

Note that this method is created for the different implementations by the sub classes of VMActivityCtx.

Overrides:
sendInterruptEvent in class VMPrimitiveActivityCtx
Parameters:
evt - the DiscreteEvent that triggered the state change

sendContinueEvent

protected void sendContinueEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Sends a continue event to the event notifier.

Note that this method is created for the different implementations by the sub classes of VMActivityCtx.

Overrides:
sendContinueEvent in class VMPrimitiveActivityCtx
Parameters:
evt - the DiscreteEvent that triggered the state change

sendImpasseEvent

protected void sendImpasseEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Sends an impasse event to the event notifier.

Note that this method is created for the different implementations by the sub classes of VMActivityCtx.

Overrides:
sendImpasseEvent in class VMPrimitiveActivityCtx
Parameters:
evt - the DiscreteEvent that triggered the state change

sendContinueFromImpasseEvent

protected void sendContinueFromImpasseEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Sends a continue from impasse event to the event notifier.

Note that this method is created for the different implementations by the sub classes of VMActivityCtx.

Overrides:
sendContinueFromImpasseEvent in class VMPrimitiveActivityCtx
Parameters:
evt - the DiscreteEvent that triggered the state change

sendCompleteEvent

protected void sendCompleteEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Sends a complete event to the event notifier.

Note that this method is created for the different implementations by the sub classes of VMActivityCtx.

Overrides:
sendCompleteEvent in class VMPrimitiveActivityCtx
Parameters:
evt - the DiscreteEvent that triggered the state change

sendAbortEvent

protected void sendAbortEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Sends an abort event to the event notifier.

Note that this method is created for the different implementations by the sub classes of VMActivityCtx.

Overrides:
sendAbortEvent in class VMPrimitiveActivityCtx
Parameters:
evt - the DiscreteEvent that triggered the state change


Copyright © 1997-2012 All Rights Reserved.