public abstract class AbstractModbusBridge extends AbstractOpenemsComponent implements BridgeModbus, org.osgi.service.event.EventHandler
BridgeModbus.ChannelId
Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_RETRIES
Default Modbus retries.
|
protected static int |
DEFAULT_TIMEOUT
Default Modbus timeout in [ms].
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractModbusBridge(ChannelId[] firstInitialChannelIds,
ChannelId[]... furtherInitialChannelIds) |
Modifier and Type | Method and Description |
---|---|
protected void |
activate(org.osgi.service.component.ComponentContext context,
java.lang.String id,
java.lang.String alias,
boolean enabled,
LogVerbosity logVerbosity,
int invalidateElementsAfterReadErrors) |
void |
addProtocol(java.lang.String sourceId,
ModbusProtocol protocol)
Adds the protocol.
|
abstract void |
closeModbusConnection()
Closes the Modbus connection.
|
protected void |
deactivate()
Handles @Deactivate of implementations.
|
LogVerbosity |
getLogVerbosity() |
abstract com.ghgande.j2mod.modbus.io.ModbusTransaction |
getNewModbusTransaction()
Creates a new Modbus Transaction on an open Modbus connection.
|
void |
handleEvent(org.osgi.service.event.Event event) |
int |
invalidateElementsAfterReadErrors()
After how many errors should a element be invalidated?.
|
protected void |
logError(org.slf4j.Logger log,
java.lang.String message)
Log an error message including the Component ID.
|
void |
logInfo(org.slf4j.Logger log,
java.lang.String message)
Log an info message including the Component ID.
|
protected void |
logWarn(org.slf4j.Logger log,
java.lang.String message)
Log a warn message including the Component ID.
|
void |
removeProtocol(java.lang.String sourceId)
Removes the protocol.
|
_channel, activate, addChannel, addChannels, addChannels, alias, channels, getComponentContext, id, isEnabled, logDebug, modified, removeChannel
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
_setCycleTimeIsTooShort, _setExecutionDuration, _setSlaveCommunicationFailed, getCycleTimeIsTooShort, getCycleTimeIsTooShortChannel, getExecutionDuration, getExecutionDurationChannel, getSlaveCommunicationFailed, getSlaveCommunicationFailedChannel
_channel, _getChannelAs, alias, channel, channel, channels, debugLog, getComponentContext, getModbusSlaveNatureTable, getState, getStateChannel, hasFaults, id, isEnabled, serviceFactoryPid, servicePid, updateConfigurationProperty, updateReferenceFilter
protected static final int DEFAULT_TIMEOUT
Modbus library default is 3000 ms
protected static final int DEFAULT_RETRIES
Modbus library default is 5
protected void activate(org.osgi.service.component.ComponentContext context, java.lang.String id, java.lang.String alias, boolean enabled, LogVerbosity logVerbosity, int invalidateElementsAfterReadErrors)
protected void deactivate()
AbstractOpenemsComponent
deactivate
in class AbstractOpenemsComponent
public void addProtocol(java.lang.String sourceId, ModbusProtocol protocol)
addProtocol
in interface BridgeModbus
sourceId
- Component-ID of the sourceprotocol
- the ModbusProtocolpublic void removeProtocol(java.lang.String sourceId)
removeProtocol
in interface BridgeModbus
sourceId
- Component-ID of the sourcepublic void handleEvent(org.osgi.service.event.Event event)
handleEvent
in interface org.osgi.service.event.EventHandler
public abstract com.ghgande.j2mod.modbus.io.ModbusTransaction getNewModbusTransaction() throws OpenemsException
OpenemsException
- on errorpublic abstract void closeModbusConnection()
public LogVerbosity getLogVerbosity()
public void logInfo(org.slf4j.Logger log, java.lang.String message)
AbstractOpenemsComponent
logInfo
in class AbstractOpenemsComponent
log
- the Logger instancemessage
- the messageprotected void logWarn(org.slf4j.Logger log, java.lang.String message)
AbstractOpenemsComponent
logWarn
in class AbstractOpenemsComponent
log
- the Logger instancemessage
- the messageprotected void logError(org.slf4j.Logger log, java.lang.String message)
AbstractOpenemsComponent
logError
in class AbstractOpenemsComponent
log
- the Logger instancemessage
- the messagepublic int invalidateElementsAfterReadErrors()