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