PDComm.PdcommRuntime
Class
Loads the PDComm native library and checks that its ABI is compatible with this binding.
public static class PdcommRuntimeCall PdcommRuntime.Initialize once at startup with the absolute path of the native library (pdcomm_ffi.dll, libpdcomm_ffi.so or libpdcomm_ffi.dylib). If you do not, the first API call initializes the runtime from the default search locations: the binding's assembly directory, the application directory and the operating system's safe directories.
Initialization checks the ABI version reported by the library (ABI 0.17 through the version this binding was built for) and the presence of every core export, then routes all of this assembly's native calls to that library. Optional feature areas, such as diagnostic logging or formatted process programs, check their own exports when first used and throw NotSupportedException when the loaded library lacks them.
All members are thread-safe. The runtime cannot be unloaded or switched to another library once initialized.
PdcommRuntime.Initialize(args[0]);
var limits = new SecsLimits(4096, 1024, 32, 8);
using var label = SecsItem.FromAscii("Temperature", limits);
Console.WriteLine($"ABI {PdcommRuntime.AbiVersion}; SECS-II {Convert.ToHexString(label.Encode())}");Members
Initialize
Method
Loads and validates the PDComm native library.
public static void Initialize(string? libraryPath = null)Calling this method again after a successful initialization does nothing when libraryPath is null or names the same file. A failed attempt releases the library and leaves the runtime uninitialized, so it can be retried.
This method is thread-safe.
Parameters
| Name | Description |
|---|---|
libraryPath | The absolute path of the native library, or null to search the binding's assembly directory, the application directory and the operating system's safe directories for pdcomm_ffi. |
Notes
- Throws
ArgumentException:libraryPathis not an absolute path. - Throws
InvalidOperationException: The runtime is already initialized with a different library path. - Throws
DllNotFoundException: The library cannot be found or loaded. - Throws
BadImageFormatException: The file is not a native library for this process. - Throws
NotSupportedException: The library reports an ABI version outside the range this binding supports. - Throws
EntryPointNotFoundException: The library lacks the version export or a required core export.
AbiVersion
Property
Gets the ABI version of the loaded native library, as major.minor.
public static Version AbiVersion { get; }Reading this property initializes the runtime from the default search locations if needed.
Returns
The native ABI version, for example 0.30.
Notes
- Throws
DllNotFoundException: The runtime was not initialized and the default library cannot be found. - Throws
NotSupportedException: The default library has an unsupported ABI version. - Throws
EntryPointNotFoundException: The default library lacks a required export.