Class AbstractModbusBridge

    • Field Detail

      • DEFAULT_TIMEOUT

        protected static final int DEFAULT_TIMEOUT
        Default Modbus timeout in [ms].

        Modbus library default is 3000 ms

        See Also:
        Constant Field Values
      • DEFAULT_RETRIES

        protected static final int DEFAULT_RETRIES
        Default Modbus retries.

        Modbus library default is 5

        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractModbusBridge

        protected AbstractModbusBridge​(ChannelId[] firstInitialChannelIds,
                                       ChannelId[]... furtherInitialChannelIds)
    • Method Detail

      • activate

        protected void activate​(org.osgi.service.component.ComponentContext context,
                                java.lang.String id,
                                java.lang.String alias,
                                boolean enabled)
        Description copied from class: AbstractOpenemsComponent
        Handles @Activate of implementations. Prints log output.
        Overrides:
        activate in class AbstractOpenemsComponent
        Parameters:
        context - the OSGi ComponentContext
        id - the unique OpenEMS Component ID
        alias - Human-readable name of this Component. Typically 'config.alias()'. Defaults to 'id' if empty
        enabled - is the Component enabled?
      • activate

        protected void activate​(org.osgi.service.component.ComponentContext context,
                                java.lang.String id,
                                java.lang.String alias,
                                boolean enabled,
                                LogVerbosity logVerbosity,
                                int invalidateElementsAfterReadErrors)
      • getCycle

        public abstract Cycle getCycle()
        Gets the Cycle.
        Returns:
        the Cycle
      • addProtocol

        public void addProtocol​(java.lang.String sourceId,
                                ModbusProtocol protocol)
        Adds the protocol.
        Specified by:
        addProtocol in interface BridgeModbus
        Parameters:
        sourceId - Component-ID of the source
        protocol - the ModbusProtocol
      • removeProtocol

        public void removeProtocol​(java.lang.String sourceId)
        Removes the protocol.
        Specified by:
        removeProtocol in interface BridgeModbus
        Parameters:
        sourceId - Component-ID of the source
      • handleEvent

        public void handleEvent​(org.osgi.service.event.Event event)
        Specified by:
        handleEvent in interface org.osgi.service.event.EventHandler
      • getNewModbusTransaction

        public abstract com.ghgande.j2mod.modbus.io.ModbusTransaction getNewModbusTransaction()
                                                                                       throws OpenemsException
        Creates a new Modbus Transaction on an open Modbus connection.
        Returns:
        the Modbus Transaction
        Throws:
        OpenemsException - on error
      • closeModbusConnection

        public abstract void closeModbusConnection()
        Closes the Modbus connection.
      • logInfo

        public void logInfo​(org.slf4j.Logger log,
                            java.lang.String message)
        Description copied from class: AbstractOpenemsComponent
        Log an info message including the Component ID.
        Overrides:
        logInfo in class AbstractOpenemsComponent
        Parameters:
        log - the Logger instance
        message - the message
      • logWarn

        protected void logWarn​(org.slf4j.Logger log,
                               java.lang.String message)
        Description copied from class: AbstractOpenemsComponent
        Log a warn message including the Component ID.
        Overrides:
        logWarn in class AbstractOpenemsComponent
        Parameters:
        log - the Logger instance
        message - the message
      • logError

        protected void logError​(org.slf4j.Logger log,
                                java.lang.String message)
        Description copied from class: AbstractOpenemsComponent
        Log an error message including the Component ID.
        Overrides:
        logError in class AbstractOpenemsComponent
        Parameters:
        log - the Logger instance
        message - the message
      • invalidateElementsAfterReadErrors

        public int invalidateElementsAfterReadErrors()
        After how many errors should a element be invalidated?.
        Returns:
        value