Go to last post Go to first unread
Offline C.Hauser  
#1 Posted : Wednesday, October 14, 2015 8:31:40 AM(UTC)

Rank: Newbie

Joined: 10/12/2015(UTC)
Posts: 1

Hey together,

I want to create and delete a monitored Item to my already existing data model of sessions and subscriptions:

I can iterate through the session and the subscriptions, but i cant seem to find the correct way in the documentation to create a monitored item to the subscription.


bool UaClient::CreateMonitoredItem(std::wstring paramSessionName, int paramSubscriptionId)
	bool result = false;

	Result status(DOMAIN_GENERAL, IResult::Bad);	

	std::vector<IUaClientSession*> allSessions_l  = m_uaConnection->GetAllSessions();

	for (vector<IUaClientSession*>::const_iterator session = allSessions_l.begin(), e = allSessions_l.end(); session != e; ++session)
		std::shared_ptr<IUaClientSessionConfiguration> sessionConfiguration_l =  (*session)->GetSessionConfiguration();
		Mtk::Ua::Stack::IUaString* sessionName = Mtk::Ua::Stack::IUaString::Create();

		(*sessionName) = sessionConfiguration_l->SessionName();		 
		char* chrptrSessionName;
		chrptrSessionName = (*sessionName).c_str();
		std::string sessionName_l(chrptrSessionName);
		string convertedSessionName(paramSessionName.begin(), paramSessionName.end());

		if(sessionName_l == convertedSessionName)
			std::vector<IUaSubscription*> allSubscriptions_l = (*session)->GetAllSubscriptions();
			for (vector<IUaSubscription*>::const_iterator subscription = allSubscriptions_l.begin(), e = allSubscriptions_l.end(); subscription != e; ++subscription)
				Mtk::General::uint32_t subscriptionID = (*subscription)->SubscriptionID();

				std::string subscriptionID_l;

				if(subscriptionID == paramSubscriptionId)
					 Mtk::Ua::Stack::ICreateMonitoredItemsRequest* request = Mtk::Ua::Stack::ICreateMonitoredItemsRequest::Create();
					(*request).SubscriptionId() = subscriptionID;
                                        //THIS IS WHERE I STUCK , ARE THESE LINES CORRECT ?											

	if (status.Succeeded())
		result = true;
		result = false;
	return result;

The method should create a monitored item on the given subscription in the parameters.

Can anyone help me ? I dont see the correct place in the documentation.


Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.