
|
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:
- your Weather Station is connected to the
COM2 serial port of your computer
- the WiringHelpers Bean Suite is properly
installed, and the CLASSPATH is correctly updated
- 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.

Figure 1 - The WeatherStation demo
Where:
- Temperature: TextField that
contains the current temperature value. (Label on the right side of this TextField
displays the current measure unit - C.)
- Wind Speed: TextField that
contains the current wind speed value. (Label on the right side of this TextField displays
the current measure unit - KM/H.)
- Wind Direction: TextField that contains the current
wind direction.
Choose Metrics:
Choice to choose the current metrics. You can choose American or European metrics to see
how the corresponding values are changed.
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:
Create a new class with the Frame
superclass.
Put on the frame:
TextField for a temperature value
(set the "Temperature" label on the left side, and the "C"
label on the right side)
TextField for a wind speed value (set
the "Wind Speed" label on the left side, and the "KM/H"
label on the right side)
TextField for a wind direction value
(set the "Wind Direction" label on the left side)
Choice to choose metrics (set the
"Choose Metrics" label).
Put on the design surface:
the WeatherStation bean
the TemperatureMonitor bean
the WindSpeedMonitor bean
the WindDirectionMonitor bean
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:
Connect the Demo
Frame.windowClosing event to
the WeatherStation1.closePort() method.
Connect the WeatherStation1.myself property to
the TemperatureMonitor1.weatherStation property.
Connect the WeatherStation1.myself property to
the WindSpeedMonitor1.weatherStation property.
Connect the WeatherStation1.myself property to
the WindDirectionMonitor1.weatherStation property.
Connect the TemperatureMonitor1.resultString to
the "Temperature"
TextField.text property.
Connect the WindSpeedMonitor1.resultString to
the "Wind
Speed" TextField.text property.
Connect the WindDirectionMonitor1.resultString to
the "Wind
Direction" TextField.text property;
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).
Connect the Demo
Frame.windowOpened event to
the Choice1.addItem() method (set the "European"
parameter for this connection).
Connect the Demo
Frame.windowOpened event to
the Choice1.addItem()
method (set the "American" parameter for this connection).
Connect the
Selector1.onCase1 event to
the "C"
label.text property (set the "C" parameter
for this connection).
Connect the
Selector1.onCase2 event to
the "C"
label.text property (set the "F" parameter
for this connection).
Connect the
Selector1.onCase1 event to
the "KM/H"
label.text property (set the "KM/H"
parameter for this connection).
Connect the Selector1.onCase2 event to
the "KM/H"
label.text property (set the "MPH" parameter
for this connection).
Connect the Selector1.onCase1 event to
the TemperatureMonitor1.measureUnit property (set the "0"
parameter for this connection).
Connect the
Selector1.onCase2 event to
the TemperatureMonitor1.measureUnit property (set the "1"
parameter for this connection).
Connect the Selector1.onCase1 event to
the WindSpeedMonitor1.measureUnit property (set the "1" parameter
for this connection).
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.

Figure 2 - The Demo wiring
diagram
For detailed instructions on wiring of each bean, see the documentation provided with
this package.