Package io.openems.edge.bridge.modbus
Class BridgeModbusSerialImpl
- java.lang.Object
-
- io.openems.edge.common.component.AbstractOpenemsComponent
-
- io.openems.edge.bridge.modbus.api.AbstractModbusBridge
-
- io.openems.edge.bridge.modbus.BridgeModbusSerialImpl
-
- All Implemented Interfaces:
BridgeModbus
,BridgeModbusSerial
,OpenemsComponent
,org.osgi.service.event.EventHandler
public class BridgeModbusSerialImpl extends AbstractModbusBridge implements BridgeModbus, BridgeModbusSerial, OpenemsComponent, org.osgi.service.event.EventHandler
Provides a service for connecting to, querying and writing to a Modbus/RTU device.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.openems.edge.bridge.modbus.api.BridgeModbus
BridgeModbus.ChannelId
-
Nested classes/interfaces inherited from interface io.openems.edge.bridge.modbus.api.BridgeModbusSerial
BridgeModbusSerial.ChannelId
-
Nested classes/interfaces inherited from interface io.openems.edge.common.component.OpenemsComponent
OpenemsComponent.ChannelId
-
-
Field Summary
-
Fields inherited from class io.openems.edge.bridge.modbus.api.AbstractModbusBridge
DEFAULT_RETRIES, DEFAULT_TIMEOUT, worker
-
-
Constructor Summary
Constructors Constructor Description BridgeModbusSerialImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closeModbusConnection()
Closes the Modbus connection.protected void
deactivate()
Handles @Deactivate of implementations.int
getBaudrate()
Gets the Baudrate (e.g.Cycle
getCycle()
Gets theCycle
.int
getDatabits()
Gets the Databits (e.g.com.ghgande.j2mod.modbus.io.ModbusTransaction
getNewModbusTransaction()
Creates a new Modbus Transaction on an open Modbus connection.Parity
getParity()
Gets the Parity.java.lang.String
getPortName()
Gets the Port-Name (e.g.Stopbit
getStopbits()
Gets the Stopbits.-
Methods inherited from class io.openems.edge.bridge.modbus.api.AbstractModbusBridge
activate, activate, addProtocol, getLogVerbosity, handleEvent, invalidateElementsAfterReadErrors, logError, logInfo, logWarn, removeProtocol
-
Methods inherited from class io.openems.edge.common.component.AbstractOpenemsComponent
_channel, activate, addChannel, addChannels, addChannels, alias, channels, getComponentContext, id, isEnabled, logDebug, modified, removeChannel
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.openems.edge.bridge.modbus.api.BridgeModbus
_setCycleTimeIsTooShort, _setExecutionDuration, addProtocol, getCycleTimeIsTooShort, getCycleTimeIsTooShortChannel, getExecutionDuration, getExecutionDurationChannel, removeProtocol
-
Methods inherited from interface io.openems.edge.common.component.OpenemsComponent
_channel, _getChannelAs, alias, channel, channel, channels, debugLog, getComponentContext, getState, getStateChannel, hasFaults, id, isEnabled, serviceFactoryPid, servicePid
-
-
-
-
Method Detail
-
deactivate
protected void deactivate()
Description copied from class:AbstractOpenemsComponent
Handles @Deactivate of implementations. Prints log output.- Overrides:
deactivate
in classAbstractModbusBridge
-
getCycle
public Cycle getCycle()
Description copied from class:AbstractModbusBridge
Gets theCycle
.- Specified by:
getCycle
in classAbstractModbusBridge
- Returns:
- the Cycle
-
closeModbusConnection
public void closeModbusConnection()
Description copied from class:AbstractModbusBridge
Closes the Modbus connection.- Specified by:
closeModbusConnection
in classAbstractModbusBridge
-
getNewModbusTransaction
public com.ghgande.j2mod.modbus.io.ModbusTransaction getNewModbusTransaction() throws OpenemsException
Description copied from class:AbstractModbusBridge
Creates a new Modbus Transaction on an open Modbus connection.- Specified by:
getNewModbusTransaction
in classAbstractModbusBridge
- Returns:
- the Modbus Transaction
- Throws:
OpenemsException
- on error
-
getBaudrate
public int getBaudrate()
Description copied from interface:BridgeModbusSerial
Gets the Baudrate (e.g. 9600).- Specified by:
getBaudrate
in interfaceBridgeModbusSerial
- Returns:
- the Baudrate
-
getDatabits
public int getDatabits()
Description copied from interface:BridgeModbusSerial
Gets the Databits (e.g. 8).- Specified by:
getDatabits
in interfaceBridgeModbusSerial
- Returns:
- the Databits
-
getParity
public Parity getParity()
Description copied from interface:BridgeModbusSerial
Gets the Parity.- Specified by:
getParity
in interfaceBridgeModbusSerial
- Returns:
- the Parity.
-
getPortName
public java.lang.String getPortName()
Description copied from interface:BridgeModbusSerial
Gets the Port-Name (e.g. '/dev/ttyUSB0' or 'COM3').- Specified by:
getPortName
in interfaceBridgeModbusSerial
- Returns:
- the Port-Name
-
getStopbits
public Stopbit getStopbits()
Description copied from interface:BridgeModbusSerial
Gets the Stopbits.- Specified by:
getStopbits
in interfaceBridgeModbusSerial
- Returns:
- the Stopbits
-
-