To follow this tutorial you must have the PalCom Open Source Toolbox installed on your computer, see the download page for info on how to do this.

Tutorial for how to build the geotagger example

The demo application on the Try-it! page uses a precompiled geotagger application. This tutorial describes how to repeat the demo from scratch, demonstrating how to program for palpable computing.

The tutorial explains the overall structure of the various components of the demo, and how to compile and start them. The last part goes through how to assemble the services into an assembly and ways to launch this assembly.

Starting the Overview Browser and the PalCom Launcher

The first part of the demo on the Try-it! page is the Overview Browser (OVB) providing a "window" to the PalCom services on the network. There are three ways in which to start the OVB:
  1. The pal-ovb script starts the OVB from the "out-of-the-box" package, i.e. with classpath directed to the /palcom/lib directory containing the latest export of pre-compiled code.
  2. The pal-dev-ovb script starts the OVB from the latest compile of /palcom/developer source code. Unless you have made local changes to the OVB source code, the developer-OVB should be identical to the out-of-the-box OVB. Notice that before executing the pal-dev-ovb script you must have compiled the developer source code with either pal-dev-build -J or from inside Eclipse (see /doc/setup/Eclipse-build.txt)
  3. From inside Eclipse you can right-click and select "run as Java application" on the OverViewBrowserDevice.java under the pal-visualization/test project.
Accordingly, there are 3 ways to start the launcher:
  1. pal-launcher
  2. pal-dev-launcher. As with pal-dev-ovb this requires that you have first compiled the developer source code, either with pal-dev-build -J or from inside Eclipse.
  3. From Eclipse, start the ApplicationLauncherGUI.java from the pal-applicationlauncher project.

Compiling and launching the geotagger code

The code for the services and simluated devices can be found in the package ist.palcom.services.simulated-geotagger, that is checked in under palcom/developer/application-layer/services/simulated-geotagger. The corresponding Eclipse project is simulated-geotagger In the simulated-geotagger there is a Main class that upon launch calls all the necessary services automatically, and in the start subpackage to the simulated-geotagger there are classes, "MyXXX", that allows for individual launch of the different services, as it is done in the try-it demo.

If you compiled the developer tree as described above, you have automatically also compiled the geotagger into the palcom developer applications jar file. If not, run pal-dev-build -J, or from Eclipse, open the dev-lib project and run the Ant script by right-clicking on build.xml, and choosing Run As->Ant Build.

With the launcher you can now browse to the jar file containing the geotagger. The "out-of-the-box" jar is palcom/lib/jars/palcom-applications.jar. If you compiled the complete source tree with either pal-dev-build -J or from Eclipse, the developer jar file can be found at palcom/developer/dev-lib/jars/generated/palcom-applications.jar.

You should now be able to start all services, as in the demo on the try it page.

Notice, that all services and simulated devices can also be launched from Eclipse (i.e. without the launcher application) if that is more convenient for you. Services can of course also be launched completely manually, for instance: java -cp palcom-applications.jar ist.palcom.simulated.geotagger.start.MyLaptop

Assembling the geotagger assembly

We are now ready to create the geotagger assembly. In the demo it was loaded from an assembly descriptor file (a .ass file). There are two ways of creating an assembly file:
  1. Manually via a text editor. Not recommended
  2. Recording a snap-shot of a running assembly using the Eclipse-based Developer's Browser.
The assembly files are XML descriptions of the running assembly, and as such they can be written manually, though this will probably be a very cumbersome process. More conveniently, the assemblies can be assembled using the Eclipse-based Developer's Browser. The developer's browser comes in two versions: One Eclipse-based version (i.e. a browser that runs as a Eclipse Application) and one stand-alone version made as a RCP product (Rich Client Platform). In this tutorial we will only explain what to do in order to get the geotagger assembly up and running. You can find a more comprehensive user guide for this browser in the "Tool" section of the Developer's Companion.

