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

Subscribe to and read a flag structure

This scenario guides you through the steps required to subscribe to and read a flag structure. 

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

To subscribe to and read a flag structure

  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. Subscribe to the "flag.packqual" PubSub topic.
  5. Receive a PubSub message.
  6. Process the PubSub message.
  7. Unsubscribe from the topic by disposing the connection.

Example code

internal void AddSubscriptionAndReadFlagStructure()
{
    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.flag.packqual";
                // Subscribe to a topic.
                var subscription = pubsubConnection.Subscribe(topic);
                // Receive a PubSub message.
                var pubSubMsg = subscription.Receive();
                // Process the PubSub message.
                byte[] blobByteArray = pubSubMsg.GetBlob();
                FlagPackQual flagPackQual = new FlagPackQual();
                flagPackQual.CompactedFlags = blobByteArray;
                Console.WriteLine(
quot;Current topic is in Manual Mode:
{flagPackQual.Manual}"); } }// Unsubscribe from the topic by disposing the connection. } catch (Exception ex) { Console.WriteLine("Error:" + ex.Message); } }
TitleResults for “How to create a CRG?”Also Available in