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

Read a primitive array type

This scenario guides you through the steps required to read a primitive array type in the RealTime database (RTDB).

To read a primitive array type

  1. Open the Program.cs file from the created project.   
  2. Open the RTDB.
  3. Access the aceCode table.
  4. Lock the aceCode table for reading.
  5. Locate the ace record.
  6. Lock the ace record for reading.
  7. Access the code array field of the located ace record.
  8. Unlock the ace record.
  9. Unlock the aceCode table.

Example code

try
{
    IRealTimeDatabase database = new RealTimeDatabase();
    // Open the RTDB.
    if (!database.IsOpen())
    {
        database.Open();
    }
    // Access the aceCode table.   
    using (IRealTimeTable table = new RealTimeTable("acecode"))
    {
        ITableLockRequestType tableLockRequest = new TableLockRequestType();
        // Lock the aceCode table for reading.
        table.Lock(tableLockRequest.SAFE_READ);
        // Locate the ace record. 
        var nameField = new RealTimeStringField(table.Name, "name");
       
        using (IRealTimeRecord record = table.FindRecord(nameField, "aceCode"))
        {
            IRecordLockRequestType recordLockRequest = new RecordLockRequestType();
            // Lock the ace record for reading.
            record.Lock(recordLockRequest.SAFE_READ);
            // Access the code array field of the located ace record.
            var arrayField = new RealTimeField(table.Name, "code");
            var arrayType = new RealTimeArrayType(arrayField.GetRealTimeType().Name);                       
            var primitiveArray = new PrimitiveRealTimeArray<ulong>(record, "code", arrayType.ArraySize);
           
            foreach (var result in primitiveArray)
            {
                Console.WriteLine(
quot;Buffer value:
{result}"); } } // Leaving scope releases the ace record lock. } // Leaving scope releases the aceCode table lock. } catch (Exception ex) { Console.WriteLine(
quot;An error occurred while reading the buffer field:
{ex.Message}"); }
TitleResults for “How to create a CRG?”Also Available in