aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2019-05-30 13:54:44 -0700
committerMartin Braun <martin.braun@ettus.com>2019-11-26 11:49:14 -0800
commitad4004f1f78d5b64dae50b6e456d0206e824978f (patch)
treedf701340ac1d493ee5b7de72985ea1c5f3571ee2
parentb8a6c64d6012ab1ec0b3b843fccec2d990d440a3 (diff)
downloaduhd-ad4004f1f78d5b64dae50b6e456d0206e824978f.tar.gz
uhd-ad4004f1f78d5b64dae50b6e456d0206e824978f.tar.bz2
uhd-ad4004f1f78d5b64dae50b6e456d0206e824978f.zip
rfnoc: node: Add default command time API
-rw-r--r--host/include/uhd/rfnoc/node.hpp42
-rw-r--r--host/lib/rfnoc/node.cpp23
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)
{