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 and modify a slot field

This scenario guides you through the steps required to read and modify a slot-type field of an analog record in the RealTime database (RTDB).

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

To read and modify a slot field

  1. Open the Program.cs file from the created project.
  2. Open the RTDB.
  3. Access the analog table.
  4. Lock the analog record for writing.
  5. Get the slot field of a record.
  6. Lock the record for writing.
  7. Modify the record.
  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 tableLockRequest = new TableLockRequestType();
        // Lock the analog table for writing.
        table.Lock(tableLockRequest.SAFE_WRITE);
       
        // Get the slot field of a record.
        using (IRealTimeRecord record = new RealTimeRecord(table, 28))
        {
            IRecordLockRequestType recordLockRequest = new RecordLockRequestType();
            // Lock the record for writing.
            record.Lock(recordLockRequest.SAFE_WRITE);
            // Modify the record.
            var rtuSlot = record.ReadField<Int32>("rtu");
            record.WriteField<Int32>("rtu", 10);
            Console.WriteLine(
quot;Rtu changed from
{rtuSlot} to: {record.ReadField<Int32>("rtu")}"); } // Leaving scope releases the record lock. } // Leaving scope releases the analog table lock. } catch (Exception ex) { Console.WriteLine(
quot;An error occurred while reading/writing the slot field:
{ex.Message}"); }
TitleResults for “How to create a CRG?”Also Available in