Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Build an OPC UA Client
QtWS25 Last Chance

Build an OPC UA Client

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 2.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mogli123
    wrote on 15 Jan 2019, 07:20 last edited by Mogli123
    #1

    Hi,

    I have created an OPC UA server (not in Qt), and now I want to create a client in Qt to get the data from my Siemens S7.
    I have Qt 5.12 and have added open62541.
    I do not know how I should proceed now, since I lack the experience.
    Does anyone have some experience and can help me with a sample code, for example?
    I have been working at Qt and C ++ for about 4 months and I am still a beginner.

    Thanks in advance.

    Mogli

    O 1 Reply Last reply 15 Jan 2019, 09:53
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 15 Jan 2019, 07:26 last edited by
      #2

      Hi
      Did you try the samples ?
      https://doc-snapshots.qt.io/qtopcua/qtopcua-examples.html

      M 1 Reply Last reply 15 Jan 2019, 09:39
      4
      • M mrjj
        15 Jan 2019, 07:26

        Hi
        Did you try the samples ?
        https://doc-snapshots.qt.io/qtopcua/qtopcua-examples.html

        M Offline
        M Offline
        Mogli123
        wrote on 15 Jan 2019, 09:39 last edited by
        #3

        @mrjj
        Yes I have, but I do not know for sure how to implement it in my project and what is necessary and what is not

        M 1 Reply Last reply 15 Jan 2019, 09:51
        0
        • M Mogli123
          15 Jan 2019, 09:39

          @mrjj
          Yes I have, but I do not know for sure how to implement it in my project and what is necessary and what is not

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 15 Jan 2019, 09:51 last edited by
          #4

          @Mogli123
          hi
          But that is kinda hard to answer for us as it depends on what your client does/needs.
          You do understand OPC as protocol/standard with nodes etc, I assume since you made a server ?

          if we look at
          https://doc-snapshots.qt.io/qtopcua/qtopcua-waterpump-waterpump-qmlcpp-example.html
          most is needed besides the HMI part.

          also if we look at
          https://doc-snapshots.qt.io/qtopcua/qtopcua-opcuaviewer-example.html
          all is needed for enumerating the nodes but again the listview is not.

          1 Reply Last reply
          3
          • M Mogli123
            15 Jan 2019, 07:20

            Hi,

            I have created an OPC UA server (not in Qt), and now I want to create a client in Qt to get the data from my Siemens S7.
            I have Qt 5.12 and have added open62541.
            I do not know how I should proceed now, since I lack the experience.
            Does anyone have some experience and can help me with a sample code, for example?
            I have been working at Qt and C ++ for about 4 months and I am still a beginner.

            Thanks in advance.

            Mogli

            O Offline
            O Offline
            ODБOï
            wrote on 15 Jan 2019, 09:53 last edited by
            #5

            Hi,
            @Mogli123 said in Build an OPC UA Client:

            I have Qt 5.12 and have added open62541.

            With Qt5.12 open62541 is added to Qt OPC UA so you only need to build qtopcua
            see this page for steps : build https://blog.basyskom.com/building-qt-opc-ua-with-open62541/

            M 1 Reply Last reply 22 Jan 2019, 07:25
            3
            • O ODБOï
              15 Jan 2019, 09:53

              Hi,
              @Mogli123 said in Build an OPC UA Client:

              I have Qt 5.12 and have added open62541.

              With Qt5.12 open62541 is added to Qt OPC UA so you only need to build qtopcua
              see this page for steps : build https://blog.basyskom.com/building-qt-opc-ua-with-open62541/

              M Offline
              M Offline
              Mogli123
              wrote on 22 Jan 2019, 07:25 last edited by Mogli123
              #6

              @LeLev
              @mrjj

              Hi,

              first thank you for your help.
              I read the examples and tried a bit around
              but I still do not understand how exactly I build a client and what I need exactly for building it.

              Sorry if it is not difficult but I can't managed it.

              I would like to read the following data (most of which are of the int32 type) shown in the pictures.

              0_1548141410270_2019-01-22_08h15_51.png

              0_1548141414758_2019-01-22_08h15_45.png

              Taht's my code so far (it's from the examle from this page link text)

                  QOpcUaProvider provider;
              //    if (provider.availableBackends().isEmpty())
              //        return;
                  QOpcUaClient *client = provider.createClient(provider.availableBackends()[0]);
              //    if (!client)
              //        return;
                  // Connect to the stateChanged signal. Compatible slots of QObjects can be used instead of a lambda.
                  QObject::connect(client, &QOpcUaClient::stateChanged, [client](QOpcUaClient::ClientState state) {
                      qDebug() << "Client state changed:" << state;
                      if (state == QOpcUaClient::ClientState::Connected) {
                          QOpcUaNode *node = client->node("ns=0;i=84");
                          if (node)
                              qDebug() << "A node object has been created";
                      }
                  });
                  client->connectToEndpoint(QUrl("opc.tcp://WIN-B39D138RQ4S:55101")); // Connect the client to the server 
              

              I know I have to crate nodes but I don't knwo how exaclty...

              I hope you can explain to me how I should do it, what I need and why exactly.
              I would be very grateful.
              I do not want to copy a program, I would like to understand it.

              I'm not an expert in c + + apologize for asking stupid questions.

              Thanks in advance

              Greetings Mogli

              O 1 Reply Last reply 22 Jan 2019, 08:09
              0
              • M Mogli123
                22 Jan 2019, 07:25

                @LeLev
                @mrjj

                Hi,

                first thank you for your help.
                I read the examples and tried a bit around
                but I still do not understand how exactly I build a client and what I need exactly for building it.

                Sorry if it is not difficult but I can't managed it.

                I would like to read the following data (most of which are of the int32 type) shown in the pictures.

                0_1548141410270_2019-01-22_08h15_51.png

                0_1548141414758_2019-01-22_08h15_45.png

                Taht's my code so far (it's from the examle from this page link text)

                    QOpcUaProvider provider;
                //    if (provider.availableBackends().isEmpty())
                //        return;
                    QOpcUaClient *client = provider.createClient(provider.availableBackends()[0]);
                //    if (!client)
                //        return;
                    // Connect to the stateChanged signal. Compatible slots of QObjects can be used instead of a lambda.
                    QObject::connect(client, &QOpcUaClient::stateChanged, [client](QOpcUaClient::ClientState state) {
                        qDebug() << "Client state changed:" << state;
                        if (state == QOpcUaClient::ClientState::Connected) {
                            QOpcUaNode *node = client->node("ns=0;i=84");
                            if (node)
                                qDebug() << "A node object has been created";
                        }
                    });
                    client->connectToEndpoint(QUrl("opc.tcp://WIN-B39D138RQ4S:55101")); // Connect the client to the server 
                

                I know I have to crate nodes but I don't knwo how exaclty...

                I hope you can explain to me how I should do it, what I need and why exactly.
                I would be very grateful.
                I do not want to copy a program, I would like to understand it.

                I'm not an expert in c + + apologize for asking stupid questions.

                Thanks in advance

                Greetings Mogli

                O Offline
                O Offline
                ODБOï
                wrote on 22 Jan 2019, 08:09 last edited by
                #7

                @Mogli123 Hi, Using Qt OPC UA in a basic UI application example is very good. Try to understand it

                M 1 Reply Last reply 12 Feb 2019, 10:18
                6
                • O ODБOï
                  22 Jan 2019, 08:09

                  @Mogli123 Hi, Using Qt OPC UA in a basic UI application example is very good. Try to understand it

                  M Offline
                  M Offline
                  Mogli123
                  wrote on 12 Feb 2019, 10:18 last edited by
                  #8

                  @LeLev
                  @mrjj
                  now it works
                  thank you for your tips

                  1 Reply Last reply
                  1

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved