[pytango] 367/483: Implement feature-request #103

Sandor Bodo-Merle sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:15:00 UTC 2017


This is an automated email from the git hooks/post-receive script.

sbodomerle-guest pushed a commit to annotated tag bliss_8.10
in repository pytango.

commit 9aee730c624b4d32c46e2391aba85e7449328fee
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date:   Wed Apr 2 14:32:07 2014 +0000

    Implement feature-request #103
    
    git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@25332 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
 src/boost/cpp/attr_conf_event_data.cpp  | 45 +++++++++++++++++++++++++++------
 src/boost/cpp/data_ready_event_data.cpp | 39 ++++++++++++++++++++++------
 src/boost/cpp/event_data.cpp            | 45 ++++++++++++++++++++++++++++-----
 3 files changed, 107 insertions(+), 22 deletions(-)

diff --git a/src/boost/cpp/attr_conf_event_data.cpp b/src/boost/cpp/attr_conf_event_data.cpp
index cee7201..15c5521 100644
--- a/src/boost/cpp/attr_conf_event_data.cpp
+++ b/src/boost/cpp/attr_conf_event_data.cpp
@@ -12,26 +12,55 @@
 #include "precompiled_header.hpp"
 #include <tango.h>
 
+#include "exception.h"
+
 using namespace boost::python;
 
