Demo Readme





Weather Station Bean Suite Version 1.1

This demo shows how you can create a simple application that monitors temperature, wind speed, and wind direction and displays their current values.

For information on how to create this application using visual programming, see Wiring Instructions. .

To see the wiring and run the application in VisualAge for Java 2.0, download and install the WiringHelpers Bean Suite (http://www.alphaworks.ibm.com), import the Bean Suite jar files (in the lib directory) and the demo dat file (in the demo directory) into VisualAge for Java 2.0. The dat file contains a demo package that you can add to any project in your VisualAge workspace. If you add this package to a project other than where the associated jar file(s) was(were) imported, use VisualAge's "Check Class Path..." option to compute the correct CLASSPATH setting before you run the demo application. This will ensure that VisualAge can locate all the classes needed to run the application.

How to Run This Demo

To run this demo, you, first of all, need to have the Dallas 1-Wire Weather Station WS-1 Kit with DS9097U-9 serial port adapter.

Then make sure that:

  1. your Weather Station is connected to the COM2 serial port of your computer
  2. the WiringHelpers Bean Suite is properly installed, and the CLASSPATH is correctly updated
  3. the Weather Station Bean Suite is properly installed, as described in the documentation provided with this package.

Change to the demo directory, and type java runDemo at the command prompt. This starts the demo.

What the Demo Does

Suppose we want to build an application that displays the current values of temperature, wind direction, and wind speed.

The result of the Demo application is shown in Figure 1.

Weather Station Demo

Figure 1 - The WeatherStation demo

Where:

Wiring Instructions

Note: To simplify the wiring instructions, we did not include samples of any error situation handling, e.g. like the wrong Weather Station installation.

To build the application, you should do the following:

  1. Create a new class with the Frame superclass.
  2. Put on the frame:
    1. TextField for a temperature value (set the "Temperature" label on the left side, and the "C" label on the right side)
    2. TextField for a wind speed value (set the "Wind Speed" label on the left side, and the "KM/H" label on the right side)
    3. TextField for a wind direction value (set the "Wind Direction" label on the left side)
    4. Choice to choose metrics (set the "Choose Metrics" label).
  3. Put on the design surface:
    1. the WeatherStation bean
    2. the TemperatureMonitor bean
    3. the WindSpeedMonitor bean
    4. the WindDirectionMonitor bean
    5. the Selector bean from the WiringHelpers Bean Suite (set the "0" parameter for the case1 property and the "1" parameter for the case2 property).

Do the following connections:

  1. Connect the Demo Frame.windowClosing event to
                 the
    WeatherStation1.closePort() method.

  2. Connect the WeatherStation1.myself property to
                 the
    TemperatureMonitor1.weatherStation property.

  3. Connect the WeatherStation1.myself property to
                 the
    WindSpeedMonitor1.weatherStation property.

  4. Connect the WeatherStation1.myself property to
                 the
    WindDirectionMonitor1.weatherStation property.

  5. Connect the TemperatureMonitor1.resultString to
                 the "Temperature"
    TextField.text property.

  6. Connect the WindSpeedMonitor1.resultString to
                 the "Wind Speed"
    TextField.text property.

  7. Connect the WindDirectionMonitor1.resultString to
                 the "Wind Direction"
    TextField.text property;

  8. Connect the "Choose Metrics" Choice.itemStateChanged event to
                 the
    Selector1.inputIntSelector property
    (connect the
    value property of this connection to the "Choose Metrics" Choice.selectedIndex property).

  9. Connect the Demo Frame.windowOpened event to
                 the
    Choice1.addItem() method (set the "European" parameter for this connection).

  10. Connect the Demo Frame.windowOpened event to
                  the
    Choice1.addItem() method (set the "American" parameter for this connection).

  11. Connect the Selector1.onCase1 event to
                  the "C"
    label.text property (set the "C" parameter for this connection).

  12. Connect the Selector1.onCase2 event to
                  the "C"
    label.text property (set the "F" parameter for this connection).

  13. Connect the Selector1.onCase1 event to
                  the "KM/H"
    label.text property (set the "KM/H" parameter for this connection).

  14. Connect the Selector1.onCase2 event to
                  the "KM/H"
    label.text property (set the "MPH" parameter for this connection).

  15. Connect the Selector1.onCase1 event to
                  the
    TemperatureMonitor1.measureUnit property (set the "0" parameter for this connection).

  16. Connect the Selector1.onCase2 event to
                  the
    TemperatureMonitor1.measureUnit property (set the "1" parameter for this connection).

  17. Connect the Selector1.onCase1 event to
                  the
    WindSpeedMonitor1.measureUnit property (set the "1" parameter for this connection).

  18. Connect the Selector.onCase2 event to
                  the
    WindSpeedMonitor1.measureUnit property (set the "0" parameter for this connection).

Note: All custom properties of the WeatherStation beans have the default values.

Refer to Figure 3 for the wiring diagram of this application.

WeatherStation Demo wiring diagram

Figure 2 - The Demo wiring diagram

For detailed instructions on wiring of each bean, see the documentation provided with this package.