public static class Iec21Port.Builder
extends java.lang.Object
Constructor and Description |
---|
Builder(java.lang.String serialPortName)
Create an Iec21Port builder.
|
Modifier and Type | Method and Description |
---|---|
Iec21Port |
buildAndOpen()
Build and open the Iec21Port.
|
Iec21Port.Builder |
enableFixedBaudrate(boolean fixedBaudRate)
Enable a fixed baud rate.
|
Iec21Port.Builder |
enableVerboseMode(boolean verbose)
Enable or disable verbose output to standard out.
|
Iec21Port.Builder |
setBaudRateChangeDelay(int baudRateChangeDelay)
Set the time in ms to wait before changing the baud rate during message exchange.
|
Iec21Port.Builder |
setDeviceAddress(java.lang.String deviceAddress)
Set the device address which is transmitted as part of the request message that is sent to the meter.
|
Iec21Port.Builder |
setInitialBaudrate(int initialBaudrate)
Set the initial baud rate.
|
Iec21Port.Builder |
setRequestStartCharacters(java.lang.String requestStartCharacters)
Sets the RequestMessage start characters.
|
Iec21Port.Builder |
setTimeout(int timeout)
Set the maximum time in ms to wait for new data from the remote device.
|
public Builder(java.lang.String serialPortName)
serialPortName
- examples for serial port identifiers on Linux are "/dev/ttyS0" or "/dev/ttyUSB0" and on Windows
"COM1"public Iec21Port.Builder setBaudRateChangeDelay(int baudRateChangeDelay)
The default value is 0.
baudRateChangeDelay
- the baud rate change delaypublic Iec21Port.Builder setInitialBaudrate(int initialBaudrate)
The default is 300 baud for modes A, B, and C and 2400 baud for mode D. This function allows to change the initial baud rate in case the meter does not use the default initial baud rate.
initialBaudrate
- the initial baud ratepublic Iec21Port.Builder setTimeout(int timeout)
The default value is 5000 (= 5 seconds).
timeout
- the maximum time in ms to wait for new data.public Iec21Port.Builder setDeviceAddress(java.lang.String deviceAddress)
The default value is the empty string.
deviceAddress
- the device addresspublic Iec21Port.Builder setRequestStartCharacters(java.lang.String requestStartCharacters)
Default value is: /?
requestStartCharacters
- characters at the start of a RequestMessagepublic Iec21Port.Builder enableVerboseMode(boolean verbose)
Default is disabled.
verbose
- if true enable verbose modepublic Iec21Port.Builder enableFixedBaudrate(boolean fixedBaudRate)
In mode C communication starts with baud rate 300 and then by default changes to a baud rate suggested by the meter. Enable a fixed baud rate if the baud rate shall NOT change.
fixedBaudRate
- if true enable fixed baud ratepublic Iec21Port buildAndOpen() throws java.io.IOException
java.io.IOException
- if an error occurs while opening the associated serial port (e.g. when the serial port is
occupied).