[pytango] 05/98: Implement pipe config (client side)

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


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

sbodomerle-guest pushed a commit to tag v9.2.0
in repository pytango.

commit 1d98b59d61ea30a95b9e0750bd4ceaf0d78e999f
Author: Jose Tiago Coutinho Macara <tiago.coutinho at esrf.fr>
Date:   Wed Dec 2 13:18:09 2015 +0100

    Implement pipe config (client side)
---
 Makefile                           |   1 +
 src/boost/cpp/base_types.cpp       |  13 +++++
 src/boost/cpp/device_proxy.cpp     |  24 +++++++++
 src/boost/cpp/from_py.cpp          |  29 +++++++++++
 src/boost/cpp/from_py.h            |   3 ++
 src/boost/cpp/pipe_info.cpp        |  30 +++++++++++
 src/boost/cpp/to_py.cpp            |  29 +++++++++++
 src/boost/cpp/to_py.h              |   6 +++
 src/boost/python/device_proxy.py   | 103 ++++++++++++++++++++++++++++++++++++-
 src/boost/python/device_server.py  |  12 +++++
 src/boost/python/pytango_pprint.py |   8 +--
 11 files changed, 253 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 7c00938..c465d95 100644
--- a/Makefile
+++ b/Makefile
@@ -154,6 +154,7 @@ $(OBJS_DIR)/attribute_dimension.o \
 $(OBJS_DIR)/attribute_event_info.o \
 $(OBJS_DIR)/attribute_info.o \
 $(OBJS_DIR)/attribute_info_ex.o \
+$(OBJS_DIR)/pipe_info.o \
 $(OBJS_DIR)/attribute_proxy.o \
 $(OBJS_DIR)/base_types.o \
 $(OBJS_DIR)/callback.o \
diff --git a/src/boost/cpp/base_types.cpp b/src/boost/cpp/base_types.cpp
index d8d4ceb..7b3ad53 100644
--- a/src/boost/cpp/base_types.cpp
+++ b/src/boost/cpp/base_types.cpp
@@ -39,6 +39,7 @@ void export_device_data();
 void export_device_attribute();
 void export_device_data_history();
 void export_device_attribute_history();
+void export_pipe_info();
 
 void export_dev_error();
 void export_time_val();
@@ -120,6 +121,15 @@ inline bool operator==(const Tango::DeviceDataHistory& ddh1_, const Tango::Devic
            //ddh1.errors() == ddh2.errors();
 }
 
