Package org.openmuc.j62056
Class Iec21Port.Builder
java.lang.Object
org.openmuc.j62056.Iec21Port.Builder
- Enclosing class:
- Iec21Port
A builder for Iec21Ports.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionBuild and open the Iec21Port.enableFixedBaudrate
(boolean fixedBaudRate) Enable a fixed baud rate.enableVerboseMode
(boolean verbose) Enable or disable verbose output to standard out.setAcknowledgeMode
(char acknowledgeMode) Sets the acknowledgeMode charactersetBaudRateChangeDelay
(int baudRateChangeDelay) Set the time in ms to wait before changing the baud rate during message exchange.setDeviceAddress
(String deviceAddress) Set the device address which is transmitted as part of the request message that is sent to the meter.setInitialBaudrate
(int initialBaudrate) Set the initial baud rate.setRequestStartCharacters
(String requestStartCharacters) Sets the RequestMessage start characters.setSelectExpectData
(String selectExpectData) Sets the Manufacturer Data for expected select response.setSelectManufacturerData
(String selectManufacturerData) Sets the Manufacturer Data for select.setTimeout
(int timeout) Set the maximum time in ms to wait for new data from the remote device.
-
Constructor Details
-
Builder
Create an Iec21Port builder.- Parameters:
serialPortName
- examples for serial port identifiers on Linux are "/dev/ttyS0" or "/dev/ttyUSB0" and on Windows "COM1"
-
-
Method Details
-
setBaudRateChangeDelay
Set the time in ms to wait before changing the baud rate during message exchange. This parameter can usually be set to zero for regular serial ports. If a USB to serial converter is used, you might have to use a delay of around 250ms because otherwise the baud rate is changed before the previous message (i.e. the acknowledgment) has been completely sent.The default value is 0.
- Parameters:
baudRateChangeDelay
- the baud rate change delay- Returns:
- the builder
-
setInitialBaudrate
Set the initial baud rate.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.
- Parameters:
initialBaudrate
- the initial baud rate- Returns:
- the builder
-
setTimeout
Set the maximum time in ms to wait for new data from the remote device. A timeout of zero is interpreted as an infinite timeout.The default value is 5000 (= 5 seconds).
- Parameters:
timeout
- the maximum time in ms to wait for new data.- Returns:
- the builder
-
setDeviceAddress
Set the device address which is transmitted as part of the request message that is sent to the meter.The default value is the empty string.
- Parameters:
deviceAddress
- the device address- Returns:
- the builder
-
setRequestStartCharacters
Sets the RequestMessage start characters.Default value is: /?
- Parameters:
requestStartCharacters
- characters at the start of a RequestMessage- Returns:
- the builder
-
setSelectManufacturerData
Sets the Manufacturer Data for select.- Parameters:
selectManufacturerData
- payload for select message- Returns:
- the builder
-
setSelectExpectData
Sets the Manufacturer Data for expected select response.- Parameters:
selectExpectData
- payload for expected select reply- Returns:
- the builder
-
setAcknowledgeMode
Sets the acknowledgeMode character- Parameters:
acknowledgeMode
- value for Acknowledge Mode- Returns:
- the builder
-
enableVerboseMode
Enable or disable verbose output to standard out.Default is disabled.
- Parameters:
verbose
- if true enable verbose mode- Returns:
- the builder
-
enableFixedBaudrate
Enable a fixed baud rate.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.
- Parameters:
fixedBaudRate
- if true enable fixed baud rate- Returns:
- the builder
-
buildAndOpen
Build and open the Iec21Port.- Returns:
- the opened Iec21Port
- Throws:
IOException
- if an error occurs while opening the associated serial port (e.g. when the serial port is occupied).
-