py_opcua_module.cpp
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 #include <boost/python.hpp>
00012 //#include <Python.h>
00013 #include <datetime.h>
00014 #include <boost/date_time/posix_time/posix_time_types.hpp>
00015 #include <boost/date_time/gregorian/gregorian.hpp>
00016 #include <boost/date_time/c_local_time_adjustor.hpp>
00017 
00018 #include "opc/ua/client/client.h"
00019 #include "opc/ua/client/binary_client.h"
00020 #include "opc/ua/node.h"
00021 #include "opc/ua/event.h"
00022 #include "opc/ua/server/server.h"
00023 #include "opc/ua/protocol/protocol.h"
00024 #include "opc/ua/services/services.h"
00025 #include "opc/ua/subscription.h"
00026 #include "opc/ua/protocol/string_utils.h"
00027 
00028 #include "py_opcua_enums.h"
00029 #include "py_opcua_helpers.h"
00030 #include "py_opcua_subscriptionclient.h"
00031 #include "py_opcua_variant.h"
00032 
00033 #if PY_MAJOR_VERSION >= 3
00034   #define PyString_Check               PyUnicode_Check
00035   #define PyString_AsString(S)           PyBytes_AsString(PyUnicode_AsUTF8String(S)) 
00036 #endif
00037 
00038 using namespace boost::python;
00039 using namespace OpcUa;
00040 
00041 //--------------------------------------------------------------------------
00042 // Overloads
00043 //--------------------------------------------------------------------------
00044 
00045 BOOST_PYTHON_FUNCTION_OVERLOADS(DateTimeFromTimeT_stub, DateTime::FromTimeT, 1, 2);
00046 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(SubscriptionSubscribeDataChange_stubs, Subscription::SubscribeDataChange, 1, 2);
00047 //BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(NodeGetBrowseName_stubs, Node::GetBrowseName, 0, 1);
00048 
00049 
00050 //--------------------------------------------------------------------------
00051 // DateTime helpers
00052 //--------------------------------------------------------------------------
00053 
00054 static  boost::python::object ToPyDateTime(const DateTime& self )
00055 {
00056   boost::posix_time::ptime ref(boost::gregorian::date(1601,1,1));
00057   boost::posix_time::ptime dt = ref + boost::posix_time::microseconds(self.Value/10);
00058   // The constructor of the python datetime objects creates a datetime object using the locale timezone
00059   // but returns a naive timezone objects...this sounds a bit crazy...
00060   // we may want to add timezone... I do not know how
00061   uint32_t precision = dt.time_of_day().num_fractional_digits();
00062   PyObject* obj = PyDateTime_FromDateAndTime((int)dt.date().year(),
00063                                           (int)dt.date().month(),
00064                                           (int)dt.date().day(),
00065                                           dt.time_of_day().hours(),
00066                                           dt.time_of_day().minutes(),
00067                                           dt.time_of_day().seconds(),
00068                                           dt.time_of_day().fractional_seconds() / pow(10, precision-6));
00069   return boost::python::object(boost::python::handle<>(obj));
00070 }
00071 
00072 static uint64_t ToWinEpoch(PyObject* pydate)
00073 {
00074   boost::gregorian::date _date(PyDateTime_GET_YEAR(pydate), PyDateTime_GET_MONTH(pydate), PyDateTime_GET_DAY(pydate));
00075   boost::posix_time::time_duration _duration(PyDateTime_DATE_GET_HOUR(pydate), PyDateTime_DATE_GET_MINUTE(pydate), PyDateTime_DATE_GET_SECOND(pydate), 0);
00076   _duration += boost::posix_time::microseconds(PyDateTime_DATE_GET_MICROSECOND(pydate));
00077 
00078         boost::posix_time::ptime myptime(_date, _duration);
00079   boost::posix_time::ptime ref(boost::gregorian::date(1601,1,1));
00080   return (myptime - ref).total_microseconds() * 10;
00081 }
00082 
00083 static boost::shared_ptr<DateTime> makeOpcUaDateTime(const boost::python::object& bobj)
00084 {
00085   PyObject* pydate = bobj.ptr();
00086   if ( ! PyDateTime_Check(pydate) )
00087   {
00088     throw std::runtime_error("method take a python datetime as argument");
00089   }
00090 
00091   return boost::shared_ptr<DateTime>(new DateTime(ToWinEpoch(pydate)));
00092 }
00093 
00094 struct DateTimeOpcUaToPythonConverter
00095 {
00096   static PyObject* convert(const DateTime& dt)
00097   {
00098     return boost::python::incref( ToPyDateTime(dt).ptr());
00099   }
00100 };
00101 
00102 struct DateTimePythonToOpcUaConverter
00103 {
00104 
00105   DateTimePythonToOpcUaConverter()
00106   {
00107     boost::python::converter::registry::push_back(&convertible, &construct, boost::python::type_id<DateTime>());
00108   }
00109 
00110   static void* convertible(PyObject* obj_ptr)
00111   {
00112     if (!PyDateTime_Check(obj_ptr)) return 0;
00113     return obj_ptr;
00114   }
00115 
00116   static void construct( PyObject* obj_ptr, boost::python::converter::rvalue_from_python_stage1_data* data)
00117   {
00118       void* storage = (
00119         (boost::python::converter::rvalue_from_python_storage<DateTime>*)
00120         data)->storage.bytes;
00121  
00122       new (storage) DateTime(ToWinEpoch(obj_ptr));
00123  
00124       data->convertible = storage;
00125   }
00126 };
00127 
00128 //--------------------------------------------------------------------------
00129 //LocalizedText
00130 //--------------------------------------------------------------------------
00131 
00132 struct LocalizedTextToPythonConverter
00133 {
00134   static PyObject* convert(const LocalizedText& text)
00135   {
00136     return boost::python::incref(boost::python::object(text.Text.c_str()).ptr());
00137   }
00138 };
00139 
00140 struct PythonStringToLocalizedTextConverter
00141 {
00142 
00143   PythonStringToLocalizedTextConverter()
00144   {
00145     boost::python::converter::registry::push_back(&convertible, &construct, boost::python::type_id<LocalizedText>());
00146   }
00147 
00148   static void* convertible(PyObject* obj_ptr)
00149   {
00150     if (!PyString_Check(obj_ptr)) return 0;
00151     return obj_ptr;
00152   }
00153 
00154   static void construct( PyObject* obj_ptr, boost::python::converter::rvalue_from_python_stage1_data* data)
00155   {
00156       void* storage = ( (boost::python::converter::rvalue_from_python_storage<LocalizedText>*)data)->storage.bytes;
00157       const char* value = PyString_AsString(obj_ptr);
00158       new (storage) LocalizedText(std::string(value));
00159       data->convertible = storage;
00160   }
00161 };
00162 
00163 
00164 //--------------------------------------------------------------------------
00165 // NodeId helpers
00166 //--------------------------------------------------------------------------
00167 
00168 static boost::shared_ptr<NodeId> NodeId_constructor(const std::string & encodedNodeId)
00169 { return boost::shared_ptr<NodeId>(new NodeId(ToNodeId(encodedNodeId))); }
00170 
00171 static object NodeId_GetIdentifier(const NodeId & self)
00172 {
00173   if (self.IsInteger())
00174     { return object(self.GetIntegerIdentifier()); }
00175 
00176   else if (self.IsString())
00177     { return object(self.GetStringIdentifier()); }
00178 
00179   else if (self.IsGuid())
00180     { return object(self.GetGuidIdentifier()); }
00181 
00182   else if (self.IsBinary())
00183     { return object(self.GetBinaryIdentifier()); }
00184 
00185   else
00186     { throw std::logic_error("Error unknown identifier."); }
00187 }
00188 
00189 //--------------------------------------------------------------------------
00190 // DataValue helpers
00191 //--------------------------------------------------------------------------
00192 
00193 static boost::shared_ptr<DataValue> DataValue_constructor1(const object & obj, VariantType vtype)
00194 { return boost::shared_ptr<DataValue>(new DataValue(ToVariant2(obj, vtype))); }
00195 
00196 static object DataValue_get_value(const DataValue & self)
00197 { return ToObject(self.Value); }
00198 
00199 static void DataValue_set_value(DataValue & self, const object & obj, VariantType vtype)
00200 { self.Value = ToVariant2(obj, vtype); self.Encoding |= DATA_VALUE; }
00201 
00202 static StatusCode DataValue_get_status(const DataValue & self)
00203 { return self.Status; }
00204 
00205 static void DataValue_set_status(DataValue & self, const StatusCode & sc)
00206 { self.Status = sc; self.Encoding |= DATA_VALUE_STATUS_CODE; }
00207 
00208 static DateTime DataValue_get_source_timestamp(const DataValue & self)
00209 { return self.SourceTimestamp; }
00210 
00211 static void DataValue_set_source_timestamp(DataValue & self, const DateTime & dt)
00212 { self.SourceTimestamp = dt; self.Encoding |= DATA_VALUE_SOURCE_TIMESTAMP; }
00213 
00214 static uint16_t DataValue_get_source_picoseconds(const DataValue & self)
00215 { return self.SourcePicoseconds; }
00216 
00217 static void DataValue_set_source_picoseconds(DataValue & self, uint16_t ps)
00218 { self.SourcePicoseconds = ps; self.Encoding |= DATA_VALUE_SOURCE_PICOSECONDS; }
00219 
00220 static DateTime DataValue_get_server_timestamp(const DataValue & self)
00221 { return self.ServerTimestamp; }
00222 
00223 static void DataValue_set_server_timestamp(DataValue & self, const DateTime & dt)
00224 { self.ServerTimestamp = dt; self.Encoding |= DATA_VALUE_Server_TIMESTAMP; }
00225 
00226 static uint16_t DataValue_get_server_picoseconds(const DataValue & self)
00227 { return self.ServerPicoseconds; }
00228 
00229 static void DataValue_set_server_picoseconds(DataValue & self, uint16_t ps)
00230 { self.ServerPicoseconds = ps; self.Encoding |= DATA_VALUE_Server_PICOSECONDS; }
00231 
00232 //--------------------------------------------------------------------------
00233 // Node helpers
00234 //--------------------------------------------------------------------------
00235 //
00236 
00237 static void Node_SetValue(Node & self, const object & obj, VariantType vtype)
00238 { self.SetValue(ToVariant2(obj, vtype)); }
00239 
00240 //--------------------------------------------------------------------------
00241 // UaClient helpers
00242 //--------------------------------------------------------------------------
00243 
00244 static boost::shared_ptr<Subscription> UaClient_CreateSubscription(UaClient & self, uint period, PySubscriptionHandler & callback)
00245 {
00246   std::unique_ptr<Subscription> sub  = self.CreateSubscription(period, callback);
00247   return boost::shared_ptr<Subscription>(sub.release());
00248 }
00249 
00250 static Node UaClient_GetNode(UaClient & self, ObjectId objectid)
00251 {
00252   return self.GetNode(NodeId(objectid));
00253 }
00254 
00255 //--------------------------------------------------------------------------
00256 // UaServer helpers
00257 //--------------------------------------------------------------------------
00258 
00259 static boost::shared_ptr<Subscription> UaServer_CreateSubscription(UaServer & self, uint period, PySubscriptionHandler & callback)
00260 {
00261   std::unique_ptr<Subscription> sub  = self.CreateSubscription(period, callback);
00262   return boost::shared_ptr<Subscription>(sub.release());
00263 }
00264 
00265 static Node UaServer_GetNode(UaServer & self, ObjectId objectid)
00266 {
00267   return self.GetNode(NodeId(objectid));
00268 }
00269 
00270 
00271 //--------------------------------------------------------------------------
00272 // module
00273 //--------------------------------------------------------------------------
00274 
00275 BOOST_PYTHON_MODULE(opcua)
00276 {
00277   PyDateTime_IMPORT; 
00278 
00279   using self_ns::str; // hack to enable __str__ in python classes with str(self)
00280 
00281   PyEval_InitThreads();
00282 
00283   py_opcua_enums();
00284 
00285   DateTimePythonToOpcUaConverter(); 
00286   PythonStringToLocalizedTextConverter(); 
00287   to_python_converter<LocalizedText, LocalizedTextToPythonConverter>(); 
00288   // Enable next line to return PyDateTime instead og DateTime in python
00289   //to_python_converter<DateTime, DateTimeOpcUaToPythonConverter>(); 
00290 
00291 
00292 
00293   to_python_converter<std::vector<std::string>, vector_to_python_converter<std::string>>();
00294   vector_from_python_converter<std::string>();
00295 
00296   variant_from_python_converter();
00297   to_python_converter<Variant, variant_to_python_converter>();
00298 
00299   class_<DateTime>("DateTime", init<>())
00300   .def(init<int64_t>())
00301   .def("now", &DateTime::DateTime::Current)
00302   .def("__init__", make_constructor(makeOpcUaDateTime))
00303   .def("from_time_t", &DateTime::FromTimeT, DateTimeFromTimeT_stub((arg("sec"), arg("usec")=0)))
00304   .staticmethod("from_time_t")
00305   .def("to_datetime", &ToPyDateTime)
00306   .def("to_time_t", &DateTime::ToTimeT)
00307   .def_readwrite("value", &DateTime::Value)
00308   ;
00309 
00310   //class_<LocalizedText>("LocalizedText")
00311   //.def_readwrite("Encoding", &LocalizedText::Encoding)
00312   //.def_readwrite("Locale", &LocalizedText::Locale)
00313   //.def_readwrite("Text", &LocalizedText::Text)
00314   //;
00315 
00316   
00317   class_<NodeId, boost::shared_ptr<NodeId>>("NodeId")
00318   .def(init<uint32_t, uint16_t>())
00319   .def(init<std::string, uint16_t>())
00320   .def("__init__", make_constructor(NodeId_constructor)) // XXX add this constructor to freeopcua
00321   .add_property("namespace_index", &NodeId::GetNamespaceIndex)
00322   .add_property("identifier", &NodeId_GetIdentifier)
00323   .add_property("encoding", &NodeId::GetEncodingValue)
00324   .add_property("is_integer", &NodeId::IsInteger)
00325   .add_property("is_binary", &NodeId::IsBinary)
00326   .add_property("is_guid", &NodeId::IsGuid)
00327   .add_property("is_string", &NodeId::IsString)
00328   .def_readonly("namespace_uri", &NodeId::NamespaceURI)
00329   .def(str(self))
00330   .def(repr(self))
00331   .def(self == self)
00332   ;
00333 
00334   to_python_converter<std::vector<QualifiedName>, vector_to_python_converter<QualifiedName>>();
00335   to_python_converter<std::vector<std::vector<QualifiedName>>, vector_to_python_converter<std::vector<QualifiedName>>>();
00336   class_<QualifiedName>("QualifiedName")
00337   .def(init<uint16_t, std::string>())
00338   .def(init<std::string, uint16_t>()) // XXX A.D.D, right
00339   //.def("parse", &ToQualifiedName)      XXX def()
00340   .def_readwrite("namespace_index", &QualifiedName::NamespaceIndex)
00341   .def_readwrite("name", &QualifiedName::Name)
00342   .def(str(self))
00343   .def(repr(self))
00344   .def(self == self)
00345   ;
00346 
00347   class_<DataValue, boost::shared_ptr<DataValue>>("DataValue")
00348   .def(init<const Variant &>())
00349   .def("__init__", make_constructor(DataValue_constructor1))  // Variant, VariantType
00350 #define _property(X) add_property( #X, &DataValue_get_ ## X, &DataValue_set_ ## X)
00351   ._property(value)
00352   ._property(status)
00353   ._property(source_timestamp)
00354   ._property(source_picoseconds)
00355   ._property(server_timestamp)
00356   ._property(server_picoseconds)
00357 #undef _property
00358   ;
00359 
00360   to_python_converter<std::vector<DataValue>, vector_to_python_converter<DataValue>>();
00361 
00362   class_<ApplicationDescription>("ApplicationDescription")
00363   .def_readwrite("uri", &ApplicationDescription::ApplicationUri)
00364   .def_readwrite("product_uri", &ApplicationDescription::ProductUri)
00365   .def_readwrite("name", &ApplicationDescription::ApplicationName)
00366   .def_readwrite("type", &ApplicationDescription::ApplicationType)
00367   .def_readwrite("gateway_server_uri", &ApplicationDescription::GatewayServerUri)
00368   .def_readwrite("discovery_profile_uri", &ApplicationDescription::DiscoveryProfileUri)
00369   .def_readwrite_vector("discovery_urls", &ApplicationDescription::DiscoveryUrls)
00370   ;
00371 
00372   to_python_converter<std::vector<ApplicationDescription>, vector_to_python_converter<ApplicationDescription>>();
00373 
00374   class_<UserTokenPolicy>("UserTokenPolicy")
00375   .def_readwrite("policy_id", &UserTokenPolicy::PolicyId)
00376   .def_readwrite("token_type", &UserTokenPolicy::TokenType)
00377   .def_readwrite("issued_token_type", &UserTokenPolicy::IssuedTokenType)
00378   .def_readwrite("issuer_endpoint_url", &UserTokenPolicy::IssuerEndpointUrl)
00379   .def_readwrite("security_policy_uri", &UserTokenPolicy::SecurityPolicyUri)
00380   ;
00381 
00382   to_python_converter<std::vector<UserTokenPolicy>, vector_to_python_converter<UserTokenPolicy>>();
00383   vector_from_python_converter<UserTokenPolicy>();
00384 
00385   class_<EndpointDescription>("EndpointDescription")
00386   .def_readwrite("url", &EndpointDescription::EndpointUrl)
00387   .def_readwrite("server_description", &EndpointDescription::Server)
00388   .def_readwrite("security_mode", &EndpointDescription::SecurityMode)
00389   .def_readwrite("security_policy_uri", &EndpointDescription::SecurityPolicyUri)
00390   .def_readwrite_vector("user_identify_tokens", &EndpointDescription::UserIdentityTokens)
00391   .def_readwrite("transport_profile_uri", &EndpointDescription::TransportProfileUri)
00392   .def_readwrite("security_level", &EndpointDescription::SecurityLevel)
00393   ;
00394 
00395   to_python_converter<std::vector<EndpointDescription>, vector_to_python_converter<EndpointDescription>>();
00396 
00397   class_<ReferenceDescription>("ReferenceDescription")
00398   .def_readwrite("reference_type_id", &ReferenceDescription::ReferenceTypeId)
00399   .def_readwrite("is_forward", &ReferenceDescription::IsForward)
00400   .def_readwrite("target_node_id", &ReferenceDescription::TargetNodeId)
00401   .def_readwrite("browse_name", &ReferenceDescription::BrowseName)
00402   .def_readwrite("display_name", &ReferenceDescription::DisplayName)
00403   .def_readwrite("target_node_class", &ReferenceDescription::TargetNodeClass)
00404   .def_readwrite("target_node_type_definition", &ReferenceDescription::TargetNodeTypeDefinition)
00405   ;
00406 
00407   to_python_converter<std::vector<ReferenceDescription>, vector_to_python_converter<ReferenceDescription>>();
00408 
00409   class_<ReadValueId>("ReadValueId")
00410   .def_readwrite("node_id", &ReadValueId::NodeId)
00411   .def_readwrite("attribute_id", &ReadValueId::AttributeId)
00412   .def_readwrite("index_range", &ReadValueId::IndexRange)
00413   .def_readwrite("data_encoding", &ReadValueId::DataEncoding)
00414   ;
00415 
00416   to_python_converter<std::vector<ReadValueId>, vector_to_python_converter<ReadValueId>>();
00417 
00418   class_<WriteValue>("WriteValue")
00419   .def_readwrite("node_id", &WriteValue::NodeId)
00420   .def_readwrite("attribute_id", &WriteValue::AttributeId)
00421   .def_readwrite("index_range", &WriteValue::IndexRange)
00422   .def_readwrite("value", &WriteValue::Value)
00423   ;
00424 
00425   to_python_converter<std::vector<WriteValue>, vector_to_python_converter<WriteValue>>();
00426   vector_from_python_converter<WriteValue>();
00427 
00428 //  XXX
00429 //  class_<Variant>("Variant")
00430 //  .def("value", &VariantValue)
00431 //  .def("type", &Variant::Type)
00432 //  .def("is_array", &Variant::IsArray)
00433 //  .def("is_scalar", &Variant::IsScalar)
00434 //  .def("is_null", &Variant::IsNul)
00435 //  ;
00436 
00437   class_<Node>("Node", init<Services::SharedPtr, NodeId>())
00438   .def(init<Node>())
00439   .def("get_id", &Node::GetId)
00440   .def("get_attribute", &Node::GetAttribute)
00441   .def("set_attribute", &Node::SetAttribute)
00442   .def("get_value", &Node::GetValue)
00443   .def("set_value", (void(Node::*)(const DataValue &) const) &Node::SetValue)
00444   .def("set_value", (void(Node::*)(const Variant &) const) &Node::SetValue)
00445   .def("set_value", &Node_SetValue)
00446   .def("get_properties", &Node::GetProperties)
00447   .def("get_variables", &Node::GetVariables)
00448   .def("get_browse_name", &Node::GetBrowseName)
00449   .def("get_children", (std::vector<Node> (Node::*)() const) &Node::GetChildren)
00450   .def("get_child", (Node(Node::*)(const std::vector<std::string> &) const) &Node::GetChild)
00451   .def("get_child", (Node(Node::*)(const std::string &) const) &Node::GetChild)
00452   .def("add_folder", (Node(Node::*)(const NodeId &, const QualifiedName &) const) &Node::AddFolder)
00453   .def("add_folder", (Node(Node::*)(const std::string &, const std::string &) const) &Node::AddFolder)
00454   .def("add_folder", (Node(Node::*)(uint32_t, const std::string &) const) &Node::AddFolder)
00455   .def("add_object", (Node(Node::*)(const NodeId &, const QualifiedName &) const) &Node::AddObject)
00456   .def("add_object", (Node(Node::*)(const std::string &, const std::string &) const) &Node::AddObject)
00457   .def("add_object", (Node(Node::*)(uint32_t, const std::string &) const) &Node::AddObject)
00458   .def("add_variable", (Node(Node::*)(const NodeId &, const QualifiedName &, const Variant &) const) &Node::AddVariable)
00459   .def("add_variable", (Node(Node::*)(const std::string &, const std::string &, const Variant &) const) &Node::AddVariable)
00460   .def("add_variable", (Node(Node::*)(uint32_t, const std::string &, const Variant &) const) &Node::AddVariable)
00461   .def("add_property", (Node(Node::*)(const NodeId &, const QualifiedName &, const Variant &) const) &Node::AddProperty)
00462   .def("add_property", (Node(Node::*)(const std::string &, const std::string &, const Variant &) const) &Node::AddProperty)
00463   .def("add_property", (Node(Node::*)(uint32_t, const std::string &, const Variant &) const) &Node::AddProperty)
00464   .def(str(self))
00465   .def(repr(self))
00466   .def(self == self)
00467   ;
00468 
00469   to_python_converter<std::vector<Node>, vector_to_python_converter<Node>>();
00470   vector_from_python_converter<Node>();
00471   
00472   class_<SubscriptionHandler, PySubscriptionHandler, boost::noncopyable>("SubscriptionHandler", init<>())
00473   .def("data_change", &PySubscriptionHandler::DefaultDataChange)
00474   .staticmethod("data_change")
00475   .def("event", &PySubscriptionHandler::DefaultEvent)
00476   .staticmethod("event")
00477   .def("status_change", &PySubscriptionHandler::DefaultStatusChange)
00478   .staticmethod("status_change")
00479   ;
00480 
00481   class_<Event>("Event", init<const NodeId &>())
00482   .def(init<>())
00483   .def("get_value", (Variant(Event::*)(const std::string &) const) &Event::GetValue)
00484   .def("set_value", (void (Event::*)(const std::string &, Variant)) &Event::SetValue)
00485   .def("get_value_keys", &Event::GetValueKeys)
00486   .def_readwrite("event_id", &Event::EventId)
00487   .def_readwrite("event_type", &Event::EventType)
00488   .def_readwrite("local_time", &Event::LocalTime)
00489   .add_property("message", make_getter(&Event::Message, return_value_policy<return_by_value>()), make_setter(&Event::Message, return_value_policy<return_by_value>()))
00490   .def_readwrite("receive_time", &Event::ReceiveTime)
00491   .def_readwrite("severity", &Event::Severity)
00492   .def_readwrite("source_name", &Event::SourceName)
00493   .def_readwrite("source_node", &Event::SourceNode)
00494   .def_readwrite("time", &Event::Time)
00495   .def(str(self))
00496   .def(repr(self))
00497   ;
00498 
00499   class_<Subscription, boost::shared_ptr<Subscription>, boost::noncopyable>("Subscription", no_init)
00500   .def("subscribe_data_change", (uint32_t (Subscription::*)(const Node &, AttributeId)) &Subscription::SubscribeDataChange, SubscriptionSubscribeDataChange_stubs((arg("node"), arg("attr") = AttributeId::Value)))
00501   .def("delete", &Subscription::Delete)
00502   .def("unsubscribe", (void (Subscription::*)(uint32_t)) &Subscription::UnSubscribe)
00503   .def("subscribe_events", (uint32_t (Subscription::*)()) &Subscription::SubscribeEvents)
00504   .def("subscribe_events", (uint32_t (Subscription::*)(const Node &, const Node &)) &Subscription::SubscribeEvents)
00505   //.def(str(self))
00506   //.def(repr(self))
00507   ;
00508 
00509   class_<UaClient, boost::noncopyable>("Client", init<>())
00510   .def(init<bool>())
00511   .def("connect", (void (UaClient::*)(const std::string&)) &UaClient::Connect)
00512   .def("connect", (void (UaClient::*)(const EndpointDescription&)) &UaClient::Connect)
00513   .def("disconnect", &UaClient::Disconnect)
00514   .def("get_namespace_index", &UaClient::GetNamespaceIndex)
00515   .def("get_root_node", &UaClient::GetRootNode)
00516   .def("get_objects_node", &UaClient::GetObjectsNode)
00517   .def("get_server_node", &UaClient::GetServerNode)
00518   .def("get_node", (Node(UaClient::*)(const std::string&) const) &UaClient::GetNode)
00519   .def("get_node", (Node(UaClient::*)(const NodeId&) const) &UaClient::GetNode)
00520   .def("get_node", &UaClient_GetNode)
00521   .def("get_endpoint", &UaClient::GetEndpoint)
00522   .def("get_server_endpoints", (std::vector<EndpointDescription> (UaClient::*)(const std::string&)) &UaClient::GetServerEndpoints)
00523   .def("get_server_endpoints", (std::vector<EndpointDescription> (UaClient::*)()) &UaClient::GetServerEndpoints)
00524   .def("set_session_name", &UaClient::SetSessionName)
00525   .def("get_session_name", &UaClient::GetSessionName)
00526   .def("get_application_uri", &UaClient::GetApplicationURI)
00527   .def("set_application_uri", &UaClient::SetApplicationURI)
00528   .def("set_security_policy", &UaClient::SetSecurityPolicy)
00529   .def("get_security_policy", &UaClient::GetSecurityPolicy)
00530   .def("create_subscription", &UaClient_CreateSubscription)
00531   //.def(str(self))
00532   //.def(repr(self))
00533   ;
00534 
00535   class_<UaServer, boost::noncopyable >("Server", init<>())
00536   .def(init<bool>())
00537   .def("start", &UaServer::Start)
00538   .def("stop", &UaServer::Stop)
00539   .def("register_namespace", &UaServer::RegisterNamespace)
00540   .def("get_namespace_index", &UaServer::GetNamespaceIndex)
00541   .def("get_root_node", &UaServer::GetRootNode)
00542   .def("get_objects_node", &UaServer::GetObjectsNode)
00543   .def("get_server_node", &UaServer::GetServerNode)
00544   .def("get_node", (Node(UaServer::*)(const std::string&) const) &UaServer::GetNode)
00545   .def("get_node", (Node(UaServer::*)(const NodeId&) const) &UaServer::GetNode)
00546   .def("get_node", &UaServer_GetNode)
00547   .def("set_uri", &UaServer::SetServerURI)
00548   .def("add_xml_address_space", &UaServer::AddAddressSpace)
00549   .def("set_server_name", &UaServer::SetServerName)
00550   .def("set_endpoint", &UaServer::SetEndpoint)
00551   .def("create_subscription", &UaServer_CreateSubscription)
00552   .def("trigger_event", &UaServer::TriggerEvent)
00553   //.def(str(self))
00554   //.def(repr(self))
00555   ;
00556 
00557 }
00558 


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Sat Jun 8 2019 18:24:56