server_operations.cpp
Go to the documentation of this file.
00001 #include "opc/ua/server_operations.h"
00002 
00003 namespace OpcUa {
00004         ServerOperations::ServerOperations(Services::SharedPtr Server) : Server(Server)
00005         {
00006         }
00007 
00008         void ServerOperations::WriteAttributes(std::vector<WriteValue>& updates)
00009         {
00010                 std::vector<StatusCode> codes = Server->Attributes()->Write(updates);
00011                 CheckStatusCode(codes.front());
00012         }
00013 
00014         std::vector<DataValue> ServerOperations::ReadAttributes(std::vector<ReadValueId>& attributes)
00015         {
00016                 ReadParameters params;
00017                 params.AttributesToRead = attributes;
00018                 auto vec = Server->Attributes()->Read(params);
00019                 return vec;
00020         }
00021 
00022         std::vector<DataValue> ServerOperations::ReadAttributes(std::vector<Node>& nodes, AttributeId attr)
00023         {
00024                 std::vector<ReadValueId> request;
00025                 for (auto& n : nodes) {
00026                         ReadValueId r;
00027                         r.NodeId = n.GetId();
00028                         r.AttributeId = attr;
00029                         request.push_back(r);
00030                 }
00031                 return ReadAttributes(request);
00032         }
00033 
00034         std::vector<Node> ServerOperations::RegisterNodes(std::vector<Node>& nodes)
00035         {
00036                 std::vector<OpcUa::NodeId> ids;
00037                 for (auto& node : nodes) {
00038                         ids.push_back(node.GetId());
00039                 }
00040                 auto result = Server->Views()->RegisterNodes(ids);
00041                 auto rit = result.begin();
00042                 std::vector<Node> out;
00043                 for (auto nit = nodes.begin(); nit != nodes.end() && rit != result.end(); ++nit, ++rit)
00044                 {
00045                         out.push_back(Node(nit->GetServices(), *rit));
00046                 }
00047 
00048                 return out;
00049         }
00050 
00051         void ServerOperations::UnregisterNodes(std::vector<Node>& nodes)
00052         {
00053                 std::vector<OpcUa::NodeId> ids;
00054                 for (auto& node : nodes) {
00055                         ids.push_back(node.GetId());
00056                 }
00057 
00058                 Server->Views()->UnregisterNodes(ids);
00059         }
00060 }


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Sat Jun 8 2019 18:24:56