Hello World - Sample Xholon App

What is it

This model is a very simple example of how to write and run a Xholon application. Several xholon objects cooperate to write the words Hello and World a specified number of times. This requires writing four XML configuration files, one XML information file, an application Java class, a detailed action Java class, and a Java constants interface. The same number of files are required whether it's a Hello World application, or a much more complex system.

HelloWorld_Vrml_xhn.xml is a variation of Hello World that creates a 3d VRML file.

HelloWorld_TestTime_xhn.xml is a variation of Hello World that shows how to use a periodic timer to perform a regular action in a Xholon application.

XhHelloWorld_str.java (src/...tutorials) shows how the same tasks are accomplished with strings. It does not require the extra CE class identifying the preset int values and it is potentially much more flexible in that it allows new classes to be created on the fly. The disadvantage is that it can be expected to run 10 - 20% slower as is typical when employing string comparisons.

How to use it

Run it:

  1. Run the Java application through the Xhn GUI (org.primordion.xholon.app.Xhn.java), and select File --> Open --> HelloWorld --> HelloWorld_xhn.xml.
  2. Expand the Controller node in the tree.
  3. Press the Start node.
  4. You should see a display of all the parameters that are set in the HelloWorld_xhn.xml file, followed by the words "Hello World" displayed five times in the console window (see below).

Hello World !
Hello World !
Hello World !
Hello World !
Hello World !

Things to notice

Take a look at the XML configuration files in the config/HelloWorld folder.

Look at XhHelloWorld.java (src/...tutorials) to see how xholon objects send messages to each other, and how they receive messages. The HelloWorldSystem object processes received messages in the act() function. Hello and World send messages using the sendMessage() function. Each message contains a signal, for example the int SIGNAL_ONE in this application.

Things to try

Change the MaxProcessLoops parameter in HelloWorld_xhn.xml. What happens if this is an even number? An odd number? If you set it to -1 the application will run forever.

Set the ShowParams parameter to false.

Change the TimeStepInterval parameter to 100. Set it to 0. Set it to 1. This parameter determines how long the application sleeps after each time step.

Extending the model

This is a very simple model that can be extended in many ways.

Xholon features

This application demonstrates most of the essential features of a Xholon application:

  • The use of Java and XML.
  • Hierarchical structure, with two active objects inside a container.
  • The use of ports.

Credits and references

The Xholon web site includes a Hello World Tutorial that will walk you through creating the Hello World application.

Hello World Tutorial