in_a_nutshell.rst 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. Introduction to OPC UA
  2. ======================
  3. OPC UA, a collection of services
  4. --------------------------------
  5. In OPC UA, all communication is based on service calls, each consisting of a request and a response
  6. message. Be careful to note the difference between services and methods. Services are pre-defined in
  7. the standard and cannot be changed. But you can use the *Call* service to invoke user-defined
  8. methods on the server.
  9. For completeness, the following tables contain all services defined in the standard. Do not bother
  10. with their details yet. We will introduce the different services later in the text. In open62541,
  11. each service is implemented in a single function. See the \ref services section for details.
  12. **Establishing communication**
  13. +-----------------------------+-----------------------------+------------------------------+
  14. | Discovery Service Set | SecureChannel Service Set | Session Service Set |
  15. +=============================+=============================+==============================+
  16. | FindServers | OpenSecureChannel | CreateSession |
  17. +-----------------------------+-----------------------------+------------------------------+
  18. | GetEndpoints | CloseSecureChannel | ActivateSession |
  19. +-----------------------------+-----------------------------+------------------------------+
  20. | RegisterServer | | CloseSession |
  21. +-----------------------------+-----------------------------+------------------------------+
  22. | | | Cancel |
  23. +-----------------------------+-----------------------------+------------------------------+
  24. **Interaction with the information model**
  25. +-----------------------------+-------------------------------+------------------------------+------------------------------+----------------------+
  26. | Attribute Service Set | View Service Set | Method Service Set | NodeManagement Service Set | Query Service Set |
  27. +=============================+===============================+==============================+==============================+======================+
  28. | Read | Browse | Call | AddNodes | QueryFirst |
  29. +-----------------------------+-------------------------------+------------------------------+------------------------------+----------------------+
  30. | HistoryRead | BrowseNext | | AddReferences | QueryNext |
  31. +-----------------------------+-------------------------------+------------------------------+------------------------------+----------------------+
  32. | Write | TranslateBrowsePathsToNodeids | | DeleteNodes | |
  33. +-----------------------------+-------------------------------+------------------------------+------------------------------+----------------------+
  34. | HistoryUpdate | RegisterNodes | | DeleteReferences | |
  35. +-----------------------------+-------------------------------+------------------------------+------------------------------+----------------------+
  36. | | UnregisterNodes | | | |
  37. +-----------------------------+-------------------------------+------------------------------+------------------------------+----------------------+
  38. **Notifications**
  39. +-----------------------------+-------------------------------+
  40. | MonitoredItem Service Set | Subscription Service Set |
  41. +=============================+===============================+
  42. | CreateMonitoredItems | CreateSubscription |
  43. +-----------------------------+-------------------------------+
  44. | ModifyMonitoreditems | ModifySubscription |
  45. +-----------------------------+-------------------------------+
  46. | SetMonitoringMode | SetPublishingMode |
  47. +-----------------------------+-------------------------------+
  48. | SetTriggering | Publish |
  49. +-----------------------------+-------------------------------+
  50. | DeleteMonitoredItems | Republish |
  51. +-----------------------------+-------------------------------+
  52. | | TransferSubscription |
  53. +-----------------------------+-------------------------------+
  54. | | DeleteSubscription |
  55. +-----------------------------+-------------------------------+
  56. OPC UA, a web of nodes
  57. ----------------------
  58. The information model in each OPC UA server is a web of interconnected nodes.
  59. There are eight different types of nodes. Depending on its type, every node
  60. contains different attributes. Some attributes, such as the *NodeId* (unique
  61. identifier) and the *BrowseName*, are contained in all node types.
  62. +-----------------------+-------------------+
  63. | ReferenceTypeNode | MethodNode |
  64. +-----------------------+-------------------+
  65. | DataTypeNode | ObjectTypeNode |
  66. +-----------------------+-------------------+
  67. | VariableTypeNode | ObjectNode |
  68. +-----------------------+-------------------+
  69. | VariableNode | ViewNode |
  70. +-----------------------+-------------------+
  71. Nodes are interconnected by directed reference-triples of the form ``(nodeid,
  72. referencetype, target-nodeid)``. Therefore an OPC UA information model is
  73. easiest imagined as a *web of nodes*. Reference types can be
  74. - standard- or user-defined and
  75. - either non-hierarchical (e.g., indicating the type of a variable-node) or
  76. hierarchical (e.g., indicating a parent-child relationship).
  77. OPC UA, a protocol
  78. ------------------
  79. The OPC UA protocol (both binary and XML-based) is based on 25 *built-in*
  80. datatypes. In open62541, these are defined in ua_types.h.
  81. The builtin datatypes are combined to more complex structures. When the structure contains an array,
  82. then the size of the array is stored in an Int32 value just before the array itself. A size of -1
  83. indicates an undefined array. Positive sizes (and zero) have the usual semantics.
  84. Most importantly, every service has a request and a response message defined as such a data
  85. structure. The entire OPC UA protocol revolves around the exchange of these request and response
  86. messages. Their exact definitions can be looked up here:
  87. https://opcfoundation.org/UA/schemas/Opc.Ua.Types.bsd.xml. In open62541, we autogenerate the
  88. C-structs to handle the standard-defined structures automatically. See ua_types_generated.h for
  89. comparison.