Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #pragma once
00021
00022 #include <opc/ua/services/services.h>
00023
00024 #include <sstream>
00025
00026
00027 namespace OpcUa
00028 {
00029
00030 class NodeNotFoundException : public std::runtime_error
00031 {
00032 public:
00033 NodeNotFoundException() : std::runtime_error("NodeNotFoundException") { }
00034 };
00035
00041
00042 class Node
00043 {
00044 public:
00045
00046 explicit Node(Services::SharedPtr srv);
00047 Node(Services::SharedPtr srv, const NodeId& id);
00048 Node(const Node& other);
00049 Node(){}
00050
00051 NodeId GetId() const;
00052
00053 QualifiedName GetBrowseName() const;
00054
00055
00058 std::vector<Node> GetChildren(const OpcUa::ReferenceId& refid) const;
00059
00062 std::vector<Node> GetChildren() const;
00063
00064
00065
00066
00067
00068 Node GetChild(const std::vector<OpcUa::QualifiedName>& path) const;
00069 Node GetChild(const std::vector<std::string>& path) const;
00070 Node GetChild(const std::string& browsename) const ;
00071
00072 std::vector<Node> GetProperties() const {return GetChildren(OpcUa::ReferenceId::HasProperty);}
00073 std::vector<Node> GetVariables() const {return GetChildren(OpcUa::ReferenceId::HasComponent);}
00074
00075
00076
00077
00078
00079
00080
00081 DataValue GetAttribute(const AttributeId attr) const;
00082 void SetAttribute(AttributeId attr, const DataValue &dval) const;
00083
00084
00085
00086 Variant GetValue() const;
00087 DataValue GetDataValue() const;
00088 void SetValue(const Variant& val) const;
00089 void SetValue(const DataValue& dval) const;
00090
00091 Variant GetDataType() const;
00092
00093
00094 std::vector<Variant> CallMethod(NodeId methodId, std::vector<Variant> inputArguments) const;
00095 std::vector<std::vector<Variant>> CallMethods(std::vector<NodeId> methodIds, std::vector<std::vector<Variant>> inputArguments) const;
00096
00097
00098 std::vector<AddNodesResult> AddNodes(std::vector<AddNodesItem> items) const;
00099 std::vector<StatusCode> AddReferences(std::vector<AddReferencesItem> items) const;
00100
00101
00102
00103 Node AddFolder(const NodeId& folderId, const QualifiedName& browseName) const;
00104 Node AddFolder(const std::string& nodeid, const std::string& browseName) const;
00105 Node AddFolder(uint32_t namespaceidx, const std::string& browseName) const;
00106
00107 Node AddObject(const NodeId& folderId, const QualifiedName& browseName) const;
00108 Node AddObject(const std::string& nodeid, const std::string& browseName) const;
00109 Node AddObject(uint32_t namespaceidx, const std::string& browseName) const;
00110
00111 Node AddVariable(const NodeId& variableId, const QualifiedName& browsename, const Variant& val) const;
00112 Node AddVariable(uint32_t namespaceidx, const std::string& BrowseName, const Variant& val) const;
00113 Node AddVariable(const std::string& nodeId, const std::string& browseName, const Variant& val) const;
00114
00115 Node AddProperty(const NodeId& propertyId, const QualifiedName& browsename, const Variant& val) const;
00116 Node AddProperty(const std::string& nodeid, const std::string& browseName, const Variant& val) const;
00117 Node AddProperty(uint32_t namespaceidx, const std::string& browseName, const Variant& val) const;
00118
00119 Node AddMethod(const NodeId& variableId, const QualifiedName& browsename, std::function<std::vector<OpcUa::Variant> (std::vector<OpcUa::Variant> arguments)> method) const;
00120 Node AddMethod(uint32_t namespaceidx, const std::string& BrowseName, std::function<std::vector<OpcUa::Variant> (std::vector<OpcUa::Variant> arguments)> method) const;
00121 Node AddMethod(const std::string& nodeId, const std::string& browseName, std::function<std::vector<OpcUa::Variant> (std::vector<OpcUa::Variant> arguments)> method) const;
00122
00123 std::string ToString() const;
00124
00125 bool operator==(Node const& x) const { return Id == x.Id; }
00126 bool operator!=(Node const& x) const { return Id != x.Id; }
00127
00128
00129 OpcUa::Services::SharedPtr GetServices() const {return Server;}
00130
00131 protected:
00132 OpcUa::Services::SharedPtr Server;
00133 NodeId Id;
00134 };
00135
00136
00137 std::ostream& operator<<(std::ostream& os, const Node& node);
00138
00139
00140
00141 ObjectId VariantTypeToDataType(VariantType vt);
00142
00143
00144 }
00145