jamod at SF

net.wimpi.modbus.util
Class SerialParameters

java.lang.Object
  extended bynet.wimpi.modbus.util.SerialParameters

public class SerialParameters
extends java.lang.Object

Helper class wrapping all serial port communication parameters. Very similar to the javax.comm demos, however, not the same.

Version:
1.2rc1 (09/11/2004)
Author:
Dieter Wimberger, John Charlton

Constructor Summary
SerialParameters()
          Constructs a new SerialParameters instance with default values.
SerialParameters(java.util.Properties props, java.lang.String prefix)
          Constructs a new SerialParameters instance with parameters obtained from a Properties instance.
SerialParameters(java.lang.String portName, int baudRate, int flowControlIn, int flowControlOut, int databits, int stopbits, int parity, boolean echo)
          Constructs a new SerialParameters instance with given parameters.
 
Method Summary
 int getBaudRate()
          Return the baud rate as int.
 java.lang.String getBaudRateString()
          Returns the baud rate as a String.
 int getDatabits()
          Returns the number of data bits as int.
 java.lang.String getDatabitsString()
          Returns the number of data bits as String.
 java.lang.String getEncoding()
          Returns the encoding to be used.
 int getFlowControlIn()
          Returns the input flow control type as int.
 java.lang.String getFlowControlInString()
          Returns the input flow control type as String.
 int getFlowControlOut()
          Returns the output flow control type as int.
 java.lang.String getFlowControlOutString()
          Returns the output flow control type as String.
 int getParity()
          Returns the parity schema as int.
 java.lang.String getParityString()
          Returns the parity schema as String.
 java.lang.String getPortName()
          Returns the port name.
 int getStopbits()
          Returns the number of stop bits as int.
 java.lang.String getStopbitsString()
          Returns the number of stop bits as String.
 boolean isEcho()
          Get the Echo value.
 void setBaudRate(int rate)
          Sets the baud rate.
 void setBaudRate(java.lang.String rate)
          Sets the baud rate.
 void setDatabits(int databits)
          Sets the number of data bits.
 void setDatabits(java.lang.String databits)
          Sets the number of data bits from the given String.
 void setEcho(boolean newEcho)
          Set the Echo value.
 void setEncoding(java.lang.String enc)
          Sets the encoding to be used.
 void setFlowControlIn(int flowcontrol)
          Sets the type of flow control for the input as given by the passed in int.
 void setFlowControlIn(java.lang.String flowcontrol)
          Sets the type of flow control for the input as given by the passed in String.
 void setFlowControlOut(int flowControlOut)
          Sets the output flow control type as given by the passed in int.
 void setFlowControlOut(java.lang.String flowControlOut)
          Sets the output flow control type as given by the passed in String.
 void setParity(int parity)
          Sets the parity schema.
 void setParity(java.lang.String parity)
          Sets the parity schema from the given String.
 void setPortName(java.lang.String name)
          Sets the port name.
 void setStopbits(int stopbits)
          Sets the number of stop bits.
 void setStopbits(java.lang.String stopbits)
          Sets the number of stop bits from the given String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerialParameters

public SerialParameters()
Constructs a new SerialParameters instance with default values.


SerialParameters

public SerialParameters(java.lang.String portName,
                        int baudRate,
                        int flowControlIn,
                        int flowControlOut,
                        int databits,
                        int stopbits,
                        int parity,
                        boolean echo)
Constructs a new SerialParameters instance with given parameters.

Parameters:
portName - The name of the port.
baudRate - The baud rate.
flowControlIn - Type of flow control for receiving.
flowControlOut - Type of flow control for sending.
databits - The number of data bits.
stopbits - The number of stop bits.
parity - The type of parity.
echo - Flag for setting the RS485 echo mode.

SerialParameters

public SerialParameters(java.util.Properties props,
                        java.lang.String prefix)
Constructs a new SerialParameters instance with parameters obtained from a Properties instance.

Parameters:
props - a Properties instance.
prefix - a prefix for the properties keys if embedded into other properties.
Method Detail

setPortName

public void setPortName(java.lang.String name)
Sets the port name.

Parameters:
name - the new port name.

getPortName

public java.lang.String getPortName()
Returns the port name.

