subscription_service_internal.h
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 #pragma once
00011 
00012 #include "address_space_addon.h"
00013 #include "internal_subscription.h"
00014 
00015 
00016 #include <opc/ua/server/subscription_service.h>
00017 #include <opc/ua/server/address_space.h>
00018 #include <opc/ua/event.h>
00019 #include <opc/ua/protocol/monitored_items.h>
00020 #include <opc/ua/protocol/strings.h>
00021 #include <opc/ua/protocol/string_utils.h>
00022 
00023 #include <boost/asio.hpp>
00024 #include <boost/thread/shared_mutex.hpp>
00025 #include <ctime>
00026 #include <limits>
00027 #include <list>
00028 #include <map>
00029 #include <queue>
00030 #include <deque>
00031 #include <set>
00032 #include <thread>
00033 
00034 namespace OpcUa
00035 {
00036   namespace Internal
00037   {
00038 
00039     class InternalSubscription;
00040 
00041     typedef std::map <uint32_t, std::shared_ptr<InternalSubscription>> SubscriptionsIdMap; // Map SubscptioinId, SubscriptionData
00042 
00043 
00044     class SubscriptionServiceInternal : public Server::SubscriptionService
00045     {
00046       public:
00047         SubscriptionServiceInternal(Server::AddressSpace::SharedPtr addressspace, boost::asio::io_service& io, bool debug);
00048 
00049        ~SubscriptionServiceInternal();
00050 
00051         virtual std::vector<StatusCode> DeleteSubscriptions(const std::vector<uint32_t>& subscriptions);
00052         virtual SubscriptionData CreateSubscription(const CreateSubscriptionRequest& request, std::function<void (PublishResult)> callback);
00053         virtual std::vector<MonitoredItemCreateResult> CreateMonitoredItems(const MonitoredItemsParameters& params);
00054         virtual std::vector<StatusCode> DeleteMonitoredItems(const DeleteMonitoredItemsParameters& params);
00055         virtual void Publish(const PublishRequest& request);
00056         virtual RepublishResponse Republish(const RepublishParameters& request);
00057 
00058         void DeleteAllSubscriptions();
00059         boost::asio::io_service& GetIOService();
00060         bool PopPublishRequest(NodeId node);
00061         void TriggerEvent(NodeId node, Event event);
00062         Server::AddressSpace& GetAddressSpace();
00063 
00064       private:
00065         boost::asio::io_service& io;
00066         Server::AddressSpace::SharedPtr AddressSpace;
00067         bool Debug;
00068         mutable boost::shared_mutex DbMutex;
00069         SubscriptionsIdMap SubscriptionsMap; // Map SubscptioinId, SubscriptionData
00070         uint32_t LastSubscriptionId = 2;
00071         std::map<NodeId, uint32_t> PublishRequestQueues;
00072     };
00073 
00074 
00075   }
00076 
00077 }
00078 
00079 namespace 
00080 {
00081   OpcUa::ByteString GenerateEventId()
00082   {
00083     //stupid id generator
00084     OpcUa::ByteString str;
00085     for (int i = 0; i < 8; i++)
00086       {
00087         int32_t val = rand() % std::numeric_limits<int32_t>::max(); 
00088         str.Data.push_back(val);
00089       }
00090     return str;
00091   }
00092 }


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