+inline bool operator==(const Tango::PipeInfo& pi1, const Tango::PipeInfo& pi2)
+{
+    return pi1.name == pi2.name &&
+	pi1.description == pi2.description &&
+	pi1.label == pi2.label &&
+	pi1.disp_level == pi2.disp_level &&
+	pi1.writable == pi2.writable &&
+	pi1.extensions == pi2.extensions;
+}
 }
 
 /**
@@ -290,6 +300,8 @@ void export_base_types()
 
     class_<Tango::AttributeInfoListEx>("AttributeInfoListEx")
         .def(vector_indexing_suite<Tango::AttributeInfoListEx, false>());
+    class_<Tango::PipeInfoList>("PipeInfoList")
+        .def(vector_indexing_suite<Tango::PipeInfoList, false>());
 
     class_<std::vector<Tango::Attr *> >("AttrList")
         .def(vector_indexing_suite<std::vector<Tango::Attr *>, true>());
@@ -404,6 +416,7 @@ void export_base_types()
     export_device_attribute();
     export_device_data_history();
     export_device_attribute_history();
+    export_pipe_info();
 
     export_dev_error();
     export_time_val();
diff --git a/src/boost/cpp/device_proxy.cpp b/src/boost/cpp/device_proxy.cpp
index a60f1f0..da3311d 100644
--- a/src/boost/cpp/device_proxy.cpp
+++ b/src/boost/cpp/device_proxy.cpp
@@ -555,6 +555,30 @@ void export_device_proxy()
             ( arg_("self"), arg_("filter"), arg_("array") ) )
 
         //
+        // pipe methods
+        //
+
+        .def("get_pipe_list", &Tango::DeviceProxy::get_pipe_list,
+	     ( arg_("self") ),
+	     bopy::return_value_policy<bopy::manage_new_object>() )
+
+        .def("_get_pipe_config",
+	     (Tango::PipeInfoList* (Tango::DeviceProxy::*)(StdStringVector &))
+	     &Tango::DeviceProxy::get_pipe_config,
+	     ( arg_("self"), arg_("pipe_names") ),
+	     bopy::return_value_policy<bopy::manage_new_object>() )
+
+        .def("_get_pipe_config",
+	     (Tango::PipeInfo (Tango::DeviceProxy::*)(const std::string&))
+	     &Tango::DeviceProxy::get_pipe_config,
+	     ( arg_("self"), arg_("pipe_name") ) )
+
+        .def("_set_pipe_config",
+	     (void (Tango::DeviceProxy::*)(Tango::PipeInfoList &))
+	     &Tango::DeviceProxy::set_pipe_config,
+	     ( arg_("self"), arg_("seq") ) )
+
+        //
         // attribute methods
         //
 
diff --git a/src/boost/cpp/from_py.cpp b/src/boost/cpp/from_py.cpp
index 478c47c..22dca57 100644
--- a/src/boost/cpp/from_py.cpp
+++ b/src/boost/cpp/from_py.cpp
@@ -415,3 +415,32 @@ void from_py_object(object &py_obj, Tango::AttributeConfigList_5 &attr_conf_list
         from_py_object(tmp, attr_conf_list[i]);
     }
 }
+
+void from_py_object(object &py_obj, Tango::PipeConfig &pipe_conf)
+{
+    pipe_conf.name = obj_to_new_char(py_obj.attr("name"));
+    pipe_conf.description = obj_to_new_char(py_obj.attr("description"));
+    pipe_conf.label = obj_to_new_char(py_obj.attr("label"));
+    pipe_conf.level = extract<Tango::DispLevel>(py_obj.attr("level"));
+    pipe_conf.writable = extract<Tango::PipeWriteType>(py_obj.attr("writable"));
+    convert2array(py_obj.attr("extensions"), pipe_conf.extensions);
+}
+
+void from_py_object(object &py_obj, Tango::PipeConfigList &pipe_conf_list)
+{
+    PyObject* py_obj_ptr = py_obj.ptr();
+
+    if (!PySequence_Check(py_obj_ptr))
+    {
+        pipe_conf_list.length(1);
+        from_py_object(py_obj, pipe_conf_list[0]);
+        return;
+    }
+
+    CORBA::ULong size = static_cast<CORBA::ULong>(boost::python::len(py_obj));
+    pipe_conf_list.length(size);
+    for (CORBA::ULong i=0; i < size; ++i) {
+        object tmp = py_obj[i];
+        from_py_object(tmp, pipe_conf_list[i]);
+    }
+}
diff --git a/src/boost/cpp/from_py.h b/src/boost/cpp/from_py.h
index efe33a5..d86cd65 100644
--- a/src/boost/cpp/from_py.h
+++ b/src/boost/cpp/from_py.h
@@ -701,3 +701,6 @@ void from_py_object(bopy::object &, Tango::AttributeConfigList &);
 void from_py_object(bopy::object &, Tango::AttributeConfigList_2 &);
 void from_py_object(bopy::object &, Tango::AttributeConfigList_3 &);
 void from_py_object(bopy::object &, Tango::AttributeConfigList_5 &);
+
+void from_py_object(bopy::object &, Tango::PipeConfig &);
+void from_py_object(bopy::object &, Tango::PipeConfigList &);
diff --git a/src/boost/cpp/pipe_info.cpp b/src/boost/cpp/pipe_info.cpp
new file mode 100644
index 0000000..fb5ab30
--- /dev/null
+++ b/src/boost/cpp/pipe_info.cpp
@@ -0,0 +1,30 @@
+/******************************************************************************
+  This file is part of PyTango (http://www.tinyurl.com/PyTango)
+
+  Copyright 2006-2012 CELLS / ALBA Synchrotron, Bellaterra, Spain
+  Copyright 2013-2014 European Synchrotron Radiation Facility, Grenoble, France
+
+  Distributed under the terms of the GNU Lesser General Public License,
+  either version 3 of the License, or (at your option) any later version.
+  See LICENSE.txt for more info.
+******************************************************************************/
+
+#include "precompiled_header.hpp"
+#include <tango.h>
+
+using namespace boost::python;
+
+void export_pipe_info()
+{
+    class_<Tango::PipeInfo>
+        ("PipeInfo")
+        .def(init<const Tango::PipeInfo&>())
+        .enable_pickling()
+	.def_readwrite("name",  &Tango::PipeInfo::name)
+	.def_readwrite("description",  &Tango::PipeInfo::description)
+	.def_readwrite("label",  &Tango::PipeInfo::label)
+        .def_readwrite("disp_level", &Tango::PipeInfo::disp_level)
+        .def_readwrite("writable", &Tango::PipeInfo::writable)
+        .def_readwrite("extensions", &Tango::PipeInfo::extensions)
+    ;
+}
diff --git a/src/boost/cpp/to_py.cpp b/src/boost/cpp/to_py.cpp
index ea57a03..66eff51 100644
--- a/src/boost/cpp/to_py.cpp
+++ b/src/boost/cpp/to_py.cpp
@@ -257,3 +257,32 @@ boost::python::list to_py(const Tango::AttributeConfigList_5 &attr_conf_list)
     }
     return py_attr_conf_list;
 }
