|
J-Sim v1.2.1-p7 API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectdrcl.DrclObj
drcl.comp.Component
drcl.net.Module
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.
| Nested Class Summary |
| Nested classes inherited from class drcl.comp.Component |
Component.Locks |
| 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. |
| 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.DrclObj |
clone |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final java.lang.String PortGroup_UP
public static final java.lang.String PortGroup_DOWN
public Port downPort
public Port upPort
protected Port timerPort
setTimeout(Object, double),
setTimeoutAt(Object, double)protected Address address
| Constructor Detail |
public Module()
public Module(java.lang.String id_)
| Method Detail |
public void duplicate(java.lang.Object source_)
Component
duplicate in interface ObjectDuplicableduplicate in class Component
protected final boolean deliver(java.lang.Object data_,
java.lang.String portID_)
data_ at the (up) port specified.
Returns false if failed (e.g. port does not exist).
protected void dataArriveAtDownPort(java.lang.Object data_,
Port downPort_)
protected void dataArriveAtUpPort(java.lang.Object data_,
Port upPort_)
protected void timeout(java.lang.Object data_)
setTimeout(Object, double),
setTimeoutAt(Object, double)
protected void processOther(java.lang.Object data_,
Port inPort_)
protected void process(java.lang.Object data_,
Port inPort_)
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.
process in class Componentdata_ - the arrival data.inPort_ - the port where the data arrives.dataArriveAtUpPort(Object, drcl.comp.Port),
dataArriveAtDownPort(Object, drcl.comp.Port),
processOther(Object, drcl.comp.Port)
public final ACATimer setTimeoutAt(java.lang.Object evt_,
double time_)
timeout(Object)
public final ACATimer setTimeout(java.lang.Object evt_,
double duration_)
timeout(Object)public final void cancelTimeout(ACATimer handle_)
public final void setAddress(Address address_)
public final Address getAddress()
protected void removeDefaultDownPort()
down@), if it is not used by this module.
This method should be called in the construction code block.
protected void removeDefaultUpPort()
up@), if it is not used by this module.
This method should be called in the construction code block.
protected void removeTimerPort()
.timer@), if it is not used by this module.
This method should be called in the construction code block.
|
J-Sim v1.2.1-p7 API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||