summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorRainer Keller <Rainer.Keller@qt.io>2018-11-22 13:37:59 +0100
committerRainer Keller <Rainer.Keller@qt.io>2019-01-21 14:39:49 +0000
commit8b3792ef1893767fad158be2ac17a7c16785cd59 (patch)
tree7354d8df2fbb53bb1d28c017f754be21e245fad3 /examples
parent660f132a5b5e409e621b7900f46741686278dfb0 (diff)
Move classes out of namespace
All classes are moved out of the QOpcUa namespace and separated into separate files. Historically we had namespaced classes and classed with a prefix, which led to confusion. To unify the API, this change removes the namespace as the rest of Qt isn't typically namespaced. [ChangeLog][QOpcUa] All classes from the QOpcUA namespace are renamed: QOpcUa::Typename to QOpcUaQTypename Change-Id: I981645e0a9b4d769ad73ab4b9a9268019904b378 Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/opcua/opcuaviewer/mainwindow.cpp6
-rw-r--r--examples/opcua/opcuaviewer/mainwindow.h8
-rw-r--r--examples/opcua/opcuaviewer/treeitem.cpp70
-rw-r--r--examples/opcua/opcuaviewer/treeitem.h8
-rw-r--r--examples/opcua/waterpump/waterpump-qmlcpp/opcuamachinebackend.cpp2
-rw-r--r--examples/opcua/waterpump/waterpump-qmlcpp/opcuamachinebackend.h2
6 files changed, 54 insertions, 42 deletions
diff --git a/examples/opcua/opcuaviewer/mainwindow.cpp b/examples/opcua/opcuaviewer/mainwindow.cpp
index eb91531..f829a8f 100644
--- a/examples/opcua/opcuaviewer/mainwindow.cpp
+++ b/examples/opcua/opcuaviewer/mainwindow.cpp
@@ -251,9 +251,9 @@ void MainWindow::findServers()
}
}
-void MainWindow::findServersComplete(const QVector<QOpcUa::QApplicationDescription> &servers, QOpcUa::UaStatusCode statusCode)
+void MainWindow::findServersComplete(const QVector<QOpcUaApplicationDescription> &servers, QOpcUa::UaStatusCode statusCode)
{
- QOpcUa::QApplicationDescription server;
+ QOpcUaApplicationDescription server;
if (isSuccessStatus(statusCode)) {
mServers->clear();
@@ -279,7 +279,7 @@ void MainWindow::getEndpoints()
}
}
-void MainWindow::getEndpointsComplete(const QVector<QOpcUa::QEndpointDescription> &endpoints, QOpcUa::UaStatusCode statusCode)
+void MainWindow::getEndpointsComplete(const QVector<QOpcUaEndpointDescription> &endpoints, QOpcUa::UaStatusCode statusCode)
{
int index = 0;
const char *modes[] = {
diff --git a/examples/opcua/opcuaviewer/mainwindow.h b/examples/opcua/opcuaviewer/mainwindow.h
index 1457e3b..cf8b5a6 100644
--- a/examples/opcua/opcuaviewer/mainwindow.h
+++ b/examples/opcua/opcuaviewer/mainwindow.h
@@ -75,9 +75,9 @@ public:
private slots:
void connectToServer();
void findServers();
- void findServersComplete(const QVector<QOpcUa::QApplicationDescription> &servers, QOpcUa::UaStatusCode statusCode);
+ void findServersComplete(const QVector<QOpcUaApplicationDescription> &servers, QOpcUa::UaStatusCode statusCode);
void getEndpoints();
- void getEndpointsComplete(const QVector<QOpcUa::QEndpointDescription> &endpoints, QOpcUa::UaStatusCode statusCode);
+ void getEndpointsComplete(const QVector<QOpcUaEndpointDescription> &endpoints, QOpcUa::UaStatusCode statusCode);
void clientConnected();
void clientDisconnected();
void namespacesArrayUpdated(const QStringList &namespaceArray);
@@ -105,11 +105,11 @@ private:
OpcUaModel *mOpcUaModel;
QOpcUaProvider *mOpcUaProvider;
QOpcUaClient *mOpcUaClient;
- QVector<QOpcUa::QEndpointDescription> mEndpointList;
+ QVector<QOpcUaEndpointDescription> mEndpointList;
bool mClientConnected;
QOpcUaApplicationIdentity m_identity;
QOpcUaPkiConfiguration m_pkiConfig;
- QOpcUa::QEndpointDescription m_endpoint; // current endpoint used to connect
+ QOpcUaEndpointDescription m_endpoint; // current endpoint used to connect
};
QT_END_NAMESPACE
diff --git a/examples/opcua/opcuaviewer/treeitem.cpp b/examples/opcua/opcuaviewer/treeitem.cpp
index 56b10a7..b069189 100644
--- a/examples/opcua/opcuaviewer/treeitem.cpp
+++ b/examples/opcua/opcuaviewer/treeitem.cpp
@@ -50,7 +50,17 @@
#include "treeitem.h"
#include "opcuamodel.h"
+#include <QOpcUaArgument>
+#include <QOpcUaAxisInformation>
#include <QOpcUaClient>
+#include <QOpcUaComplexNumber>
+#include <QOpcUaDoubleComplexNumber>
+#include <QOpcUaEUInformation>
+#include <QOpcUaExtensionObject>
+#include <QOpcUaLocalizedText>
+#include <QOpcUaQualifiedName>
+#include <QOpcUaRange>
+#include <QOpcUaXValue>
#include <QMetaEnum>
#include <QPixmap>
@@ -151,7 +161,7 @@ QVariant TreeItem::data(int column)
if (!mAttributesReady)
return tr("Loading ...");
- return mOpcNode->attribute(QOpcUa::NodeAttribute::Description).value<QOpcUa::QLocalizedText>().text();
+ return mOpcNode->attribute(QOpcUa::NodeAttribute::Description).value<QOpcUaLocalizedText>().text();
}
return QVariant();
}
@@ -228,9 +238,9 @@ void TreeItem::handleAttributes(QOpcUa::NodeAttributes attr)
if (attr & QOpcUa::NodeAttribute::NodeClass)
mNodeClass = mOpcNode->attribute(QOpcUa::NodeAttribute::NodeClass).value<QOpcUa::NodeClass>();
if (attr & QOpcUa::NodeAttribute::BrowseName)
- mNodeBrowseName = mOpcNode->attribute(QOpcUa::NodeAttribute::BrowseName).value<QOpcUa::QQualifiedName>().name();
+ mNodeBrowseName = mOpcNode->attribute(QOpcUa::NodeAttribute::BrowseName).value<QOpcUaQualifiedName>().name();
if (attr & QOpcUa::NodeAttribute::DisplayName)
- mNodeDisplayName = mOpcNode->attribute(QOpcUa::NodeAttribute::DisplayName).value<QOpcUa::QLocalizedText>().text();
+ mNodeDisplayName = mOpcNode->attribute(QOpcUa::NodeAttribute::DisplayName).value<QOpcUaLocalizedText>().text();
mAttributesReady = true;
emit mModel->dataChanged(mModel->createIndex(row(), 0, this), mModel->createIndex(row(), numberOfDisplayColumns - 1, this));
@@ -294,48 +304,48 @@ QString TreeItem::variantToString(const QVariant &value, const QString &typeNode
return QLatin1String("0x") + value.toByteArray().toHex();
else if (value.type() == QVariant::DateTime)
return value.toDateTime().toString(Qt::ISODate);
- else if (value.canConvert<QOpcUa::QQualifiedName>()) {
- const auto name = value.value<QOpcUa::QQualifiedName>();
+ else if (value.canConvert<QOpcUaQualifiedName>()) {
+ const auto name = value.value<QOpcUaQualifiedName>();
return QStringLiteral("[NamespaceIndex: %1, Name: \"%2\"]").arg(name.namespaceIndex()).arg(name.name());
- } else if (value.canConvert<QOpcUa::QLocalizedText>()) {
- const auto text = value.value<QOpcUa::QLocalizedText>();
+ } else if (value.canConvert<QOpcUaLocalizedText>()) {
+ const auto text = value.value<QOpcUaLocalizedText>();
return localizedTextToString(text);
- } else if (value.canConvert<QOpcUa::QRange>()) {
- const auto range = value.value<QOpcUa::QRange>();
+ } else if (value.canConvert<QOpcUaRange>()) {
+ const auto range = value.value<QOpcUaRange>();
return rangeToString(range);
- } else if (value.canConvert<QOpcUa::QComplexNumber>()) {
- const auto complex = value.value<QOpcUa::QComplexNumber>();
+ } else if (value.canConvert<QOpcUaComplexNumber>()) {
+ const auto complex = value.value<QOpcUaComplexNumber>();
return QStringLiteral("[Real: %1, Imaginary: %2]").arg(complex.real()).arg(complex.imaginary());
- } else if (value.canConvert<QOpcUa::QDoubleComplexNumber>()) {
- const auto complex = value.value<QOpcUa::QDoubleComplexNumber>();
+ } else if (value.canConvert<QOpcUaDoubleComplexNumber>()) {
+ const auto complex = value.value<QOpcUaDoubleComplexNumber>();
return QStringLiteral("[Real: %1, Imaginary: %2]").arg(complex.real()).arg(complex.imaginary());
- } else if (value.canConvert<QOpcUa::QXValue>()) {
- const auto xv = value.value<QOpcUa::QXValue>();
+ } else if (value.canConvert<QOpcUaXValue>()) {
+ const auto xv = value.value<QOpcUaXValue>();
return QStringLiteral("[X: %1, Value: %2]").arg(xv.x()).arg(xv.value());
- } else if (value.canConvert<QOpcUa::QEUInformation>()) {
- const auto info = value.value<QOpcUa::QEUInformation>();
+ } else if (value.canConvert<QOpcUaEUInformation>()) {
+ const auto info = value.value<QOpcUaEUInformation>();
return euInformationToString(info);
- } else if (value.canConvert<QOpcUa::QAxisInformation>()) {
- const auto info = value.value<QOpcUa::QAxisInformation>();
+ } else if (value.canConvert<QOpcUaAxisInformation>()) {
+ const auto info = value.value<QOpcUaAxisInformation>();
return QStringLiteral("[EUInformation: %1, EURange: %2, Title: %3 , AxisScaleType: %4, AxisSteps: %5]").arg(
euInformationToString(info.engineeringUnits())).arg(rangeToString(info.eURange())).arg(localizedTextToString(info.title())).arg(
info.axisScaleType() == QOpcUa::AxisScale::Linear ? "Linear" : (info.axisScaleType() == QOpcUa::AxisScale::Ln) ? "Ln" : "Log").arg(
numberArrayToString(info.axisSteps()));
- } else if (value.canConvert<QOpcUa::QExpandedNodeId>()) {
- const auto id = value.value<QOpcUa::QExpandedNodeId>();
+ } else if (value.canConvert<QOpcUaExpandedNodeId>()) {
+ const auto id = value.value<QOpcUaExpandedNodeId>();
return QStringLiteral("[NodeId: \"%1\", ServerIndex: \"%2\", NamespaceUri: \"%3\"]").arg(
id.nodeId()).arg(id.serverIndex()).arg(id.namespaceUri());
- } else if (value.canConvert<QOpcUa::QArgument>()) {
- const auto a = value.value<QOpcUa::QArgument>();
+ } else if (value.canConvert<QOpcUaArgument>()) {
+ const auto a = value.value<QOpcUaArgument>();
return QStringLiteral("[Name: \"%1\", DataType: \"%2\", ValueRank: \"%3\", ArrayDimensions: %4, Description: %5]").arg(
a.name()).arg(a.dataTypeId()).arg(a.valueRank()).arg(numberArrayToString(a.arrayDimensions())).arg(
localizedTextToString(a.description()));
- } else if (value.canConvert<QOpcUa::QExtensionObject>()) {
- const auto obj = value.value<QOpcUa::QExtensionObject>();
+ } else if (value.canConvert<QOpcUaExtensionObject>()) {
+ const auto obj = value.value<QOpcUaExtensionObject>();
return QStringLiteral("[TypeId: \"%1\", Encoding: %2, Body: 0x%3]").arg(obj.encodingTypeId()).arg(
- obj.encoding() == QOpcUa::QExtensionObject::Encoding::NoBody ?
- "NoBody" : (obj.encoding() == QOpcUa::QExtensionObject::Encoding::ByteString ?
+ obj.encoding() == QOpcUaExtensionObject::Encoding::NoBody ?
+ "NoBody" : (obj.encoding() == QOpcUaExtensionObject::Encoding::ByteString ?
"ByteString" : "XML")).arg(obj.encodedBody().isEmpty() ? "0" : QString(obj.encodedBody().toHex()));
}
@@ -345,17 +355,17 @@ QString TreeItem::variantToString(const QVariant &value, const QString &typeNode
return QString();
}
-QString TreeItem::localizedTextToString(const QOpcUa::QLocalizedText &text) const
+QString TreeItem::localizedTextToString(const QOpcUaLocalizedText &text) const
{
return QStringLiteral("[Locale: \"%1\", Text: \"%2\"]").arg(text.locale()).arg(text.text());
}
-QString TreeItem::rangeToString(const QOpcUa::QRange &range) const
+QString TreeItem::rangeToString(const QOpcUaRange &range) const
{
return QStringLiteral("[Low: %1, High: %2]").arg(range.low()).arg(range.high());
}
-QString TreeItem::euInformationToString(const QOpcUa::QEUInformation &info) const
+QString TreeItem::euInformationToString(const QOpcUaEUInformation &info) const
{
return QStringLiteral("[UnitId: %1, NamespaceUri: \"%2\", DisplayName: %3, Description: %4]").arg(info.unitId()).arg(
info.namespaceUri()).arg(localizedTextToString(info.displayName())).arg(localizedTextToString(info.description()));
diff --git a/examples/opcua/opcuaviewer/treeitem.h b/examples/opcua/opcuaviewer/treeitem.h
index bc3c8a9..eef36a7 100644
--- a/examples/opcua/opcuaviewer/treeitem.h
+++ b/examples/opcua/opcuaviewer/treeitem.h
@@ -58,6 +58,8 @@
QT_BEGIN_NAMESPACE
class OpcUaModel;
+class QOpcUaRange;
+class QOpcUaEUInformation;
class TreeItem : public QObject
{
@@ -89,9 +91,9 @@ protected:
private:
QString variantToString(const QVariant &value, const QString &typeNodeId = QString()) const;
- QString localizedTextToString(const QOpcUa::QLocalizedText &text) const;
- QString rangeToString(const QOpcUa::QRange &range) const;
- QString euInformationToString(const QOpcUa::QEUInformation &info) const;
+ QString localizedTextToString(const QOpcUaLocalizedText &text) const;
+ QString rangeToString(const QOpcUaRange &range) const;
+ QString euInformationToString(const QOpcUaEUInformation &info) const;
template <typename T>
QString numberArrayToString(const QVector<T> &vec) const;
diff --git a/examples/opcua/waterpump/waterpump-qmlcpp/opcuamachinebackend.cpp b/examples/opcua/waterpump/waterpump-qmlcpp/opcuamachinebackend.cpp
index f1971ce..e6ac84e 100644
--- a/examples/opcua/waterpump/waterpump-qmlcpp/opcuamachinebackend.cpp
+++ b/examples/opcua/waterpump/waterpump-qmlcpp/opcuamachinebackend.cpp
@@ -284,7 +284,7 @@ void OpcUaMachineBackend::resetSimulation()
m_machineNode->callMethod("ns=2;s=Machine.Reset");
}
-void OpcUaMachineBackend::requestEndpointsFinished(const QVector<QOpcUa::QEndpointDescription> &endpoints)
+void OpcUaMachineBackend::requestEndpointsFinished(const QVector<QOpcUaEndpointDescription> &endpoints)
{
if (endpoints.isEmpty()) {
qWarning() << "The server did not return any endpoints";
diff --git a/examples/opcua/waterpump/waterpump-qmlcpp/opcuamachinebackend.h b/examples/opcua/waterpump/waterpump-qmlcpp/opcuamachinebackend.h
index 4ea39a0..21f564e 100644
--- a/examples/opcua/waterpump/waterpump-qmlcpp/opcuamachinebackend.h
+++ b/examples/opcua/waterpump/waterpump-qmlcpp/opcuamachinebackend.h
@@ -102,7 +102,7 @@ public:
Q_INVOKABLE void resetSimulation();
public slots:
- void requestEndpointsFinished(const QVector<QOpcUa::QEndpointDescription> &endpoints);
+ void requestEndpointsFinished(const QVector<QOpcUaEndpointDescription> &endpoints);
void clientStateHandler(QOpcUaClient::ClientState state);
void machineStateUpdated(QOpcUa::NodeAttribute attr, const QVariant &value);
void percentFilledTank1Updated(QOpcUa::NodeAttribute attr, const QVariant &value);