stella.io
Class NudamConfig

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.NudamConfig
All Implemented Interfaces:
Driver, Cloneable, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying

public class NudamConfig
extends RS485Server

A simple configuration tool for NuDam modules. For this program to work, the NuDam module must be in the so-called DEFAULT mode, that is the DEFAULT pin (usually pin number 6) must be connected to GND.
Never connect the DEFAULT pin to any power signal.

The class opens the serial port with the current settings, as defined in the RS485Server class. It reads in the current address (which is, I'd guess always 00 in DEFAULT mode). The new address, baud rate, input range and checksum-flag are found in the KEY_NEWADDRESS, the KEY_NEWBAUD, the KEY_NEWRANGE, and the KEY_NEWCHECKSUM properties.
After opening the serial port with PropertyResources.init(), call configure() followed by AbstractSerialDriver.close() to perform the configuration. Do not forget to unplug the DEFALUT pin after configuration.


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 static Map CODETOBAUD
          A look-up table matching NuDam config codes to baud rates.
private static String DEFADDRESS
          The default address is 00 in DEFAULT mode.
private static String DEFNEWBAUD
          The default new baud rate.
private static boolean DEFNEWCHECKSUM
          The default new baud rate.
private static String DEFNEWRANGE
          The default new baud rate.
private static Map INPUTTOVOLT
          A look-up table matching NuDam config codes to input ranges.
static String KEY_ADDRESS
          The key to the current address
static String KEY_NEWADDRESS
          The key to the new address
static String KEY_NEWBAUD
          The key to the new address
static String KEY_NEWCHECKSUM
          The key to the new address
static String KEY_NEWRANGE
          The key to the new address
private  String newbaud
          The new baud-rate code.
private  String newrange
          The new input-range code.
private static Map NIBBLETOMODULE
          A look-up table matching NuDam read-config data format to NuDam types.
private static String TRAIL
          The set-configuration command trailing character.
 
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_RESPONDTIME, 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
NudamConfig(Map prop)
          Constructs a new NuDam configuration tool.
 
Method Summary
 void configure()
          Sends the configure command.
static void main(String[] arg)
          Reads in the new configuration from the properties file supplied as the first command line argument.
 
Methods inherited from class stella.io.RS485Server
deferCommand, ensureCommand, exit, getCheckSum, getCheckSumming, isReading, open, readString, setCheckSumming, toString, writeCommand, 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_ADDRESS

public static final String KEY_ADDRESS
The key to the current address

See Also:
Constant Field Values

KEY_NEWADDRESS

public static final String KEY_NEWADDRESS
The key to the new address

See Also:
Constant Field Values

KEY_NEWBAUD

public static final String KEY_NEWBAUD
The key to the new address

See Also:
Constant Field Values

KEY_NEWRANGE

public static final String KEY_NEWRANGE
The key to the new address

See Also:
Constant Field Values

KEY_NEWCHECKSUM

public static final String KEY_NEWCHECKSUM
The key to the new address

See Also:
Constant Field Values

DEFADDRESS

private static final String DEFADDRESS
The default address is 00 in DEFAULT mode.

See Also:
Constant Field Values

DEFNEWBAUD

private static final String DEFNEWBAUD
The default new baud rate.

See Also:
Constant Field Values

DEFNEWRANGE

private static final String DEFNEWRANGE
The default new baud rate.

See Also:
Constant Field Values

DEFNEWCHECKSUM

private static final boolean DEFNEWCHECKSUM
The default new baud rate.

See Also:
Constant Field Values

TRAIL

private static final String TRAIL
The set-configuration command trailing character.

See Also:
Constant Field Values

CODETOBAUD

private static final Map CODETOBAUD
A look-up table matching NuDam config codes to baud rates.


INPUTTOVOLT

private static final Map INPUTTOVOLT
A look-up table matching NuDam config codes to input ranges.


NIBBLETOMODULE

private static final Map NIBBLETOMODULE
A look-up table matching NuDam read-config data format to NuDam types.


newbaud

private String newbaud
The new baud-rate code.


newrange

private String newrange
The new input-range code.

Constructor Detail

NudamConfig

public NudamConfig(Map prop)
Constructs a new NuDam configuration tool. All new parameters have default values, except the module address which must be supplied in the properties handed over. If no new address is found, or the baud-rate, respectively the input range has no recognized value, construction fails with an IllegalArgumentException.

Method Detail

configure

public void configure()
               throws IOException
Sends the configure command. Note that on set configuration the checksum flag only enters as a set/unset 6th bit (2^6) in the last byte.

Throws:
IOException

main

public static void main(String[] arg)
                 throws IOException
Reads in the new configuration from the properties file supplied as the first command line argument. The serial port is opened, the configuration command is writtn and the serial port is closed again. The new address of the module is only visible after the DEFAULT pin has been unplugged.

Throws:
IOException