Modify the publishing/replicating behavior of a field
- Last UpdatedApr 08, 2026
- 2 minute read
This scenario guides you through the steps required to modify the publication/replication behavior of a field in the RealTime database (RTDB).
To identify the code associated with each step, see the code comments in the Example code section.
The High Performance Database (HPDB) Set has the following RealTime notifications in the RTChangeNotification class:
- Use None for no notification.
- Use Publish for a publication if the field's value has changed.
- Use PublishAndReplicate for a publication and replication if the field's value has changed.
- Use ForcedPublish for a forced publication of the field's value when the value doesn’t change.
- Use ForcedPubAndRep for forced publication and replication of the field's value when the value doesn’t change.
Publish and Replicate is the default notification process.
To modify the publication/replication behavior of a field
- Open the Program.cs file from the created project.
- Open the RTDB.
- Access the analog table.
- Lock the analog table for safe reading.
- Find the analog record.
- Lock the analog record for safe reading.
- Access the analog flag field of the found analog.
- Force the replication of the found analog flag field by using one of the following methods:
- Use the WriteData function.
var isFlashing = record.ReadField<Boolean>("flag.flash"); record.WriteData("flag.flash", !isFlashing, OASySDNA.RealTime.HighPerformanceSetDB.RTChangeNotification.ForcedPubAndRep); - Use the WriteBool function of the HPDBRealTimeRecord.
var isFlashing = record.ReadField<Boolean>("flag.flash"); record.HPDBRealTimeRecord.WriteBool("flag.flash", !isFlashing, OASySDNA.RealTime.HighPerformanceSetDB.RTChangeNotification.ForcedPubAndRep);
- Use the WriteData function.
- Unlock the analog record.
- Unlock the analog table.
Locks can be released either by calling Unlock(), or by locking the objects with a using(...){} block so that the lock is implicitly released when leaving the scope of the block.
Example code
try
{
IRealTimeDatabase database = new RealTimeDatabase();
// 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 safe reading.
table.Lock(tableLockRequest.SAFE_WRITE);
var nameField = new RealTimeStringField(table.Name, "name");
// Find the analog record.
using (IRealTimeRecord record = table.FindRecord(nameField, "AutoCommandAnalog01"))
{
// Lock the analog record for safe reading.
IRecordLockRequestType recordLockRequest = new RecordLockRequestType();
record.Lock(recordLockRequest.SAFE_WRITE);
// Access the analog flag field of the found analog.
var isFlashing = record.ReadField<Boolean>("flag.flash");
// Force the replication of the found analog flag field.
record.WriteData("flag.flash", !isFlashing, OASySDNA.RealTime.HighPerformanceSetDB.RTChangeNotification.ForcedPubAndRep);
Console.WriteLine(quot;Flash changed from {isFlashing} to: {record.ReadField<Boolean>("flag.flash")}");
} // Leaving scope releases the analog record lock.
} // Leaving scope releases the analog table lock.
}
catch (Exception ex)
{
Console.WriteLine(quot;An error occurred while publishing a field: {ex.Message}");
}