+extern boost::python::object PyTango_DevFailed;
+
+namespace PyAttrConfEventData
+{
+    static boost::shared_ptr<Tango::AttrConfEventData> makeAttrConfEventData()
+    {
+        Tango::AttrConfEventData *result = new Tango::AttrConfEventData;
+        return boost::shared_ptr<Tango::AttrConfEventData>(result);
+    }
+
+    static void set_errors(Tango::AttrConfEventData &event_data, 
+                           boost::python::object &dev_failed)
+    {
+        Tango::DevFailed df;
+        boost::python::object errors = dev_failed.attr("args");
+        sequencePyDevError_2_DevErrorList(errors.ptr(), event_data.errors);
+    }
+};
+
 void export_attr_conf_event_data()
 {
     class_<Tango::AttrConfEventData>("AttrConfEventData",
         init<const Tango::AttrConfEventData &>())
-        // The original Tango::EventData structure has a 'device' field.
+
+        .def("__init__", boost::python::make_constructor(PyAttrConfEventData::makeAttrConfEventData))
+
+        // The original Tango::AttrConfEventData structure has a 'device' field.
         // However, if we returned this directly we would get a different
         // python device each time. So we are doing our weird things to make
         // sure the device returned is the same where the read action was
-        // performed. So we don't return Tango::EventData::device directly.
+        // performed. So we don't return Tango::AttrConfEventData::device directly.
         // See callback.cpp
         .setattr("device",object())
-        .def_readonly("attr_name", &Tango::AttrConfEventData::attr_name)
-        .def_readonly("event", &Tango::AttrConfEventData::event)
+        .def_readwrite("attr_name", &Tango::AttrConfEventData::attr_name)
+        .def_readwrite("event", &Tango::AttrConfEventData::event)
+
         .setattr("attr_conf",object())
-        .def_readonly("err", &Tango::AttrConfEventData::err)
-        .def_readonly("reception_date", &Tango::AttrConfEventData::reception_date)
-        .add_property("errors", make_getter(&Tango::AttrConfEventData::errors, 
-            return_value_policy<copy_non_const_reference>()))
+
+        .def_readwrite("err", &Tango::AttrConfEventData::err)
+        .def_readwrite("reception_date", &Tango::AttrConfEventData::reception_date)
+        .add_property("errors", 
+		      make_getter(&Tango::AttrConfEventData::errors, 
+				  return_value_policy<copy_non_const_reference>()),
+		      &PyAttrConfEventData::set_errors)
+
         .def("get_date", &Tango::AttrConfEventData::get_date,
             return_internal_reference<>())
     ;
diff --git a/src/boost/cpp/data_ready_event_data.cpp b/src/boost/cpp/data_ready_event_data.cpp
index 073e395..6000598 100644
--- a/src/boost/cpp/data_ready_event_data.cpp
+++ b/src/boost/cpp/data_ready_event_data.cpp
@@ -12,14 +12,32 @@
 #include "precompiled_header.hpp"
 #include <tango.h>
 
+#include "exception.h"
+
 using namespace boost::python;
 
+extern boost::python::object PyTango_DevFailed;
+
 struct PyDataReadyEventData
 {
     static inline Tango::DeviceProxy* get_device(Tango::DataReadyEventData &self)
     {
         return self.device;
     }
+
+    static boost::shared_ptr<Tango::DataReadyEventData> makeDataReadyEventData()
+    {
+        Tango::DataReadyEventData *result = new Tango::DataReadyEventData;
+        return boost::shared_ptr<Tango::DataReadyEventData>(result);
+    }
+
+    static void set_errors(Tango::DataReadyEventData &event_data, 
+	                   boost::python::object &dev_failed)
+    {
+        Tango::DevFailed df;
+        boost::python::object errors = dev_failed.attr("args");
+        sequencePyDevError_2_DevErrorList(errors.ptr(), event_data.errors);
+    }
 };
 
 void export_data_ready_event_data()
@@ -27,6 +45,8 @@ void export_data_ready_event_data()
     class_<Tango::DataReadyEventData>("DataReadyEventData",
         init<const Tango::DataReadyEventData &>())
 
+        .def("__init__", boost::python::make_constructor(PyDataReadyEventData::makeDataReadyEventData))
+
         // The original Tango::EventData structure has a 'device' field.
         // However, if we returned this directly we would get a different
         // python device each time. So we are doing our weird things to make
@@ -34,14 +54,17 @@ void export_data_ready_event_data()
         // performed. So we don't return Tango::EventData::device directly.
         // See callback.cpp
         .setattr("device",object())
-        .def_readonly("attr_name", &Tango::DataReadyEventData::attr_name)
-        .def_readonly("event", &Tango::DataReadyEventData::event)
-        .def_readonly("attr_data_type", &Tango::DataReadyEventData::attr_data_type)
-        .def_readonly("ctr", &Tango::DataReadyEventData::ctr)
-        .def_readonly("err", &Tango::DataReadyEventData::err)
-        .def_readonly("reception_date", &Tango::DataReadyEventData::reception_date)
-        .add_property("errors", make_getter(&Tango::DataReadyEventData::errors, 
-            return_value_policy<copy_non_const_reference>()))
+        .def_readwrite("attr_name", &Tango::DataReadyEventData::attr_name)
+        .def_readwrite("event", &Tango::DataReadyEventData::event)
+        .def_readwrite("attr_data_type", &Tango::DataReadyEventData::attr_data_type)
+        .def_readwrite("ctr", &Tango::DataReadyEventData::ctr)
+        .def_readwrite("err", &Tango::DataReadyEventData::err)
+        .def_readwrite("reception_date", &Tango::DataReadyEventData::reception_date)
+        .add_property("errors", 
+		      make_getter(&Tango::DataReadyEventData::errors, 
+				  return_value_policy<copy_non_const_reference>()),
+		      &PyDataReadyEventData::set_errors)
+
         .def("get_date", &Tango::DataReadyEventData::get_date,
             return_internal_reference<>())
     ;
diff --git a/src/boost/cpp/event_data.cpp b/src/boost/cpp/event_data.cpp
index a9f7f49..f55405f 100644
--- a/src/boost/cpp/event_data.cpp
+++ b/src/boost/cpp/event_data.cpp
@@ -12,13 +12,44 @@
 #include "precompiled_header.hpp"
 #include <tango.h>
 
+#include "exception.h"
+
 using namespace boost::python;
 
+extern boost::python::object PyTango_DevFailed;
+
+namespace PyEventData
+{
+    static boost::shared_ptr<Tango::EventData> makeEventData()
+    {
+        Tango::EventData *result = new Tango::EventData;
+        result->attr_value = new Tango::DeviceAttribute();
+       return boost::shared_ptr<Tango::EventData>(result);
+    }
+
+    static void set_errors(Tango::EventData &event_data, boost::python::object &error)
+    {
+        PyObject* error_ptr = error.ptr();
+        if (PyObject_IsInstance(error_ptr, PyTango_DevFailed.ptr()))
+        {
+            Tango::DevFailed df;
+	    boost::python::object error_list = error.attr("args");
+	    sequencePyDevError_2_DevErrorList(error_list.ptr(), event_data.errors);
+        }
+        else
+        {
+            sequencePyDevError_2_DevErrorList(error_ptr, event_data.errors);
+        }
+    }
+};
+
 void export_event_data()
 {
     class_<Tango::EventData>("EventData",
         init<const Tango::EventData &>())
     
+        .def("__init__", boost::python::make_constructor(PyEventData::makeEventData))
+
         // The original Tango::EventData structure has a 'device' field.
         // However, if we returned this directly we would get a different
         // python device each time. So we are doing our weird things to make
@@ -27,8 +58,8 @@ void export_event_data()
         // See callback.cpp
         .setattr("device", object())
         
-        .def_readonly("attr_name", &Tango::EventData::attr_name)
-        .def_readonly("event", &Tango::EventData::event)
+        .def_readwrite("attr_name", &Tango::EventData::attr_name)
+        .def_readwrite("event", &Tango::EventData::event)
         
         // The original Tango::EventData structure has "get_attr_value" but
         // we can't refer it directly here because we have to extract value
@@ -36,10 +67,12 @@ void export_event_data()
         // See callback.cpp
         .setattr("attr_value", object())
         
-        .def_readonly("err", &Tango::EventData::err)
-        .def_readonly("reception_date", &Tango::EventData::reception_date)
-        .add_property("errors", make_getter(&Tango::EventData::errors, 
-            return_value_policy<copy_non_const_reference>()))
+        .def_readwrite("err", &Tango::EventData::err)
+        .def_readwrite("reception_date", &Tango::EventData::reception_date)
+        .add_property("errors", 
+		      make_getter(&Tango::EventData::errors, 
+				  return_value_policy<copy_non_const_reference>()),
+		      &PyEventData::set_errors)
         
         .def("get_date", &Tango::EventData::get_date, 
             return_internal_reference<>())

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pytango.git



More information about the debian-science-commits mailing list