DRCL JavaSim API

drcl.net
Class Module

java.lang.Object
  |
  +--drcl.DrclObj
        |
        +--drcl.comp.Component
              |
              +--drcl.net.Module
All Implemented Interfaces:
java.lang.Cloneable, ObjectDuplicable, java.io.Serializable
Direct Known Subclasses:
PktDispatcher, PktFilter, Protocol, Receiver, routing_msp, SApplication, SUDPApplication

public class Module
extends Component

A module is a component which implements a protocol. The ports of a module are categorized into "up" and "down" groups. "Up" and "down" indicate the direction of data flow in the protocol stack of a node. By default, it contains one "up" port (up@) and one "down" port (down@).

A module is also equipped with a timer port (.timer@) and defines a set of methods to set up and cancel timeout events (setTimeout(Object, double), setTimeoutAt(Object, double), and cancelTimeout(drcl.comp.ACATimer). The first two methods return an ACATimer object which contains the event object and the time when the timer expires. The timer object can be used to cancel the timeout event using cancelTimeout(ACATimer).

Incoming data is dispatched in process(Object, Port) to four handlers by the port at which data arrives: dataArriveAtUpPort(Object, Port), dataArriveAtDownPort(Object, Port), timeout(Object), and processOther(Object, Port). A subclass should override one or more of the handlers to handle the incoming data as necessary.

A module is associated with an address scheme (address), which separates the dividing of address space from the functionality of the module.

See Also:
Serialized Form

Inner classes inherited from class drcl.comp.Component
Component.LockPack
 
Field Summary
protected  Address address
          The address scheme associated with this module.
 Port downPort
          The default "down" port.
static java.lang.String PortGroup_DOWN
          The ID of the "down" port group.
static java.lang.String PortGroup_UP
          The ID of the "up" port group.
protected  Port timerPort
          The port at which the timeout events come.
 Port upPort
          The default "up" port.
 
Fields inherited from class drcl.comp.Component
FLAG_COMPONENT_NOTIFICATION, FLAG_DEBUG_ENABLED, FLAG_DIRECT_OUTPUT_ENABLED, FLAG_ENABLED, FLAG_ERROR_ENABLED, FLAG_EVENT_ENABLED, FLAG_GARBAGE_DISPLAY_ENABLED, FLAG_GARBAGE_ENABLED, FLAG_PORT_NOTIFICATION, FLAG_STARTED, FLAG_STOPPED, FLAG_TRACE_ENABLED, FLAG_UNDEFINED_START, id, infoPort, lockHead, name, parent, PortGroup_DEFAULT_GROUP, PortGroup_EVENT, PortGroup_SERVICE, Root, Trace_DATA, Trace_SEND
 
Constructor Summary
Module()
           
Module(java.lang.String id_)
           
 
Method Summary
 void cancelTimeout(ACATimer handle_)
          Cancels a timeout event.
protected  void dataArriveAtDownPort(java.lang.Object data_, Port downPort_)
          The handler invoked when a packet arrives at a "down" port.
protected  void dataArriveAtUpPort(java.lang.Object data_, Port upPort_)
          The handler invoked when a packet arrives at an "up" port.
protected  boolean deliver(java.lang.Object data_, java.lang.String portID_)
          Delivers data_ at the (up) port specified.
 void duplicate(java.lang.Object source_)
          Duplicates the content of source_, including ID, name, child components and connections among them, to this component.
 Address getAddress()
          Returns the address scheme associated with this module.
protected  void process(java.lang.Object data_, Port inPort_)
          This method classifies inPort_ and delegates process of data to the appropriate handler.
protected  void processOther(java.lang.Object data_, Port inPort_)
          The handler invoked when a packet arrived at a port other than the "up", "down" and timer ports.
protected  void removeDefaultDownPort()
          Removes the equipped down port (down@), if it is not used by this module.
protected  void removeDefaultUpPort()
          Removes the equipped up port (up@), if it is not used by this module.
protected  void removeTimerPort()
          Removes the equipped timer port (.timer@), if it is not used by this module.
 void setAddress(Address address_)
          Sets the address scheme associated with this module.
 ACATimer setTimeout(java.lang.Object evt_, double duration_)
          Sets up a timeout event at the specified time later.
 ACATimer setTimeoutAt(java.lang.Object evt_, double time_)
          Sets up a timeout event at the specified absolute time.
protected  void timeout(java.lang.Object data_)
          The handler invoked when a timeout event occurs.
 
Methods inherited from class drcl.comp.Component
_resume, _start, _stop, addComponent, addComponent, addEventPort, addEventPort, addForkPort, addPort, addPort, addPort, addPort, addPort, addPort, addPort, addPort, addServerPort, addServerPort, cancelFork, componentAdded, componentRemoved, connect, containsComponent, containsComponent, containsPort, debug, disconnectAll, disconnectAllPeers, disconnectAllPorts, drop, drop, error, error, expose, exposeEventPorts, exposePort, exposePort, exposePort, exposePort, exposePort, findAvailable, findAvailable, findAvailable, finishing, fork, forkAt, getAllComponents, getAllPorts, getAllPorts, getAllWiresInside, getAllWiresInsideOut, getAllWiresOut, getComponent, getComponentFlag, getComponentFlag, getContract, getContractHT, getContractHT, getDebugFlagsInBinary, getDebugLevelNames, getForkManager, getID, getName, getParent, getPort, getPort, getRoot, getRuntime, getTime, iduplicate, info, isAncestorOf, isComponentNotificationEnabled, isContainer, isDebugEnabled, isDebugEnabledAt, isDirectOutputEnabled, isEnabled, isErrorNoticeEnabled, isEventExportEnabled, isGarbageDisplayEnabled, isGarbageEnabled, isPortNotificationEnabled, isPortRemovable, isStarted, isStopped, isTraceEnabled, lock, notify, notifyAll, operate, portAdded, portRemoved, reboot, removeAll, removeAllComponents, removeAllPorts, removeAllPorts, removeComponent, removeComponent, removePort, removePort, removePort, reset, resume, run, sduplicate, send, sendAt, setComponentFlag, setComponentFlag, setComponentNotificationEnabled, setContract, setDebugEnabled, setDebugEnabled, setDebugEnabledAt, setDebugEnabledAt, setDebugEnabledAt, setDirectOutputEnabled, setDirectOutputEnabled, setEnabled, setErrorNoticeEnabled, setErrorNoticeEnabled, setEventExportEnabled, setEventExportEnabled, setExecutionBoundary, setGarbageDisplayEnabled, setGarbageDisplayEnabled, setGarbageEnabled, setGarbageEnabled, setID, setID, setName, setPort, setPort, setPortNotificationEnabled, setPortRemovable, setRuntime, setTraceEnabled, setTraceEnabled, sleepFor, sleepUntil, stop, toString, unexpose, unlock, useLocalForkManager, useLocalForkManager, wait
 
Methods inherited from class drcl.DrclObj
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PortGroup_UP

public static final java.lang.String PortGroup_UP
The ID of the "up" port group.

PortGroup_DOWN

public static final java.lang.String PortGroup_DOWN
The ID of the "down" port group.

downPort

public Port downPort
The default "down" port.

upPort

public Port upPort
The default "up" port.

timerPort

protected Port timerPort
The port at which the timeout events come.
See Also:
setTimeout(Object, double), setTimeoutAt(Object, double)

address

protected Address address
The address scheme associated with this module.
Constructor Detail

Module

public Module()

Module

public Module(java.lang.String id_)
Method Detail

duplicate

public void duplicate(java.lang.Object source_)
Description copied from class: Component
Duplicates the content of source_, including ID, name, child components and connections among them, to this component. Subclasses need to override this method to copy its own variables.
Overrides:
duplicate in class Component

deliver

protected final boolean deliver(java.lang.Object data_,
                                java.lang.String portID_)
Delivers data_ at the (up) port specified. Returns false if failed (e.g. port does not exist).

dataArriveAtDownPort

protected void dataArriveAtDownPort(java.lang.Object data_,
                                    Port downPort_)
The handler invoked when a packet arrives at a "down" port. Subclasses should override it to handle such an event.

dataArriveAtUpPort

protected void dataArriveAtUpPort(java.lang.Object data_,
                                  Port upPort_)
The handler invoked when a packet arrives at an "up" port. Subclasses should override it to handle such an event.

timeout

protected void timeout(java.lang.Object data_)
The handler invoked when a timeout event occurs. Subclasses should override it to handle such an event.
See Also:
setTimeout(Object, double), setTimeoutAt(Object, double)

processOther

protected void processOther(java.lang.Object data_,
                            Port inPort_)
The handler invoked when a packet arrived at a port other than the "up", "down" and timer ports.

process

protected void process(java.lang.Object data_,
                       Port inPort_)
This method classifies inPort_ and delegates process of data to the appropriate handler. If a subclass decides to override this method, then it should call super.process(data_, inPort_) to make those handlers effective.
Overrides:
process in class Component
See Also:
dataArriveAtUpPort(Object, drcl.comp.Port), dataArriveAtDownPort(Object, drcl.comp.Port), processOther(Object, drcl.comp.Port)

setTimeoutAt

public final ACATimer setTimeoutAt(java.lang.Object evt_,
                                   double time_)
Sets up a timeout event at the specified absolute time. Returns a timer object that can be used to cancel the event.
See Also:
timeout(Object)

setTimeout

public final ACATimer setTimeout(java.lang.Object evt_,
                                 double duration_)
Sets up a timeout event at the specified time later. Returns a timer object that can be used to cancel the event.
See Also:
timeout(Object)

cancelTimeout

public final void cancelTimeout(ACATimer handle_)
Cancels a timeout event.

setAddress

public final void setAddress(Address address_)
Sets the address scheme associated with this module.

getAddress

public final Address getAddress()
Returns the address scheme associated with this module.

removeDefaultDownPort

protected void removeDefaultDownPort()
Removes the equipped down port (down@), if it is not used by this module. This method should be called in the construction code block.

removeDefaultUpPort

protected void removeDefaultUpPort()
Removes the equipped up port (up@), if it is not used by this module. This method should be called in the construction code block.

removeTimerPort

protected void removeTimerPort()
Removes the equipped timer port (.timer@), if it is not used by this module. This method should be called in the construction code block.

DRCL JavaSim API

Copyright © 2001 - DRCL, OSU     ~ Back to JavaSim Home ~