public class RS485Configurator extends RS485Server
In most cases you will use the graphical tool that comes with the configurator:
stella.jview.JRS485ConfigRS485Server.Checksum, RS485Server.Command, RS485Server.Info, RS485Server.ScanAbstractSerialDriver.Available| Modifier and Type | Field and Description |
|---|---|
protected static String |
ADDRESSFILL
The address fill-in String ("**").
|
private static TreeMap |
CODETOBAUD
A hash map matching baud codes to baud rates.
|
private static String |
DEFADDRESS
The default address of the module (00).
|
private static TreeMap |
INPUTTOVOLT
A hash map matching input ranges to volts.
|
static String |
KEY_ADDRESS
The key linked to the hexadecimal address of the module.
|
protected static String |
LEADCHAR
The command characterizing leading char ("-").
|
private HashMap |
no
Matching no-parameter commands to command lines.
|
private HashMap |
one
Matching one-parameter commands to command lines.
|
private String |
orgconf
The original configuration read in at port opening.
|
protected static String[] |
RESERVED
The default keyword recognized.
|
static String |
SIMPLE_COMMAND
A key starting with this prefix is linked to a no-parameter command.
|
static String |
SINGLE_COMMAND
Keys starting with this prefix are single-parameter commands.
|
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, lockinport, 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, LOCK, outport, STATICLOCKKEY_DRIVERNAMEKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORCONFIG, KEY_CLASS| Constructor and Description |
|---|
RS485Configurator(Map prop)
Constructs a new RS485Configurator.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getAddressFromReply()
Return the code segment of the reply after readstatus defining the
return address.
|
Set |
getAllBaudCodes()
Returns all baud codes as a set.
|
Set |
getAllRangeCodes()
Returns all input ranges as a set.
|
Set |
getAllSimple()
Returns the command names for all non-parameter commands as a set.
|
Set |
getAllSingle()
Returns the command names for all one-parameter commands as a set.
|
String |
getBaudFromCode(String baudcode)
Converts the baud 2-character code into the actual bitrate.
|
String |
getBaudFromReply()
Return the code segment of the reply after readstatus defining the
baud rate.
|
String |
getChecksumCodeFromFlag(boolean flag)
Returns the value of the checksumming code as a function as the checksum
flag.
|
boolean |
getChecksumFlagFromCode(String code)
Returns the value of the checksumming flag out of the checksumming
code.
|
String |
getChecksumFromReply()
Return the code segment of the reply after readstatus defining the
checksum flag.
|
String |
getCodeFromBaud(String baud)
Converts the baud rate, given as an integer, to the baud-rate code.
|
String |
getCodeFromRange(String volt)
Converts a descriptive input range into
the code to send to the module.
|
private static String |
getCodeFromValue(String value,
Map target)
Returns the key asociated with a certain value in the given map.
|
String |
getRangeFromCode(String code)
Converts the two-character input range code into a more descriptive
input range.
|
String |
getTypeFromReply()
Return the code segment of the reply after readstatus defining the
module type.
|
static void |
main(String[] arg)
Sends a configuration command to the serial port.
|
private void |
readConf()
Reads the currecnt configuration.
|
private String |
replace(String which) |
boolean |
sendCommandLine(String line)
Sends the command line to the serial port.
|
protected boolean |
sendConfigCommand(String oldadd,
String newadd,
String code,
String baud,
String checkflag)
Sends the main configure command to the serial port.
|
protected boolean |
sendReserved(String type,
String arg)
Writes one of the reserved commands.
|
boolean |
setOpen()
Opens the serial port.
|
deferCommand, ensureCommand, exit, getCheckSum, getCheckSumming, isReading, open, readString, setCheckSumming, toString, writeCommand, writeStringclose, createPortEventListener, createPortEventListener, deregisterSoleEventListener, disableEvent, enableEvent, getDriverName, init, isOpen, registerSoleEventListener, resetOriginalParameterscreateDriver, equals, hashCodeaugment, augment, augment, augment, augment, clone, 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, initProperties, isNew, parseObject, parseObject, reload, reload, removeProperty, requires, rescanned, setObject, setProperties, setProperty, stringPropertiespublic static final String SIMPLE_COMMAND
public static final String SINGLE_COMMAND
public static final String KEY_ADDRESS
protected static final String[] RESERVED
private static final String DEFADDRESS
protected static final String LEADCHAR
protected static final String ADDRESSFILL
private HashMap no
private HashMap one
private String orgconf
private static final TreeMap INPUTTOVOLT
private static final TreeMap CODETOBAUD
public RS485Configurator(Map prop)
public boolean setOpen()
throws IOException
IOExceptionprivate void readConf()
throws IOException
IOExceptionpublic boolean sendCommandLine(String line) throws IOException
LEADCHAR.
First, the reserved command
names are scanned. If no match is found the no-parameter commands are
scanned. Again if no match is found the one-parameter commands are
scanned. If no match is found at all false is returned.When a match is found the appropriate command is constructed and sent to the serial server. The command is constructed in an obscure way if the command is one of the reserved words. For no-parameter commands, the appropriate value found in the no-parameter look-up table is sent. One parameter commands are augmented with whatever is found after the command name in the command line. No response is read in.
IOExceptionprotected boolean sendReserved(String type, String arg) throws IOException
IOExceptionprotected boolean sendConfigCommand(String oldadd, String newadd, String code, String baud, String checkflag) throws IOException
KEY_ADDRESS property is set to the new value but baud rate
and checksumming is left unchanged. After the
string has been sent, the configuration is read in again with a call
to readConf().IOExceptionpublic String getAddressFromReply()
public String getTypeFromReply()
public String getBaudFromReply()
public String getChecksumFromReply()
public String getBaudFromCode(String baudcode)
Implementation note: the code-to-baud rate is hard-coded into the program.
public String getCodeFromBaud(String baud)
public String getRangeFromCode(String code)
public String getCodeFromRange(String volt)
public Set getAllBaudCodes()
public Set getAllRangeCodes()
public Set getAllSimple()
public Set getAllSingle()
public boolean getChecksumFlagFromCode(String code)
public String getChecksumCodeFromFlag(boolean flag)
private static final String getCodeFromValue(String value, Map target)
public static void main(String[] arg) throws IOException
IOException