Rapid SCADA: Configuring Custom Event Archives Safely

Jason IP2 min read
Other ManufacturerSCADA ConfigurationTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Map archiveBit to archiveMask

Rapid SCADA uses two related archive selectors for events. WriteEvent accepts an archiveMask because one event can be written to multiple archives at the same time. GetEvents accepts one archiveBit because a query reads from a single archive.

Operation Selector Meaning
Write an event archiveMask Bitmask selecting one or more destination archives
Read events archiveBit Bit position selecting one archive

For one archive, calculate the write mask from the read bit as archiveMask = 1 << archiveBit. Therefore, archiveBit = 4 corresponds to archiveMask = 16. Consult the available ArchiveMask class when implementing this mapping.

Configure a custom event archive

The archive mask is a signed integer, so the evidence identifies 31 available archive bits rather than 32. Before creating an archive in code, check whether the intended bit or code is already occupied or whether the archive has already been created.

  1. Select an unused archive bit and confirm that no existing archive owns it.
  2. Create the required archive entry, guarding against duplicate creation.
  3. Calculate its mask with 1 << archiveBit.
  4. Pass the mask to WriteEvent and the corresponding bit to GetEvents.

Use a bounded event query range

Do not construct TimeRange with the minimum and maximum DateTime values; that range caused an overflow in the reported test. Use explicit operational bounds around the required period instead.

var archiveBit = 4;
var archiveMask = 1 << archiveBit;

ServerContext.WriteEvent(archiveMask, new Event
{
    Timestamp = DateTime.UtcNow,
    CnlNum = 1,
    DeviceNum = 1,
    CnlVal = 11,
    CnlStat = CnlStatusID.Defined,
    Text = "123321",
    Data = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04,
                        0x05, 0x06, 0x07, 0x08, 0x09 }
});

var range = new TimeRange(
    DateTime.Today.AddDays(-2),
    DateTime.Today.AddDays(2),
    true);

var events = ServerContext.GetEvents(archiveBit, range, null);

Verify write and historical retrieval

Write a timestamped event, then query the matching archiveBit over a bounded range that includes that timestamp. Confirm that the result count is nonzero and that the returned timestamps include the written event. If retrieval fails, first verify the mask-to-bit relationship, then confirm that the archive bit was not already assigned elsewhere.

FAQ

Why can Rapid SCADA write my event but not read it back?

Writing uses archiveMask, while reading uses archiveBit. For archiveBit = 4, write with archiveMask = 16 and query with bit 4.

How many event archive bits can the archive mask address?

The evidence identifies 31 available bits because the archive mask is a signed integer. Check that the selected bit is unused before creating a custom archive.

Why does a Rapid SCADA TimeRange query overflow?

Using the minimum and maximum DateTime values caused an overflow. Replace them with bounded dates that cover only the required event interval, such as two days before through two days after today.

Back to blog