py_opcua_module.cpp
Go to the documentation of this file.
1 
11 #include <boost/python.hpp>
12 //#include <Python.h>
13 #include <datetime.h>
14 #include <boost/date_time/posix_time/posix_time_types.hpp>
15 #include <boost/date_time/gregorian/gregorian.hpp>
16 #include <boost/date_time/c_local_time_adjustor.hpp>
17 
18 #include "opc/ua/client/client.h"
20 #include "opc/ua/node.h"
21 #include "opc/ua/event.h"
22 #include "opc/ua/server/server.h"
25 #include "opc/ua/subscription.h"
27 
28 #include "py_opcua_enums.h"
29 #include "py_opcua_helpers.h"
31 #include "py_opcua_variant.h"
32 
33 #if PY_MAJOR_VERSION >= 3
34 #define PyString_Check PyUnicode_Check
35 #define PyString_AsString(S) PyBytes_AsString(PyUnicode_AsUTF8String(S))
36 #endif
37 
38 using namespace boost::python;
39 using namespace OpcUa;
40 
41 //--------------------------------------------------------------------------
42 // Overloads
43 //--------------------------------------------------------------------------
44 
45 BOOST_PYTHON_FUNCTION_OVERLOADS(DateTimeFromTimeT_stub, DateTime::FromTimeT, 1, 2);
46 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(SubscriptionSubscribeDataChange_stubs, Subscription::SubscribeDataChange, 1, 2);
47 //BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(NodeGetBrowseName_stubs, Node::GetBrowseName, 0, 1);
48 
49 
50 //--------------------------------------------------------------------------
51 // DateTime helpers
52 //--------------------------------------------------------------------------
53 
54 static boost::python::object ToPyDateTime(const DateTime & self)
55 {
56  boost::posix_time::ptime ref(boost::gregorian::date(1601, 1, 1));
57  boost::posix_time::ptime dt = ref + boost::posix_time::microseconds(self.Value / 10);
58  // The constructor of the python datetime objects creates a datetime object using the locale timezone
59  // but returns a naive timezone objects...this sounds a bit crazy...
60  // we may want to add timezone... I do not know how
61  uint32_t precision = dt.time_of_day().num_fractional_digits();
62  PyObject * obj = PyDateTime_FromDateAndTime((int)dt.date().year(),
63  (int)dt.date().month(),
64  (int)dt.date().day(),
65  dt.time_of_day().hours(),
66  dt.time_of_day().minutes(),
67  dt.time_of_day().seconds(),
68  dt.time_of_day().fractional_seconds() / pow(10, precision - 6));
69  return boost::python::object(boost::python::handle<>(obj));
70 }
71 
72 static uint64_t ToWinEpoch(PyObject * pydate)
73 {
74  boost::gregorian::date _date(PyDateTime_GET_YEAR(pydate), PyDateTime_GET_MONTH(pydate), PyDateTime_GET_DAY(pydate));
75  boost::posix_time::time_duration _duration(PyDateTime_DATE_GET_HOUR(pydate), PyDateTime_DATE_GET_MINUTE(pydate), PyDateTime_DATE_GET_SECOND(pydate), 0);
76  _duration += boost::posix_time::microseconds(PyDateTime_DATE_GET_MICROSECOND(pydate));
77 
78  boost::posix_time::ptime myptime(_date, _duration);
79  boost::posix_time::ptime ref(boost::gregorian::date(1601, 1, 1));
80  return (myptime - ref).total_microseconds() * 10;
81 }
82 
83 static std::shared_ptr<DateTime> makeOpcUaDateTime(const boost::python::object & bobj)
84 {
85  PyObject * pydate = bobj.ptr();
86 
87  if (! PyDateTime_Check(pydate))
88  {
89  throw std::runtime_error("method take a python datetime as argument");
90  }
91 
92  return std::shared_ptr<DateTime>(new DateTime(ToWinEpoch(pydate)));
93 }
94 
96 {
97  static PyObject * convert(const DateTime & dt)
98  {
99  return boost::python::incref(ToPyDateTime(dt).ptr());
100  }
101 };
102 
104 {
105 
107  {
108  boost::python::converter::registry::push_back(&convertible, &construct, boost::python::type_id<DateTime>());
109  }
110 
111  static void * convertible(PyObject * obj_ptr)
112  {
113  if (!PyDateTime_Check(obj_ptr)) { return 0; }
114 
115  return obj_ptr;
116  }
117 
118  static void construct(PyObject * obj_ptr, boost::python::converter::rvalue_from_python_stage1_data * data)
119  {
120  void * storage = ((boost::python::converter::rvalue_from_python_storage<DateTime> *)data)->storage.bytes;
121 
122  new(storage) DateTime(ToWinEpoch(obj_ptr));
123 
124  data->convertible = storage;
125  }
126 };
127 
128 //--------------------------------------------------------------------------
129 //LocalizedText
130 //--------------------------------------------------------------------------
131 
133 {
134  static PyObject * convert(const LocalizedText & text)
135  {
136  return boost::python::incref(boost::python::object(text.Text.c_str()).ptr());
137  }
138 };
139 
141 {
142 
144  {
145  boost::python::converter::registry::push_back(&convertible, &construct, boost::python::type_id<LocalizedText>());
146  }
147 
148  static void * convertible(PyObject * obj_ptr)
149  {
150  if (!PyString_Check(obj_ptr)) { return 0; }
151 
152  return obj_ptr;
153  }
154 
155  static void construct(PyObject * obj_ptr, boost::python::converter::rvalue_from_python_stage1_data * data)
156  {
157  void * storage = ((boost::python::converter::rvalue_from_python_storage<LocalizedText> *)data)->storage.bytes;
158  const char * value = PyString_AsString(obj_ptr);
159  new(storage) LocalizedText(std::string(value));
160  data->convertible = storage;
161  }
162 };
163 
164 
165 //--------------------------------------------------------------------------
166 // NodeId helpers
167 //--------------------------------------------------------------------------
168 
169 static std::shared_ptr<NodeId> NodeId_constructor(const std::string & encodedNodeId)
170 { return std::shared_ptr<NodeId>(new NodeId(ToNodeId(encodedNodeId))); }
171 
172 static object NodeId_GetIdentifier(const NodeId & self)
173 {
174  if (self.IsInteger())
175  { return object(self.GetIntegerIdentifier()); }
176 
177  else if (self.IsString())
178  { return object(self.GetStringIdentifier()); }
179 
180  else if (self.IsGuid())
181  { return object(self.GetGuidIdentifier()); }
182 
183  else if (self.IsBinary())
184  { return object(self.GetBinaryIdentifier()); }
185 
186  else
187  { throw std::logic_error("Error unknown identifier."); }
188 }
189 
190 //--------------------------------------------------------------------------
191 // DataValue helpers
192 //--------------------------------------------------------------------------
193 
194 static std::shared_ptr<DataValue> DataValue_constructor1(const object & obj, VariantType vtype)
195 { return std::shared_ptr<DataValue>(new DataValue(ToVariant2(obj, vtype))); }
196 
197 static object DataValue_get_value(const DataValue & self)
198 { return ToObject(self.Value); }
199 
200 static void DataValue_set_value(DataValue & self, const object & obj, VariantType vtype)
201 { self.Value = ToVariant2(obj, vtype); self.Encoding |= DATA_VALUE; }
202 
204 { return self.Status; }
205 
206 static void DataValue_set_status(DataValue & self, const StatusCode & sc)
207 { self.Status = sc; self.Encoding |= DATA_VALUE_STATUS_CODE; }
208 
210 { return self.SourceTimestamp; }
211 
212 static void DataValue_set_source_timestamp(DataValue & self, const DateTime & dt)
213 { self.SourceTimestamp = dt; self.Encoding |= DATA_VALUE_SOURCE_TIMESTAMP; }
214 
215 static uint16_t DataValue_get_source_picoseconds(const DataValue & self)
216 { return self.SourcePicoseconds; }
217 
218 static void DataValue_set_source_picoseconds(DataValue & self, uint16_t ps)
219 { self.SourcePicoseconds = ps; self.Encoding |= DATA_VALUE_SOURCE_PICOSECONDS; }
220 
222 { return self.ServerTimestamp; }
223 
224 static void DataValue_set_server_timestamp(DataValue & self, const DateTime & dt)
225 { self.ServerTimestamp = dt; self.Encoding |= DATA_VALUE_Server_TIMESTAMP; }
226 
227 static uint16_t DataValue_get_server_picoseconds(const DataValue & self)
228 { return self.ServerPicoseconds; }
229 
230 static void DataValue_set_server_picoseconds(DataValue & self, uint16_t ps)
231 { self.ServerPicoseconds = ps; self.Encoding |= DATA_VALUE_Server_PICOSECONDS; }
232 
233 //--------------------------------------------------------------------------
234 // Node helpers
235 //--------------------------------------------------------------------------
236 //
237 
238 static void Node_SetValue(Node & self, const object & obj, VariantType vtype)
239 { self.SetValue(ToVariant2(obj, vtype)); }
240 
241 //--------------------------------------------------------------------------
242 // UaClient helpers
243 //--------------------------------------------------------------------------
244 
245 static std::shared_ptr<Subscription> UaClient_CreateSubscription(UaClient & self, uint period, PySubscriptionHandler & callback)
246 {
247  return self.CreateSubscription(period, callback);
248 }
249 
250 static Node UaClient_GetNode(UaClient & self, ObjectId objectid)
251 {
252  return self.GetNode(NodeId(objectid));
253 }
254 
255 //--------------------------------------------------------------------------
256 // UaServer helpers
257 //--------------------------------------------------------------------------
258 
259 static std::shared_ptr<Subscription> UaServer_CreateSubscription(UaServer & self, uint period, PySubscriptionHandler & callback)
260 {
261  return self.CreateSubscription(period, callback);
262 }
263 
264 static Node UaServer_GetNode(UaServer & self, ObjectId objectid)
265 {
266  return self.GetNode(NodeId(objectid));
267 }
268 
269 
270 //--------------------------------------------------------------------------
271 // module
272 //--------------------------------------------------------------------------
273 
275 {
276  PyDateTime_IMPORT;
277 
278  using self_ns::str; // hack to enable __str__ in python classes with str(self)
279 
280  PyEval_InitThreads();
281 
282  py_opcua_enums();
283 
286  to_python_converter<LocalizedText, LocalizedTextToPythonConverter>();
287  // Enable next line to return PyDateTime instead og DateTime in python
288  //to_python_converter<DateTime, DateTimeOpcUaToPythonConverter>();
289 
290 
291 
292  to_python_converter<std::vector<std::string>, vector_to_python_converter<std::string>>();
294 
296  to_python_converter<Variant, variant_to_python_converter>();
297 
298  class_<DateTime>("DateTime", init<>())
299  .def(init<int64_t>())
300  .def("now", &DateTime::DateTime::Current)
301  .def("__init__", make_constructor(makeOpcUaDateTime))
302  .def("from_time_t", &DateTime::FromTimeT, DateTimeFromTimeT_stub((arg("sec"), arg("usec") = 0)))
303  .staticmethod("from_time_t")
304  .def("to_datetime", &ToPyDateTime)
305  .def("to_time_t", &DateTime::ToTimeT)
306  .def_readwrite("value", &DateTime::Value)
307  ;
308 
309  //class_<LocalizedText>("LocalizedText")
310  //.def_readwrite("Encoding", &LocalizedText::Encoding)
311  //.def_readwrite("Locale", &LocalizedText::Locale)
312  //.def_readwrite("Text", &LocalizedText::Text)
313  //;
314 
315 
316  class_<NodeId, std::shared_ptr<NodeId>>("NodeId")
317  .def(init<uint32_t, uint16_t>())
318  .def(init<std::string, uint16_t>())
319  .def("__init__", make_constructor(NodeId_constructor)) // XXX add this constructor to freeopcua
320  .add_property("namespace_index", &NodeId::GetNamespaceIndex)
321  .add_property("identifier", &NodeId_GetIdentifier)
322  .add_property("encoding", &NodeId::GetEncodingValue)
323  .add_property("is_integer", &NodeId::IsInteger)
324  .add_property("is_binary", &NodeId::IsBinary)
325  .add_property("is_guid", &NodeId::IsGuid)
326  .add_property("is_string", &NodeId::IsString)
327  .def_readonly("namespace_uri", &NodeId::NamespaceURI)
328  .def(str(self))
329  .def(repr(self))
330  .def(self == self)
331  ;
332 
333  to_python_converter<std::vector<QualifiedName>, vector_to_python_converter<QualifiedName>>();
334  to_python_converter<std::vector<std::vector<QualifiedName>>, vector_to_python_converter<std::vector<QualifiedName>>>();
335  class_<QualifiedName>("QualifiedName")
336  .def(init<uint16_t, std::string>())
337  .def(init<std::string, uint16_t>()) // XXX A.D.D, right
338  //.def("parse", &ToQualifiedName) XXX def()
339  .def_readwrite("namespace_index", &QualifiedName::NamespaceIndex)
340  .def_readwrite("name", &QualifiedName::Name)
341  .def(str(self))
342  .def(repr(self))
343  .def(self == self)
344  ;
345 
346  class_<DataValue, std::shared_ptr<DataValue>>("DataValue")
347  .def(init<const Variant &>())
348  .def("__init__", make_constructor(DataValue_constructor1)) // Variant, VariantType
349 #define _property(X) add_property( #X, &DataValue_get_ ## X, &DataValue_set_ ## X)
350  ._property(value)
351  ._property(status)
352  ._property(source_timestamp)
353  ._property(source_picoseconds)
354  ._property(server_timestamp)
355  ._property(server_picoseconds)
356 #undef _property
357  ;
358 
359  to_python_converter<std::vector<DataValue>, vector_to_python_converter<DataValue>>();
360 
361  class_<ApplicationDescription>("ApplicationDescription")
362  .def_readwrite("uri", &ApplicationDescription::ApplicationUri)
363  .def_readwrite("product_uri", &ApplicationDescription::ProductUri)
364  .def_readwrite("name", &ApplicationDescription::ApplicationName)
365  .def_readwrite("type", &ApplicationDescription::ApplicationType)
366  .def_readwrite("gateway_server_uri", &ApplicationDescription::GatewayServerUri)
367  .def_readwrite("discovery_profile_uri", &ApplicationDescription::DiscoveryProfileUri)
368  .def_readwrite_vector("discovery_urls", &ApplicationDescription::DiscoveryUrls)
369  ;
370 
371  to_python_converter<std::vector<ApplicationDescription>, vector_to_python_converter<ApplicationDescription>>();
372 
373  class_<UserTokenPolicy>("UserTokenPolicy")
374  .def_readwrite("policy_id", &UserTokenPolicy::PolicyId)
375  .def_readwrite("token_type", &UserTokenPolicy::TokenType)
376  .def_readwrite("issued_token_type", &UserTokenPolicy::IssuedTokenType)
377  .def_readwrite("issuer_endpoint_url", &UserTokenPolicy::IssuerEndpointUrl)
378  .def_readwrite("security_policy_uri", &UserTokenPolicy::SecurityPolicyUri)
379  ;
380 
381  to_python_converter<std::vector<UserTokenPolicy>, vector_to_python_converter<UserTokenPolicy>>();
383 
384  class_<EndpointDescription>("EndpointDescription")
385  .def_readwrite("url", &EndpointDescription::EndpointUrl)
386  .def_readwrite("server_description", &EndpointDescription::Server)
387  .def_readwrite("security_mode", &EndpointDescription::SecurityMode)
388  .def_readwrite("security_policy_uri", &EndpointDescription::SecurityPolicyUri)
389  .def_readwrite_vector("user_identify_tokens", &EndpointDescription::UserIdentityTokens)
390  .def_readwrite("transport_profile_uri", &EndpointDescription::TransportProfileUri)
391  .def_readwrite("security_level", &EndpointDescription::SecurityLevel)
392  ;
393 
394  to_python_converter<std::vector<EndpointDescription>, vector_to_python_converter<EndpointDescription>>();
395 
396  class_<ReferenceDescription>("ReferenceDescription")
397  .def_readwrite("reference_type_id", &ReferenceDescription::ReferenceTypeId)
398  .def_readwrite("is_forward", &ReferenceDescription::IsForward)
399  .def_readwrite("target_node_id", &ReferenceDescription::TargetNodeId)
400  .def_readwrite("browse_name", &ReferenceDescription::BrowseName)
401  .def_readwrite("display_name", &ReferenceDescription::DisplayName)
402  .def_readwrite("target_node_class", &ReferenceDescription::TargetNodeClass)
403  .def_readwrite("target_node_type_definition", &ReferenceDescription::TargetNodeTypeDefinition)
404  ;
405 
406  to_python_converter<std::vector<ReferenceDescription>, vector_to_python_converter<ReferenceDescription>>();
407 
408  class_<ReadValueId>("ReadValueId")
409  .def_readwrite("node_id", &ReadValueId::NodeId)
410  .def_readwrite("attribute_id", &ReadValueId::AttributeId)
411  .def_readwrite("index_range", &ReadValueId::IndexRange)
412  .def_readwrite("data_encoding", &ReadValueId::DataEncoding)
413  ;
414 
415  to_python_converter<std::vector<ReadValueId>, vector_to_python_converter<ReadValueId>>();
416 
417  class_<WriteValue>("WriteValue")
418  .def_readwrite("node_id", &WriteValue::NodeId)
419  .def_readwrite("attribute_id", &WriteValue::AttributeId)
420  .def_readwrite("index_range", &WriteValue::IndexRange)
421  .def_readwrite("value", &WriteValue::Value)
422  ;
423 
424  to_python_converter<std::vector<WriteValue>, vector_to_python_converter<WriteValue>>();
426 
427 // XXX
428 // class_<Variant>("Variant")
429 // .def("value", &VariantValue)
430 // .def("type", &Variant::Type)
431 // .def("is_array", &Variant::IsArray)
432 // .def("is_scalar", &Variant::IsScalar)
433 // .def("is_null", &Variant::IsNul)
434 // ;
435 
436  class_<Node>("Node", init<Services::SharedPtr, NodeId>())
437  .def(init<Node>())
438  .def("get_id", &Node::GetId)
439  .def("get_attribute", &Node::GetAttribute)
440  .def("set_attribute", &Node::SetAttribute)
441  .def("get_value", &Node::GetValue)
442  .def("set_value", (void(Node::*)(const DataValue &) const) &Node::SetValue)
443  .def("set_value", (void(Node::*)(const Variant &) const) &Node::SetValue)
444  .def("set_value", &Node_SetValue)
445  .def("get_properties", &Node::GetProperties)
446  .def("get_variables", &Node::GetVariables)
447  .def("get_browse_name", &Node::GetBrowseName)
448  .def("get_children", (std::vector<Node> (Node::*)() const) &Node::GetChildren)
449  .def("get_child", (Node(Node::*)(const std::vector<std::string> &) const) &Node::GetChild)
450  .def("get_child", (Node(Node::*)(const std::string &) const) &Node::GetChild)
451  .def("add_folder", (Node(Node::*)(const NodeId &, const QualifiedName &) const) &Node::AddFolder)
452  .def("add_folder", (Node(Node::*)(const std::string &, const std::string &) const) &Node::AddFolder)
453  .def("add_folder", (Node(Node::*)(uint32_t, const std::string &) const) &Node::AddFolder)
454  .def("add_object", (Node(Node::*)(const NodeId &, const QualifiedName &) const) &Node::AddObject)
455  .def("add_object", (Node(Node::*)(const std::string &, const std::string &) const) &Node::AddObject)
456  .def("add_object", (Node(Node::*)(uint32_t, const std::string &) const) &Node::AddObject)
457  .def("add_variable", (Node(Node::*)(const NodeId &, const QualifiedName &, const Variant &) const) &Node::AddVariable)
458  .def("add_variable", (Node(Node::*)(const std::string &, const std::string &, const Variant &) const) &Node::AddVariable)
459  .def("add_variable", (Node(Node::*)(uint32_t, const std::string &, const Variant &) const) &Node::AddVariable)
460  .def("add_property", (Node(Node::*)(const NodeId &, const QualifiedName &, const Variant &) const) &Node::AddProperty)
461  .def("add_property", (Node(Node::*)(const std::string &, const std::string &, const Variant &) const) &Node::AddProperty)
462  .def("add_property", (Node(Node::*)(uint32_t, const std::string &, const Variant &) const) &Node::AddProperty)
463  .def(str(self))
464  .def(repr(self))
465  .def(self == self)
466  ;
467 
468  to_python_converter<std::vector<Node>, vector_to_python_converter<Node>>();
470 
471  class_<SubscriptionHandler, PySubscriptionHandler, boost::noncopyable>("SubscriptionHandler", init<>())
472  .def("data_change", &PySubscriptionHandler::DefaultDataChange)
473  .staticmethod("data_change")
475  .staticmethod("event")
476  .def("status_change", &PySubscriptionHandler::DefaultStatusChange)
477  .staticmethod("status_change")
478  ;
479 
480  class_<Event>("Event", init<const NodeId &>())
481  .def(init<>())
482  .def("get_value", (Variant(Event::*)(const std::string &) const) &Event::GetValue)
483  .def("set_value", (void (Event::*)(const std::string &, Variant)) &Event::SetValue)
484  .def("get_value_keys", &Event::GetValueKeys)
485  .def_readwrite("event_id", &Event::EventId)
486  .def_readwrite("event_type", &Event::EventType)
487  .def_readwrite("local_time", &Event::LocalTime)
488  .add_property("message", make_getter(&Event::Message, return_value_policy<return_by_value>()), make_setter(&Event::Message, return_value_policy<return_by_value>()))
489  .def_readwrite("receive_time", &Event::ReceiveTime)
490  .def_readwrite("severity", &Event::Severity)
491  .def_readwrite("source_name", &Event::SourceName)
492  .def_readwrite("source_node", &Event::SourceNode)
493  .def_readwrite("time", &Event::Time)
494  .def(str(self))
495  .def(repr(self))
496  ;
497 
498  class_<Subscription, std::shared_ptr<Subscription>, boost::noncopyable>("Subscription", no_init)
499  .def("subscribe_data_change", (uint32_t (Subscription::*)(const Node &, AttributeId)) &Subscription::SubscribeDataChange, SubscriptionSubscribeDataChange_stubs((arg("node"), arg("attr") = AttributeId::Value)))
500  .def("delete", &Subscription::Delete)
501  .def("unsubscribe", (void (Subscription::*)(uint32_t)) &Subscription::UnSubscribe)
502  .def("subscribe_events", (uint32_t (Subscription::*)()) &Subscription::SubscribeEvents)
503  .def("subscribe_events", (uint32_t (Subscription::*)(const Node &, const Node &)) &Subscription::SubscribeEvents)
504  //.def(str(self))
505  //.def(repr(self))
506  ;
507 
508  class_<UaClient, boost::noncopyable>("Client", init<>())
509  .def(init<bool>())
510  .def("connect", (void (UaClient::*)(const std::string &)) &UaClient::Connect)
511  .def("connect", (void (UaClient::*)(const EndpointDescription &)) &UaClient::Connect)
512  .def("disconnect", &UaClient::Disconnect)
513  .def("get_namespace_index", &UaClient::GetNamespaceIndex)
514  .def("get_root_node", &UaClient::GetRootNode)
515  .def("get_objects_node", &UaClient::GetObjectsNode)
516  .def("get_server_node", &UaClient::GetServerNode)
517  .def("get_node", (Node(UaClient::*)(const std::string &) const) &UaClient::GetNode)
518  .def("get_node", (Node(UaClient::*)(const NodeId &) const) &UaClient::GetNode)
519  .def("get_node", &UaClient_GetNode)
520  .def("get_endpoint", &UaClient::GetEndpoint)
521  .def("get_server_endpoints", (std::vector<EndpointDescription> (UaClient::*)(const std::string &)) &UaClient::GetServerEndpoints)
522  .def("get_server_endpoints", (std::vector<EndpointDescription> (UaClient::*)()) &UaClient::GetServerEndpoints)
523  .def("set_session_name", &UaClient::SetSessionName)
524  .def("get_session_name", &UaClient::GetSessionName)
525  .def("get_application_uri", &UaClient::GetApplicationURI)
526  .def("set_application_uri", &UaClient::SetApplicationURI)
527  .def("set_security_policy", &UaClient::SetSecurityPolicy)
528  .def("get_security_policy", &UaClient::GetSecurityPolicy)
529  .def("create_subscription", &UaClient_CreateSubscription)
530  //.def(str(self))
531  //.def(repr(self))
532  ;
533 
534  class_<UaServer, boost::noncopyable >("Server", init<>())
535  .def(init<bool>())
536  .def("start", &UaServer::Start)
537  .def("stop", &UaServer::Stop)
538  .def("register_namespace", &UaServer::RegisterNamespace)
539  .def("get_namespace_index", &UaServer::GetNamespaceIndex)
540  .def("get_root_node", &UaServer::GetRootNode)
541  .def("get_objects_node", &UaServer::GetObjectsNode)
542  .def("get_server_node", &UaServer::GetServerNode)
543  .def("get_node", (Node(UaServer::*)(const std::string &) const) &UaServer::GetNode)
544  .def("get_node", (Node(UaServer::*)(const NodeId &) const) &UaServer::GetNode)
545  .def("get_node", &UaServer_GetNode)
546  .def("set_uri", &UaServer::SetServerURI)
547  .def("add_xml_address_space", &UaServer::AddAddressSpace)
548  .def("set_server_name", &UaServer::SetServerName)
549  .def("set_endpoint", &UaServer::SetEndpoint)
550  .def("create_subscription", &UaServer_CreateSubscription)
551  .def("trigger_event", &UaServer::TriggerEvent)
552  //.def(str(self))
553  //.def(repr(self))
554  ;
555 
556 }
557 
const char SourceName[]
Definition: strings.h:180
const char ReceiveTime[]
Definition: strings.h:130
static std::shared_ptr< DateTime > makeOpcUaDateTime(const boost::python::object &bobj)
static uint16_t DataValue_get_server_picoseconds(const DataValue &self)
const char LocalTime[]
Definition: strings.h:97
static void DefaultDataChange(const SubscriptionHandler &self_, uint32_t handle, const Node &node, const object &val, uint32_t attribute)
static std::shared_ptr< NodeId > NodeId_constructor(const std::string &encodedNodeId)
const char Message[]
Definition: strings.h:102
const uint8_t DATA_VALUE_STATUS_CODE
Definition: data_value.h:19
static void DataValue_set_server_picoseconds(DataValue &self, uint16_t ps)
static void * convertible(PyObject *obj_ptr)
Variant ToVariant2(const object &obj, VariantType vtype)
static void Node_SetValue(Node &self, const object &obj, VariantType vtype)
const char EventId[]
Definition: strings.h:57
#define _property(X)
const char Severity[]
Definition: strings.h:175
static void DataValue_set_source_picoseconds(DataValue &self, uint16_t ps)
static std::shared_ptr< DataValue > DataValue_constructor1(const object &obj, VariantType vtype)
object ToObject(const Variant &var)
static std::shared_ptr< Subscription > UaServer_CreateSubscription(UaServer &self, uint period, PySubscriptionHandler &callback)
static object NodeId_GetIdentifier(const NodeId &self)
const char NodeId[]
Definition: strings.h:116
const char EventType[]
Definition: strings.h:58
static void construct(PyObject *obj_ptr, boost::python::converter::rvalue_from_python_stage1_data *data)
const uint8_t DATA_VALUE_Server_TIMESTAMP
Definition: data_value.h:21
static uint64_t ToWinEpoch(PyObject *pydate)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(SubscriptionSubscribeDataChange_stubs, Subscription::SubscribeDataChange, 1, 2)
const char SourceNode[]
Definition: strings.h:181
const char Time[]
Definition: strings.h:195
static object DataValue_get_value(const DataValue &self)
BOOST_PYTHON_MODULE(opcua)
VariantType
Definition: variant.h:27
static void DefaultEvent(const SubscriptionHandler &self_, uint32_t handle, const OpcUa::Event &event)
const uint8_t DATA_VALUE_SOURCE_PICOSECONDS
Definition: data_value.h:22
ObjectId
Definition: object_ids.h:12
static PyObject * convert(const LocalizedText &text)
static void DefaultStatusChange(const SubscriptionHandler &self_, StatusCode status)
static StatusCode DataValue_get_status(const DataValue &self)
const uint8_t DATA_VALUE_SOURCE_TIMESTAMP
Definition: data_value.h:20
OPC UA Address space part. GNU LGPL.
const uint8_t DATA_VALUE_Server_PICOSECONDS
Definition: data_value.h:23
static void construct(PyObject *obj_ptr, boost::python::converter::rvalue_from_python_stage1_data *data)
static DateTime DataValue_get_source_timestamp(const DataValue &self)
BOOST_PYTHON_FUNCTION_OVERLOADS(DateTimeFromTimeT_stub, DateTime::FromTimeT, 1, 2)
static void DataValue_set_server_timestamp(DataValue &self, const DateTime &dt)
A Node object represent an OPC-UA node. It is high level object intended for developper who want to e...
Definition: node.h:42
internal::NamedArg< char > arg(StringRef name, const T &arg)
Definition: format.h:3918
std::string Text
Definition: types.h:136
void py_opcua_enums()
Python bindings for freeopcua. GNU LGPL.
NodeId ToNodeId(const std::string &str, uint32_t defaultNamespace=0)
static DateTime DataValue_get_server_timestamp(const DataValue &self)
static std::shared_ptr< Subscription > UaClient_CreateSubscription(UaClient &self, uint period, PySubscriptionHandler &callback)
static boost::python::object ToPyDateTime(const DateTime &self)
static Node UaClient_GetNode(UaClient &self, ObjectId objectid)
static Node UaServer_GetNode(UaServer &self, ObjectId objectid)
static void DataValue_set_value(DataValue &self, const object &obj, VariantType vtype)
const uint8_t DATA_VALUE
Definition: data_value.h:18
Python bindings for freeopcua. GNU LGPL.
static void DataValue_set_status(DataValue &self, const StatusCode &sc)
static void * convertible(PyObject *obj_ptr)
static uint16_t DataValue_get_source_picoseconds(const DataValue &self)
static PyObject * convert(const DateTime &dt)
EndpointDescription GetEndpoint(OpcUa::Binary::IOStream &stream)
std::unique_ptr< RemoteConnection > Connect(const std::string &host, unsigned port, const Common::Logger::SharedPtr &logger)
ApplicationType
Definition: enums.h:56
const char Server[]
Definition: strings.h:121
static void Delete(T *x)
static void DataValue_set_source_timestamp(DataValue &self, const DateTime &dt)


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:12:07