Starting the developer's browser can be done in multiple ways:

  1. From a shell environment the pal-developer script can be run to launch the out-of-the-box stand-alone version of the browser.
  2. The "full" version of the browser can be startet from within Eclipse by selecting "Run as Eclipse application" from the plugin.xml in the EclipseBrowser project. (See the user guide in the Developer's Companion. for details.)
  3. The stand-alone version can be exported as a platform-dependent application from inside eclipse by selecting the "Eclipse Product expert wizard" from the RCPBrowser.product file in the RCPBrowser project. This will produce a zip archive containing an executable file/jars for the browser.

Assuming you have started the stand alone version you will see the three panes open: "Browser view", "NavigatorView", and "XML view". (The full Eclipse-based version has more views, but the essential functionality in order to compose assemblies are contained in these three. See the Developer's Companion for details on the browser.)

In the "Browser view" you should see the top branch ("Universe") og the tree of discovered services and devices. First step is to create an empty assembly description and drag the geotagger devices onto the description:

Right-click on the "Navigator view" and select New Project. Select the "new project" wizard and click "next". Name your project and press "Finish".

Right-click once again on the "Navigator view" to create a new file: Select "New->other" and select the "new file" wizard. Select your project as the container of the new file and name the assembly file. The PalCom convention is to finish the name with the ".ass" extension, e.g. "mygeotagger.ass".

Make sure the 4 devices (Camera, GPS, Laptop, and Server) is running on your computer (or on another computer on the same LAN). The 4 devices should appear in the "Browser View" pane. You can now drag the devices one-by-one to the assembly editor pane dropping them in the "Devices" folder in the assembly description tree.

Next, the services in need of connections to the assembly must be dragged from the browser view pane to the assembly editor pane. In the geotagger example this concerns all services except the ResourceManager and the AssemblyManager on the Laptop (both of these work independently on the assembly). Expand the devices in the "Browser view" and drag the services one by one to the "services" node in the assembly tree.

Now comes the logic part, or the "assembly programming/scripting". Here the needed connections and logic to run the geotagger example will be explained, to get more detail about assembly logic, please refer to the PalCom deliverable 43.

It is possible to set up connections directly between services, but in the geotagger example all services communicate via the assembly. To declare these connections all services must again be dragged to the editor, this time in the "connections" node.

Since the assembly acts as the central logical unit variables that must be shared between the services can be held in the assembly. In the geotagger example the only value that needs to be exchanged between the services is the last GPS coordinate. Variables are declared by selecting the "Variables" node and doing "Add variable declaration" from the context menu (i.e. right-clicking on the Variables node). Declare a new variable called something like "latestCoordinate" with type text/plain.

Next we must make sure communication is set up. The "latestCoordinate" (or what you named the variable) must be updated from the GPS device. Therefore we drag the out-going "coordcommand" from the "Position" service on the "My GPS" device to the Eventhandler node. (The command is found be expanding the "PRDServiceFMDescription" under the Position service in the Browser view.) A clause called "when coordcommand from Position" is added to the assembly tree. We can add a assignment to this clause by right-clicking on it and selecting "Add assignment". In the assignment dialogue select the "latestCoordinate" and assign to it the "text/plain wgs84".

Likewise, we need to set up the other functionalities in the assembly, i.e. the exchange of photos from the camera, to the stuffer service on the laptop and on to the photo database of the server.

After doing this you should now have the following clauses in the event handler list:

<-- Eventhandler clauses are declared by dragging a CommandInfo node (from a ServiceDescription) in the Browser view to the "Script" node in the Assembly editor.

Assignment statements are added to an Eventhandler clause by selecting it and doing "Add assignment" from the context menu. Choose target and source variables from the dialogs.

SendMessage statements are added by dragging a CommandInfo node from the Browser view to the EventHandler clause. If the command has parameters, dialogs appear allowing you to select parameter values. Alternatively,select an EventHandler clause and do "add Send Message" from the context menu.

Invoke statements are the counterpart to SendMessage statements, on the assembly’s own synthesized service, and are added a similar way; by dragging a CommandInfo from the ServiceDescription in the Assembly editor to the EventHandlerClause. Alternatively,select an EventHandler clause and do "add Invoke" from the context menu. -->

When the assembly is up and running in the Developer's Bowser, you can save the current XML description. (Does "SaveAs" work?) (What does "release" mean?)

Extending the geotagger with a Google Earth service

The last part of the try-it demo involves extending the assembly to incorporate the Google Earth service. You can find the Google Earth service in the package ist.palcom.services.googleearth.simulated-geotagger, that is checked in under palcom/developer/application-layer/services/simulated-geotagger. The corresponding Eclipse project is simulated-geotagger.

You should now be able to make the final steps that are similar to those described in the demo.