Class AbstractTask

    • Constructor Detail

      • AbstractTask

        public AbstractTask​(int startAddress,
                            ModbusElement<?>... elements)
    • Method Detail

      • getElements

        public ModbusElement<?>[] getElements()
        Description copied from interface: Task
        Gets the ModbusElements.
        Specified by:
        getElements in interface Task
        Returns:
        an array of ModbusElements
      • getLength

        public int getLength()
        Description copied from interface: Task
        Gets the length from first to last Modbus register address.
        Specified by:
        getLength in interface Task
        Returns:
        the address
      • getStartAddress

        public int getStartAddress()
        Description copied from interface: Task
        Gets the start Modbus register address.
        Specified by:
        getStartAddress in interface Task
        Returns:
        the address
      • execute

        public final int execute​(AbstractModbusBridge bridge)
                          throws OpenemsException
        Executes the tasks - i.e. sends the query of a ReadTask or writes a WriteTask.

        Internally the _execute()-method of the specific subclass gets called.

        Specified by:
        execute in interface Task
        Parameters:
        bridge - the Modbus-Bridge
        Returns:
        the number of executed Sub-Tasks
        Throws:
        OpenemsException - on error
      • isDebug

        public boolean isDebug()
      • getLogVerbosity

        protected LogVerbosity getLogVerbosity​(AbstractModbusBridge bridge)
        Combines the global and local (via isDebug log verbosity.
        Parameters:
        bridge - the parent Bridge
        Returns:
        the combined LogVerbosity
      • hasBeenExecuted

        public boolean hasBeenExecuted()
        Description copied from interface: Task
        Gets whether this ReadTask has been successfully executed before.
        Specified by:
        hasBeenExecuted in interface Task
        Returns:
        true if this Task has been executed successfully at least once
      • deactivate

        public void deactivate()
        Description copied from interface: Task
        This is called on deactivate of the Modbus-Bridge. It can be used to clear any references like listeners.
        Specified by:
        deactivate in interface Task
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getExecuteDuration

        public long getExecuteDuration()
        Description copied from interface: Task
        Gets the execution duration of the last execution (successful or not not successful) in [ms].
        Specified by:
        getExecuteDuration in interface Task
        Returns:
        the duration in [ms]
      • getActiondescription

        protected abstract java.lang.String getActiondescription()