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

Publish data into a PubSub topic

This scenario guides you through the steps required to publish data into a PubSub topic.

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

To publish data into a PubSub topic

  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.

Example code

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