Elevator Controller - Sample Xholon App

What is it

This model simulates the control of a pair of elevators operating in a multi-story building.

The Jung version also demonstrates the use of JUNG to graphically display the structure as a network and as a tree. For the JUNG version, you will need to first download the JUNG software.

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 --> Elevator --> Elevator_xhn.xml.
  2. Expand the Controller node in the tree.
  3. Press the Start node.
  4. You should see a series of messages on the console window (see below) showing messages that have been sent between xholon instances. Each message shows the signal type, any data, the sender, and the receiver.

XhElevator signal:500 data:null sender:gui_1 receiver:callButton_3
XhElevator signal:500 data:null sender:gui_1 receiver:callButton_16
XhElevator signal:500 data:null sender:gui_1 receiver:floorSelectionButton_32
XhElevator signal:600 data:null sender:tickGenerator_42 receiver:hoist_41
XhElevator signal:600 data:null sender:tickGenerator_59 receiver:hoist_58
XhElevator signal:501 data:null sender:callButton_3 receiver:gui_1
XhElevator signal:500 data:null sender:callButton_3 receiver:dispatcher_60
XhElevator signal:501 data:null sender:callButton_16 receiver:gui_1
XhElevator signal:500 data:null sender:callButton_16 receiver:dispatcher_60
XhElevator signal:501 data:null sender:floorSelectionButton_32 receiver:gui_1
XhElevator signal:500 data:null sender:floorSelectionButton_32 receiver:hoist_41

Things to notice

This application records message interactions between xholons. It optionally captures all messages that are sent from one xholon to another and can produce a UML Sequence Diagram from this. These are the same messages that are displayed on the console window (shown above) as the application is executing. You can control this by setting UseInteractions in Elevator_xhn.xml to "true" or "false". To learn more about this feature, look at _README.txt in the Xholon interaction folder. Also have a look at the captured data file elevator.pic, and the graphic files elevator.png and elevator.svg. Even if you don't use the third-party tools that allow you to produce .png and .svg files from the .pic file, you can still look at the .pic text file to learn about messages that were sent between xholons.

interactions - Sequence diagram

Run Elevator_Jung_xhn.xml. Look at the resulting network display. This diagram shows all xholons in the executing model as small circles, and all port references as arrows between the circles. Compare the arrows with the port specifications in ClassDetails.xml.

JUNG network diagram

Also look at the tree display when you run Elevator_Jung_xhn.xml. It graphically shows the entire composite structure hierarchy of the model.

JUNG tree diagram

Things to try

Play around with the JUNG-generated network and tree views. You can zoom, turn labels on and off, rotate, move and otherwise transform the images (using "Transforming"), and pick one or more nodes to move (using "Picking"). Save these images as .png or .jpg files.

Extending the model

This model is not yet complete.

Implement the detailed code in the Dispatcher xholon to allow it to collect sensor inofrmation from the various floor and elevator buttons, and use this to control the elevator hoist.

Implement a separate GUI that would allow you to press all the buttons, and would show the two elevators moving up and down.

Xholon features

Look at the code in AppElevator_Jung.java to learn how to generate network and tree diagrams showing the structure of your applications. The code is after "if (useGraphicalTreeViewer)" and after "if (useGraphicalNetworkViewer)".

Also look at the code after "if (getUseInteractions())" to learn how to generate the .pic interaction file.

Credits and references

See the JUNG homepage at sourceforge