+
+object to_py(const Tango::PipeConfig &pipe_conf, object py_pipe_conf)
+{
+    if(py_pipe_conf.ptr() == Py_None)
+    {
+        PYTANGO_MOD
+        py_pipe_conf = pytango.attr("PipeConfig")();
+    }
+
+    py_pipe_conf.attr("name") = str(pipe_conf.name.in());
+    py_pipe_conf.attr("description") = str(pipe_conf.description.in());
+    py_pipe_conf.attr("label") = str(pipe_conf.label.in());
+    py_pipe_conf.attr("level") = pipe_conf.level;
+    py_pipe_conf.attr("writable") = pipe_conf.writable;
+    py_pipe_conf.attr("extensions") = CORBA_sequence_to_list<Tango::DevVarStringArray>::to_list(pipe_conf.extensions);
+    return py_pipe_conf;
+}
+
+boost::python::list to_py(const Tango::PipeConfigList &pipe_conf_list)
+{
+    boost::python::list py_pipe_conf_list;
+    boost::python::object none;
+    for(unsigned long index = 0; index < pipe_conf_list.length(); ++index)
+    {
+        const Tango::PipeConfig &pipe_conf = pipe_conf_list[index];
+        py_pipe_conf_list.append(to_py(pipe_conf, none));
+    }
+    return py_pipe_conf_list;
+}
diff --git a/src/boost/cpp/to_py.h b/src/boost/cpp/to_py.h
index 0fdd1cb..d04bb63 100644
--- a/src/boost/cpp/to_py.h
+++ b/src/boost/cpp/to_py.h
@@ -361,6 +361,12 @@ boost::python::list to_py(const Tango::AttributeConfigList_2 &);
 boost::python::list to_py(const Tango::AttributeConfigList_3 &);
 boost::python::list to_py(const Tango::AttributeConfigList_5 &);
 
