[PATCH] Added handling for Dynamic Properties
Matthias Goldhoorn
matthias.goldhoorn at dfki.de
Mon Apr 15 14:40:32 CEST 2013
---
lib/orocos/base.rb | 1 +
lib/orocos/task_context_base.rb | 14 ++++++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/lib/orocos/base.rb b/lib/orocos/base.rb
index 4380f82..9839776 100644
--- a/lib/orocos/base.rb
+++ b/lib/orocos/base.rb
@@ -7,6 +7,7 @@
module Orocos
class InternalError < Exception; end
class AmbiguousName < RuntimeError; end
+ class PropertyChangeRejected < RuntimeError; end
def self.register_pkgconfig_path(path)
base_path = caller(1).first.gsub(/:\d+:.*/, '')
diff --git a/lib/orocos/task_context_base.rb b/lib/orocos/task_context_base.rb
index 8b99688..38f7947 100644
--- a/lib/orocos/task_context_base.rb
+++ b/lib/orocos/task_context_base.rb
@@ -76,8 +76,18 @@ def read
# Sets a new value for the property/attribute
def write(value, timestamp = Time.now)
ensure_type_available
- value = Typelib.from_ruby(value, type)
- do_write(@orocos_type_name, value)
+ prop = task.model.find_property(name)
+ if(prop.nil?)
+ raise ArgumentError, "Could not find Property #{name} on Task, make sure it's generated by Orogen"
+ end
+ if(prop.dynamic?)
+ if(!task.operation("set#{name.capitalize}").callop(value))
+ raise PropertyChangeRejected, "The Change of property #{name} was rejected by the remote Task"
+ end
+ else
+ value = Typelib.from_ruby(value, type)
+ do_write(@orocos_type_name, value)
+ end
log_value(value, timestamp)
value
end
--
1.7.10.4
--------------050802090700040005080300--
More information about the Rock-dev
mailing list