C M 1 1 A E v e n t s
J e s s e  P e t e r s o n



CM11AEvents is a demonstration program that can be used to see the two types (three flavors) of CM11A events: CM11AStatusEvent (Status event) and CM11AEvent (Power Fail and Macro Initiated).

The program CM11AEvents can be started by entering the following command line:

java CM11AEvents [-port serial_port]

Where:

 
-port serial_port Set the serial port that the CM11A can be contacted on. Default: COM2

Example

Running CM11AEvents on the default serial port of 'COM2'.

java CM11AEvents

Running CM11AEvents on serial port 'COM1'.

java CM11AEvents -port COM1


Code

The source code for CM11AEvents.java can be found in the samples/CM11AEvents directory. The class implements both the CM11AListener interface and the CM11AStatusListener interface. After allocating the CM11A object, the CM11AEvents object registers itself as a CM11AListener and a CM11AStatusListener with the method calls addCM11AListener and addCM11AStatusListener respectively.

A simple command interface is provided to facilitate event generation. If the <Enter> key is pressed, the CM11A device will be queried for its current status. When the status is retrieved, the status listener method is called with the CM11AStatusEvent which is printed to standard out.

If the CM11A device has been programmed with any macros, you can invoke the macro and get a CM11AEvent indicating that a macro was invoked.

You can also simulate a power failure to the CM11AEvent indicating resumption from a power failure. You can do this by monentarilly unplugging the CM11A device from the outlet. After plugging the device back in, a CM11AEvent indicating a power failure should occur. When a power failure event does occur, the CM11A expects to receive a "set clock" message before it will continue processing commands. The CM11A class has the ability to automatically generate this command after recovering from a power failure. The autorecovery can be turned off however, allowing manual handling of the power failure. The powerFailure method show how to handle both cases. You can test either case by turning autorecovery on or off by typing "auto" or "noauto" in the simple interface.

When done with the test, type "exit" to terminate the program.



Copyright © 1999 Jesse Peterson