SignalR API
The SignalR API utilizes the Microsoft SignalR library. SignalR is a library for developers that simplifies the process of adding real-time web functionality to applications. Real-time web functionality is the ability to have server code push content to connected clients instantly as it becomes available, rather than having the server wait for a client to request new data.
In the OPC UA API the SignalR API is primarily used for subscribing to data and event values. This means that the API calls back to the client (e.g browser), when values have changed.
The SignalR API exposes a set of RPC-methods. The client must then implement corresponding callback methods to receive results fromt the API.
Hub
The address of the SignalR hub is /OpcUaHub.
The methods below can be reached through this hub.
Methods
ReadValues
This method is called to read values (i.e. the value of attribute with id = 13) of one or more nodes.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | array of ReadValuesRequest | Contains the nodes to read and the connection info |
OnReadValues
This is the callback method for ReadValues.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in ReadValues |
response | array of ReadValuesResponse | Contains the values of the nodes if successful. |
The second parameter is an array of ReadValuesResponse, and contains the values (i.e. the value of attribute with id = 13) of the nodes or an error code if unsuccessful. The order of the arrays are the same as the order of the arrays in ReadValues.
WriteValues
This method is called to write values (i.e. the value of attribute with id = 13) to one or more nodes.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | array of WriteValuesRequest | Contains the nodes and values to write and the connection info |
OnWriteValues
This is the callback method for WriteValues.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in WriteValues |
response | array of WriteValuesResponse | Contains the status of the write operation. |
ReadDataTypes
This method is called to read datatypes (i.e. the value of attribute with id = 14) of one or more nodes.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | ReadDataTypesRequest | Contains the nodes to read and the connection info |
OnReadDataTypes
This is the callback method for ReadDataTypes.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in ReadDataTypes |
response | array of ReadDataTypesResponse | Contains the datatypes of the nodes if successful. |
ReadAttributes
This method is called to read attributes of one or more nodes.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | array of ReadAttributesRequest | Contains the nodes and attribute ids to read and the connection info |
OnReadAttributes
This is the callback method for ReadAttributes.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in ReadAttributes |
response | array of ReadAttributesResponse | Contains the values of the attributes of the nodes if successful. |
The second parameter is an array of ReadAttributesResponse, and contains the values of the attributes or an error code if unsuccessful. The order of the arrays are the same as the order of the arrays in ReadAttributes.
WriteAttributes
This method is called to write attributes to one or more nodes.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | array of WriteAttributesRequest | Contains the nodes, attribute ids and values to write and the connection info |
OnWriteAttributes
This is the callback method for WriteAttributes.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in WriteAttributes |
response | array of WriteAttributesResponse | Contains the status of the write operation. |
HistoryReadRaw
This method reads raw history data from an OPC UA Server.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | ReadHistoryRawValuesRequest | Contains the nodes, attribute ids to read and the connection info |
OnOnHistoryReadRaw
This is the callback method for HistoryReadRaw.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in HistoryReadRaw |
response | ReadHistoryRawValuesResponse | Contains the result of the read operation. |
HistoryReadProcessed
This method reads processed data from an OPC UA Server.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | ReadHistoryProcessedValuesRequest | Contains the nodes, attribute ids and other arguments needed for reading processed data. |
OnHistoryReadProcessed
This is the callback method for HistoryReadProcessed.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in HistoryReadProcessed |
response | ReadHistoryProcessedValuesResponse | Contains the result of the read operation. |
GetHistoricalAggregates
This method gets the available historical aggregates from an OPC UA Server.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | HistoricalAggregateRequest |
OnGetHistoricalAggregates
This is the callback method for GetHistoricalAggregates.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in GetHistoricalAggregates |
response | HistoryAggregateResponse | Contains the historical aggregates for the OPC UA Server. |
HistoryWriteValues
This method writes historical data to an OPC UA Server.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | HistoryWriteRequest | Contains the values to write. |
OnHistoryWriteValues
This is the callback method for HistoryWriteValues.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in HistoryWriteValues |
response | HistoryWriteResponse | Contains the result of the write operation. |
ReadEventsHistory
This method reads the event history from an OPC UA Server.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | ReadEventHistoryRequest | Contains the information needed for reading event history |
OnReadEventsHistory
This is the callback method for ReadEventsHistory.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in ReadEventsHistory |
response | ReadEventHistoryResponse | Contains the historical events. |
ReadEventsHistoryExtended
This method reads the event history from an OPC UA Server. The difference between this method and ReadEventsHistory is that the fields to be queried for are not predefined.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | ReadEventHistoryExtendedRequest | Contains the information needed for reading event history |
OnReadEventsHistoryExtended
This is the callback method for ReadEventsHistoryExtended.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in ReadEventsHistoryExtended |
response | ReadEventHistoryExtendedResponse | Contains the historical events. |
WriteEventsHistory
This method writes event history to an OPC UA Server.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | WriteEventHistoryRequest | Contains the information needed for writing event history |
OnWriteEventsHistory
This is the callback method for WriteEventsHistory.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in WriteEventsHistory |
response | WriteEventHistoryResponse | Contains the result of the write operation. |
WriteEventsHistoryExtended
This method writes event history to an OPC UA Server.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | WriteEventHistoryExtendedRequest | Contains the information needed for writing event history |
OnWriteEventsHistoryExtended
This is the callback method for WriteEventsHistoryExtended.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in WriteEventsHistoryExtended |
response | WriteEventHistoryExtendedResponse | Contains the result of the write operation. |
GetEventFields
This method gets the predefined event fields. These event fields are usually the most queried, and are available for querying in an easy way. This can be seen in ReadEventHistoryRequest.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
OnEventFieldsFetched
This is the callback method for GetEventFields.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in GetEventFields |
response | array of EventFieldDefinition | Contains the predefined events which can be queried in ReadEventHistoryRequest. |
GetEventTypes
This method gets Event types.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | GetEventTypesRequest | Contains the information needed getting event-types |
OnGetEventTypes
This is the callback method for GetEventTypes.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in GetEventTypes |
response | GetEventTypesResponse | Contains the event types. |
AddEventComments
This method adds comment to an event.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | array of AddCommentRequest | Contains the event id and comment |
OnEventsCommented
This is the callback method for AddEventComments.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in AddEventComments |
response | array of AddCommentResponse | The response tells whether the AddComment was successful. |
ConfirmEvents
This method confirms events.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | array of ConfirmRequest | Contains the event id and comment |
OnEventsConfirmed
This is the callback method for ConfirmEvents.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in ConfirmEvents |
response | array of ConfirmResponse | The response tells whether the Confirm was successful. |
AcknowledgeEvents
This method acknowledges events.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | array of AcknowledgeRequest | Contains the event id and comment |
OnEventsAcknowledged
This is the callback method for AcknowledgeEvents.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in AcknowledgeEvents |
response | array of AcknowledgeResponse | The response tells whether the Acknowledge was successful. |
CreateEventSubscription
This method creates an event subscription. When subscribing to events two callback methods are involved. First the OnEventSubscriptionCreated is invoked telling whether the subscription was created correctly. Then as events happen the OnEvents method will be invoked, containing all the events which have occured since the last OnEvents call. The first OnEvents call after a successful event subscription has occured, will contain the current state of all the applicable event sources.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | CreateEventSubscriptionRequest | Contains the information needed to create event subscription |
OnEventSubscriptionCreated
This is the callback method invoked after the CreateEventSubscription has been called.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in CreateEventSubscription. |
response | CreateEventSubscriptionResponse | The response tells whether the subscription has been created successfully. |
OnEvents
This is the callback method invoked when the events have occured for the subscription.
Parameter | Type | Description |
---|---|---|
response | EventsChangedResponse | Contains the events which have occured since the previous OnEvents invocation. |
CloseEventSubscription
This method closes (stops) an event subscription. If this method is not called, it will be automatically called when the client disconnects.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | CloseEventSubscriptionRequest | Contains the id of the subscription to be closed. |
OnEventSubscriptionClosed
This is the callback method for CloseEventSubscription.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in CloseEventSubscription. |
response | CloseEventSubscriptionResponse | The response tells whether the subscription has been closed successfully. |
CreateDataValueSubscription
This method creates a data value subscription. When subscribing to data values two callback methods are involved. First the OnDataValueSubscriptionCreated is invoked telling whether the subscription was created correctly. Then as data values change the OnDataValuesUpdate method will be invoked, containing all the data values which have changed since the last OnDataValuesUpdate call.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | CreateDataValueSubscriptionRequest | Contains the information needed to create data value subscription |
startSubscription | Boolean | If true the subscription starts right away. If false the StartDataValueSubscription has to be called. |
OnDataValueSubscriptionCreated
This is the callback method invoked after the CreateDataValueSubscription has been called.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in CreateDataValueSubscription. |
response | CreateDataValueSubscriptionResponse | The response tells whether the subscription has been created successfully. |
OnDataValuesUpdate
This is the callback method invoked when the data values have changed for the subscription.
Parameter | Type | Description |
---|---|---|
response | DataValuesChangedResponse | Contains the data values which have changed since the previous OnDataValuesUpdate invocation. |
CloseDataValueSubscription
This method closes (stops) a data value subscription. If this method is not called, it will be automatically called when the client disconnects.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback |
request | CloseDataValueSubscriptionRequest | Contains the id of the subscription to be closed. |
OnDataValueSubscriptionClosed
This is the callback method for CloseDataValueSubscription.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in CloseDataValueSubscription. |
response | CloseDataValueSubscriptionResponse | The response tells whether the subscription has been closed successfully. |
StartDataValueSubscription
This method starts a subscription created by CreateDataValueSubscription.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback. |
subscriptionid | String | The id of the subscription to be started. |
OnDataValueSubscriptionStarted
This is the callback method for StartDataValueSubscription.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in StartDataValueSubscription. |
response | StartDataValueSubscriptionResponse | The response tells whether the subscription has been started successfully. |
GetNamespaces
This method gets the namespaces of a OPC UA Server.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback. |
request | NamespacesRequest |
OnNamespacesFetched
This is the callback method for GetNamespaces.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in GetNamespaces. |
response | NamespaceResponse | Contains the namespaces |
Browse
This method is used to browse the UA Address Space for nodes.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback. |
request | BrowseRequest | The information needed to start a browse operation. |
OnBrowse
This is the callback method for Browse.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in Browse. |
response | BrowseResponse | Contains the references to nodes. |
BrowseMulti
This method is used to browse with multiple source nodes the UA Address Space for nodes.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback. |
request | BrowseMultiRequest | Browse request |
OnBrowseMulti
This is the callback method for BrowseMulti.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in BrowseMulti. |
response | MultiBrowseResponse | Contains the references to nodes. |
BrowseChildren
This method is used to browse the UA Address Space for children nodes. The children nodes are defined as nodes of node class: Variable, Object, DataType, VariableType or ObjectType.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback. |
request | ChildrenRequest | The information needed to start a browse children operation. |
OnBrowseChildren
This is the callback method for BrowseChildren.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in BrowseChildren. |
response | BrowseResponse | Contains the references to nodes. |
BrowseProperties
This method is used to browse the UA Address Space for properties. The property nodes are defined as nodes of node class: Variable which has a HasProperty reference.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback. |
request | BrowsePropertiesRequest | The information needed to start a browse for properties operation. |
OnBrowseProperties
This is the callback method for BrowseProperties.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in BrowseProperties. |
response | BrowseResponse | Contains the references to nodes. |
BrowsePropertiesMulti
This method is used to browse the UA Address Space for properties. The property nodes are defined as nodes of node class: Variable which has a HasProperty reference.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback. |
request | BrowsePropertiesMultiRequest | The information needed to start a browse for properties operation. |
OnBrowsePropertiesMulti
This is the callback method for BrowsePropertiesMulti.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in BrowsePropertiesMulti. |
response | MultiBrowseResponse | Contains the references to nodes. |
TranslateBrowsePathsToNodeIds
Translates browse paths to node ids.
Parameter | Type | Description |
---|---|---|
requestId | String | A string which is returned in the callback. |
request | TranslateBrowsePathsRequest | Contains starting nodes and relative paths. |
OnTranslateBrowsePathsToNodeIds
This is the callback method for TranslateBrowsePathsToNodeIds.
Parameter | Type | Description |
---|---|---|
requestId | String | The string which is passed in TranslateBrowsePathsToNodeIds. |
response | TranslateBrowsePathsResponse | Contains the node ids for the relative paths. |