Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2662

SbkConverter::copyToPython is null for "PySide6.QtOpcUa.QOpcUaReadResult"

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.7.0
    • 6.6.3
    • PySide
    • Windows 10 22H2, Python 3.11
    • 12744e330 (tqtc/dev), b7d62470a (tqtc/6.7.0), 142b02fd6 (tqtc/6.7)

    Description

      This issue seems similar to PYSIDE-1824

       

      Code
      Attached is a modifed version of the official OpcUa Viewer Example (https://doc.qt.io/qtforpython-6/examples/example_opcua_opcuaviewer.html ) where mainwindow.py was modified to call QOpcUaClient.readNodeAttributes(). The subsequent QOpcUaClient.readNodeAttributesFinished() signal is connected to a new slot called "onReadNodeAttributesFinished":

      # === THE FIRST FEW LINES ARE FROM THE EXAMPLE ===
      @Slot()
      def clientConnected(self):
          self._client_connected = True
          self.updateUiState()
      
          self._opcua_client.namespaceArrayUpdated.connect(self.namespacesArrayUpdated)
          self._opcua_client.updateNamespaceArray()
      
      
          # === NEW LINES ADDED BELOW HERE ===
          # This works out-of-the-box with the OPC UA C++ Demo Server (https://www.unified-automation.com/downloads/opc-ua-servers.html ).
          # If using a different server, replace the request ID with a valid node on your server.
          self._opcua_client.readNodeAttributesFinished.connect(self.onReadNodeAttributesFinished)
          request = [QOpcUaReadItem("ns=3;s=AirConditioner_1.Temperature")]
          self._opcua_client.readNodeAttributes(request)
      
      
      @Slot(list, QOpcUa.UaStatusCode)
      def onReadNodeAttributesFinished(self, results, serviceResult):
          print("Node attributes read. State: {} Result: {}".format(serviceResult, results))
          for result in results:
              if isinstance(result, QOpcUaReadResult):
                  print("{}: {} ({})".format(
                      result.nodeId(), result.value(), result.attribute()))
      

       

      Steps to reproduce

      1. Run your OPC UA server
      2. Load the attached example
      3. Ensure that OpenSSL is available in the PATH (required to load the "open62541" plugin)
      4. Run the example and connect to your server

       

      (Unfortunately, a real OPC UA server is required to trigger the QOpcUaClient.readNodeAttributesFinished() signal - manually emitting this using Python-constructed objects doesn't work)

       

      Outcomes

      C:\Qt\QtForPython\6.6.3\Src\examples\opcua\opcuaviewer\main.py:19: RuntimeWarning: CopyCppToPython(): SbkConverter::copyToPython is null for "PySide6.QtOpcUa.QOpcUaReadResult".
        sys.exit(app.exec())
      Node attributes read. State: UaStatusCode.Good Result: [None]
      

      Note: We expect the Result list to contain a PySide6.QtOpcUa.QOpcUaReadResult object instead of None

      [signal] void QOpcUaClient::readNodeAttributesFinished(QList<QOpcUaReadResult> results,
       QOpcUa::UaStatusCode serviceResult)
      

      Attachments

        1. opcuaviewer-modified.zip
          22 kB
        2. pyside2662_repro.diff
          2 kB
        3. pyside2662.zip
          23 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            skoh-qt Sze Howe Koh
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes