model.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (C) 2013-2014 by Alexander Rykovanov *
3  * rykovanov.as@gmail.com *
4  * *
5  * This library is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU Lesser General Public License as *
7  * published by the Free Software Foundation; version 3 of the License. *
8  * *
9  * This library is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU Lesser General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU Lesser General Public License *
15  * along with this library; if not, write to the *
16  * Free Software Foundation, Inc., *
17  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18  ******************************************************************************/
19 
20 #pragma once
21 
23 #include <opc/ua/protocol/object_ids.h> // Ids of standard nodes.
24 
25 namespace OpcUa
26 {
27 namespace Model
28 {
29 
30 class Reference;
31 class Variable;
32 
33 class Node
34 {
35 public:
36  Node(NodeId id, Services::SharedPtr services);
37 
38  NodeId GetId() const;
39 
40 
43 
44  std::vector<Reference> GetReferencies() const;
45 
46 public:
47  Services::SharedPtr GetServices() const
48  {
49  return OpcUaServices;
50  }
51 
52 protected:
53  Node(Services::SharedPtr services);
54 
55 protected:
59  Services::SharedPtr OpcUaServices;
60 };
61 
62 
63 class ReferenceType : public Node
64 {
65 public:
66  ReferenceType(NodeId typeId, Services::SharedPtr services);
67 
68  ReferenceType Parent() const;
69 
70  QualifiedName Name() const;
71  QualifiedName InverseName() const;
72 };
73 
74 class Reference
75 {
76 public:
77  ReferenceType Type();
78 
79  Node Source() const;
80  Node Target() const;
81 };
82 
83 class DataType : public Node
84 {
85 public:
86  DataType(NodeId typeId, Services::SharedPtr services);
87 
88  bool IsAbstrasct() const;
89  DataType Parent() const;
90 
91  std::vector<DataType> SubTypes() const;
92 
93 private:
94  bool IsAbstract = false;
96 };
97 
98 class VariableType : public Node
99 {
100 public:
101  VariableType(NodeId typeId, Services::SharedPtr services);
102 
103  // Existing variable type.
104  VariableType(Services::SharedPtr services, const NodeId & typeId);
105 
106  bool IsBase() const;
107  bool IsAbstract() const;
108  VariableType Parent() const;
109  std::vector<VariableType> SubTypes() const;
110 
111  DataType ValueType() const;
112 
113  DataValue GetDefaultValue() const;
114  void SetDefaultValue(const DataValue & value);
115 
116  std::vector<Variable> GetVariables() const;
117  Variable GetVariable(const QualifiedName & name) const;
118  Variable GetVariable(const RelativePath & path) const;
119 
120 private:
121  bool Abstract = false;
125 };
126 
127 
128 class Variable : public Node
129 {
130 public:
131  Variable(NodeId variableId, Services::SharedPtr services);
132 
133  VariableType GetType() const;
134 
135  DataValue GetValue() const;
136  void SetValue(const Variant & value);
137  void SetValue(const DataValue & value);
138  VariantType GetDataType() const;
139 
140  std::vector<Variable> Variables() const;
141  Variable GetVariable(const QualifiedName & name) const;
142  Variable GetVariable(const std::vector<QualifiedName> & path) const;
143 
144 private:
145  friend class Object;
146 
147  Variable(Services::SharedPtr services)
148  : Node(services)
149  {
150  }
151 
152 private:
155 };
156 
157 
158 class Object;
159 
160 class ObjectType : public Node
161 {
162 public:
163  ObjectType(NodeId objectId, Services::SharedPtr services);
164 
165  bool IsBase() const;
166  bool IsAbstract() const;
167 
168  std::vector<Variable> Variables() const;
169  std::vector<Object> Objects() const;
170 
171  std::vector<ObjectType> SubTypes() const;
172 
173  ObjectType Parent() const;
174 
175 private:
176  bool Abstract = false;
178 };
179 
180 
181 class Object : public Node
182 {
183 public:
184  Object(NodeId objectId, Services::SharedPtr services);
185  Object(Object && object);
186  Object(const Object & object);
187 
188  ObjectType GetType() const;
189 
191  std::vector<Variable> GetVariables() const;
193  Variable GetVariable(const QualifiedName & name) const;
195  Variable GetVariable(const RelativePath & path) const;
196 
204  Variable CreateVariable(const QualifiedName & browseName, const Variant & value);
205  Variable CreateVariable(const NodeId & newVariableId, const QualifiedName & browseName, const Variant & value);
206  Variable CreateVariable(const QualifiedName & browseName, const VariableType & type);
207  Variable CreateVariable(const NodeId & newVariableId, const QualifiedName & browseName, const VariableType & type);
208 
209  std::vector<Object> GetObjects() const;
210  Object GetObject(const QualifiedName & name) const;
211  Object GetObject(const RelativePath & name) const;
212 
213  Object CreateObject(const ObjectType & type, const QualifiedName & browseName);
214  Object CreateObject(const NodeId & newNodeId, const ObjectType & nodeType, const QualifiedName & browseName);
215  Object CreateObject(const ObjectType & type, const QualifiedName & browseName, const std::string & displayName);
216  Object CreateObject(const NodeId & newNodeId, const ObjectType & type, const QualifiedName & browseName, const std::string & displayName);
217 
218 private:
219  Object CreateObject(const NodeId & newNodeId, const NodeId & parentNode, const NodeId & typeId, const QualifiedName & browseName, const std::string & displayName);
220  Variable CreateVariable(const NodeId & newNodeId, const NodeId & parentNode, const NodeId & typeId, const QualifiedName & browseName, const std::string & displayName);
221 
222  NodeId InstantiateType(const NodeId & newNodeId, const NodeId & parentNode, const NodeId & typeId, NodeClass nodeClass, const QualifiedName & browseName, const std::string & displayName);
223  std::vector<ReferenceDescription> BrowseObjectsAndVariables(const NodeId & id);
224 
225  std::map<NodeId, std::vector<ReferenceDescription>> CopyObjectsAndVariables(const NodeId & targetNode, const std::vector<ReferenceDescription> & refs);
226  AddNodesItem CreateVariableCopy(const NodeId & parentId, const ReferenceDescription & ref);
227  AddNodesItem CreateObjectCopy(const NodeId & parentId, const ReferenceDescription & ref);
228 
229 private:
230  explicit Object(Services::SharedPtr services);
231 };
232 
233 class Server
234 {
235 public:
236  Server(Services::SharedPtr services);
237 
238  Object RootObject() const;
239  Object GetObject(const NodeId & id) const;
240  ObjectType GetObjectType(const NodeId & typeId) const;
241 
242 public:
243  Services::SharedPtr GetServices() const;
244 
245 private:
246  Services::SharedPtr Connection;
247 };
248 
249 } // namespace Model
250 } // namespace OpcUa
QualifiedName BrowseName
Definition: model.h:57
NodeId ParentTypeId
Definition: model.h:95
Variable(Services::SharedPtr services)
Definition: model.h:147
name
Definition: setup.py:38
VariantType
Definition: variant.h:27
const char Objects[]
Definition: strings.h:120
Node(NodeId id, Services::SharedPtr services)
Definition: model_node.cpp:26
OPC UA Address space part. GNU LGPL.
QualifiedName GetBrowseName() const
Definition: model_node.cpp:48
std::vector< Reference > GetReferencies() const
Definition: model_node.cpp:58
NodeClass
Definition: enums.h:39
LocalizedText DisplayName
Definition: model.h:58
Services::SharedPtr GetServices() const
Definition: model.h:47
NodeId GetId() const
Definition: model_node.cpp:43
DataValue DefaultValue
Definition: model.h:122
Services::SharedPtr Connection
Definition: model.h:246
Services::SharedPtr OpcUaServices
Definition: model.h:59
LocalizedText GetDisplayName() const
Definition: model_node.cpp:53


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