Class AbstractRatOutput

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract Class[] accepts()
      Returns the type of data that gets accepted.
      protected Hashtable<String,​Object> backupState()
      Backs up the current state of the actor before update the variables.
      boolean canInput()
      Whether input can be supplied at the moment.
      protected String check()
      Hook method for performing checks.
      void cleanUp()
      Cleans up data structures, frees up memory.
      protected void configureLogger()
      Initializes the logger.
      protected abstract String doTransmit()
      Performs the actual transmission.
      protected void doWait​(int msec)
      A simple waiting method.
      protected HashSet<String> findVariables()
      Recursively finds all the variables used in this RatOutput.
      String getAdditionalInformation()
      Returns the additional information.
      String getFullName()
      Returns the full name of the receiver.
      Rat getOwner()
      Returns the actor the transmitter belongs to.
      protected adams.flow.control.StorageQueueHandler getQueue​(adams.flow.control.StorageName name)
      Returns the flow's queue.
      String getQuickInfo()
      Returns a quick info about the actor, which will be displayed in the GUI.
      adams.core.Variables getVariables()
      Returns the Variables instance to use.
      protected String handleException​(String msg, Throwable t)
      Outputs the stacktrace along with the message on stderr and returns a combination of both of them as string.
      protected void initialize()
      Initializes the members.
      String initTransmission()
      Initializes the transmission.
      void input​(Object obj)
      The data to transmit.
      protected boolean isBackedUp​(String key)
      Checks whether a specified key is present in the current backup state.
      boolean isStopped()
      Returns whether the transmitter has been stopped.
      protected void pruneBackup()
      Removes entries from the backup.
      protected void pruneBackup​(String key)
      Removes the object with the specified key from the current backup state.
      protected void restoreState​(Hashtable<String,​Object> state)
      Restores the state of the actor before the variables got updated.
      void setOwner​(Rat value)
      Sets the actor the transmitter belongs to.
      String setUp()
      Hook method for performing checks at setup time.
      AbstractRatOutput shallowCopy()
      Returns a shallow copy of itself, i.e., based on the commandline options.
      AbstractRatOutput shallowCopy​(boolean expand)
      Returns a shallow copy of itself, i.e., based on the commandline options.
      void stopExecution()
      Stops the execution.
      String transmit()
      Performs the transmission.
      protected void updateDetectedVariables()
      Updates the detected variables.
      protected void updatePrefix()
      Updates the prefix of the logger.
      protected String updateVariables()
      Gets called when the actor needs to be re-setUp when a variable changes.
      void variableChanged​(adams.event.VariableChangeEvent e)
      Gets triggered when a variable changed (added, modified, removed).
      • Methods inherited from class adams.core.option.AbstractOptionHandler

        cleanUpOptions, defineOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
      • Methods inherited from class adams.core.logging.LoggingObject

        getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
      • Methods inherited from interface adams.core.Destroyable

        destroy
      • Methods inherited from interface adams.core.logging.LoggingLevelHandler

        getLoggingLevel
      • Methods inherited from interface adams.core.option.OptionHandler

        cleanUpOptions, defineOptions, getOptionManager, toCommandLine
    • Field Detail

      • m_Owner

        protected Rat m_Owner
        the owner.
      • m_Stopped

        protected boolean m_Stopped
        whether the reception was stopped.
      • m_LoggingPrefix

        protected String m_LoggingPrefix
        the logging prefix.
      • m_Input

        protected Object m_Input
        the input.
      • m_DetectedVariables

        protected HashSet<String> m_DetectedVariables
        the variable names that are used within this output.
      • m_DetectedObjectVariables

        protected HashSet<String> m_DetectedObjectVariables
        the variable names (referencing callable actors or storage) that are used within this output.
      • m_VariablesUpdated

        protected HashSet<String> m_VariablesUpdated
        whether the output needs re-setting up because of modified variables.
      • m_BackupState

        protected Hashtable<String,​Object> m_BackupState
        for backing up the state of an actor.
    • Constructor Detail

      • AbstractRatOutput

        public AbstractRatOutput()
    • Method Detail

      • initialize

        protected void initialize()
        Initializes the members.
        Overrides:
        initialize in class adams.core.option.AbstractOptionHandler
      • configureLogger

        protected void configureLogger()
        Initializes the logger.
        Overrides:
        configureLogger in class adams.core.logging.LoggingObject
      • getFullName

        public String getFullName()
        Returns the full name of the receiver.
        Specified by:
        getFullName in interface RatOutput
        Returns:
        the name
      • updatePrefix

        protected void updatePrefix()
        Updates the prefix of the logger.
      • handleException

        protected String handleException​(String msg,
                                         Throwable t)
        Outputs the stacktrace along with the message on stderr and returns a combination of both of them as string.
        Parameters:
        msg - the message for the exception
        t - the exception
        Returns:
        the full error message (message + stacktrace)
      • setOwner

        public void setOwner​(Rat value)
        Sets the actor the transmitter belongs to.
        Specified by:
        setOwner in interface RatOutput
        Parameters:
        value - the owner
      • getOwner

        public Rat getOwner()
        Returns the actor the transmitter belongs to.
        Specified by:
        getOwner in interface RatOutput
        Returns:
        the owner
      • getAdditionalInformation

        public String getAdditionalInformation()
        Returns the additional information.
        Specified by:
        getAdditionalInformation in interface adams.core.AdditionalInformationHandler
        Returns:
        the additional information, null or 0-length string for no information
      • getQuickInfo

        public String getQuickInfo()
        Returns a quick info about the actor, which will be displayed in the GUI.

        Default implementation returns null.
        Specified by:
        getQuickInfo in interface adams.core.QuickInfoSupporter
        Returns:
        null if no info available, otherwise short string
      • accepts

        public abstract Class[] accepts()
        Returns the type of data that gets accepted.
        Specified by:
        accepts in interface RatOutput
        Returns:
        the type of data
      • canInput

        public boolean canInput()
        Whether input can be supplied at the moment.
        Specified by:
        canInput in interface RatOutput
        Returns:
        true if input is accepted
      • input

        public void input​(Object obj)
        The data to transmit.
        Specified by:
        input in interface RatOutput
        Parameters:
        obj - the data
      • getVariables

        public adams.core.Variables getVariables()
        Returns the Variables instance to use.
        Returns:
        the variables instance, null if not available
      • findVariables

        protected HashSet<String> findVariables()
        Recursively finds all the variables used in this RatOutput.
        Returns:
        the variables that were found
      • updateDetectedVariables

        protected void updateDetectedVariables()
        Updates the detected variables.
      • setUp

        public String setUp()
        Hook method for performing checks at setup time.
        Specified by:
        setUp in interface RatOutput
        Returns:
        null if successful, otherwise error message
      • check

        protected String check()
        Hook method for performing checks.

        Default implementation does nothing.
        Returns:
        null if successful, otherwise error message
      • doWait

        protected void doWait​(int msec)
        A simple waiting method.
        Parameters:
        msec - the maximum number of milli-seconds to wait, no waiting if 0
      • getQueue

        protected adams.flow.control.StorageQueueHandler getQueue​(adams.flow.control.StorageName name)
        Returns the flow's queue.
        Parameters:
        name - the name of the queue
        Returns:
        the queue, null if not initialized
        See Also:
        QueueInit
      • variableChanged

        public void variableChanged​(adams.event.VariableChangeEvent e)
        Gets triggered when a variable changed (added, modified, removed).
        Specified by:
        variableChanged in interface RatOutput
        Specified by:
        variableChanged in interface adams.event.VariableChangeListener
        Parameters:
        e - the event
      • isBackedUp

        protected boolean isBackedUp​(String key)
        Checks whether a specified key is present in the current backup state.
        Parameters:
        key - the key of the object to look for in the backup state
        Returns:
        true if key present
      • pruneBackup

        protected void pruneBackup​(String key)
        Removes the object with the specified key from the current backup state.
        Parameters:
        key - the key of the object to remove from the backup state
      • pruneBackup

        protected void pruneBackup()
        Removes entries from the backup.

        Default implementation does nothing.
        See Also:
        AbstractOptionHandler.reset()
      • restoreState

        protected void restoreState​(Hashtable<String,​Object> state)
        Restores the state of the actor before the variables got updated.

        Default implementation does nothing.
        Parameters:
        state - the backup of the state to restore from
        See Also:
        updateVariables(), backupState()
      • updateVariables

        protected String updateVariables()
        Gets called when the actor needs to be re-setUp when a variable changes.
        Returns:
        null if everything is fine, otherwise error message
      • initTransmission

        public String initTransmission()
        Initializes the transmission.
        Specified by:
        initTransmission in interface RatOutput
        Returns:
        null if successfully initialized, otherwise error message
      • doTransmit

        protected abstract String doTransmit()
        Performs the actual transmission.
        Returns:
        null if successful, otherwise error message
      • transmit

        public String transmit()
        Performs the transmission.
        Specified by:
        transmit in interface RatOutput
        Returns:
        null if successful, otherwise error message
      • shallowCopy

        public AbstractRatOutput shallowCopy()
        Returns a shallow copy of itself, i.e., based on the commandline options.
        Specified by:
        shallowCopy in interface adams.core.ShallowCopySupporter<AbstractRatOutput>
        Returns:
        the shallow copy
      • shallowCopy

        public AbstractRatOutput shallowCopy​(boolean expand)
        Returns a shallow copy of itself, i.e., based on the commandline options.
        Specified by:
        shallowCopy in interface adams.core.ShallowCopySupporter<AbstractRatOutput>
        Parameters:
        expand - whether to expand variables to their current values
        Returns:
        the shallow copy
      • stopExecution

        public void stopExecution()
        Stops the execution.
        Specified by:
        stopExecution in interface RatOutput
        Specified by:
        stopExecution in interface adams.core.Stoppable
      • isStopped

        public boolean isStopped()
        Returns whether the transmitter has been stopped.
        Specified by:
        isStopped in interface RatOutput
        Specified by:
        isStopped in interface adams.core.StoppableWithFeedback
        Returns:
        true if stopped
      • cleanUp

        public void cleanUp()
        Cleans up data structures, frees up memory.
        Specified by:
        cleanUp in interface adams.core.CleanUpHandler