previous up next
Go up to 5.1 Types
Go forward to InChannel: Input Channels
RISC-Linz logo

Program: Node Programs

abstract class Program
{
  // to be overridden by the user
  abstract void main()
  String getText()

  // the node's communication interface
  InChannelSet in()
  InChannel in(int i)
  OutChannelSet out()
  OutChannel out(int i)

  // program execution control
  void assert(GlobalAssertion a)
  int getTime()
  void sleep(n)
  void yield()
  void exit(int i)
}

Each network node holds an object of some (non-abstract) subtype of Program. The method main must be overridden by the programmer; it represents the program being executed by that node.

The method getText returns a string (default: "(no information)") that consists of a sequence of lines separated by the newline character. This text is displayed by the visualizer in a pop-up window whenever the mouse pointer is moved over the visual representation of the node. The programmer may override this method to exhibit the internal state of the node.

The other methods may be used by main for communication with other nodes and for controlling the execution of the node, respectively. Their behavior is documented in the following subsection.


Maintainer: Wolfgang Schreiner
Last Modification: November 14, 1997

previous up next