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 struct array type

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

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

To read a struct array type

  1. Open the Program.cs file from the created project.
  2. Open the RTDB.
  3. Access the trendIndicatorImageSet table.
  4. Lock the trendIndicatorImageSet table for reading.
  5. Locate the test record.
  6. Lock the test record for reading.
  7. Access the IncreaseThresholds array field of the test record found.
  8. Unlock the test record.
  9. Unlock the trendIndicatorImageSet table.

Example code

try
{
    IRealTimeDatabase database = new RealTimeDatabase();
    // Open the RTDB.
    if (!database.IsOpen())
    {
        database.Open();
    }
   
    // Access the trendIndicatorImageSet table.
    using (IRealTimeTable table = new RealTimeTable("trendIndicatorImageSet"))
    {
        ITableLockRequestType tableLockRequest = new TableLockRequestType();
        // Lock the trendIndicatorImageSet table for reading.
        table.Lock(tableLockRequest.SAFE_READ);
        var nameField = new RealTimeStringField(table.Name, "name");
       
        // Locate the test record.
        using (IRealTimeRecord rtRecord = table.FindRecord(nameField, "test"))
        {
            IRecordLockRequestType recordLockRequest = new RecordLockRequestType();
            // Lock the test record for safe reading.
            rtRecord.Lock(recordLockRequest.SAFE_READ);
            // Access the IncreaseThresholds array field of the test record found.
            var increaseThresholdField = new RealTimeField(table.Name, "IncreaseThresholds");
            var realtimeArrayType = new RealTimeArrayType(increaseThresholdField.GetRealTimeType().Name);
           
            var arrayFieldName = "IncreaseThresholds";
            var readArray = new StructRealTimeArray<ITrendIndicatorImageThreshold>(rtRecord, arrayFieldName, realtimeArrayType.ArraySize,(record, arrayElement) =>
{ return new TrendIndicatorImageThreshold(record, arrayElement); });
           
            foreach (var result in readArray)
            {
                Console.WriteLine(
quot;TrendIndicatorImage IncreaseThresholds image:
{result.Image} and value: {result.Value}"); } } // Leaving scope releases the test record lock. } // Leaving scope releases the trendIndicatorImageSet table lock. } catch (Exception ex) { Console.WriteLine(
quot;An error occurred while reading a structure array:
{ex.Message}"); }
TitleResults for “How to create a CRG?”Also Available in