+boost::python::object to_py(const Tango::PipeConfig &,
+                            boost::python::object);
+
+boost::python::object to_py(const Tango::PipeConfigList &,
+                            boost::python::object);
+
 template<class T>
 inline boost::python::object to_py_list(const T *seq)
 {
diff --git a/src/boost/python/device_proxy.py b/src/boost/python/device_proxy.py
index 44f9b51..47103fe 100644
--- a/src/boost/python/device_proxy.py
+++ b/src/boost/python/device_proxy.py
@@ -26,7 +26,7 @@ import collections
 from ._PyTango import StdStringVector, DbData, DbDatum, AttributeInfo, \
     AttributeInfoEx, AttributeInfoList, AttributeInfoListEx, DeviceProxy, \
     __CallBackAutoDie, __CallBackPushEvent, EventType, DevFailed, Except, \
-    ExtractAs, GreenMode
+    ExtractAs, GreenMode, constants
 
 from .utils import is_pure_str, is_non_str_seq, is_integer
 from .utils import seq_2_StdStringVector, StdStringVector_2_seq
@@ -735,6 +735,58 @@ def __DeviceProxy__get_command_config(self, value=(constants.AllCmd,)):
         return self._get_command_config(v)
 
     raise TypeError('value must be a string or a sequence<string>')
+
+def __DeviceProxy__get_pipe_config(self, value=None):
+    """
+    get_pipe_config( self) -> PipeInfoList
+
+            Return the pipe configuration for all pipes.
+
+        Return     : (PipeInfoList) Object containing the pipes
+                     information
+
+        Throws     : ConnectionFailed, CommunicationFailed,
+                     DevFailed from device
+
+    get_pipe_config( self, name) -> PipeInfo
+
+            Return the pipe configuration for a single pipe.
+
+        Parameters :
+                - name : (str) pipe name
+
+        Return     : (PipeInfo) Object containing the pipe
+                     information
+
+        Throws     : ConnectionFailed, CommunicationFailed,
+                     DevFailed from device
+
+    get_pipe_config( self, names) -> PipeInfoList
+
+            Return the pipe configuration for the list of specified pipes. To get all the
+            pipes pass a sequence containing the constant PyTango.constants.AllPipe
+
+        Parameters :
+                - names : (sequence<str>) pipe names
+
+        Return     : (PipeInfoList) Object containing the pipes
+                     information
+
+        Throws     : ConnectionFailed, CommunicationFailed,
+                     DevFailed from device
+
+        New in PyTango 9.0.0
+    """
+    if value is None:
+        value = [constants.AllPipe]
+    if isinstance(value, StdStringVector) or is_pure_str(value):
+        return self._get_pipe_config(value)
+    elif isinstance(value, collections.Sequence):
+        v = seq_2_StdStringVector(value)
+        return self._get_pipe_config(v)
+
+    raise TypeError('value must be a string or a sequence<string>')
+
 def __DeviceProxy__set_attribute_config(self, value):
     """
     set_attribute_config( self, attr_info) -> None
@@ -809,6 +861,51 @@ def __DeviceProxy__set_attribute_config(self, value):
 
     return self._set_attribute_config(v)
 
+def __DeviceProxy__set_pipe_config(self, value):
+    """
+    set_pipe_config( self, pipe_info) -> None
+
+            Change the pipe configuration for the specified pipe
+
+        Parameters :
+                - pipe_info : (PipeInfo) pipe information
+        Return     : None
+
+        Throws     : ConnectionFailed, CommunicationFailed,
+                     DevFailed from device
+
+    set_pipe_config( self, pipe_info) -> None
+
+            Change the pipes configuration for the specified pipes
+
+        Parameters :
+                - pipe_info : (sequence<PipeInfo>) pipes information
+        Return     : None
+
+        Throws     : ConnectionFailed, CommunicationFailed,
+                     DevFailed from device
+    """
+    if isinstance(value, PipeInfo):
+        v = PipeInfoList()
+        v.append(value)
+    elif isinstance(value, PipeInfoList):
+        v = value
+    elif isinstance(value, collections.Sequence):
+        if not len(value):
+            return
+        if isinstance(value[0], PipeInfo):
+            v = PipeInfoList()
+        else:
+            raise TypeError('value must be a PipeInfo or a ' \
+                            'sequence<PipeInfo>')
+        for i in value:
+            v.append(i)
+    else:
+        raise TypeError('value must be a PipeInfo or a ' \
+                        'sequence<PipeInfo>')
+
+    return self._set_pipe_config(v)
+
 def __DeviceProxy__get_event_map_lock(self):
     """
     Internal helper method"""
@@ -1163,6 +1260,10 @@ def __init_DeviceProxy():
     DeviceProxy.set_attribute_config = __DeviceProxy__set_attribute_config
 
     DeviceProxy.get_command_config = __DeviceProxy__get_command_config
+
+    DeviceProxy.get_pipe_config = __DeviceProxy__get_pipe_config
+    DeviceProxy.set_pipe_config = __DeviceProxy__set_pipe_config
+
     DeviceProxy.__get_event_map = __DeviceProxy__get_event_map
     DeviceProxy.__get_event_map_lock = __DeviceProxy__get_event_map_lock
     DeviceProxy.subscribe_event = green(__DeviceProxy__subscribe_event)
diff --git a/src/boost/python/device_server.py b/src/boost/python/device_server.py
index 9178231..4b46e83 100644
--- a/src/boost/python/device_server.py
+++ b/src/boost/python/device_server.py
@@ -177,6 +177,18 @@ class AttributeConfig_5(object):
         self.event_prop = EventProperties()
         self.sys_extensions = []
 
+class PipeConfig(object):
+    """
+    This class represents the python interface for the Tango IDL
+    object PipeConfig."""
+
+    def __init__(self):
+        self.name = ''
+        self.description = ''
+        self.label = ''
+        self.level = PipeWriteType.PIPE_READ
+        self.extensions = []
+
 def __Attribute__get_properties(self, attr_cfg = None):
     """get_properties(self, attr_cfg = None) -> AttributeConfig
 
diff --git a/src/boost/python/pytango_pprint.py b/src/boost/python/pytango_pprint.py
index 1f048af..e3769a5 100644
--- a/src/boost/python/pytango_pprint.py
+++ b/src/boost/python/pytango_pprint.py
@@ -20,11 +20,11 @@ __docformat__ = "restructuredtext"
 import operator
 
 from ._PyTango import (StdStringVector, StdLongVector, CommandInfoList,
-    AttributeInfoList, AttributeInfoListEx,
+    AttributeInfoList, AttributeInfoListEx, PipeInfoList,
     DeviceDataHistoryList,
     GroupReplyList, GroupAttrReplyList, GroupCmdReplyList,
     DbData, DbDevInfos, DbDevExportInfos, DbDevImportInfos, DbHistoryList,
-    LockerInfo, DevCommandInfo, AttributeDimension, CommandInfo,
+    LockerInfo, DevCommandInfo, AttributeDimension, CommandInfo, PipeInfo,
     DeviceInfo, DeviceAttributeConfig, AttributeInfo, AttributeAlarmInfo,
     ChangeEventInfo, PeriodicEventInfo, ArchiveEventInfo,
     AttributeEventInfo, AttributeInfoEx,
@@ -87,7 +87,7 @@ def __registerSeqStr():
     _SeqRepr = lambda self: (self and "[%s]" % (", ".join(map(repr,self)))) or "[]"
 
     seqs = (StdStringVector, StdLongVector, CommandInfoList,
-            AttributeInfoList, AttributeInfoListEx,
+            AttributeInfoList, AttributeInfoListEx, PipeInfoList,
             DeviceDataHistoryList,
             GroupReplyList, GroupAttrReplyList, GroupCmdReplyList,
             DbData, DbDevInfos, DbDevExportInfos, DbDevImportInfos, DbHistoryList)
@@ -118,7 +118,7 @@ def __registerStructStr():
     structs = (LockerInfo, DevCommandInfo, AttributeDimension, CommandInfo,
         DeviceInfo, DeviceAttributeConfig, AttributeInfo, AttributeAlarmInfo,
         ChangeEventInfo, PeriodicEventInfo, ArchiveEventInfo,
-        AttributeEventInfo, AttributeInfoEx,
+        AttributeEventInfo, AttributeInfoEx, PipeInfo,
         DeviceAttribute, DeviceAttributeHistory, DeviceData, DeviceDataHistory,
         DbDatum, DbDevInfo, DbDevImportInfo, DbDevExportInfo, DbServerInfo,
         GroupReply, GroupAttrReply, GroupCmdReply,

-- 
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