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 an ordered or reversed record collection

This scenario guides you through the steps required to retrieve an ordered or reversed record collection for an analog table in the RealTime database (RTDB).

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

  • RecordOrderCollection methods can be called with a record number to specify the starting record to create the collection from.
  • To get the record collection in reverse order, use the GetReverseRecordOrderCollection method and ReverseRecordOrderCollection class.

To retrieve an ordered record collection

  1. Open the Program.cs file from the created project.
  2. Open the RTDB.
  3. Access the analog table.
  4. Lock the analog table for reading.
  5. Lock the record.
  6. Get an ordered record collection.
  7. Process the ordered record collection.
  8. Unlock the record.
  9. Unlock the analog table.    

Example code

IRealTimeDatabase database = new RealTimeDatabase();
try
{
    // Open the RTDB.
    if (!database.IsOpen())
    {
        database.Open();
    }
   
    // Access the analog table.
    using (IRealTimeTable table = new RealTimeTable("analog"))
    {
        ITableLockRequestType lockRequest = new TableLockRequestType();
        IRecordLockRequestType recordLockRequest = new RecordLockRequestType();
        // Lock the analog table for reading.
        table.Lock(lockRequest.SAFE_READ);
        // Get an ordered record collection.
        var orderCollection = table.GetRecordOrderCollection();
        // Process the ordered record collection.
        foreach (var rtRecord in orderCollection)
        {
            // Lock the record for reading.
            rtRecord.Lock(recordLockRequest.SAFE_READ);
            Console.WriteLine(
quot;Name:
{rtRecord.ReadString("name")} has ptnum: {rtRecord.RecordNumber}"); rtRecord.UnLock(); } // Leaving scope releases the record lock. } // Leaving scope releases the analog table lock. } catch (Exception ex) { Console.WriteLine(
quot;Error occurred while getting the RecordOrderCollection:
{ex.Message} has been raised"); }
TitleResults for “How to create a CRG?”Also Available in