Codebase analysis · CoreStory V3

OPC Classic Core Components

The OPC Classic core components: C++ and C# code for the COM/DCOM-based industrial-automation interfaces (Data Access, Alarms and Events, Historical Data Access, Data eXchange), including sample servers and .NET wrappers. Maintained by the OPC Foundation.

Maintained by
the OPC Foundation
License
OPC Foundation MIT License 1.00
Commit analyzed
efe0d1d1ea86a8a727bf26a501a261765e836766
Rules extracted
2026-11-14
Extracted by CoreStory V3
3973
accepted rules, each with a cited source quote
01 · Rules

Business rules, traced to source lines.

These 8 rules are a sample of the 3,973 CoreStory V3 extracted from OPC Classic Core Components. Each one links to the exact lines on GitHub at commit efe0d1d. The statement is CoreStory V3’s wording; the code excerpt is the source it cites.

calculation
Source/Shared/SampleServerClasses/COpcDaGroup.cpp

In SetState, when pRequestedUpdateRate is provided: if the requested value is 0 or not a multiple of MAX_UPDATE_RATE, the actual value becomes MAX_UPDATE_RATE*(dwUpdateRate/MAX_UPDATE_RATE+1) and the result is OPC_S_UNSUPPORTEDRATE; in all cases m_uTickOffset is reset to RESET_TICK_BASELINE_NO_CALLBACK and both m_dwUpdateRate and *pRevisedUpdateRate are set to dwUpdateRate.

  • 0 — requested rate causing rounding up
