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>
51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
using System.Buffers.Binary;
|
|
using System.Text;
|
|
|
|
namespace AVEVA.Historian.Client.Protocol;
|
|
|
|
internal static class HistorianBinaryPrimitives
|
|
{
|
|
public static long ToFileTimeUtc(DateTime value)
|
|
{
|
|
return value.Kind == DateTimeKind.Unspecified
|
|
? DateTime.SpecifyKind(value, DateTimeKind.Utc).ToFileTimeUtc()
|
|
: value.ToUniversalTime().ToFileTimeUtc();
|
|
}
|
|
|
|
public static void WriteUInt16LittleEndian(Stream stream, ushort value)
|
|
{
|
|
Span<byte> buffer = stackalloc byte[sizeof(ushort)];
|
|
BinaryPrimitives.WriteUInt16LittleEndian(buffer, value);
|
|
stream.Write(buffer);
|
|
}
|
|
|
|
public static void WriteUInt32LittleEndian(Stream stream, uint value)
|
|
{
|
|
Span<byte> buffer = stackalloc byte[sizeof(uint)];
|
|
BinaryPrimitives.WriteUInt32LittleEndian(buffer, value);
|
|
stream.Write(buffer);
|
|
}
|
|
|
|
public static void WriteUInt64LittleEndian(Stream stream, ulong value)
|
|
{
|
|
Span<byte> buffer = stackalloc byte[sizeof(ulong)];
|
|
BinaryPrimitives.WriteUInt64LittleEndian(buffer, value);
|
|
stream.Write(buffer);
|
|
}
|
|
|
|
public static void WriteFileTimeUtc(Stream stream, DateTime value)
|
|
{
|
|
WriteUInt64LittleEndian(stream, unchecked((ulong)ToFileTimeUtc(value)));
|
|
}
|
|
|
|
public static void WriteUtf16NullTerminated(Stream stream, string value)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(value);
|
|
|
|
byte[] bytes = Encoding.Unicode.GetBytes(value);
|
|
stream.Write(bytes);
|
|
stream.WriteByte(0);
|
|
stream.WriteByte(0);
|
|
}
|
|
}
|