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

Create a RealTimeSetRecord from a RealTimeRecord using the RealTimeRecord number

Create a RealTimeSetRecord from a RealTimeRecord using the RealTimeRecord number

This scenario guides you through the steps required to create a RealTimeSetRecord object from a RealTimeRecord.

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

Before you begin

  1. Open the Program.cs file from the created project.
  2. Open the RealTime database (RTDB).
  3. Review the list of additional namespaces needed for the desired scenario.

    using SetTableLockRequestType = OASySDNA.RealTime.HighPerformanceSetDB.TableLockRequestType;
    using SetRecordLockRequestType = OASySDNA.RealTime.HighPerformanceSetDB.RecordLockRequestType;

To create a RealTimeSetRecord

  1. Lock the analog table for reading.
  2. Find the analog record to get its pointer name.
  3. Lock the analog table for reading.
  4. Get the RealTimeSetTable.
  5. Lock the RealTimeSetTable.
  6. Create the RealTimeSetRecord object.
  7. Unlock the set record.
  8. Unlock the set table. 
  9. 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 name.
        var nameField = new RealTimeStringField(table, "name");
        using (var record = table.FindRecord(nameField, "AutoCommandAnalog01"))
        {
            // Get the RealTimeSetTable.
            using (var setTable = (RealTimeSetTable)table.GetRealTimeSetTable())
            {
                // Lock the RealTimeSetTable.
                setTable.Lock(SetTableLockRequestType.SAFE_READ);
                // Create the RealTimeSetRecord object.
                using (var setRecord = new RealTimeSetRecord(setTable, record.RecordNumber))
                {
                    setRecord.Lock(SetRecordLockRequestType.SAFE_READ);
                    // User code that uses set record.
                    var desc = setRecord.ReadField<String>("description");
                    Console.WriteLine(
quot;Description:
{desc}"); } // Leaving scope releases the set record lock. } // Leaving scope releases the set table lock. } } // Leaving scope releases the analog table lock. } catch (Exception ex) { Console.WriteLine(
quot;Error getting the RealTimeSetRecord:
{ex.Message}"); }
TitleResults for “How to create a CRG?”Also Available in