From af5b2b5e778ead57b0fe9e72561227f1ebbbfc42 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 23 Aug 2019 12:11:19 -0700 Subject: rfnoc: node: Add set_properties() node_t::set_properties() is a convenience function that lets you set multiple properties at once from a device_addr_t. --- host/lib/rfnoc/node.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'host/lib/rfnoc') diff --git a/host/lib/rfnoc/node.cpp b/host/lib/rfnoc/node.cpp index 8709df9ef..90f0a0a91 100644 --- a/host/lib/rfnoc/node.cpp +++ b/host/lib/rfnoc/node.cpp @@ -45,6 +45,25 @@ std::vector node_t::get_property_ids() const return return_value; } +void node_t::set_properties(const uhd::device_addr_t& props, const size_t instance) +{ + for (const auto& key : props.keys()) { + property_base_t* prop_ref = + _find_property({res_source_info::USER, instance}, key); + if (!prop_ref) { + RFNOC_LOG_WARNING("set_properties() cannot set property `" + << key << "': No such property."); + continue; + } + auto prop_access = _request_property_access(prop_ref, property_base_t::RW); + prop_ref->set_from_str(props.get(key)); + } + + // Now trigger a property resolution. If other properties depend on modified + // properties, they will be updated. + resolve_all(); +} + void node_t::set_command_time(uhd::time_spec_t time, const size_t instance) { if (_cmd_timespecs.size() <= instance) { -- cgit v1.2.3