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 a field pointer

This scenario guides you through the steps required to retrieve the field pointer for a record. A pointer to the field allows direct access to the memory for that field.

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

To retrieve a field pointer

When performing this procedure, ensure that the locks applied match the desired task (that is, if the record is locked for reading, do not write to the memory at the field pointer).

Any changes to a field using the field pointer will not be tracked via Management of Change (MoC) since you are directly modifying shared memory.

  1. Open the Program.cs file from the created project.
  2. Open the RealTime database (RTDB).
  3. Lock the analog table for reading.
  4. Find the analog record to get its pointer by name.
  5. Lock the analog record for reading.
  6. Get the field pointer.
  7. Unlock the analog record.
  8. Unlock the analog table.

Example code

IRealTimeDatabase database = new RealTimeDatabase();
try
{
    // Open the RTDB.
    if (!database.IsOpen())
    {
        database.Open();
    }
    using (IRealTimeTable table = new RealTimeTable("analog"))
    {
        ITableLockRequestType tableLockRequest = new TableLockRequestType();
        IRecordLockRequestType recordLockRequest = new RecordLockRequestType();
        // Lock the analog table for reading.
        table.Lock(tableLockRequest.SAFE_READ);
        // Find the analog record to get its pointer by name.
        var nameField = new RealTimeStringField(table, "name");
        using (var record = table.FindRecord(nameField, "AutoCommandAnalog01"))
        {
            // Lock the analog record for reading.
            record.Lock(recordLockRequest.SAFE_READ);
            // Get the field pointer.
            var flagField = new RealTimeField(table.Name, "flag");
            var flagFieldPointer = record.GetPointerToField(flagField);                      
            // User code that uses the field pointer.
        } // Leaving scope releases the analog record lock.
    } // Leaving scope releases the analog table lock.
}
catch (Exception ex)
{
    Console.WriteLine(
quot;Error getting the field pointer:
{ex.Message}"); }
TitleResults for “How to create a CRG?”Also Available in