if (pRequestedUpdateRate != NULL) { DWORD dwUpdateRate = *pRequestedUpdateRate; if (dwUpdateRate == 0 || dwUpdateRate%MAX_UPDATE_RATE != 0) { dwUpdateRate = MAX_UPDATE_RATE*(dwUpdateRate/MAX_UPDATE_RATE+1); // indicate that the requested rate will not be used. hResult = OPC_S_UNSUPPORTEDRATE; } // reset tick baseline. m_uTickOffset = RESET_TICK_BASELINE_NO_CALLBACK; *pRevisedUpdateRate = m_dwUpdateRate = dwUpdateRate; }

Also cited: L39

validation
Source/Shared/SampleServerClasses/COpcDaGroup.cpp

SetKeepAlive returns E_INVALIDARG when pdwRevisedKeepAliveTime is NULL; when dwKeepAliveTime==0 it sets m_dwKeepAlive and *pdwRevisedKeepAliveTime to 0 and returns S_OK; otherwise it rounds dwKeepAliveTime up to a multiple of MAX_KEEP_ALIVE_RATE=1000 (adding 1 to the integer quotient when not already a multiple), assigns the result to m_dwKeepAlive and *pdwRevisedKeepAliveTime, and returns OPC_S_UNSUPPORTEDRATE when the rounded value differs from the request, otherwise S_OK.

  • 1000 — MAX_KEEP_ALIVE_RATE granularity for keep-alive times
  • 0 — value that disables keep alive
if (dwActualRate%MAX_KEEP_ALIVE_RATE != 0) { dwActualRate = MAX_KEEP_ALIVE_RATE*(dwActualRate/MAX_KEEP_ALIVE_RATE+1); } // set new update interval. m_dwKeepAlive = *pdwRevisedKeepAliveTime = dwActualRate; return (m_dwKeepAlive != dwKeepAliveTime)?OPC_S_UNSUPPORTEDRATE:S_OK;

Also cited: L36, L800–L810

calculation
DotNetRCWs/OpcNetApi.Com/Da/OpcCom.Da.Subscription.cs

In SetSamplingRates, if the server-returned result differs from the requested SamplingRate, that item's SamplingRate is updated to the returned value and SamplingRateSpecified is set true; else if the call failed, SamplingRate is 0 and SamplingRateSpecified false. On a general exception, all items get SamplingRate 0 and SamplingRateSpecified false.

  • 0 — sampling rate cleared on failure
  • true — SamplingRateSpecified when adjusted by server
  • false — SamplingRateSpecified on failure
for (int ii = 0; ii < errors.Length; ii++) { if (items[ii].SamplingRate != results[ii]) { items[ii].SamplingRate = results[ii]; items[ii].SamplingRateSpecified = true; continue; } if (OpcCom.Interop.GetResultID(errors[ii]).Failed()) { items[ii].SamplingRate = 0; items[ii].SamplingRateSpecified = false; continue; } }
limit
DotNetRCWs/OpcNetApi.Com/Wrapper/OpcCom.Da.Wrapper.Server.cs

A continuation point is expired when the UTC-now ticks exceed its stored timestamp ticks by more than 10 minutes (TimeSpan.TicksPerMinute * 10); expired points are removed and their positions disposed.

  • 10 minutes — continuation point lifetime
if (DateTime.UtcNow.Ticks - cp.Timestamp.Ticks > TimeSpan.TicksPerMinute*10) { expiredPoints.Add(entry.Key); }

Also cited: L1224–L1229

validation
Source/Shared/SampleServerClasses/COpcDaServer.cpp

When creating a group with a non-empty requested name, creation fails with OPC_E_DUPLICATENAME if a group with that name already exists.

if (m_cGroups.Lookup(cName)) { return OPC_E_DUPLICATENAME; }

Also cited: L161–L163

calculation
Source/Shared/SampleServerClasses/COpcDaServer.cpp

When the requested group name is empty, the server generates a unique name of the form "Group%03d" using an incrementing counter, repeating until the generated name is not present in the group table.

  • Group%03d — format string for generated group name
do { _stprintf(tsName, _T("Group%03d"), ++m_uCounter); } while (m_cGroups.Lookup(tsName));

Also cited: L173

validation
DotNetRCWs/OpcNetApi.Com/Da20/OpcCom.Da20.Subscription.cs

In the synchronous Write, if an item has QualitySpecified or TimestampSpecified, its ResultID is set to ResultID.Da.E_NO_WRITEQT, DiagnosticInfo is set to null, and the item is excluded from the write.

  • E_NO_WRITEQT — ResultID assigned to items with quality or timestamp specified
if (items[ii].QualitySpecified || items[ii].TimestampSpecified) { results[ii].ResultID = ResultID.Da.E_NO_WRITEQT; results[ii].DiagnosticInfo = null; continue; }
validation
Source/Shared/SampleServerClasses/COpcDaServer.cpp

BrowseOPCItemIDs returns E_INVALIDARG if any access-rights bits outside the low two bits are set, i.e. (dwAccessRightsFilter & 0xFFFFFFFC) != 0.

  • 4294967292 — mask clearing low two bits
if ((dwAccessRightsFilter & 0xFFFFFFFC) != 0) { return E_INVALIDARG; }
02 · Capabilities
03 · Size

What was analyzed

  • C# · 91 files · 34,175 lines
  • C++ · 67 files · 23,375 lines
  • C/C++ Header · 93 files · 6,511 lines
  • IDL · 12 files · 3,838 lines
  • XML · 7 files · 1,362 lines
  • PowerShell · 10 files · 1,156 lines
  • Windows Message File · 7 files · 943 lines
  • MSBuild script · 6 files · 921 lines
  • WiX source · 4 files · 788 lines
  • Windows Resource File · 12 files · 787 lines
  • CMake · 2 files · 558 lines
  • Other (7 languages) · 23 files · 750 lines

Whole repository: 353 files. cloc 2.06 counts 75,164 lines of code in 334 of them (121,308 lines with comments and blanks).

04 · Source

Where this came from

Extracted by CoreStory V3 (build 4470 with two small engine fixes) using DeepSeek-V4.1-Flash from the public repository at commit efe0d1d on 2026-11-14.

Code excerpts are from the upstream repository and remain under its OPC Foundation MIT License 1.00 license. CoreStory is not affiliated with or endorsed by the OPC Foundation.

Want this for your own codebase?

Talk to us about mapping the business rules in your repositories.

Talk to an expert