36 std::vector<DataValue> values = services->Attributes()->Read(attrs);
88 browsePath.
Path = relativePath;
91 const std::vector<OpcUa::BrowsePathResult> & result =
GetServices()->Views()->TranslateBrowsePathsToNodeIds(params);
93 if (result.size() != 1)
94 {
throw std::runtime_error(
"object_model| Server returned more than one browse paths on TranslateBrowsePathsToNodeIds request."); }
99 if (resultPath.
Targets.size() != 1)
100 {
throw std::runtime_error(
"object_model| Server returned too many target elements on TranslateBrowsePathsToNodeIds request."); }
140 object.BrowseName = browseName;
152 newNodeRequest.
Class = nodeClass;
161 NodeManagementServices::SharedPtr nodes =
GetServices()->NodeManagement();
162 std::vector<AddNodesResult> newObjectNode = nodes->AddNodes({newNodeRequest});
164 if (newObjectNode.size() != 1)
166 throw std::runtime_error(
"opcua_model| Server returned wrong number new nodes results.");
171 std::map<NodeId, std::vector<ReferenceDescription>> nextRefs;
174 while (!nextRefs.empty())
176 std::map<NodeId, std::vector<ReferenceDescription>> newRefs;
178 for (
auto idRefs : nextRefs)
180 std::map<NodeId, std::vector<ReferenceDescription>> tmpRefs =
CopyObjectsAndVariables(idRefs.first, idRefs.second);
181 newRefs.insert(tmpRefs.begin(), tmpRefs.end());
187 return newObjectNode[0].AddedNodeId;
204 ViewServices::SharedPtr views =
GetServices()->Views();
205 return views->Browse(query)[0].Referencies;
210 std::map<NodeId, std::vector<ReferenceDescription>> nextCopyData;
214 std::vector<AddNodesResult> result;
215 std::vector<AddNodesItem> newNodeRequest;
217 switch (ref.TargetNodeClass)
246 if (newNodeRequest.empty())
251 result =
GetServices()->NodeManagement()->AddNodes(newNodeRequest);
253 nextCopyData.insert({result[0].AddedNodeId, newRefs});
281 NodeManagementServices::SharedPtr nodes =
GetServices()->NodeManagement();
282 std::vector<AddNodesResult> newNode = nodes->AddNodes({newNodeRequest});
284 if (newNode.size() != 1)
286 throw std::runtime_error(
"opcua_model| Server returned wrong number new nodes results.");
291 newVariable.
Id = newNode[0].AddedNodeId;
327 std::vector<DataValue> values =
GetServices()->Attributes()->Read(readParams);
334 attrs.
Rank = values[4].Value.As<int32_t>();
335 attrs.
Dimensions = values[5].Value.As<std::vector<uint32_t>>();
340 attrs.
WriteMask = values[10].Value.As<uint32_t>();
346 newNode.ParentNodeId = parentId;
349 newNode.Attributes = attrs;
363 std::vector<DataValue> values =
GetServices()->Attributes()->Read(readParams);
368 attrs.
WriteMask = values[2].Value.As<uint32_t>();
374 newNode.ParentNodeId = parentId;
377 newNode.Attributes = attrs;
NodeId InstantiateType(const NodeId &newNodeId, const NodeId &parentNode, const NodeId &typeId, NodeClass nodeClass, const QualifiedName &browseName, const std::string &displayName)
std::vector< OpcUa::ReadValueId > AttributesToRead
void CheckStatusCode(StatusCode code)
OpcUa Error codes. GNU LGPL.
AddNodesItem CreateObjectCopy(const NodeId &parentId, const ReferenceDescription &ref)
ReadValueId ToReadValueId(NodeId id, AttributeId attr)
std::vector< BrowseDescription > NodesToBrowse
std::vector< Variable > GetVariables() const
Get variables of the object.
std::vector< BrowsePath > BrowsePaths
LocalizedText Description
NodeId RequestedNewNodeId
LocalizedText Description
ObjectType GetType() const
Object(NodeId objectId, Services::SharedPtr services)
AddNodesItem CreateVariableCopy(const NodeId &parentId, const ReferenceDescription &ref)
Variable CreateVariable(const QualifiedName &browseName, const Variant &value)
Create a new variable.
VariableAccessLevel UserAccessLevel
fmt::BufferedFile & move(fmt::BufferedFile &f)
Duration MinimumSamplingInterval
ObjectId VariantTypeToDataType(VariantType vt)
std::vector< RelativePathElement > Elements
LocalizedText DisplayName
OPC UA Address space part. GNU LGPL.
NodeId TargetNodeTypeDefinition
std::vector< Object > GetObjects() const
VariableAccessLevel AccessLevel
BrowseResultMask ResultMask
Variable GetVariable(const QualifiedName &name) const
Get variable of the object by it name.
LocalizedText DisplayName
Object GetObject(const QualifiedName &name) const
BrowseDirection Direction
Object CreateObject(const ObjectType &type, const QualifiedName &browseName)
NodeAttributes Attributes
std::vector< BrowsePathTarget > Targets
Services::SharedPtr GetServices() const
std::vector< uint32_t > Dimensions
std::vector< ReferenceDescription > BrowseObjectsAndVariables(const NodeId &id)
std::map< NodeId, std::vector< ReferenceDescription > > CopyObjectsAndVariables(const NodeId &targetNode, const std::vector< ReferenceDescription > &refs)
Services::SharedPtr OpcUaServices
LocalizedText DisplayName