diff options
Diffstat (limited to 'host')
| -rw-r--r-- | host/include/uhd/rfnoc/node.hpp | 42 | ||||
| -rw-r--r-- | host/lib/rfnoc/node.cpp | 23 | 
2 files changed, 65 insertions, 0 deletions
diff --git a/host/include/uhd/rfnoc/node.hpp b/host/include/uhd/rfnoc/node.hpp index 54c66c985..ffbfc3319 100644 --- a/host/include/uhd/rfnoc/node.hpp +++ b/host/include/uhd/rfnoc/node.hpp @@ -12,6 +12,7 @@  #include <uhd/rfnoc/property.hpp>  #include <uhd/utils/log.hpp>  #include <uhd/utils/scope_exit.hpp> +#include <uhd/types/time_spec.hpp>  #include <unordered_map>  #include <unordered_set>  #include <boost/graph/adjacency_list.hpp> @@ -55,9 +56,15 @@ public:          DROP      }; +    static const size_t ANY_PORT = size_t(~0); +    /************************************************************************** +     * Structors +     *************************************************************************/      node_t(); +    virtual ~node_t() {} +      /******************************************       * Basic Operations       ******************************************/ @@ -137,6 +144,36 @@ public:      const prop_data_t& get_property(          const std::string& id, const size_t instance = 0) /* mutable */; +    /*! Standard API for setting the command time +     * +     * There are instances where commands need a time associated with them. +     * For example, a block could have a 'freq' user property, which should be +     * changed at a certain time. In that case, the block would have to be +     * written to handle command times. +     * +     * The reason there is no 'time' parameter in set_property() or other API +     * calls is because there is no uniform definition of what the time means; +     * it can change from block to block. The transformation of \p time to a +     * tick count, for example, is non-standard. +     * +     * The default implementation will simply stash away the time; it can be +     * retrieved by calling get_command_time(); +     */ +    virtual void set_command_time(uhd::time_spec_t time, const size_t instance); + +    /*! Return a previously set command time +     * +     * When no time was set, this will return uhd::time_spec_t::ASAP +     */ +    virtual uhd::time_spec_t get_command_time(const size_t instance) const; + +    /*! Standard API for resetting the command time +     * +     * This will clear the time previously set by set_command_time(). It +     * defaults to calling set_command_time(time_spec_t(0.0), instance) +     */ +    virtual void clear_command_time(const size_t instance); +  protected:      /******************************************       * Internal Registration Functions @@ -488,6 +525,11 @@ private:      // The default callback will simply drop actions      action_handler_t _post_action_cb = [](const res_source_info&,                                             action_info::sptr) { /* nop */ }; + +    /************************************************************************** +     * Other attributes +     *************************************************************************/ +    std::vector<uhd::time_spec_t> _cmd_timespecs;  }; // class node_t  }} /* namespace uhd::rfnoc */ diff --git a/host/lib/rfnoc/node.cpp b/host/lib/rfnoc/node.cpp index d569cea4a..cc2d7b7a9 100644 --- a/host/lib/rfnoc/node.cpp +++ b/host/lib/rfnoc/node.cpp @@ -45,6 +45,29 @@ std::vector<std::string> node_t::get_property_ids() const      return return_value;  } +void node_t::set_command_time(uhd::time_spec_t time, const size_t instance) +{ +    if (_cmd_timespecs.size() <= instance) { +        _cmd_timespecs.resize(instance + 1, uhd::time_spec_t(0.0)); +    } + +    _cmd_timespecs[instance] = time; +} + +uhd::time_spec_t node_t::get_command_time(const size_t instance) const +{ +    if (instance >= _cmd_timespecs.size()) { +        return uhd::time_spec_t::ASAP; +    } + +    return _cmd_timespecs.at(instance); +} + +void node_t::clear_command_time(const size_t instance) +{ +    set_command_time(uhd::time_spec_t(0.0), instance); +} +  /*** Protected methods *******************************************************/  void node_t::register_property(property_base_t* prop, resolve_callback_t&& clean_callback)  {  | 
