Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA Enterprise SCADA PubSub API Reference

Remove a publisher

This scenario guides you through the steps required to remove a publisher.

To identify the code associated with each step, see the code comments in the Example code section.

To remove a publisher

  1. Open the Program.cs file from the created project.
  2. Open a PubSub connection.
  3. Confirm there is a connection with the PubSub system.
  4. Publish data on a topic.
  5. Remove this application as a publisher by using one of the following methods:
  • Using the RemovePublisher method.
    // Remove this application as a publisher.
    pubsubConnection.RemovePublisher(topic);
  • Once the using block is finished, disposing the connection will remove the publisher, clean up, and disconnect from the engine. If a using block is used, calling Disconnect explicity is optional.

Example code

internal void RemovePublisher()
{
    try
    {
        IPubSubConnectionFactory pubSubConnectionFactory = new PubSubConnectionFactory();
        // Open a PubSub connection.
        using (var pubsubConnection = pubSubConnectionFactory.OpenConnection())
        {
            // Confirm there is a connection with the PubSub system.
            if (pubsubConnection.IsConnected())
            {
                var topic = "es.realtime.db.analog.DeviceRollupAnalog01.curval";
                var pubSubMessage = new PubSubMessageBuilder(topic, PubSubHeaderData.PS_NORMAL_DATA).Write(24.5).GetResult();
                // Publish data on a topic.
                pubsubConnection.Publish(pubSubMessage);
                // Remove this application as a publisher.
                pubsubConnection.RemovePublisher(topic);
            }
        }
    }
    catch (Exception ex)
    {
        Console.WriteLine("Error:" + ex.Message);
    }
}
TitleResults for “How to create a CRG?”Also Available in