Unsolved OPCUA - match callback to read request
-
Hi,
I am trying to read values using the QOpcUaClient readNodeAttributes method and readNodeAttributesFinished signal.
We only have one QOpcUaClient instance in our app but multiple source code locations where we read data (and therefore have connected multiple slots to the readNodeAttributesFinished). This is obviously wrong because the reading of one item will (of course) trigger all slots and not just the one I want. The thing is: looking at the signal there seems no (easy) way to match the request to the response. Am I supposed to disconnect/connect signals all the time ? What if I have multiple operation in parallel ? Should I compare all nodeids I receive and hope that a match is unique ? Should I create multiple instances of QOpcUaClient (which is probably quite expensive) ?
Either I am missing something (obvious ?) or the QT OPC UA API is flawed.
To me it seems that the signal/slot mechanism is not well suited for this type of problem. Using signal / slot I would at least like to have a 'handle' to match requests and responses easily. Or better not use signal / slot at all and provide a lambda to the readNodeAttributes call.
Any help is appreciated.
Henning
-
I would at least like to have a 'handle' to match requests and responses easily
It looks like your looking for QObject::sender() function, see documentation about signals & slots...
For cases where you may require information on the sender of the signal, Qt provides the QObject::sender() function, which returns a pointer to the object that sent the signal.
Or better not use signal / slot at all
Mmm, it doesn't seem a good idea. Signals/slots are a very strong feature of Qt framework...