event.cpp
Go to the documentation of this file.
1 
2 #include <iostream> //Debug
3 
4 #include <opc/ua/event.h>
6 
7 namespace OpcUa
8 {
9 
10 Event::Event() : EventType(ObjectId::BaseEventType)
11 {
12 }
13 
14 Event::Event(const NodeId & type) : EventType(type) {}
15 
16 Event::Event(const Node & type) : EventType(type.GetId()) {}
17 
18 std::vector<std::vector<QualifiedName>> Event::GetValueKeys()
19 {
20  std::vector<std::vector<QualifiedName>> qns;
21 
22  for (auto qn : PathValues)
23  {
24  qns.push_back(qn.first);
25  }
26 
27  return qns;
28 }
29 
30 void Event::SetValue(const QualifiedName & path, Variant value)
31 {
32  SetValue(std::vector<QualifiedName>({path}), value);
33 }
34 
35 void Event::SetValue(const std::vector<QualifiedName> & path, Variant value)
36 {
37  PathValues[path] = value;
38 }
39 
40 void Event::SetValue(AttributeId attribute, Variant value)
41 {
42  AttributeValues[attribute] = value;
43 }
44 
46 {
47  std::vector<QualifiedName> path;
48  path.push_back(ToQualifiedName(name));
49  return SetValue(path, value);
50 }
51 
53 {
54  return GetValue(std::vector<QualifiedName>({path}));
55 }
56 
57 Variant Event::GetValue(const std::vector<QualifiedName> & path) const
58 {
59  PathMap::const_iterator it = PathValues.find(path);
60  std::cout << "Looking for Event value: ";
61 
62  for (auto qn : path)
63  {
64  std::cout << qn ;
65  }
66 
67  std::cout << std::endl;
68 
69  if (it == PathValues.end())
70  {
71  std::cout << "Bad Not found " << std::endl;
72  return Variant();
73  }
74 
75  else
76  {
77  std::cout << "ok" << std::endl;
78  return it->second;
79  }
80 }
81 
82 Variant Event::GetValue(const std::string & qualifiedname) const
83 {
84  std::vector<QualifiedName> path;
85  path.push_back(ToQualifiedName(qualifiedname));
86  return GetValue(path);
87 }
88 
90 {
91  AttributeMap::const_iterator it = AttributeValues.find(attribute);
92 
93  if (it == AttributeValues.end())
94  {
95  return Variant();
96  }
97 
98  else
99  {
100  return it->second;
101  }
102 }
103 }
PathMap PathValues
Definition: event.h:67
const char EventType[]
Definition: strings.h:58
std::vector< std::vector< QualifiedName > > GetValueKeys()
Definition: event.cpp:18
name
Definition: setup.py:38
NodeId EventType
Definition: event.h:37
ObjectId
Definition: object_ids.h:12
OPC UA Address space part. GNU LGPL.
Variant GetValue(const std::vector< QualifiedName > &path) const
Definition: event.cpp:57
QualifiedName ToQualifiedName(const std::string &str, uint32_t default_ns=0)
A Node object represent an OPC-UA node. It is high level object intended for developper who want to e...
Definition: node.h:42
AttributeMap AttributeValues
Definition: event.h:68
void SetValue(const std::vector< QualifiedName > &path, Variant value)
Definition: event.cpp:35


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