Returns:
the port name.

setBaudRate

public void setBaudRate(int rate)
Sets the baud rate.

Parameters:
rate - the new baud rate.

setBaudRate

public void setBaudRate(java.lang.String rate)
Sets the baud rate.

Parameters:
rate - the new baud rate.

getBaudRate

public int getBaudRate()
Return the baud rate as int.

Returns:
the baud rate as int.

getBaudRateString

public java.lang.String getBaudRateString()
Returns the baud rate as a String.

Returns:
the baud rate as String.

setFlowControlIn

public void setFlowControlIn(int flowcontrol)
Sets the type of flow control for the input as given by the passed in int.

Parameters:
flowcontrol - the new flow control type.

setFlowControlIn

public void setFlowControlIn(java.lang.String flowcontrol)
Sets the type of flow control for the input as given by the passed in String.

Parameters:
flowcontrol - the flow control for reading type.

getFlowControlIn

public int getFlowControlIn()
Returns the input flow control type as int.

Returns:
the input flow control type as int.

getFlowControlInString

public java.lang.String getFlowControlInString()
Returns the input flow control type as String.

Returns:
the input flow control type as String.

setFlowControlOut

public void setFlowControlOut(int flowControlOut)
Sets the output flow control type as given by the passed in int.

Parameters:
flowControlOut - new output flow control type as int.

setFlowControlOut

public void setFlowControlOut(java.lang.String flowControlOut)
Sets the output flow control type as given by the passed in String.

Parameters:
flowControlOut - the new output flow control type as String.

getFlowControlOut

public int getFlowControlOut()
Returns the output flow control type as int.

Returns:
the output flow control type as int.

getFlowControlOutString

public java.lang.String getFlowControlOutString()
Returns the output flow control type as String.

Returns:
the output flow control type as String.

setDatabits

public void setDatabits(int databits)
Sets the number of data bits.

Parameters:
databits - the new number of data bits.

setDatabits

public void setDatabits(java.lang.String databits)
Sets the number of data bits from the given String.

Parameters:
databits - the new number of data bits as String.

getDatabits

public int getDatabits()
Returns the number of data bits as int.

Returns:
the number of data bits as int.

getDatabitsString

public java.lang.String getDatabitsString()
Returns the number of data bits as String.

Returns:
the number of data bits as String.

setStopbits

public void setStopbits(int stopbits)
Sets the number of stop bits.

Parameters:
stopbits - the new number of stop bits setting.

setStopbits

public void setStopbits(java.lang.String stopbits)
Sets the number of stop bits from the given String.

Parameters:
stopbits - the number of stop bits as String.

getStopbits

public int getStopbits()
Returns the number of stop bits as int.

Returns:
the number of stop bits as int.

getStopbitsString

public java.lang.String getStopbitsString()
Returns the number of stop bits as String.

Returns:
the number of stop bits as String.

setParity

public void setParity(int parity)
Sets the parity schema.

Parameters:
parity - the new parity schema as int.

setParity

public void setParity(java.lang.String parity)
Sets the parity schema from the given String.

Parameters:
parity - the new parity schema as String.

getParity

public int getParity()
Returns the parity schema as int.

Returns:
the parity schema as int.

getParityString

public java.lang.String getParityString()
Returns the parity schema as String.

Returns:
the parity schema as String.

setEncoding

public void setEncoding(java.lang.String enc)
Sets the encoding to be used.

Parameters:
enc - the encoding as string.
See Also:
Modbus.SERIAL_ENCODING_ASCII, Modbus.SERIAL_ENCODING_RTU, Modbus.SERIAL_ENCODING_BIN

getEncoding

public java.lang.String getEncoding()
Returns the encoding to be used.

Returns:
the encoding as string.
See Also:
Modbus.SERIAL_ENCODING_ASCII, Modbus.SERIAL_ENCODING_RTU, Modbus.SERIAL_ENCODING_BIN

isEcho

public boolean isEcho()
Get the Echo value.

Returns:
the Echo value.

setEcho

public void setEcho(boolean newEcho)
Set the Echo value.

Parameters:
newEcho - The new Echo value.

jamod at SF

Copyright 2002-2004 jamod development team.