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

AVEVA Enterprise SCADA High Performance Database (HPDB) API Reference

Retrieve field information for a RealTime table filtered by field kind

Retrieve field information for a RealTime table filtered by field kind

This scenario guides you through the steps required to retrieve field information for a RealTime database (RTDB) table, filtered by field kind.

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

Before you begin

  • Review the list of additional namespaces needed for this scenario.

    using System;
    using OASySDNA.RealTime.Data.Common.HighPerformanceDBWrapper;
    using OASySDNA.RealTime.Data.Common.HighPerformanceDBWrapper.Interfaces;
    using OASySDNA.RealTime.Data.Common.HighPerformanceSetDBWrapper.Interfaces;
    using OASySDNA.RealTime.HighPerformanceSetDB;

To retrieve the field information of a RealTime table filtered by field kind

  1. Open the Program.cs file from the created project.
  2. Open the RTDB.
  3. Get the table RealTime type.
  4. Filter by RealTimeFieldKinds.

    RealTimeFieldKinds enumeration represents the kinds of RTDB table fields.

    This enumeration may be combined using bitwise logical AND/OR operators to generate a filter criteria bit mask to pass into the GetRealTimeFieldInfoCollection() method, returning only the results that match the filter.

    • RTTYPE_STRUCT: RealTime struct type.
    • RTTYPE_STRING: RealTime string type.
    • RTTYPE_ENUM: RealTime enum type.
    • RTTYPE_ARRAY: RealTime array type.
    • RTTYPE_SLOT: RealTime slot type.
    • RTTYPE_PRIMITIVE: RealTime primitive type.
    • RTTYPE_PSEUDO: RealTime pseudonym type.
    • RTTYPE_KEYS: RealTime keys type.
    • RTTYPE_ALL: RealTime all type.
  5. Get the RealTime fieldInfoCollection.
  6. For each field, process the field collection results by doing the following:
    • Get fieldInfo properties.

Example code

IRealTimeDatabase database = new RealTimeDatabase();
try
{
    // Open the RTDB.
    if (!database.IsOpen())
    {
        database.Open();
    }
    using (IRealTimeTable table = new RealTimeTable("analog"))
    {
        // Get the table RealTime type.
        IRealTimeStructType tableType = table.GetRecordRealTimeType();
        // Filter by RealTimeFieldKinds
        RealTimeFieldKinds fieldKinds = RealTimeFieldKinds.RTTYPE_STRING | RealTimeFieldKinds.RTTYPE_SLOT;
        // Get the RealTime fieldInfoCollection
        var fieldInfoCollection = tableType.GetRealTimeFieldInfoCollection(fieldKinds);
        // Process field collection results.
        foreach (var fieldInfo in fieldInfoCollection)
        {
            var isKeyString = fieldInfo.Key ? "a key" : "not a key ";
            // Get Field Info properties
            Console.WriteLine(
quot;Field
{fieldInfo.Name} is {isKeyString}"); } } } catch (Exception ex) { Console.WriteLine(
quot;An error occurred while getting all the fields:
{ex.Message}."); }
TitleResults for “How to create a CRG?”Also Available in