1// Copyright (C) 2015 basysKom GmbH, opensource@basyskom.com
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qopcuatype.h"
5
6#include <private/qopcuasecuritypolicyuris_p.h>
7
8#include <QMetaEnum>
9#include <QRegularExpression>
10#include <QUuid>
11#include <QString>
12#include <QList>
13
14QT_BEGIN_NAMESPACE
15
16using namespace Qt::Literals::StringLiterals;
17
18/*!
19 \namespace QOpcUa
20 \inmodule QtOpcua
21
22 \brief The QOpcUa namespace contains miscellaneous identifiers used throughout the Qt OPC UA library.
23*/
24
25/*!
26 \enum QOpcUa::NodeClass
27
28 This enum specifies the class a node belongs to. OPC UA specifies a fixed
29 set of eight different classes.
30
31 \value Undefined The node class is not known. This is the case before
32 the NodeClass attribute has been read on the server.
33
34 \value Object An Object node.
35 \value Variable A Variable node.
36 \value Method A Method node.
37 \value ObjectType An ObjectType node.
38 \value VariableType A VariableType node.
39 \value ReferenceType A ReferenceType node.
40 \value DataType A DataType node.
41 \value View A View node.
42*/
43
44/*!
45 \enum QOpcUa::ReferenceTypeId
46
47 This enum contains the reference types specified in OPC UA 1.05 part 3, 7.
48 They are used to filter for a certain reference type in \l QOpcUaNode::browseChildren
49 and for the reference type information in \l QOpcUaReferenceDescription.
50
51 \value Unspecified Not a valid reference type.
52 \value References The abstract base type for all references.
53 \value NonHierarchicalReferences The abstract base type for all non-hierarchical references.
54 \value HierarchicalReferences The abstract base type for all hierarchical references.
55 \value HasChild The abstract base type for all non-looping hierarchical references.
56 \value Organizes The type for hierarchical references that are used to organize nodes.
57 \value HasEventSource The type for non-looping hierarchical references that are used to organize event sources.
58 \value HasModellingRule The type for references from instance declarations to modelling rule nodes.
59 \value HasEncoding The type for references from data type nodes to to data type encoding nodes.
60 \value HasDescription The type for references from data type encoding nodes to data type description nodes.
61 \value HasTypeDefinition The type for references from a instance node to its type definition node.
62 \value GeneratesEvent The type for references from a node to an event type that is raised by node.
63 \value Aggregates The type for non-looping hierarchical references that are used to aggregate nodes into complex types.
64 \value HasSubtype The type for non-looping hierarchical references that are used to define sub types.
65 \value HasProperty The type for non-looping hierarchical reference from a node to its property.
66 \value HasComponent The type for non-looping hierarchical reference from a node to its component.
67 \value HasNotifier The type for non-looping hierarchical references that are used to indicate how events propagate from node to node.
68 \value HasOrderedComponent The type for non-looping hierarchical reference from a node to its component when the order of references matters.
69 \value FromState The type for a reference to the state before a transition.
70 \value ToState The type for a reference to the state after a transition.
71 \value HasCause The type for a reference to a method that can cause a transition to occur.
72 \value HasEffect The type for a reference to an event that may be raised when a transition occurs.
73 \value HasHistoricalConfiguration The type for a reference to the historical configuration for a data variable.
74 \value HasSubStateMachine The type for a reference to a substate for a state.
75 \value HasArgumentDescription The type for a reference to an argument description
76 \value HasOptionalInputArgumentDescription The type for a reference to an optional input argument description
77 \value AlwaysGeneratesEvent The type for references from a node to an event type that is always raised by node.
78 \value HasTrueSubState The type for references from a TRUE super state node to a subordinate state node.
79 \value HasFalseSubState The type for references from a FALSE super state node to a subordinate state node.
80 \value HasCondition The type for references from a ConditionSource node to a Condition.
81 \value HasPubSubConnection The type for a reference to a PubSub connection
82 \value DataSetToWriter The type for a reference to a data set writer
83 \value HasGuard The type for a reference to a guard
84 \value HasDataSetWriter The type for a reference to a data set writer
85 \value HasDataSetReader The type for a reference to data set reader
86 \value HasAlarmSuppressionGroup The type for a reference to an alarm suppression group
87 \value AlarmGroupMember The type for a reference to an alarm group member
88 \value HasEffectDisable The type for a reference to an alarm which is disabled by a transition
89 \value HasDictionaryEntry The type for a reference to a dictionary entry
90 \value HasInterface The type for a reference to an interface
91 \value HasAddIn The type for a reference to an addin
92 \value HasEffectEnable The type for a reference to an alarm which is enabled by a transition
93 \value HasEffectSuppressed The type for a reference to an alarm which is suppressed by a transition
94 \value HasEffectUnsuppressed The type for a reference to an alarm which is unsuppressed by a transition
95 \value HasWriterGroup The type for a reference to a writer group
96 \value HasReaderGroup The type for a reference to a reader group
97 \value AliasFor The type for a reference to the node represented by an alias
98 \value IsDeprecated The type for a reference to the information model where the starting node was first deprecated
99 \value HasStructuredComponent Indicate that a VariableType or Variable also exposes its Structure fields as Variables in the information model
100 \value AssociatedWith The type for a reference to indicate an association between two nodes
101 \value UsesPriorityMappingTable The type for a reference to indicate usage of a priority mapping table
102 \value HasLowerLayerInterface Virtual interfaces shall reference their physical interfaces with this reference type
103 \value IsExecutableOn The type for a reference to relate a software component to its execution environment
104 \value Controls Relates a controlling component to the components controlled by the controlling component
105 \value Utilizes Relates a component to other components that are needed by the component in order to work
106 \value Requires Relates a component to other components it requires in order to work
107 \value IsPhysicallyConnectedTo Connects two components that are physically connected, without one being a subcomponent of the other
108 \value RepresentsSameEntityAs The type for a reference to indicate that two nodes represent the same entity
109 \value RepresentsSameHardwareAs The type for a reference to indicate that two nodes represent the same hardware
110 \value RepresentsSameFunctionalityAs The type for a reference to indicate that two nodes represent the same functionality
111 \value IsHostedBy Relates functionality represented by an OPC UA Node to the hardware and software needed to provide the functionality
112 \value HasPhysicalComponent Relates a hardware component to its subcomponent, which is also a hardware component
113 \value HasContainedComponent Relates a hardware component to its subcomponent that is inside the component.
114 \value HasAttachedComponent Indicates that the subcomponent is attached to the component
115 \value IsExecutingOn The type for a reference to relate a software component to its current execution environment
116 \value HasPushedSecurityGroup The type for a reference to a pushed security group
117 \value [since 6.9] AlarmSuppressionGroupMember Connects alarm instances or bool variables to an alarm group
118 \value [since 6.9] HasReferenceDescription Connects a node of any node class to a reference description variable.
119*/
120
121/*!
122\enum QOpcUa::NodeAttribute
123
124 This enum contains the 22 node attributes defined in OPC UA 1.05 part 3, 5.
125
126 \value None No node attribute.
127 \value NodeId Mandatory for all nodes. Contains the node's id in the OPC UA address space.
128 \value NodeClass Mandatory for all nodes. Contains the node id describing the node class of the node.
129 \value BrowseName Mandatory for all nodes. Contains a non-localized human readable name of the node.
130 \value DisplayName Mandatory for all nodes. Contains a localized human readable name for display purposes.
131 \value Description Contains a localized human readable description of the node.
132 \value WriteMask Contains a bit mask. Each bit corresponds to a writable attribute (OPC UA 1.05 part 3, 8.60).
133 \value UserWriteMask Same as WriteMask but for the current user.
134 \value IsAbstract True if the node is an abstract type which means that no nodes of this type shall exist.
135 \value Symmetric True if a reference's meaning is the same seen from both ends.
136 \value InverseName The localized inverse name of a reference (for example "HasSubtype" has the InverseName "SubtypeOf").
137 \value ContainsNoLoops True if there is no way to get back to a node following forward references in the current view.
138 \value EventNotifier Contains a bit mask used to indicate if subscribing to events and access to historic events is supported (OPC UA 1.05 part 3, 8.59).
139 \value Value The value of a Variable node.
140 \value DataType The NodeId of the Value attribute's data type (for example "ns=0;i=13" for DateTime, see https://opcfoundation.org/UA/schemas/1.05/NodeIds.csv).
141 \value ValueRank Contains information about the structure of the Value attribute (scalar/array) (OPC UA 1.05 part 3, 5.6.2).
142 \value ArrayDimensions An array containing the length for each dimension of a multi-dimensional array.
143 \value AccessLevel Contains a bit mask. Each bit corresponds to an access capability (OPC UA 1.05 part 3, 5.6.2).
144 \value UserAccessLevel Same as AccessLevel, but for the current user.
145 \value MinimumSamplingInterval Contains the shortest possible interval in which the server is able to sample the value.
146 \value Historizing True if historical data is collected.
147 \value Executable True if the node is currently executable. Only relevant for Method nodes.
148 \value UserExecutable Same as Executable, but for the current user.
149 \value [since 6.7] DataTypeDefinition The data type definition attribute of a data type node.
150 \value [since 6.9] RolePermissions Permissions for all roles with access to the node.
151 \value [since 6.9] UserRolePermissions Permissions for all roles of the requesting session.
152 \value [since 6.9] AccessRestrictions The AccessRestrictions of the node.
153 \value [since 6.9] AccessLevelEx Contains a bit mask. Each bit corresponds to an access capability (OPC UA 1.05 part 3, 8.58).
154*/
155
156/*!
157 \enum QOpcUa::WriteMaskBit
158
159 This enum contains all possible bits for the WriteMask and UserWriteMask node attributes
160 defined in OPC UA 1.05 part 3, 8.60.
161
162 \value None No attribute is writable.
163 \value AccessLevel The AccessLevel attribute is writable.
164 \value ArrayDimensions The ArrayDimensions attribute is writable.
165 \value BrowseName The BrowseName attribute is writable.
166 \value ContainsNoLoops The ContainsNoLoops attribute is writable.
167 \value DataType The DataType attribute is writable.
168 \value Description The Description attribute is writable.
169 \value DisplayName The DisplayName attribute is writable.
170 \value EventNotifier The EventNotifier attribute is writable.
171 \value Executable The Executable attribute is writable.
172 \value Historizing The Historizing attribute is writable.
173 \value InverseName The InverseName attribute is writable.
174 \value IsAbstract The IsAbstract attribute is writable.
175 \value MinimumSamplingInterval The MinimumSamplingInterval attribute is writable.
176 \value NodeClass The NodeClass attribute is writable.
177 \value NodeId The NodeId attribute is writable.
178 \value Symmetric The Symmetric attribute is writable.
179 \value UserAccessLevel The UserAccessLevel attribute is writable.
180 \value UserExecutable The UserExecutable attribute is writable.
181 \value UserWriteMask The UserWriteMask attribute is writable.
182 \value ValueRank The ValueRank attribute is writable.
183 \value WriteMask The WriteMask attribute is writable.
184 \value ValueForVariableType The Value attribute of a variable type is writable.
185 \value [since 6.9] DataTypeDefinition The DataTypeDefinition attribute is writable.
186 \value [since 6.9] RolePermissions The RolePermissions attribute is writable.
187 \value [since 6.9] AccessRestrictions The AccessRestrictions attribute is writable.
188 \value [since 6.9] AccessLevelEx The AccessLevelEx attribute is writable.
189*/
190
191/*!
192 \enum QOpcUa::AccessLevelBit
193
194 This enum contains all possible bits for the AccessLevel and UserAccessLevel node attributes
195 defined in OPC UA 1.05 part 3, 8.57.
196
197 \value None No read access to the Value attribute is permitted.
198 \value CurrentRead The current value can be read.
199 \value CurrentWrite The current value can be written.
200 \value HistoryRead The history of the value is readable.
201 \value HistoryWrite The history of the value is writable.
202 \value SemanticChange The property variable generates SemanticChangeEvents.
203 \value StatusWrite The status code of the value is writable.
204 \value TimestampWrite The SourceTimestamp is writable.
205*/
206
207/*!
208 \enum QOpcUa::AccessLevelExBit
209 \since 6.9
210
211 This enum contains all possible bits for the AccessLevelEx node attribute
212 defined in OPC UA 1.05 part 3, 8.58.
213
214 \value None No read access to the Value attribute is permitted.
215 \value CurrentRead The current value can be read.
216 \value CurrentWrite The current value can be written.
217 \value HistoryRead The history of the value is readable.
218 \value HistoryWrite The history of the value is writable.
219 \value SemanticChange The property variable generates SemanticChangeEvents.
220 \value StatusWrite The status code of the value is writable.
221 \value TimestampWrite The SourceTimestamp is writable.
222 \value NonatomicRead Indicates if the read is non-atomic.
223 \value NonatomicWrite Indicates if the write is non-atomic.
224 \value WriteFullArrayOnly Indicates if writing an index range of an array is supported.
225 \value NoSubDataTypes Indicates if a write also accepts subtypes of the type.
226 \value NonVolatile Indicates if the variable is volatile.
227 \value Constant Indicates if the variable's value is constant.
228*/
229
230/*!
231 \enum QOpcUa::EventNotifierBit
232
233 This enum contains all possible bits for the EventNotifier node attribute
234 defined in OPC UA 1.05 part 3, 8.59.
235
236 \value None The node can't be used to interact with events.
237 \value SubscribeToEvents A client can subscribe to events.
238 \value HistoryRead A client can read the event history.
239 \value HistoryWrite A client can write the event history.
240*/
241
242/*!
243 \enum QOpcUa::TimestampsToReturn
244 \since 6.7
245
246 This enum contains the options for timestamps to return for service calls.
247 It is specified in OPC UA 1.05, Part 4, 7.40.
248
249 \value Source Return the source timestamp
250 \value Server Return the server timestamp
251 \value Both Return the source and the server timestamp
252 \value Neither Return no timestamps
253 \value Invalid The invalid value specified by OPC UA
254*/
255
256/*!
257 \fn inline uint QOpcUa::qHash(const QOpcUa::NodeAttribute& attr)
258
259 Returns a \l QHash key for \a attr.
260*/
261
262/*!
263 \enum QOpcUa::Types
264
265 Enumerates the types supported by Qt OPC UA.
266
267 \value Boolean
268 \value Int32
269 \value UInt32
270 \value Double
271 \value Float
272 \value String
273 \value LocalizedText
274 \value DateTime
275 \value UInt16
276 \value Int16
277 \value UInt64
278 \value Int64
279 \value Byte
280 \value SByte
281 \value ByteString
282 \value XmlElement
283 \value NodeId
284 \value Guid
285 \value QualifiedName A name qualified by an OPC UA namespace index.
286 \value StatusCode
287 \value ExtensionObject A data structure which contains a serialized object.
288 \value Range A range composed from the two double values low and high.
289 \value EUInformation The unit of measurement for an analog value.
290 \value ComplexNumber The OPC UA ComplexNumber type.
291 \value DoubleComplexNumber The OPC UA DoubleComplexNumber type.
292 \value AxisInformation Information about an axis.
293 \value XV A float value with a double precision position on an axis.
294 \value ExpandedNodeId A node id with additional namespace URI and server index.
295 \value Argument The OPC UA Argument type.
296 \value StructureDefinition The OPC UA StructureDefinition type
297 \value StructureField The OPC UA StructureField type
298 \value EnumDefinition The OPC UA EnumDefinition type
299 \value EnumField The OPC UA EnumField type
300 \value DiagnosticInfo The OPC UA DiagnosticInfo type
301 \value SimpleAttributeOperand The OPC UA SimpleAttributeOperand type.
302 \value AttributeOperand The OPC UA AttributeOperand type.
303 \value LiteralOperand The OPC UA LiteralOperand type.
304 \value ElementOperand The OPC UA ElementOperand type.
305 \value RelativePathElement The OPC UA RelativePathElement type.
306 \value ContentFilterElement The OPC UA ContentFilterElement type.
307 \value EventFilter The OPC UA EventFilter type.
308 \value Undefined
309*/
310
311/*!
312 \enum QOpcUa::UaStatusCode
313
314 Enumerates all status codes from \l {https://opcfoundation.org/UA/schemas/1.05/Opc.Ua.StatusCodes.csv}
315
316 \value Good The operation succeeded.
317 \value Uncertain The operation was uncertain.
318 \value Bad The operation failed.
319 \value BadUnexpectedError An unexpected error occurred.
320 \value BadInternalError An internal error occurred as a result of a programming or configuration error.
321 \value BadOutOfMemory Not enough memory to complete the operation.
322 \value BadResourceUnavailable An operating system resource is not available.
323 \value BadCommunicationError A low level communication error occurred.
324 \value BadEncodingError Encoding halted because of invalid data in the objects being serialized.
325 \value BadDecodingError Decoding halted because of invalid data in the stream.
326 \value BadEncodingLimitsExceeded The message encoding/decoding limits imposed by the stack have been exceeded.
327 \value BadRequestTooLarge The request message size exceeds limits set by the server.
328 \value BadResponseTooLarge The response message size exceeds limits set by the client.
329 \value BadUnknownResponse An unrecognized response was received from the server.
330 \value BadTimeout The operation timed out.
331 \value BadServiceUnsupported The server does not support the requested service.
332 \value BadShutdown The operation was cancelled because the application is shutting down.
333 \value BadServerNotConnected The operation could not complete because the client is not connected to the server.
334 \value BadServerHalted The server has stopped and cannot process any requests.
335 \value BadNothingToDo No processing could be done because there was nothing to do.
336 \value BadTooManyOperations The request could not be processed because it specified too many operations.
337 \value BadTooManyMonitoredItems The request could not be processed because there are too many monitored items in the subscription.
338 \value BadDataTypeIdUnknown The extension object cannot be (de)serialized because the data type id is not recognized.
339 \value BadCertificateInvalid The certificate provided as a parameter is not valid.
340 \value BadSecurityChecksFailed An error occurred verifying security.
341 \value BadCertificatePolicyCheckFailed The certificate does not meet the requirements of the security policy.
342 \value BadCertificateTimeInvalid The certificate has expired or is not yet valid.
343 \value BadCertificateIssuerTimeInvalid An issuer certificate has expired or is not yet valid.
344 \value BadCertificateHostNameInvalid The HostName used to connect to a server does not match a HostName in the certificate.
345 \value BadCertificateUriInvalid The URI specified in the ApplicationDescription does not match the URI in the certificate.
346 \value BadCertificateUseNotAllowed The certificate may not be used for the requested operation.
347 \value BadCertificateIssuerUseNotAllowed The issuer certificate may not be used for the requested operation.
348 \value BadCertificateUntrusted The certificate is not trusted.
349 \value BadCertificateRevocationUnknown It was not possible to determine if the certificate has been revoked.
350 \value BadCertificateIssuerRevocationUnknown It was not possible to determine if the issuer certificate has been revoked.
351 \value BadCertificateRevoked The certificate has been revoked.
352 \value BadCertificateIssuerRevoked The issuer certificate has been revoked.
353 \value BadCertificateChainIncomplete The certificate chain is incomplete.
354 \value BadUserAccessDenied User does not have permission to perform the requested operation.
355 \value BadIdentityTokenInvalid The user identity token is not valid.
356 \value BadIdentityTokenRejected The user identity token is valid but the server has rejected it.
357 \value BadSecureChannelIdInvalid The specified secure channel is no longer valid.
358 \value BadInvalidTimestamp The timestamp is outside the range allowed by the server.
359 \value BadNonceInvalid The nonce does appear to be not a random value or it is not the correct length.
360 \value BadSessionIdInvalid The session id is not valid.
361 \value BadSessionClosed The session was closed by the client.
362 \value BadSessionNotActivated The session cannot be used because ActivateSession has not been called.
363 \value BadSubscriptionIdInvalid The subscription id is not valid.
364 \value BadRequestHeaderInvalid The header for the request is missing or invalid.
365 \value BadTimestampsToReturnInvalid The timestamps to return parameter is invalid.
366 \value BadRequestCancelledByClient The request was cancelled by the client.
367 \value BadTooManyArguments Too many arguments were provided.
368 \value BadLicenseExpired The server requires a license to operate in general or to perform a service or operation, but existing license is expired.
369 \value BadLicenseLimitsExceeded The server has limits on number of allowed operations / objects, based on installed licenses, and these limits where exceeded.
370 \value BadLicenseNotAvailable The server does not have a license which is required to operate in general or to perform a service or operation.
371 \value GoodSubscriptionTransferred The subscription was transferred to another session.
372 \value GoodCompletesAsynchronously The processing will complete asynchronously.
373 \value GoodOverload Sampling has slowed down due to resource limitations.
374 \value GoodClamped The value written was accepted but was clamped.
375 \value BadNoCommunication Communication with the data source is defined, but not established, and there is no last known value available.
376 \value BadWaitingForInitialData Waiting for the server to obtain values from the underlying data source.
377 \value BadNodeIdInvalid The syntax of the node id is not valid.
378 \value BadNodeIdUnknown The node id refers to a node that does not exist in the server address space.
379 \value BadAttributeIdInvalid The attribute is not supported for the specified Node.
380 \value BadIndexRangeInvalid The syntax of the index range parameter is invalid.
381 \value BadIndexRangeNoData No data exists within the range of indexes specified.
382 \value BadDataEncodingInvalid The data encoding is invalid.
383 \value BadDataEncodingUnsupported The server does not support the requested data encoding for the node.
384 \value BadNotReadable The access level does not allow reading or subscribing to the Node.
385 \value BadNotWritable The access level does not allow writing to the Node.
386 \value BadOutOfRange The value was out of range.
387 \value BadNotSupported The requested operation is not supported.
388 \value BadNotFound A requested item was not found or a search operation ended without success.
389 \value BadObjectDeleted The object cannot be used because it has been deleted.
390 \value BadNotImplemented Requested operation is not implemented.
391 \value BadMonitoringModeInvalid The monitoring mode is invalid.
392 \value BadMonitoredItemIdInvalid The monitoring item id does not refer to a valid monitored item.
393 \value BadMonitoredItemFilterInvalid The monitored item filter parameter is not valid.
394 \value BadMonitoredItemFilterUnsupported The server does not support the requested monitored item filter.
395 \value BadFilterNotAllowed A monitoring filter cannot be used in combination with the attribute specified.
396 \value BadStructureMissing A mandatory structured parameter was missing or null.
397 \value BadEventFilterInvalid The event filter is not valid.
398 \value BadContentFilterInvalid The content filter is not valid.
399 \value BadFilterOperatorInvalid An unrecognized operator was provided in a filter.
400 \value BadFilterOperatorUnsupported A valid operator was provided, but the server does not provide support for this filter operator.
401 \value BadFilterOperandCountMismatch The number of operands provided for the filter operator was less then expected for the operand provided.
402 \value BadFilterOperandInvalid The operand used in a content filter is not valid.
403 \value BadFilterElementInvalid The referenced element is not a valid element in the content filter.
404 \value BadFilterLiteralInvalid The referenced literal is not a valid value.
405 \value BadContinuationPointInvalid The continuation point provide is longer valid.
406 \value BadNoContinuationPoints The operation could not be processed because all continuation points have been allocated.
407 \value BadReferenceTypeIdInvalid The reference type id does not refer to a valid reference type node.
408 \value BadBrowseDirectionInvalid The browse direction is not valid.
409 \value BadNodeNotInView The node is not part of the view.
410 \value BadNumericOverflow The number was not accepted because of a numeric overflow.
411 \value BadServerUriInvalid The ServerUri is not a valid URI.
412 \value BadServerNameMissing No ServerName was specified.
413 \value BadDiscoveryUrlMissing No DiscoveryUrl was specified.
414 \value BadSempahoreFileMissing The semaphore file specified by the client is not valid.
415 \value BadRequestTypeInvalid The security token request type is not valid.
416 \value BadSecurityModeRejected The security mode does not meet the requirements set by the server.
417 \value BadSecurityPolicyRejected The security policy does not meet the requirements set by the server.
418 \value BadTooManySessions The server has reached its maximum number of sessions.
419 \value BadUserSignatureInvalid The user token signature is missing or invalid.
420 \value BadApplicationSignatureInvalid The signature generated with the client certificate is missing or invalid.
421 \value BadNoValidCertificates The client did not provide at least one software certificate that is valid and meets the profile requirements for the server.
422 \value BadIdentityChangeNotSupported The server does not support changing the user identity assigned to the session.
423 \value BadRequestCancelledByRequest The request was cancelled by the client with the Cancel service.
424 \value BadParentNodeIdInvalid The parent node id does not to refer to a valid node.
425 \value BadReferenceNotAllowed The reference could not be created because it violates constraints imposed by the data model.
426 \value BadNodeIdRejected The requested node id was reject because it was either invalid or server does not allow node ids to be specified by the client.
427 \value BadNodeIdExists The requested node id is already used by another node.
428 \value BadNodeClassInvalid The node class is not valid.
429 \value BadBrowseNameInvalid The browse name is invalid.
430 \value BadBrowseNameDuplicated The browse name is not unique among nodes that share the same relationship with the parent.
431 \value BadNodeAttributesInvalid The node attributes are not valid for the node class.
432 \value BadTypeDefinitionInvalid The type definition node id does not reference an appropriate type node.
433 \value BadSourceNodeIdInvalid The source node id does not reference a valid node.
434 \value BadTargetNodeIdInvalid The target node id does not reference a valid node.
435 \value BadDuplicateReferenceNotAllowed The reference type between the nodes is already defined.
436 \value BadInvalidSelfReference The server does not allow this type of self reference on this node.
437 \value BadReferenceLocalOnly The reference type is not valid for a reference to a remote server.
438 \value BadNoDeleteRights The server will not allow the node to be deleted.
439 \value UncertainReferenceNotDeleted The server was not able to delete all target references.
440 \value BadServerIndexInvalid The server index is not valid.
441 \value BadViewIdUnknown The view id does not refer to a valid view node.
442 \value BadViewTimestampInvalid The view timestamp is not available or not supported.
443 \value BadViewParameterMismatch The view parameters are not consistent with each other.
444 \value BadViewVersionInvalid The view version is not available or not supported.
445 \value UncertainNotAllNodesAvailable The list of references may not be complete because the underlying system is not available.
446 \value GoodResultsMayBeIncomplete The server should have followed a reference to a node in a remote server but did not. The result set may be incomplete.
447 \value BadNotTypeDefinition The provided Nodeid was not a type definition nodeid.
448 \value UncertainReferenceOutOfServer One of the references to follow in the relative path references to a node in the address space in another server.
449 \value BadTooManyMatches The requested operation has too many matches to return.
450 \value BadQueryTooComplex The requested operation requires too many resources in the server.
451 \value BadNoMatch The requested operation has no match to return.
452 \value BadMaxAgeInvalid The max age parameter is invalid.
453 \value BadSecurityModeInsufficient The operation is not permitted over the current secure channel.
454 \value BadHistoryOperationInvalid The history details parameter is not valid.
455 \value BadHistoryOperationUnsupported The server does not support the requested operation.
456 \value BadInvalidTimestampArgument The defined timestamp to return was invalid.
457 \value BadWriteNotSupported The server does not support writing the combination of value, status and timestamps provided.
458 \value BadTypeMismatch The value supplied for the attribute is not of the same type as the attribute's value.
459 \value BadMethodInvalid The method id does not refer to a method for the specified object.
460 \value BadArgumentsMissing The client did not specify all of the input arguments for the method.
461 \value BadNotExecutable The executable attribute does not allow the execution of the method.
462 \value BadTooManySubscriptions The server has reached its maximum number of subscriptions.
463 \value BadTooManyPublishRequests The server has reached the maximum number of queued publish requests.
464 \value BadNoSubscription There is no subscription available for this session.
465 \value BadSequenceNumberUnknown The sequence number is unknown to the server.
466 \value GoodRetransmissionQueueNotSupported The Server does not support retransmission queue and acknowledgement of sequence numbers is not available.
467 \value BadMessageNotAvailable The requested notification message is no longer available.
468 \value BadInsufficientClientProfile The client of the current session does not support one or more Profiles that are necessary for the subscription.
469 \value BadStateNotActive The sub-state machine is not currently active.
470 \value BadAlreadyExists An equivalent rule already exists.
471 \value BadTcpServerTooBusy The server cannot process the request because it is too busy.
472 \value BadTcpMessageTypeInvalid The type of the message specified in the header invalid.
473 \value BadTcpSecureChannelUnknown The SecureChannelId and/or TokenId are not currently in use.
474 \value BadTcpMessageTooLarge The size of the message chunk specified in the header is too large.
475 \value BadTcpNotEnoughResources There are not enough resources to process the request.
476 \value BadTcpInternalError An internal error occurred.
477 \value BadTcpEndpointUrlInvalid The server does not recognize the QueryString specified.
478 \value BadRequestInterrupted The request could not be sent because of a network interruption.
479 \value BadRequestTimeout Timeout occurred while processing the request.
480 \value BadSecureChannelClosed The secure channel has been closed.
481 \value BadSecureChannelTokenUnknown The token has expired or is not recognized.
482 \value BadSequenceNumberInvalid The sequence number is not valid.
483 \value BadProtocolVersionUnsupported The applications do not have compatible protocol versions.
484 \value BadConfigurationError There is a problem with the configuration that affects the usefulness of the value.
485 \value BadNotConnected The variable should receive its value from another variable, but has never been configured to do so.
486 \value BadDeviceFailure There has been a failure in the device/data source that generates the value that has affected the value.
487 \value BadSensorFailure There has been a failure in the sensor from which the value is derived by the device/data source.
488 \value BadOutOfService The source of the data is not operational.
489 \value BadDeadbandFilterInvalid The deadband filter is not valid.
490 \value UncertainNoCommunicationLastUsableValue Communication to the data source has failed. The variable value is the last value that had a good quality.
491 \value UncertainLastUsableValue Whatever was updating this value has stopped doing so.
492 \value UncertainSubstituteValue The value is an operational value that was manually overwritten.
493 \value UncertainInitialValue The value is an initial value for a variable that normally receives its value from another variable.
494 \value UncertainSensorNotAccurate The value is at one of the sensor limits.
495 \value UncertainEngineeringUnitsExceeded The value is outside of the range of values defined for this parameter.
496 \value UncertainSubNormal The value is derived from multiple sources and has less than the required number of Good sources.
497 \value GoodLocalOverride The value has been overridden.
498 \value BadRefreshInProgress This Condition refresh failed, a Condition refresh operation is already in progress.
499 \value BadConditionAlreadyDisabled This condition has already been disabled.
500 \value BadConditionAlreadyEnabled This condition has already been enabled.
501 \value BadConditionDisabled Property not available, this condition is disabled.
502 \value BadEventIdUnknown The specified event id is not recognized.
503 \value BadEventNotAcknowledgeable The event cannot be acknowledged.
504 \value BadDialogNotActive The dialog condition is not active.
505 \value BadDialogResponseInvalid The response is not valid for the dialog.
506 \value BadConditionBranchAlreadyAcked The condition branch has already been acknowledged.
507 \value BadConditionBranchAlreadyConfirmed The condition branch has already been confirmed.
508 \value BadConditionAlreadyShelved The condition has already been shelved.
509 \value BadConditionNotShelved The condition is not currently shelved.
510 \value BadShelvingTimeOutOfRange The shelving time not within an acceptable range.
511 \value BadNoData No data exists for the requested time range or event filter.
512 \value BadBoundNotFound No data found to provide upper or lower bound value.
513 \value BadBoundNotSupported The server cannot retrieve a bound for the variable.
514 \value BadDataLost Data is missing due to collection started/stopped/lost.
515 \value BadDataUnavailable Expected data is unavailable for the requested time range due to an un-mounted volume, an off-line archive or tape, or similar reason for temporary unavailability.
516 \value BadEntryExists The data or event was not successfully inserted because a matching entry exists.
517 \value BadNoEntryExists The data or event was not successfully updated because no matching entry exists.
518 \value BadTimestampNotSupported The client requested history using a timestamp format the server does not support (i.e requested ServerTimestamp when server only supports SourceTimestamp).
519 \value GoodEntryInserted The data or event was successfully inserted into the historical database.
520 \value GoodEntryReplaced The data or event field was successfully replaced in the historical database.
521 \value UncertainDataSubNormal The value is derived from multiple values and has less than the required number of Good values.
522 \value GoodNoData No data exists for the requested time range or event filter.
523 \value GoodMoreData More data is available in the time range beyond the number of values requested.
524 \value BadAggregateListMismatch The requested number of Aggregates does not match the requested number of NodeIds.
525 \value BadAggregateNotSupported The requested Aggregate is not support by the server.
526 \value BadAggregateInvalidInputs The aggregate value could not be derived due to invalid data inputs.
527 \value BadAggregateConfigurationRejected The aggregate configuration is not valid for specified node.
528 \value GoodDataIgnored The request specifies fields which are not valid for the EventType or cannot be saved by the historian.
529 \value BadRequestNotAllowed The request was rejected by the server because it did not meet the criteria set by the server.
530 \value BadRequestNotComplete The request has not been processed by the server yet.
531 \value BadTransactionPending The operation is not allowed because a transaction is in progress.
532 \value BadTicketRequired The device identity needs a ticket before it can be accepted.
533 \value BadTicketInvalid The device identity needs a ticket before it can be accepted.
534 \value BadLocked The requested operation is not allowed, because the Node is locked by a different application.
535 \value GoodEdited The value does not come from the real source and has been edited by the server.
536 \value GoodPostActionFailed There was an error in execution of these post-actions.
537 \value UncertainDominantValueChanged The related EngineeringUnit has been changed but the Variable Value is still provided based on the previous unit.
538 \value GoodDependentValueChanged A dependent value has been changed but the change has not been applied to the device.
539 \value BadDominantValueChanged The related EngineeringUnit has been changed but this change has not been applied to the device. The Variable Value is still dependent on the previous unit but its status is currently Bad.
540 \value UncertainDependentValueChanged A dependent value has been changed but the change has not been applied to the device. The quality of the dominant variable is uncertain.
541 \value BadDependentValueChanged A dependent value has been changed but the change has not been applied to the device. The quality of the dominant variable is Bad.
542 \value GoodEdited_DependentValueChanged It is delivered with a dominant Variable value when a dependent Variable has changed but the change has not been applied.
543 \value GoodEdited_DominantValueChanged It is delivered with a dependent Variable value when a dominant Variable has changed but the change has not been applied.
544 \value GoodEdited_DominantValueChanged_DependentValueChanged It is delivered with a dependent Variable value when a dominant or dependent Variable has changed but change has not been applied.
545 \value BadEdited_OutOfRange It is delivered with a Variable value when Variable has changed but the value is not legal.
546 \value BadInitialValue_OutOfRange It is delivered with a Variable value when a source Variable has changed but the value is not legal.
547 \value BadOutOfRange_DominantValueChanged It is delivered with a dependent Variable value when a dominant Variable has changed and the value is not legal.
548 \value BadEdited_OutOfRange_DominantValueChanged It is delivered with a dependent Variable value when a dominant Variable has changed, the value is not legal and the change has not been applied.
549 \value BadOutOfRange_DominantValueChanged_DependentValueChanged It is delivered with a dependent Variable value when a dominant or dependent Variable has changed and the value is not legal.
550 \value BadEdited_OutOfRange_DominantValueChanged_DependentValueChanged It is delivered with a dependent Variable value when a dominant or dependent Variable has changed, the value is not legal and the change has not been applied.
551 \value GoodCommunicationEvent The communication layer has raised an event.
552 \value GoodShutdownEvent The system is shutting down.
553 \value GoodCallAgain The operation is not finished and needs to be called again.
554 \value GoodNonCriticalTimeout A non-critical timeout occurred.
555 \value BadInvalidArgument One or more arguments are invalid.
556 \value BadConnectionRejected Could not establish a network connection to remote server.
557 \value BadDisconnect The server has disconnected from the client.
558 \value BadConnectionClosed The network connection has been closed.
559 \value BadInvalidState The operation cannot be completed because the object is closed, uninitialized or in some other invalid state.
560 \value BadEndOfStream Cannot move beyond end of the stream.
561 \value BadNoDataAvailable No data is currently available for reading from a non-blocking stream.
562 \value BadWaitingForResponse The asynchronous operation is waiting for a response.
563 \value BadOperationAbandoned The asynchronous operation was abandoned by the caller.
564 \value BadExpectedStreamToBlock The stream did not return all data requested (possibly because it is a non-blocking stream).
565 \value BadWouldBlock Non blocking behaviour is required and the operation would block.
566 \value BadSyntaxError A value had an invalid syntax.
567 \value BadMaxConnectionsReached The operation could not be finished because all available connections are in use.
568 \value UncertainTransducerInManual The value may not be accurate because the transducer is in manual mode.
569 \value UncertainSimulatedValue The value is simulated.
570 \value UncertainSensorCalibration The value may not be accurate due to a sensor calibration fault.
571 \value UncertainConfigurationError The value may not be accurate due to a configuration issue.
572 \value GoodCascadeInitializationAcknowledged The value source supports cascade handshaking and the value has been Initialized based on an initialization request from a cascade secondary.
573 \value GoodCascadeInitializationRequest The value source supports cascade handshaking and is requesting initialization of a cascade primary.
574 \value GoodCascadeNotInvited The value source supports cascade handshaking, however, the source’s current state does not allow for cascade.
575 \value GoodCascadeNotSelected The value source supports cascade handshaking, however, the source has not selected the corresponding cascade primary for use.
576 \value GoodFaultStateActive There is a fault state condition active in the value source.
577 \value GoodInitiateFaultState A fault state condition is being requested of the destination.
578 \value GoodCascade The value is accurate, and the signal source supports cascade handshaking.
579 \value BadDataSetIdInvalid The DataSet specified for the DataSetWriter creation is invalid.
580*/
581
582/*!
583 \enum QOpcUa::ErrorCategory
584
585 This enum contains simplified categories for OPC UA errors.
586
587 \value NoError The operation has been successful.
588 \value NodeError There is a problem with the node, e. g. it does not exist.
589 \value AttributeError The attributes to operate on where invalid.
590 \value PermissionError The user did not have the permission to perform the operation.
591 \value ArgumentError The arguments supplied by the user were invalid or incomplete.
592 \value TypeError There has been a type mismatch for a write operation.
593 \value ConnectionError Communication with the server did not work as expected.
594 \value UnspecifiedError Any error that is not categorized. The detailed status code must be checked.
595*/
596
597/*!
598 This method can be used to check if a call has successfully finished.
599
600 Returns \c true if \a statusCode's severity field is Good.
601*/
602bool QOpcUa::isSuccessStatus(QOpcUa::UaStatusCode statusCode)
603{
604 return (statusCode & 0xC0000000) == 0;
605}
606
607/*!
608 \typedef QOpcUa::TypedVariant
609
610 This is QPair<QVariant, QOpcUa::Types>.
611*/
612
613static bool isNodeError(QOpcUa::UaStatusCode statusCode)
614{
615 switch (statusCode) {
616 case QOpcUa::UaStatusCode::BadMethodInvalid:
617 case QOpcUa::UaStatusCode::BadNodeIdInvalid:
618 case QOpcUa::UaStatusCode::BadNodeIdExists:
619 case QOpcUa::UaStatusCode::BadNodeIdRejected:
620 case QOpcUa::UaStatusCode::BadNodeIdUnknown:
621 case QOpcUa::UaStatusCode::BadObjectDeleted:
622 return true;
623 default:
624 return false;
625 }
626}
627
628static bool isAttributeError(QOpcUa::UaStatusCode statusCode)
629{
630 switch (statusCode) {
631 case QOpcUa::UaStatusCode::BadAttributeIdInvalid:
632 case QOpcUa::UaStatusCode::BadNodeAttributesInvalid:
633 return true;
634 default:
635 return false;
636 }
637}
638
639static bool isPermissionError(QOpcUa::UaStatusCode statusCode)
640{
641 switch (statusCode) {
642 case QOpcUa::UaStatusCode::BadUserAccessDenied:
643 case QOpcUa::UaStatusCode::BadNotWritable:
644 case QOpcUa::UaStatusCode::BadNoDeleteRights:
645 case QOpcUa::UaStatusCode::BadNotReadable:
646 return true;
647 default:
648 return false;
649 }
650}
651
652static bool isArgumentError(QOpcUa::UaStatusCode statusCode)
653{
654 switch (statusCode) {
655 case QOpcUa::UaStatusCode::BadArgumentsMissing:
656 case QOpcUa::UaStatusCode::BadInvalidArgument:
657 case QOpcUa::UaStatusCode::BadTooManyArguments:
658 case QOpcUa::UaStatusCode::BadInvalidTimestampArgument:
659 return true;
660 default:
661 return false;
662 }
663}
664
665static bool isTypeError(QOpcUa::UaStatusCode statusCode)
666{
667 switch (statusCode) {
668 case QOpcUa::UaStatusCode::BadTypeMismatch:
669 case QOpcUa::UaStatusCode::BadInvalidTimestampArgument:
670 return true;
671 default:
672 return false;
673 }
674}
675
676static bool isConnectionError(QOpcUa::UaStatusCode statusCode)
677{
678 switch (statusCode) {
679 case QOpcUa::UaStatusCode::BadConnectionClosed:
680 case QOpcUa::UaStatusCode::BadNoCommunication:
681 return true;
682 default:
683 return false;
684 }
685}
686
687/*!
688 Converts \a statusCode to an \l ErrorCategory. \l ErrorCategory can be used in cases where the
689 exact error is not important.
690
691 For error handling dependent on status codes, the full status code must be used instead.
692 The meaning of the status codes for the different services is documented in OPC UA part 4.
693
694 If \a statusCode has not been categorized, UnspecifiedError is returned. In this case, the user
695 must check the full status code.
696*/
697QOpcUa::ErrorCategory QOpcUa::errorCategory(QOpcUa::UaStatusCode statusCode)
698{
699 if (isSuccessStatus(statusCode))
700 return QOpcUa::ErrorCategory::NoError;
701 if (isNodeError(statusCode))
702 return QOpcUa::ErrorCategory::NodeError;
703 if (isAttributeError(statusCode))
704 return QOpcUa::ErrorCategory::AttributeError;
705 if (isPermissionError(statusCode))
706 return QOpcUa::ErrorCategory::PermissionError;
707 if (isArgumentError(statusCode))
708 return QOpcUa::ErrorCategory::ArgumentError;
709 if (isTypeError(statusCode))
710 return QOpcUa::ErrorCategory::TypeError;
711 if (isConnectionError(statusCode))
712 return QOpcUa::ErrorCategory::ConnectionError;
713
714 return QOpcUa::ErrorCategory::UnspecifiedError;
715}
716
717/*!
718 Creates a node id string from the namespace index \a ns and the string \a identifier.
719 \sa QOpcUaNode
720*/
721QString QOpcUa::nodeIdFromString(quint16 ns, const QString &identifier)
722{
723 return u"ns=%1;s=%2"_s.arg(a: ns).arg(a: identifier);
724}
725
726/*!
727 Creates a node id string from the namespace index \a ns and the byte string \a identifier.
728 \sa QOpcUaNode
729*/
730QString QOpcUa::nodeIdFromByteString(quint16 ns, const QByteArray &identifier)
731{
732 return u"ns=%1;b=%2"_s.arg(a: ns).arg(a: QString::fromUtf8(ba: identifier.toBase64()));
733}
734
735/*!
736 Creates a node id string from the namespace index \a ns and the GUID \a identifier.
737 \sa QOpcUaNode
738*/
739QString QOpcUa::nodeIdFromGuid(quint16 ns, const QUuid &identifier)
740{
741 return u"ns=%1;g="_s.arg(a: ns).append(v: QStringView(identifier.toString()).mid(pos: 1, n: 36)); // Remove enclosing {...};
742}
743
744/*!
745 Creates a node id string from the namespace index \a ns and the integer \a identifier.
746 \sa QOpcUaNode
747*/
748QString QOpcUa::nodeIdFromInteger(quint16 ns, quint32 identifier)
749{
750 return u"ns=%1;i=%2"_s.arg(a: ns).arg(a: identifier);
751}
752
753/*!
754 Creates a node id string for the reference type id \a referenceType.
755*/
756QString QOpcUa::nodeIdFromReferenceType(QOpcUa::ReferenceTypeId referenceType)
757{
758 return u"ns=0;i=%1"_s.arg(a: static_cast<quint32>(referenceType));
759}
760
761/*!
762 Splits the node id string \a nodeIdString in its components.
763 The namespace index of the node id will be copied into \a nsIndex.
764 The identifier string is copied into \a identifier and the identifier type
765 (i, s, g, b) is copied into \a identifierType.
766
767 Returns \c true if the node id could be split successfully.
768
769 For example, "ns=1;s=MyString" is split into 1, 's' and "MyString".
770 If no namespace index is given, ns=0 is assumed.
771*/
772bool QOpcUa::nodeIdStringSplit(const QString &nodeIdString, quint16 *nsIndex, QString *identifier, char *identifierType)
773{
774 quint16 namespaceIndex = 0;
775
776 QStringList components = nodeIdString.split(sep: ';'_L1);
777
778 if (components.size() > 2)
779 return false;
780
781 static const QRegularExpression namespaceRegex(u"^ns=[0-9]+"_s);
782 if (components.size() == 2 && components.at(i: 0).contains(re: namespaceRegex)) {
783 bool success = false;
784 uint ns = QStringView(components.at(i: 0)).mid(pos: 3).toUInt(ok: &success);
785 if (!success || ns > (std::numeric_limits<quint16>::max)())
786 return false;
787 namespaceIndex = ns;
788 }
789
790 if (components.last().size() < 3)
791 return false;
792
793 static const QRegularExpression identifierRegex(u"^[isgb]="_s);
794 if (!components.last().contains(re: identifierRegex))
795 return false;
796
797 if (nsIndex)
798 *nsIndex = namespaceIndex;
799 if (identifier)
800 *identifier = QStringView(components.last()).mid(pos: 2).toString();
801 if (identifierType)
802 *identifierType = components.last().at(i: 0).toLatin1();
803
804 return true;
805}
806
807/*!
808 Returns \c true if the two node ids \a first and \a second have the same namespace index and identifier.
809 A node id string without a namespace index is assumed to be in namespace 0.
810*/
811bool QOpcUa::nodeIdEquals(const QString &first, const QString &second)
812{
813 const QStringView fView(first);
814 const QStringView sView(second);
815 if (first.startsWith(s: "ns=0;"_L1) && !second.startsWith(s: "ns="_L1))
816 return fView.mid(pos: 5) == sView;
817 else if (second.startsWith(s: "ns=0;"_L1) && !first.startsWith(s: "ns="_L1))
818 return sView.mid(pos: 5) == fView;
819 else
820 return first == second;
821}
822
823/*!
824 Returns a node id string for the namespace 0 identifier \a id.
825*/
826QString QOpcUa::namespace0Id(QOpcUa::NodeIds::Namespace0 id)
827{
828 return u"ns=0;i=%1"_s.arg(a: quint32(id));
829}
830
831/*!
832 Returns the enum value from \l QOpcUa::NodeIds::Namespace0 for \a nodeId.
833
834 If the node id is not in namespace 0 or doesn't have a numeric
835 identifier which is part of the OPC Foundation's NodeIds.csv file,
836 \l {QOpcUa::NodeIds::Namespace0} {Unknown} is returned.
837
838 If Qt OPC UA has been configured with FEATURE_ns0idnames=OFF,
839 the check if the numeric identifier is part of the NodeIds.csv
840 file is omitted. If the node id is in namespace 0 and has a
841 numeric identifier, the identifier is returned regardless if it
842 is part of the \l QOpcUa::NodeIds::Namespace0 enum.
843*/
844QOpcUa::NodeIds::Namespace0 QOpcUa::namespace0IdFromNodeId(const QString &nodeId)
845{
846 if (!nodeId.startsWith(s: "ns=0;i="_L1))
847 return QOpcUa::NodeIds::Namespace0::Unknown;
848
849 const QStringView sv = QStringView{nodeId}.mid(pos: 7);
850
851 bool ok = false;
852 quint32 identifier = sv.toUInt(ok: &ok);
853
854 if (!ok)
855 return QOpcUa::NodeIds::Namespace0::Unknown;
856
857#ifndef QT_OPCUA_NO_NS0IDNAMES
858 if (!QMetaEnum::fromType<QOpcUa::NodeIds::Namespace0>().valueToKey(value: identifier))
859 return QOpcUa::NodeIds::Namespace0::Unknown;
860#endif
861
862 return QOpcUa::NodeIds::Namespace0(identifier);
863}
864
865/*!
866 Returns the name of the namespace 0 node id \a id.
867
868 If \a id is unknown or Qt OPC UA has been configured with FEATURE_ns0idnames=OFF,
869 an empty string is returned.
870*/
871QString QOpcUa::namespace0IdName(QOpcUa::NodeIds::Namespace0 id)
872{
873#ifdef QT_OPCUA_NO_NS0IDNAMES
874 Q_UNUSED(id);
875 return QString();
876#else
877 if (id == QOpcUa::NodeIds::Namespace0::Unknown)
878 return QString();
879 return QString::fromUtf8(utf8: QMetaEnum::fromType<QOpcUa::NodeIds::Namespace0>().valueToKey(value: quint32(id)));
880#endif
881}
882
883/*!
884 \enum QOpcUa::AxisScale
885
886 The AxisScale enum as defined by OPC UA 1.05 part 8, 5.6.7.
887
888 \value Linear
889 \value Log
890 \value Ln
891*/
892
893/*!
894 Returns a textual representation of \a statusCode.
895
896 Currently, this is the name of the enum value but may be a real message in future releases.
897*/
898QString QOpcUa::statusToString(QOpcUa::UaStatusCode statusCode)
899{
900 const auto enumerator = QMetaEnum::fromType<QOpcUa::UaStatusCode>();
901 const auto key = enumerator.valueToKey(value: statusCode);
902 if (key)
903 return QString::fromLatin1(ba: key);
904 else
905 return u"Invalid enum value for UaStatusCode"_s;
906}
907
908/*!
909 \since 5.13
910
911 Returns the Qt OPC UA type from \a type.
912 In case the type does not map, \c QOpcUa::Undefined is returned.
913*/
914QOpcUa::Types QOpcUa::metaTypeToQOpcUaType(QMetaType::Type type) {
915 switch (type) {
916 case QMetaType::Bool:
917 return QOpcUa::Boolean;
918 case QMetaType::UChar:
919 return QOpcUa::Byte;
920 case QMetaType::Char:
921 return QOpcUa::SByte;
922 case QMetaType::UShort:
923 return QOpcUa::UInt16;
924 case QMetaType::Short:
925 return QOpcUa::Int16;
926 case QMetaType::Int:
927 return QOpcUa::Int32;
928 case QMetaType::UInt:
929 return QOpcUa::UInt32;
930 case QMetaType::ULongLong:
931 return QOpcUa::UInt64;
932 case QMetaType::LongLong:
933 return QOpcUa::Int64;
934 case QMetaType::Double:
935 return QOpcUa::Double;
936 case QMetaType::Float:
937 return QOpcUa::Float;
938 case QMetaType::QString:
939 return QOpcUa::String;
940 case QMetaType::QDateTime:
941 return QOpcUa::DateTime;
942 case QMetaType::QByteArray:
943 return QOpcUa::ByteString;
944 case QMetaType::QUuid:
945 return QOpcUa::Guid;
946 default:
947 break;
948 }
949 return QOpcUa::Undefined;
950}
951
952QOpcUa::Types QOpcUa::opcUaDataTypeToQOpcUaType(const QString &type)
953{
954 if (type == "ns=0;i=1"_L1)
955 return QOpcUa::Boolean;
956 else if (type == "ns=0;i=3"_L1)
957 return QOpcUa::Byte;
958 else if (type == "ns=0;i=2"_L1)
959 return QOpcUa::SByte;
960 else if (type == "ns=0;i=5"_L1)
961 return QOpcUa::UInt16;
962 else if (type == "ns=0;i=4"_L1)
963 return QOpcUa::Int16;
964 else if (type == "ns=0;i=6"_L1)
965 return QOpcUa::Int32;
966 else if (type == "ns=0;i=7"_L1)
967 return QOpcUa::UInt32;
968 else if (type == "ns=0;i=9"_L1)
969 return QOpcUa::UInt64;
970 else if (type == "ns=0;i=8"_L1)
971 return QOpcUa::Int64;
972 else if (type == "ns=0;i=11"_L1)
973 return QOpcUa::Double;
974 else if (type == "ns=0;i=10"_L1)
975 return QOpcUa::Float;
976 else if (type == "ns=0;i=12"_L1)
977 return QOpcUa::String;
978 else if (type == "ns=0;i=13"_L1)
979 return QOpcUa::DateTime;
980 else if (type == "ns=0;i=15"_L1)
981 return QOpcUa::ByteString;
982 else if (type == "ns=0;i=14"_L1)
983 return QOpcUa::Guid;
984 else
985 return QOpcUa::Undefined;
986}
987
988/*!
989 \since QtOpcUa 5.14
990
991 Returns \c true if \a securityPolicy is a secure policy, \c false
992 otherwise.
993*/
994bool QOpcUa::isSecurePolicy(const QString &securityPolicy)
995{
996 return securityPolicy == Basic128Rsa15Policy ||
997 securityPolicy == Basic256Policy ||
998 securityPolicy == Basic256Sha256Policy ||
999 securityPolicy == Aes128Sha256RsaOaepPolicy ||
1000 securityPolicy == Aes256Sha256RsaPssPolicy;
1001}
1002
1003QT_END_NAMESPACE
1004
1005

source code of qtopcua/src/opcua/client/qopcuatype.cpp