Start
Intelligent
Architechture
Putting
the Pieces Together
Programming
Brains
Building
and Interface
Education
Possible
Sources
& PDF
BUILDING
AN INTERFACE
Little code was needed
to interface to the controller, since EMIT provides
prebuilt emObject interface components and handles
the communication details.
To simplify the task
further, I used Symantexs Visual Café and integrated
the emObject components with the existing component
toolkit. This way, I could select the objects from
the component palette, add them directly to the applet,
and easily manipulate layout and component properties.
The heart of the applet
is an invisible object called emitjri (EMIT Java Runtime
Interface). A new emitjri object is configured to
communicate with this controller, which has a manufacturer
ID of four and a device ID of 11.
All emObjects are passed
a reference to the emitjri object. This way, emObject
events can directly set variables on the embedded
controller. Changes in embedded variables can also
change emObject properties directly.
emitjri also contains
function calls that enable the applet to directly
set and get embedded variable values, as well as registering
a callback to be notified when an embedded variable
value changes.
An example of an emObject
directly controlling an embedded variable is the watering
on/off image switch. This object displays one of two
images depending on its state (active or inactive).
You can establish the
connection between the image switch waterOnOff and
the embedded variable Water. So, whenever an ActionEvent
occurs (when the switch is pressed and released on
the interface), the event value (True or False) sets
Water.
The embedded-controller
clock is a good example of communicating variable
state change to the display applet. The embedded variables
Hrs, Min, and Sec change regularly, and these changes
need to be relayed to the applet.
You may set up the callbacks
for the embedded variables. Whenever the variable
values change, notifyChange is called with the variable
name and the new value. Similarly, we could have omitted
the NotifyChange callback for Sec by setting a direct
link between Sec and the emObject timeDisplay (see
Listing 2).
Since emitjri handled
the communications requirements, the majority of the
coding effort was spent defining event-handler functions.
Whenever a button is pressed, text entered, list items
selected, checkboxes checked, and so on, events are
generated. The event-handling functions for 24-/12-h
clock, a.m./p.m., and day select are characteristic
of many event handling functions that had to be created.
Many features were built
into the user interface (see Photo 1) that could not
easily be accomplished via hardware or by defining
the interface completely within the embedded controller.
The size of the applet increased to approximately
75 KB, but the controller and support interface hardware
costs were reduced.
|

Photo 1The
GUI can match the device interface or add
to the functionality available on the device.
This weather-station interface provides
an easy, intuitive view of weather conditions,
enabling the user to see the impact of changing
data on the device functions.
|
The end result is a Java
class file that we can compress onto a 32-KB EEPROM
and serve from the device. Or, emGateway could serve
the client the prestaged class file along with the
standard set of preinstalled emObjects.