inheritance tree
SimulationEngine
class definition
class SimulationEngine (Inheritance-free)
feat Links Nodes
attr time
- createLink(LinkId FromNodeId ToNodeId NofSlots Shifter)
creates a link with LinkId between the two
specified nodes that must exist. A number
of slots and a Shifter (possibly default)
must be specified.
If a Shifter is specified it will be invoked as
{Shifter GetInMsg SlotArray NofSlots ?OutMsg}
on each step. GetInMsg is a function that on
invocation returns the next message about to
enter the link or nil if none present.
SlotArray is an array with one entry for each
slot in the link. An entry may be a message
ore nil. NofSlots is the length of SlotArray
provided for convenience. Shifter should
return any message that leaves the link and
should arrive to the node in OutMsg.
Shifter may not alter any messages, only
move or possibly loose them.
- createNode(NodeId Listener)
creates a node with the specified id and
listener. On each step the listener will be
invoked as {Listener step(Time Msgs)}. Where
Time is an integer and Msgs is a list of
message#FromNodeId or notifications of lost
links.
The message format is whatever has been used
by sender and shifter. A notification of a
lost link is connectionLost#FromNodeId.
- getLinkStates($)
returns the current state of all links as
a list of state(id:LinkId
messages:CopyofMessageArray
flushing:IsFlushing)
where IsFlushing is true after removeLink has
been called with flush and before DoneAlert
has been called (see removeLink).
- getTime($)
returns the current time.
- init()
- removeLink(L How DoneAlert)
removes a link in one of two ways specified
by How. How may be crash or flush. crash
means remove immediately and loose any
messages. flush means close link now, but
allow any messages present int the link to
arrive to the destination before removing it.
A unary procedure DoneAlert will be invoked
when the link is removed (immediatly for crash).
- removeNode(NodeId)
removes the node and no further messages will
be passed to Listener.
- send(L Msg)
sends Msg on link with id L.
- step()
progresses time one step
end