-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix calling stop monitored item callback. #132
Conversation
add verification code to template
@huebl , the PR is not ready to be merged. I'd like to write some unit tests before and discuss some questions. See my comments to the code. |
@@ -582,8 +582,9 @@ namespace OpcUaStackServer | |||
} | |||
|
|||
// check monitored item list | |||
monitoredItemIds_.erase(it1); | |||
if (newMonitoredItemIds.size() > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sure that this functional used to work correctly. But judging the history of file it could never work at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've understood. The problem is only for duplication monitored items inside of a single subscription. I tested my application with different clients.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L563-562: If there is a callback for starting monitored item but no for stopping. The start callback will be called only once. I'm not sure that it's correct.
For L517-518 is the same situation.
The algorithm seems too complicated. Why we need to know IDs of monitored items to count them? We could just increment and decrement a monitored item counter. |
@@ -582,8 +582,9 @@ namespace OpcUaStackServer | |||
} | |||
|
|||
// check monitored item list | |||
monitoredItemIds_.erase(it1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, The ID is not deleted if only one ID exists in the list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if there are other IDs, `newMonitoredItemIds' is not empty and I insert the rest IDs in L587.
if (newMonitoredItemIds.size() > 0) { | ||
monitoredItemIds_.insert(std::make_pair(baseNodeClass->nodeId().data(), monitoredItemIds)); | ||
monitoredItemIds_.insert(std::make_pair(baseNodeClass->nodeId().data(), newMonitoredItemIds)); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh , the same data will be inserted again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not the same. newMonitoredItemIds
has the rest of ID's and I re-insert them deleting old ID's before. See L585.
That is an error. The ID must always be removed from the list. If you take it exactly, the bookkeeping of Start and Stop would have to be independent of the callbacks. The following combinations are possible.
We should open a bug for this bug. |
The IDs are needed for the unique identification of parameter sets (sampling interval, queue size, ... ). Several Monitored Items for the same Node ID can have different parameter sets. The parameter sets are transferred to the application with the ID (Not yet in the current implementation). In the Monitored Stop, the ID is used to identify the Monitored Item inside the application. |
I accidentally executed the pull. Sorry. |
If several monitored items are created for a node in the same subscription, a user application becomes no callbacks when all of them will be deleted.