Build an OPC UA Client
-
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
-
Hi
Did you try the samples ?
https://doc-snapshots.qt.io/qtopcua/qtopcua-examples.html -
@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. -
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/ -
@LeLev
@mrjjHi,
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.
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