3 #include <boost/thread/locks.hpp> 14 , CurrentSession(SessionAuthenticationToken)
16 , io(service.GetIOService())
17 , Timer(io,
boost::posix_time::microseconds(static_cast<unsigned long>(1000 * data.RevisedPublishingInterval)))
18 , LifeTimeCount(data.RevisedLifetimeCount)
27 std::shared_ptr<InternalSubscription>
self = shared_from_this();
28 Timer.async_wait([
self](
const boost::system::error_code & error) {
self->PublishResults(error); });
48 std::vector<uint32_t> handles;
50 boost::shared_lock<boost::shared_mutex> lock(
DbMutex);
54 handles.push_back(pair.first);
90 if (results.size() > 0)
109 std::shared_ptr<InternalSubscription>
self = shared_from_this();
110 Timer.async_wait([
self](
const boost::system::error_code & error) {
self->PublishResults(error); });
116 boost::unique_lock<boost::shared_mutex> lock(
DbMutex);
138 boost::unique_lock<boost::shared_mutex> lock(
DbMutex);
148 result.NotificationMessage.NotificationData.push_back(data);
163 TriggeredEvents.clear();
165 result.NotificationMessage.NotificationData.push_back(data);
173 mdc.second.TriggerCount = 0;
183 result.MoreNotifications =
false;
187 result.AvailableSequenceNumbers.push_back(res.NotificationMessage.SequenceNumber);
190 NotAcknowledgedResults.push_back(result);
192 LOG_DEBUG(
Logger,
"internal_subscription | id: {}, sending PublishResult with: {} notifications",
Data.
SubscriptionId, result.NotificationMessage.NotificationData.size());
194 std::vector<PublishResult> resultlist;
195 resultlist.push_back(result);
204 boost::unique_lock<boost::shared_mutex> lock(
DbMutex);
260 TriggeredDataChangeEvents.clear();
267 boost::unique_lock<boost::shared_mutex> lock(
DbMutex);
278 uint32_t callbackHandle = 0;
280 boost::unique_lock<boost::shared_mutex> lock(
DbMutex);
310 this->DataChangeCallback(id, value);
316 boost::unique_lock<boost::shared_mutex> lock(
DbMutex);
346 std::vector<DataValue> vals =
AddressSpace.Read(params);
351 event.Data.Value = vals[0];
353 boost::unique_lock<boost::shared_mutex> lock(
DbMutex);
361 std::vector<StatusCode> results;
363 for (
const uint32_t &
handle : monitoreditemsids)
388 boost::unique_lock<boost::shared_mutex> lock(
DbMutex);
399 if (it->second.CallbackHandle != 0)
403 AddressSpace.DeleteDataChangeCallback(it->second.CallbackHandle);
412 if (
ev->MonitoredItemId == handle)
431 boost::unique_lock<boost::shared_mutex> lock(
DbMutex);
435 if (pair.second == handle)
437 MonitoredEvents.erase(pair.first);
442 if (
ev->MonitoredItemId == handle)
464 boost::unique_lock<boost::shared_mutex> lock(
DbMutex);
484 event.Data.ClientHandle = monitoredDataChange.
ClientHandle;
485 event.Data.Value = value;
495 boost::shared_lock<boost::shared_mutex> lock(
DbMutex);
514 boost::unique_lock<boost::shared_mutex> lock(
DbMutex);
517 std::map<uint32_t, MonitoredDataChange>::iterator mii_it =
MonitoredDataChanges.find(monitoredItemId);
541 std::vector<Variant> fields;
560 fields.push_back(event.
EventId);
582 fields.push_back(event.
Message);
602 fields.push_back(event.
Time);
void TriggerDataChangeEvent(MonitoredDataChange monitoreditems, ReadValueId attrval)
double RequestedPublishingInterval
std::vector< OpcUa::ReadValueId > AttributesToRead
bool PopPublishRequest(NodeId node)
#define LOG_TRACE(__logger__,...)
uint32_t RevisedMaxKeepAliveCount
#define LOG_WARN(__logger__,...)
uint32_t RevisedLifetimeCount
Opc Ua computer interface. GNU LGPL.
MonitoredItemCreateResult Parameters
bool EnqueueEvent(uint32_t monitoreditemid, const Event &event)
uint32_t RetransmitSequenceNumber
uint32_t RevisedQueueSize
std::vector< QualifiedName > BrowsePath
#define LOG_DEBUG(__logger__,...)
void PublishResults(const boost::system::error_code &error)
std::list< PublishResult > NotAcknowledgedResults
OpcUa::MonitoringFilter Filter
RepublishResponse Republish(const RepublishParameters ¶ms)
const NodeId CurrentSession
uint32_t RevisedLifetimeCount
std::function< void(PublishResult)> Callback
std::vector< SimpleAttributeOperand > SelectClauses
std::vector< Variant > EventFields
OpcUa::MonitoringFilter FilterResult
uint32_t RequestedMaxKeepAliveCount
double RevisedPublishingInterval
bool DeleteMonitoredEvent(uint32_t handle)
double RevisedPublishingInterval
void NewAcknowlegment(const SubscriptionAcknowledgement &ack)
std::list< TriggeredEvent > TriggeredEvents
SubscriptionServiceInternal & Service
InternalSubscription(SubscriptionServiceInternal &service, const SubscriptionData &data, const NodeId &SessionAuthenticationToken, std::function< void(PublishResult)> Callback, const Common::Logger::SharedPtr &logger)
void TriggerEvent(NodeId node, Event event)
uint32_t NotificationSequence
std::vector< Variant > GetEventFields(const EventFilter &filter, const Event &event)
Common::Logger::SharedPtr Logger
std::vector< StatusCode > DeleteMonitoredItemsIds(const std::vector< uint32_t > &ids)
OPC UA Address space part. GNU LGPL.
MonitoredItemCreateResult CreateMonitoredItem(const MonitoredItemCreateRequest &request)
uint32_t RevisedMaxKeepAliveCount
double RevisedSamplingInterval
Variant GetValue(const std::vector< QualifiedName > &path) const
std::vector< EventFieldList > Events
uint32_t LastMonitoredItemId
void DataChangeCallback(const uint32_t &, const DataValue &value)
std::vector< PublishResult > PopPublishResult()
void DeleteAllMonitoredItems()
static DateTime Current()
std::list< TriggeredDataChange > TriggeredDataChangeEvents
NotificationData GetNotificationData()
bool DeleteMonitoredDataChange(uint32_t handle)
uint32_t RequestedLifetimeCount
boost::asio::deadline_timer Timer
OpcUa::AttributeId AttributeId
OpcUa::MonitoringParameters RequestedParameters
OpcUa::NotificationMessage NotificationMessage
OpcUa::ReadValueId ItemToMonitor
boost::shared_mutex DbMutex
std::vector< MonitoredItems > Notification
OpcUa::ResponseHeader Header
MonitoredDataChangeMap MonitoredDataChanges
ModifySubscriptionResult ModifySubscription(const ModifySubscriptionParameters &data)
MonitoredEventsMap MonitoredEvents
OpcUa::NotificationMessage NotificationMessage
OpcUa::MonitoringMode MonitoringMode