address_space_addon.cpp
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 #include "address_space_addon.h"
00012 
00013 #include <opc/common/addons_core/addon_manager.h>
00014 #include <opc/ua/server/addons/address_space.h>
00015 #include <opc/ua/server/addons/services_registry.h>
00016 #include <opc/ua/server/address_space.h>
00017 
00018 #include <iostream>
00019 
00020 namespace OpcUa
00021 {
00022   namespace Internal
00023   {
00024     AddressSpaceAddon::AddressSpaceAddon()
00025     {
00026     }
00027 
00028     AddressSpaceAddon::~AddressSpaceAddon()
00029     {
00030     }
00031 
00032     AddressSpaceAddon::Options AddressSpaceAddon::GetOptions(const Common::AddonParameters& addonParams)
00033     {
00034       AddressSpaceAddon::Options options;
00035       for (const Common::Parameter& param : addonParams.Parameters)
00036       {
00037         if (param.Name == "debug" && !param.Value.empty() && param.Value != "0")
00038         {
00039           std::cout << "Enabled debug mode for address space addon." << std::endl;
00040           options.Debug = true;
00041         }
00042       }
00043       return options;
00044     }
00045 
00046     void AddressSpaceAddon::Initialize(Common::AddonsManager& addons, const Common::AddonParameters& params)
00047     {
00048       Options options = GetOptions(params);
00049       Registry = Server::CreateAddressSpace(options.Debug);
00050       InternalServer = addons.GetAddon<OpcUa::Server::ServicesRegistry>(OpcUa::Server::ServicesRegistryAddonId);
00051       InternalServer->RegisterViewServices(Registry);
00052       InternalServer->RegisterAttributeServices(Registry);
00053       InternalServer->RegisterNodeManagementServices(Registry);
00054     }
00055 
00056     void AddressSpaceAddon::Stop()
00057     {
00058       InternalServer->UnregisterViewServices();
00059       InternalServer->UnregisterAttributeServices();
00060       InternalServer->UnregisterNodeManagementServices();
00061       InternalServer.reset();
00062       Registry.reset();
00063     }
00064 
00065     std::vector<AddNodesResult> AddressSpaceAddon::AddNodes(const std::vector<AddNodesItem>& items)
00066     {
00067       return Registry->AddNodes(items);
00068     }
00069 
00070     std::vector<StatusCode> AddressSpaceAddon::AddReferences(const std::vector<AddReferencesItem>& items)
00071     {
00072       return Registry->AddReferences(items);
00073     }
00074 
00075     std::vector<BrowseResult> AddressSpaceAddon::Browse(const OpcUa::NodesQuery& query) const
00076     {
00077       return Registry->Browse(query);
00078     }
00079     std::vector<BrowseResult> AddressSpaceAddon::BrowseNext() const
00080     {
00081       return Registry->BrowseNext();
00082     }
00083 
00084     std::vector<BrowsePathResult> AddressSpaceAddon::TranslateBrowsePathsToNodeIds(const TranslateBrowsePathsParameters& params) const 
00085     {
00086       return Registry->TranslateBrowsePathsToNodeIds(params);
00087     }
00088 
00089         std::vector<NodeId> AddressSpaceAddon::RegisterNodes(const std::vector<NodeId>& params) const
00090         {
00091                 return Registry->RegisterNodes(params);
00092         }
00093 
00094         void AddressSpaceAddon::UnregisterNodes(const std::vector<NodeId>& params) const
00095         {
00096                 return Registry->UnregisterNodes(params);
00097         }
00098 
00099     std::vector<DataValue> AddressSpaceAddon::Read(const OpcUa::ReadParameters& filter) const
00100     {
00101       return Registry->Read(filter);
00102     }
00103 
00104     std::vector<StatusCode> AddressSpaceAddon::Write(const std::vector<OpcUa::WriteValue>& filter)
00105     {
00106       return Registry->Write(filter);
00107     }
00108 
00109     uint32_t AddressSpaceAddon::AddDataChangeCallback(const NodeId& node, AttributeId attribute, std::function<Server::DataChangeCallback> callback)
00110     {
00111       return Registry->AddDataChangeCallback(node, attribute, callback);
00112     }
00113 
00114     void AddressSpaceAddon::DeleteDataChangeCallback(uint32_t clienthandle)
00115     {
00116       return Registry->DeleteDataChangeCallback(clienthandle);
00117     }
00118 
00119     StatusCode AddressSpaceAddon::SetValueCallback(const NodeId& node, AttributeId attribute, std::function<DataValue(void)> callback)
00120     {
00121       return Registry->SetValueCallback(node, attribute, callback);
00122     }
00123  
00124 
00125   } // namespace Internal
00126 } // namespace OpcUa
00127 
00128 Common::Addon::UniquePtr OpcUa::Server::AddressSpaceAddonFactory::CreateAddon()
00129 {
00130   return Common::Addon::UniquePtr(new Internal::AddressSpaceAddon());
00131 }


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