.NET Based OPC UA Client/Server SDK  3.0.10.493
Manage Subscription – Create Subscription

Prerequisites

A session with the server must be established.

Description

The following dialog shows an example dialog to create a subscription. Press the button “Show Code” to display the corresponding code, and the button “Help” to show this documentation page.

clienttutorials_create_subscription2.png

Enter the desired subscription parameters into the input field column at “Requested Parameters” and press the button “Create”. A new subscription will be created and the subscription parameters set by the server are displayed at “Revised Parameters”. Check the box in front of “Use Asynchronous Pattern” to call “BeginCreate” instead of “Create”.

Sample Code

The following code creates a new subscription using the requested subcription parameters and displays the revised parameters in the user interface.

After creating the Subscription the following properties are updated with values from the gui:

These are the settings that are requested by the client.

When calling Subscription.Create the subscription is created on the server.

The Subscription settings that are reviced by the server are stored in the properties

// initialize subscription.
m_subscription = new Subscription(session);
m_subscription.PublishingInterval = (double)PublishingIntervalUD.Value;
m_subscription.MaxKeepAliveTime = (double)KeepAliveTimeUD.Value;
m_subscription.Lifetime = (double)LifeTimeUD.Value;
m_subscription.MaxNotificationsPerPublish = (uint)MaxNotificationsUD.Value;
m_subscription.Priority = (byte)PriorityUD.Value;
m_subscription.PublishingEnabled = PublishingEnabledCK.Checked;
// create subscription.
m_subscription.Create(new RequestSettings() { OperationTimeout = 10000 });
// update controls.
CurrentPublishingIntervalTB.Text = m_subscription.CurrentPublishingInterval.ToString();
CurrentKeepAliveTimeTB.Text = m_subscription.CurrentMaxKeepAliveTime.ToString();
CurrentLifeTimeTB.Text = m_subscription.CurrentLifetime.ToString();
CurrentMaxNotificationsTB.Text = m_subscription.CurrentMaxNotificationsPerPublish.ToString();
CurrentPriorityTB.Text = m_subscription.CurrentPriority.ToString();
CurrentPublishingEnabledCK.Checked = m_subscription.CurrentPublishingEnabled;