Fix other ANSCV classes

This commit is contained in:
2026-05-09 16:47:46 +10:00
parent aa323a07a3
commit a94bf88a5b
16 changed files with 1197 additions and 197 deletions
+126
View File
@@ -317,6 +317,72 @@ namespace ANSCENTER
int enableFeature;
};
// ------------------------------------------------------------------------
// Real-time system telemetry. Snapshot of CPU / GPU / RAM / disk / network
// usage at the time of the call.
//
// Cheap to call frequently — values are cached for ~500 ms via a process-
// wide PDH sampler held in ANSLicense.cpp. The first call after process
// start blocks for ~150 ms because PDH counters require two samples to
// produce a delta-rate reading; subsequent calls are sub-millisecond.
//
// Fields the platform could not provide are set to -1 (or -1.0). Common
// reasons:
// - cpuTempDegC: ACPI thermal zone is unavailable / blocked on most
// consumer hardware. Use a vendor SDK (NVML / ADL / IPMI) for real
// thermals if you need them.
// - netLoadPercent: no network adapter advertises a non-zero
// "Current Bandwidth" (e.g. all interfaces are loopback / virtual).
// - valIGPU_MB: Windows < 10 19H1 does not expose GPU Process Memory
// PDH counters.
//
// Memory / disk units use 1024 base (1 GB == 2^30 bytes); throughput uses
// MB == 2^20 bytes for parity with Task Manager.
// ------------------------------------------------------------------------
struct SystemHealthInfo {
// CPU
double cpuLoadPercent = -1.0; // 0..100, total across all logical cores
double cpuTempDegC = -1.0; // -1 if unavailable
double cpuFreqGHz = -1.0; // current clock (turbo-aware)
std::string cpuModel; // e.g. "Intel(R) Core(TM) i9-..."
// System memory
double memTotalGB = -1.0;
double memoryUsedGB = -1.0;
double memoryFreeGB = -1.0;
double rssPercent = -1.0; // current process WS / total physical
double swapPercent = -1.0; // page file used / page file limit
// Current process
int64_t valIRSS_MB = -1; // working-set size (MB)
int64_t valSwap_MB = -1; // private commit / page-file usage (MB)
int64_t valIGPU_MB = -1; // dedicated GPU memory used by us (MB)
// GPU — values report the *primary* adapter only. On hybrid systems
// (e.g. Iris Xe + RTX 4090) the primary is picked deterministically:
// NVIDIA discrete > AMD discrete > whichever has the most VRAM. Per-
// adapter numbers are available in gpuAdaptersDetail below.
double gpuLoadPercent = -1.0; // 0..100 on the primary adapter only
std::string gpuName; // primary adapter model name
// Per-adapter rollup; one row per physical GPU, comma-separated.
// Row format: <name>|<vendor>|<load%>|<processMemMB>|<vramMB>
// Vendors: NVIDIA / AMD / Intel / Microsoft / Other
// Numbers use the C locale ('.' decimal, 2dp for load%).
std::string gpuAdaptersDetail;
// Disk (system drive — the volume holding %SystemRoot%)
double diskLoadPercent = -1.0;
double diskReadSpeedMBs = -1.0;
double diskWriteSpeedMBs = -1.0;
double diskUsedGB = -1.0;
double diskTotalGB = -1.0;
// Network (sum across all non-loopback interfaces)
double netLoadPercent = -1.0;
double netReceiveSpeedMBs = -1.0;
double netSendSpeedMBs = -1.0;
};
class ANSLICENSE_API SPDLogger
@@ -418,6 +484,7 @@ namespace ANSCENTER
public:
[[nodiscard]] static bool LicenseVerification(std::string licenseKey, int productId, std::string registrationName);
[[nodiscard]] static EngineType CheckHardwareInformation();
[[nodiscard]] static SystemHealthInfo GetSystemHealthInformation();
[[nodiscard]] static std::string ListLicenses();
[[nodiscard]] static int ActivateTrialLicense(std::string productName);
[[nodiscard]] static int DeactivateLicense(std::string productName);
@@ -455,6 +522,65 @@ extern "C" __declspec(dllexport) int ExtractModelZipFile(const char* modelZipFil
extern "C" __declspec(dllexport) int ZipFolderToZipFile(const char* modelFolderSource,const char* modelZipFileDes, const char* password);
extern "C" __declspec(dllexport) int PrepareEdgeModel(const char* modelZipFile, const char* zipFilePassword, const char* edgePassword, const char* modelName, const char* edgeSerialNumber, LStrHandle pathArray);
extern "C" __declspec(dllexport) int GetSystemHardwareInformation(LStrHandle systemHardwareInformation);
// SystemHealthParameters cluster, one scalar at a time. Pass nullptr for any
// field you do not care about. Returns 1 on success, 0 on failure. Cached
// internally so calling at LabVIEW UI rate (e.g. 1 Hz) is essentially free.
extern "C" __declspec(dllexport) int GetSystemHealthParameters(
double* cpuLoadPercent,
double* cpuTempDegC,
double* cpuFreqGHz,
LStrHandle cpuModel,
double* memTotalGB,
double* rssPercent,
double* swapPercent,
double* gpuLoadPercent,
int64_t* valIRSS_MB,
int64_t* valSwap_MB,
int64_t* valIGPU_MB,
double* memoryUsedGB,
double* memoryFreeGB,
double* diskLoadPercent,
double* diskReadSpeedMBs,
double* diskWriteSpeedMBs,
double* diskUsedGB,
double* diskTotalGB,
double* netLoadPercent,
double* netReceiveSpeedMBs,
double* netSendSpeedMBs,
LStrHandle gpuName, // primary adapter name (e.g. "NVIDIA RTX 4090"); pass nullptr to skip
LStrHandle gpuAdaptersDetail); // per-adapter rollup; pass nullptr to skip — see SystemHealthInfo for format
// Same payload as GetSystemHealthParameters, packed into a single string with
// ';' separators in this exact order:
// 1 cpuLoadPercent (%)
// 2 cpuTempDegC (°C, -1 if unavailable)
// 3 cpuFreqGHz (GHz)
// 4 cpuModel (string; any literal ';' in the model is rewritten to ',')
// 5 memTotalGB
// 6 rssPercent (%)
// 7 swapPercent (%)
// 8 gpuLoadPercent (%)
// 9 valIRSS_MB (current process working set, MB)
// 10 valSwap_MB (current process page-file usage, MB)
// 11 valIGPU_MB (current process GPU dedicated memory, MB)
// 12 memoryUsedGB
// 13 memoryFreeGB
// 14 diskLoadPercent (%)
// 15 diskReadSpeedMBs
// 16 diskWriteSpeedMBs
// 17 diskUsedGB
// 18 diskTotalGB
// 19 netLoadPercent (%)
// 20 netReceiveSpeedMBs
// 21 netSendSpeedMBs
// 22 gpuName (primary adapter model, e.g. "NVIDIA RTX 4090")
// 23 gpuAdaptersDetail (per-adapter rollup — see SystemHealthInfo struct)
// Numbers use the C locale ('.' decimal point) and 2-decimal fixed format.
// Any literal ';' in gpuName / gpuAdaptersDetail is rewritten to ',' so the
// outer separator is never ambiguous.
// Returns 1 on success, 0 on failure.
extern "C" __declspec(dllexport) int GetSystemHealthParametersString(LStrHandle outString);
extern "C" __declspec(dllexport) int ReleaseLoggers();
extern "C" __declspec(dllexport) int ListANSLicenses(std::string &listLicense);
extern "C" __declspec(dllexport) int ListANSLicenses_LV(LStrHandle ansProductLicenses);