Using the RunTimeData SDK
The namespace of all APIs in the RunTimeData SDK is:
- ArchestrA.Client.RuntimeData
The assembly name of the RunTimeData SDK is:
- ArchestrA.Client.RuntimeData.dll
The general workflow for using the RuntimeData SDK is:
- Implement the IRuntimeDataClient interface in the control of the app. If you need to provide the ability to read or write any run-time data, you must implement the IRuntimeDataClient interface to receive the DataSubscription instance. Note that data subscription is automatically suspended when the app window is minimized, and resumes when the window is restored.
Implement IRuntimeDataClient Interface Copy Codepublic partial class UserControl1, IRuntimeDataClient { public DataSubscription DataSubscription { get; set; } }
- Establish a subscription to a reference and read the value.
Subscribe to a DataReferenceSource Copy CodeDataReference[] references = this.DataSubscription.Subscribe(new [] { new DataReferenceSource("GRNode.CPULoad", (r) => { // The action is executed in a background thread, so do not operate the UI directly this.CPUUsage = r.VT.ValueAsDouble; } }
The callback in the above sample is sent from a background thread. If the handler code in the App has any UI-specific logic, the handler must execute in its Dispatcher. The above value is received in an action that has been passed in. Alternatively, you can get the data by using references[0].VTQ.Value.
- Optional: Asynchronous read:
Asynchronous Read Copy Codevar vtqArray = await this.DataSubscription.ReadAsync { new [] {new DataReferenceSource("GRNode.CPULoad")} }
- Write from subscription (see step 2 for subscription details). The following code sample shows how to write data to the subscription.
Write to Subscription Copy Codereferences[0].Write(10, (r, s)=>{}); /// Or to write to an element in array: references[0].Write(10, 0, (r, s)=>{});
- Optional: Asynchronous write:
Asynchronous Write Copy Codevar status = await this.DataSubscription.WriteAsync(new DataRefereceSource(“Tank1.SP”), 10);
See Also