stella.jview
Class JRS485Config

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by io.AbstractDriver
                  extended by io.AbstractSerialDriver
                      extended by stella.io.RS485Server
                          extended by stella.io.RS485Configurator
                              extended by stella.jview.JRS485Config
All Implemented Interfaces:
Driver, ActionListener, Cloneable, EventListener, Displayable, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying

public class JRS485Config
extends RS485Configurator
implements ActionListener, ExitCleaning, Displayable

A GUI for controlling the RS485 setup. This configurator tool is not independently checking the serial line for different modules. The address has to be stated in the properties, see {link #KEY_ADDRESS}. On startup, the module configuration is read in by sending the read configuration command, $(Add)2 to the module. The state of the checksumming flag, the module's input range and the baud rate is deduced from the reply. After successfully reading the configuration, the control window is launched. It should look similar to the following:

JRS485Config

There, the address of the module is given in the top line. This address cannot be altered, address changes are only allowed in the text field labeled new: in the first command group. There, the input range and the baud rate along with the checksumming flag can be altered, too. After the first group all commands that do not require a command line follow. Their human-readable form is a key in the configurators properties, augmented with the RS485Configurator.SIMPLE_COMMAND prefix. The value of the key points to the string representation of the actual command to send to the module, see also RS485Configurator.ADDRESSFILL. In the example, a command that reads the status of the watch dog is shown.
After the no-command-line commands the commands with a single command line are grouped. In the example its the set watchdog command. The contents of the command line is added to the appropriate command replacement as is.
If you have to send strings directly to the module (with no command expression in the other sections) you can use the text field labeled direct. Whatever you insert here -do not forget the module's address- will be transfered as-is.
The status field to the right of the exit button, JExitButton, displays all commands sent to the module and the replies received. Commands sent display in black, while responses are blue colored. The console display (black background) does also show I/O along the serial line, bytes sent out are preceeded by a > sign, while bytes received show up with a leading <.
If the user issues a command and no reply is received the input state of the configurator is regained after a certain time-out, KEY_RESPONDTIME. Insuccessful commands are answered with a No response, canceling error message displayed in red in the status field.


Nested Class Summary
 
Nested classes/interfaces inherited from class stella.io.RS485Server
RS485Server.Checksum, RS485Server.Command, RS485Server.Info, RS485Server.Scan
 
Nested classes/interfaces inherited from class io.AbstractSerialDriver
AbstractSerialDriver.Available
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  JTextField address
          The text field for the current address, non-editable.
private  JTextField addressinput
          The text field for the address.
private  JRadioButton checkoff
          The radio buttons related to the check flag false.
private  JRadioButton checkon
          The radio buttons related to the check flag true.
private  HashMap commandline
          A HashMap linking one-parameter commands to text fields.
private  JTextArea console
          The text are used for console-like I/O.
private static int DEFCOLUMN
          The default number of columns in the console (20).
private static long DEFRESPONDTIME
          The default respond time, 1 sec.
private static int DEFROW
          The default number of rows in the console (10).
private  JTextField direct
          The text field for direct input.
private  JComboBox jbaud
          The baud rates available.
private  JComboBox jrange
          The input ranges available.
static String KEY_COLUMN
          The key to the number of columns of the console.
static String KEY_RESPONDTIME
          The key for the response-reading timeout (ms).
static String KEY_ROW
          The key to the number of rows of the console.
private static String MAINCOMMAND
          The unique identifier for the main configure command.
private  JStatusExit status
          The status panel of the configurator.
private static Color TEXTBACKGROUND
          The background color of the console text area.
private static Font TEXTFONT
          The font of the console text area.
private static Color TEXTFOREGROUND
          The foreground color of the console text area.
 
Fields inherited from class stella.io.RS485Configurator
ADDRESSFILL, KEY_ADDRESS, LEADCHAR, RESERVED, SIMPLE_COMMAND, SINGLE_COMMAND
 
Fields inherited from class stella.io.RS485Server
KEY_CHECKCHAR, KEY_CHECKSUM, KEY_CLOSE, KEY_CR, KEY_ECHO, KEY_FAILTIME, KEY_FAILURES, KEY_INVALID, KEY_MAXBUFFER, KEY_MAXBUSY, KEY_QUERYTIME, KEY_REINIT, KEY_STARTUP, KEY_TIMEBUSY, lock
 
Fields inherited from class io.AbstractSerialDriver
inport, KEY_BAUDRATE, KEY_CLOSETIMEOUT, KEY_DATABIT, KEY_FLOWCONTROL, KEY_INBUFFER, KEY_NOTIFYCOOLDOWN, KEY_OUTBUFFER, KEY_PARITYBIT, KEY_PORTNAME, KEY_RECEIVEFRAMING, KEY_RECEIVETHRESHOLD, KEY_RECEIVETIMEOUT, KEY_STOPBIT, KEY_TIMEOUT, outport, staticlock
 
Fields inherited from class io.AbstractDriver
KEY_DRIVERNAME
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Constructor Summary
JRS485Config(Map prop)
          Constructs a new RS485-configuration tool.
 
Method Summary
 void actionPerformed(ActionEvent ae)
          Handles action events delivered from the ok buttons.
 void exit()
          Closes the serial line on normal exits through the exit button.
 Icon getIcon()
          Might return an icon, if one was stated in the properties
 Component getRepresentation()
          Returns a panel comprising all configuration possibilities.
private  JButton listeningOKButton(String actcom)
          Returns a button labeled 'ok'.
static void main(String[] arg)
          Launches the graphical RS485 Configuration tool.
 boolean setOpen()
          Opens the serial port.
 String writeCommand(String mess)
          The read method echos the read result to the console and to the status line.
 
Methods inherited from class stella.io.RS485Configurator
getAddressFromReply, getAllBaudCodes, getAllRangeCodes, getAllSimple, getAllSingle, getBaudFromCode, getBaudFromReply, getChecksumCodeFromFlag, getChecksumFlagFromCode, getChecksumFromReply, getCodeFromBaud, getCodeFromRange, getRangeFromCode, getTypeFromReply, sendCommandLine, sendConfigCommand, sendReserved
 
Methods inherited from class stella.io.RS485Server
deferCommand, ensureCommand, getCheckSum, getCheckSumming, isReading, open, readString, setCheckSumming, toString, writeString
 
Methods inherited from class io.AbstractSerialDriver
close, createPortEventListener, createPortEventListener, deregisterSoleEventListener, disableEvent, enableEvent, getDriverName, isOpen, registerSoleEventListener, resetOriginalParameters
 
Methods inherited from class io.AbstractDriver
createDriver, equals, hashCode
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, init, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 
Methods inherited from interface util.Initializable
init
 

Field Detail

KEY_COLUMN

public static final String KEY_COLUMN
The key to the number of columns of the console.

See Also:
Constant Field Values

KEY_ROW

public static final String KEY_ROW
The key to the number of rows of the console.

See Also:
Constant Field Values

KEY_RESPONDTIME

public static final String KEY_RESPONDTIME
The key for the response-reading timeout (ms).

See Also:
Constant Field Values

DEFCOLUMN

private static final int DEFCOLUMN
The default number of columns in the console (20).

See Also:
Constant Field Values

DEFROW

private static final int DEFROW
The default number of rows in the console (10).

See Also:
Constant Field Values

DEFRESPONDTIME

private static final long DEFRESPONDTIME
The default respond time, 1 sec.

See Also:
Constant Field Values

TEXTFOREGROUND

private static final Color TEXTFOREGROUND
The foreground color of the console text area.


TEXTBACKGROUND

private static final Color TEXTBACKGROUND
The background color of the console text area.


TEXTFONT

private static final Font TEXTFONT
The font of the console text area.


MAINCOMMAND

private static final String MAINCOMMAND
The unique identifier for the main configure command.

See Also:
Constant Field Values

direct

private JTextField direct
The text field for direct input.


status

private JStatusExit status
The status panel of the configurator.


console

private JTextArea console
The text are used for console-like I/O.


address

private JTextField address
The text field for the current address, non-editable.


addressinput

private JTextField addressinput
The text field for the address.


jbaud

private JComboBox jbaud
The baud rates available.


jrange

private JComboBox jrange
The input ranges available.


checkon

private JRadioButton checkon
The radio buttons related to the check flag true.


checkoff

private JRadioButton checkoff
The radio buttons related to the check flag false.


commandline

private HashMap commandline
A HashMap linking one-parameter commands to text fields.

Constructor Detail

JRS485Config

public JRS485Config(Map prop)
Constructs a new RS485-configuration tool. After construction, the window can be retrieved with getRepresentation().

Method Detail

getIcon

public Icon getIcon()
Might return an icon, if one was stated in the properties

Specified by:
getIcon in interface Displayable

getRepresentation

public Component getRepresentation()
Returns a panel comprising all configuration possibilities. The layout of the RS485Configurator.RESERVED commands is fixed, they all constitute to a single panel. The default setting is derived from the config string that is read in during open. Therefore, opening the serial line is done automatically if this method is called.

Specified by:
getRepresentation in interface Displayable

setOpen

public boolean setOpen()
                throws IOException
Opens the serial port. Additionally, the address read in from the read configuration method is stored in a read-only text label. The radio-button set with the baud rates is created. The radio buttons with the checksum flag is created.

Overrides:
setOpen in class RS485Configurator
Throws:
IOException

exit

public void exit()
Closes the serial line on normal exits through the exit button.

Specified by:
exit in interface ExitCleaning
Overrides:
exit in class RS485Server

actionPerformed

public void actionPerformed(ActionEvent ae)
Handles action events delivered from the ok buttons. The action command is used to differentiate between the individual buttons.

Specified by:
actionPerformed in interface ActionListener

writeCommand

public String writeCommand(String mess)
                    throws IOException
The read method echos the read result to the console and to the status line. Writing output to the console or to the status line can only occur after the string has been read. In the console, write commands are indicated with a leading <. In the status line, color coding as in JStatusPanel.done(java.lang.String) is used.

Overrides:
writeCommand in class RS485Server
Parameters:
mess - The command to write
Throws:
IOException

listeningOKButton

private JButton listeningOKButton(String actcom)
Returns a button labeled 'ok'. The main class is registered as an action listener to the button.


main

public static void main(String[] arg)
Launches the graphical RS485 Configuration tool. The first and only argument is the file name of the properties file of the RS485 configurator.