c95824a65d
Full read-only SDK (src/AVEVA.Historian.Client) implementing the CLAUDE.md required
surface against AVEVA Historian's binary WCF protocol — no native AVEVA runtime
dependency. All operations live-verified against a local Historian:
- ProbeAsync, ReadRawAsync, ReadAggregateAsync, ReadAtTimeAsync, ReadEventsAsync
- BrowseTagNamesAsync, GetTagMetadataAsync (17 native data-type codes mapped)
- GetConnectionStatusAsync, GetStoreForwardStatusAsync, GetSystemParameterAsync
- 108/108 unit + integration tests pass
Includes the reverse-engineering toolkit (tools/AVEVA.Historian.ReverseEngineering)
used to decode the protocol: WCF probes, IL inspection via dnlib, and IL-rewrite
instrumentation (instrument-wcf-{write,read}message etc.) plus the .NET Framework
trace harness (tools/AVEVA.Historian.NativeTraceHarness) for parity testing.
Sanitized handoff evidence under docs/reverse-engineering/. Native AVEVA binaries
(current/, aveva-install-x64/, aveva-install-x86/) are gitignored — fetch separately
from the AVEVA installer.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
64 lines
2.7 KiB
C#
64 lines
2.7 KiB
C#
using System.Runtime.Versioning;
|
|
using AVEVA.Historian.Client.Wcf;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace AVEVA.Historian.Client.Tests;
|
|
|
|
[SupportedOSPlatform("windows")]
|
|
public sealed class EventChainDiagnosticTests
|
|
{
|
|
private readonly ITestOutputHelper _output;
|
|
|
|
public EventChainDiagnosticTests(ITestOutputHelper output)
|
|
{
|
|
_output = output;
|
|
}
|
|
|
|
[Fact]
|
|
public async Task EventOrchestrator_DiagnosticDump_AgainstLocalHistorian()
|
|
{
|
|
string? host = Environment.GetEnvironmentVariable("HISTORIAN_HOST");
|
|
if (string.IsNullOrWhiteSpace(host) || !string.Equals(host, "localhost", StringComparison.OrdinalIgnoreCase) || !OperatingSystem.IsWindows())
|
|
{
|
|
return;
|
|
}
|
|
|
|
HistorianClientOptions options = new()
|
|
{
|
|
Host = host,
|
|
IntegratedSecurity = true,
|
|
Transport = HistorianTransport.LocalPipe
|
|
};
|
|
|
|
HistorianWcfEventOrchestrator orchestrator = new(options);
|
|
DateTime endUtc = DateTime.UtcNow;
|
|
DateTime startUtc = endUtc - TimeSpan.FromDays(7);
|
|
|
|
int observed = 0;
|
|
AVEVA.Historian.Client.Models.HistorianEvent? firstEvent = null;
|
|
await foreach (var evt in orchestrator.ReadEventsAsync(startUtc, endUtc, CancellationToken.None))
|
|
{
|
|
observed++;
|
|
firstEvent ??= evt;
|
|
}
|
|
|
|
_output.WriteLine($"Events observed: {observed}");
|
|
if (firstEvent is not null)
|
|
{
|
|
_output.WriteLine($" EventTimeUtc: {firstEvent.EventTimeUtc:O}");
|
|
_output.WriteLine($" ReceivedTimeUtc: {firstEvent.ReceivedTimeUtc:O}");
|
|
_output.WriteLine($" Type: {firstEvent.Type}");
|
|
_output.WriteLine($" Properties.Count:{firstEvent.Properties.Count}");
|
|
_output.WriteLine($" Has alarm_id: {firstEvent.Id != Guid.Empty}");
|
|
}
|
|
_output.WriteLine($"LastEnsT2Handle: {HistorianWcfEventOrchestrator.LastEnsT2Handle}");
|
|
_output.WriteLine($"LastEnsT2PayloadSha256: {HistorianWcfEventOrchestrator.LastEnsT2PayloadSha256}");
|
|
_output.WriteLine($"LastUpdC3ReturnCode: {HistorianWcfEventOrchestrator.LastUpdC3ReturnCode}");
|
|
_output.WriteLine($"LastRTag2ReturnCode: {HistorianWcfEventOrchestrator.LastRTag2ReturnCode}");
|
|
_output.WriteLine($"LastAddReturnCode (EnsT2): {HistorianWcfEventOrchestrator.LastAddReturnCode}");
|
|
_output.WriteLine($"LastAddOutputLength: {HistorianWcfEventOrchestrator.LastAddOutputLength}");
|
|
_output.WriteLine($"LastResultBufferLength: {orchestrator.LastResultBufferLength}");
|
|
_output.WriteLine($"LastErrorBufferDescription: {orchestrator.LastErrorBufferDescription}");
|
|
}
|
|
}
|