597 lines
26 KiB
C++
597 lines
26 KiB
C++
#ifndef ANSLICENSE_H
|
|
#define ANSLICENSE_H
|
|
|
|
#ifdef ANSLICENSE_EXPORTS
|
|
#define ANSLICENSE_API __declspec(dllexport)
|
|
#else
|
|
#define ANSLICENSE_API __declspec(dllimport)
|
|
#endif
|
|
|
|
// ============================================================================
|
|
// DebugView (DbgView) logging toggle.
|
|
//
|
|
// ANS_DBG is compiled into every build; visibility is chosen at runtime by
|
|
// ANSCENTER_IsDebugViewEnabled() — a cached check (~2 s) that reads:
|
|
// 1. env var ANSCENTER_DBGVIEW (="1" forces on, ="0" forces off), else
|
|
// 2. existence of C:\ProgramData\ANSCENTER\ansvisdebugview.txt (Windows) or
|
|
// /tmp/ansvisdebugview.txt (POSIX).
|
|
//
|
|
// Drop the sentinel file to turn logging on; delete it to turn it off. No
|
|
// rebuild, no restart — takes effect within ~2 s. ACLs on ProgramData are
|
|
// world-writable by default so any user can toggle.
|
|
//
|
|
// Hard kill-switch: compile with -DANSCORE_DEBUGVIEW=0 to strip ANS_DBG to
|
|
// ((void)0) — use only when even the atomic-load cost is unacceptable.
|
|
// ============================================================================
|
|
#ifndef ANSCORE_DEBUGVIEW
|
|
#define ANSCORE_DEBUGVIEW 1 // 1 = runtime-gated (default), 0 = hard-off (stripped)
|
|
#endif
|
|
|
|
// Runtime gate. Implemented in ANSLicense.cpp. Returns non-zero when logging
|
|
// should be emitted. Cheap on the hot path: one atomic load + branch; the
|
|
// filesystem check runs at most once per ~2 s.
|
|
extern "C" ANSLICENSE_API int ANSCENTER_IsDebugViewEnabled(void);
|
|
|
|
// C-linkage facade over SPDLogger so consumers can dynamic-load these via
|
|
// GetProcAddress without depending on the C++ class ABI. Each call routes to
|
|
// the process-wide SPDLogger singleton (thread-safe magic-static init).
|
|
extern "C" {
|
|
ANSLICENSE_API void ANSLogger_LogInfo (const char* src, const char* msg, const char* file, int line);
|
|
ANSLICENSE_API void ANSLogger_LogError(const char* src, const char* msg, const char* file, int line);
|
|
ANSLICENSE_API void ANSLogger_LogFatal(const char* src, const char* msg, const char* file, int line);
|
|
|
|
// DebugView choke point shared by ANS_DBG and ANSLIB_DBG. Strips noise
|
|
// path prefixes before emitting to OutputDebugStringA + stderr.
|
|
ANSLICENSE_API void ANSCENTER_DebugLog(const char* preformattedLine);
|
|
}
|
|
|
|
// ANS_DBG: Debug logging macro for DebugView (OutputDebugStringA on Windows).
|
|
// Usage: ANS_DBG("MyModule", "value=%d ptr=%p", val, ptr);
|
|
// Output: [MyModule] value=42 ptr=0x1234
|
|
//
|
|
// Routes through ANSCENTER_DebugLog so noise path prefixes (e.g. the
|
|
// ProgramData profile dir) are stripped centrally before emit. The macro just
|
|
// formats on the caller's stack and hands off the buffer.
|
|
#if ANSCORE_DEBUGVIEW
|
|
#define ANS_DBG(tag, fmt, ...) do { \
|
|
if (ANSCENTER_IsDebugViewEnabled()) { \
|
|
char _ans_dbg_buf[1024]; \
|
|
snprintf(_ans_dbg_buf, sizeof(_ans_dbg_buf), "[" tag "] " fmt "\n", ##__VA_ARGS__); \
|
|
ANSCENTER_DebugLog(_ans_dbg_buf); \
|
|
} \
|
|
} while(0)
|
|
#else
|
|
#define ANS_DBG(tag, fmt, ...) ((void)0)
|
|
#endif
|
|
|
|
|
|
#pragma once
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string>
|
|
#include <exception>
|
|
#include <iostream>
|
|
#include "anslicensing.h"
|
|
#include "LabVIEWHeader/extcode.h"
|
|
#include <mutex>
|
|
#ifdef _UNICODE
|
|
#define _T(s) L##s
|
|
#define _tprintf wprintf
|
|
#define _tcscmp wcscmp
|
|
#define _tfopen fopen
|
|
#else
|
|
#define _T(s) (s)
|
|
#define _TL(s) L##s
|
|
#define _tprintf printf
|
|
#define _tcscmp strcmp
|
|
#define _tfopen fopen
|
|
#endif
|
|
|
|
enum LicenseKeyStatus {
|
|
SUCCESS = 0,
|
|
INVALID_LICENSE_KEY = 1,
|
|
INVALID_HARDWARE_ID = 2,
|
|
LICENSE_EXPIRED = 3,
|
|
INVALID_ACTIVATION_KEY = 4,
|
|
PAYMENT_REQUIRED = 5,
|
|
INVALID_PRODUCT = 6,
|
|
UNKNOWN = 7
|
|
};
|
|
|
|
typedef struct {
|
|
int32 cnt; /* number of bytes that follow */
|
|
double value[1]; /* value of double */
|
|
} LDbl, * LDblPtr, ** LDblHandle;
|
|
|
|
namespace ANSCENTER
|
|
{
|
|
|
|
// Precision used for GPU inference
|
|
|
|
enum OCRType {
|
|
SINGLETEXT = 0,
|
|
STRUCTURE = 1
|
|
};
|
|
|
|
enum OCRLanguage {
|
|
ENGLISH = 0,
|
|
CHINESE = 1,
|
|
FRENCH = 2,
|
|
GERMANY = 3,
|
|
JAPANESE= 4,
|
|
KOREAN = 5,
|
|
CUSTOM =6
|
|
};
|
|
// Precision used for GPU inference
|
|
enum class Precision {
|
|
// Full precision floating point value
|
|
FP32,
|
|
// Half prevision floating point value
|
|
FP16,
|
|
// Int8 quantization.
|
|
// Has reduced dynamic range, may result in slight loss in accuracy.
|
|
// If INT8 is selected, must provide path to calibration dataset directory.
|
|
INT8,
|
|
};
|
|
|
|
// Options for the network
|
|
struct Options {
|
|
// Precision to use for GPU inference.
|
|
Precision precision = Precision::FP16;
|
|
// If INT8 precision is selected, must provide path to calibration dataset
|
|
// directory.
|
|
std::string calibrationDataDirectoryPath;
|
|
// The batch size to be used when computing calibration data for INT8
|
|
// inference. Should be set to as large a batch number as your GPU will
|
|
// support.
|
|
int32_t calibrationBatchSize = 128;
|
|
// The batch size which should be optimized for.
|
|
int32_t optBatchSize = 1;
|
|
// Maximum allowable batch size
|
|
int32_t maxBatchSize = 16;
|
|
// GPU device index
|
|
int deviceIndex = 0;
|
|
// Directory where the engine file should be saved
|
|
std::string engineFileDir = ".";
|
|
|
|
// Maximum allowed input width
|
|
int32_t maxInputWidth = -1; // Default to -1 --> expecting fixed input size
|
|
// Minimum allowed input width
|
|
int32_t minInputWidth = -1; // Default to -1 --> expecting fixed input size
|
|
// Optimal input width
|
|
int32_t optInputWidth = -1; // Default to -1 --> expecting fixed input size
|
|
|
|
// Maximum allowed input height
|
|
int32_t maxInputHeight = -1; // Default to -1 --> expecting fixed input size
|
|
// Minimum allowed input height
|
|
int32_t minInputHeight = -1; // Default to -1 --> expecting fixed input size
|
|
// Optimal input height
|
|
int32_t optInputHeight = -1; // Default to -1 --> expecting fixed input size
|
|
|
|
// GPU clock lock frequency in MHz.
|
|
// -1 = auto (default) — query max supported clock and lock at ~80%
|
|
// 0 = disabled — let the driver manage clocks dynamically
|
|
// >0 = lock at this specific MHz value (e.g. 2400)
|
|
// Prevents GPU power throttling that causes TensorRT timing instability
|
|
// on laptop GPUs. Requires elevated privileges; fails gracefully if not.
|
|
int32_t gpuClockLockMHz = -1;
|
|
};
|
|
|
|
enum PrecisionType {
|
|
INT8 = 0,
|
|
FP16 = 1,
|
|
FP32 = 2,
|
|
};
|
|
enum EngineType {
|
|
CPU = 0,
|
|
NVIDIA_GPU = 1,
|
|
OPENVINO_GPU = 2,
|
|
AMD_GPU = 3,
|
|
AUTO_DETECT = 99 // default: hardware auto-detection
|
|
};
|
|
enum Country {
|
|
VIETNAM = 0,
|
|
CHINA = 1,
|
|
AUSTRALIA = 2,
|
|
USA = 3,
|
|
INDONESIA = 4,
|
|
JAPAN = 5
|
|
};
|
|
|
|
enum DetectionType {
|
|
CLASSIFICATION = 0,
|
|
DETECTION = 1,
|
|
SEGMENTATION = 2,
|
|
FACEDETECTOR = 3,
|
|
FACERECOGNIZER = 4,
|
|
LICENSEPLATE = 5,
|
|
TEXTSCENSE = 6,
|
|
KEYPOINT=7,
|
|
OBB = 8 // Oriented Bounding Box
|
|
};
|
|
enum ModelType {
|
|
TENSORFLOW = 0,
|
|
YOLOV4 = 1,
|
|
YOLOV5 = 2,
|
|
YOLOV8 = 3,
|
|
TENSORRT = 4,
|
|
OPENVINO = 5,
|
|
FACEDETECT = 6,
|
|
FACERECOGNIZE = 7,
|
|
ALPR = 8,
|
|
OCR = 9,
|
|
ANOMALIB = 10,
|
|
POSE=11,
|
|
SAM=12,
|
|
ODHUBMODEL = 13,
|
|
YOLOV10RTOD = 14, // TensorRT Object Detection for Yolov10
|
|
YOLOV10OVOD = 15, // OpenVINO Object Detection for Yolov10
|
|
CUSTOMDETECTOR = 16, // Custom Detector
|
|
YOLOV12 = 17, // YoloV12 standard for yolov12
|
|
CUSTOMPY = 18, // Custom Python script model
|
|
MOTIONDETECTOR = 19, // Motion Detector,
|
|
ONNXCL =20,
|
|
ONNXPOSE=21,
|
|
RTPOSE=22,
|
|
ONNXSEG = 23,
|
|
RTSEG = 24,
|
|
ONNXOBB = 25,
|
|
RTOBB = 26,
|
|
MOVIENET=27,
|
|
ONNXSAM3=28,
|
|
RTSAM3 = 29,
|
|
ONNXYOLO = 30,
|
|
RTYOLO = 31
|
|
};
|
|
enum TrackerType {
|
|
BYTETRACK = 0,
|
|
UCMC = 1,
|
|
OCSORT = 2
|
|
};
|
|
enum ANSPRODUCTS {
|
|
ANNHUB = 1000,
|
|
DLHUB = 1001,
|
|
ODHUB = 1002,
|
|
ANSVIS = 1003,
|
|
ANS_FACERECOGNIZE = 1004,
|
|
ANS_OCR = 1005,
|
|
ANS_ALPR =1006,
|
|
ANS_CV = 1007,
|
|
ANS_TS = 1008
|
|
};
|
|
enum ANSLICENSESTATUS {
|
|
ACTIVE = 0,
|
|
EXPIRED = 1,
|
|
TRIAL=2,
|
|
UNLICENSE = 3
|
|
};
|
|
struct ModelConfig {
|
|
// All POD members default-initialized. Several callers (notably
|
|
// CreateANSODHandle in ANSODEngine/dllmain.cpp) declare a local
|
|
// ModelConfig and only set a subset of fields before passing it
|
|
// to ANSODBase::Initialize. Without these defaults inpWidth /
|
|
// inpHeight enter Initialize() as indeterminate stack values; the
|
|
// existing `<=0 → 640` guard in ANSONNXYOLO::Initialize only
|
|
// catches non-positive garbage, so a small positive stack value
|
|
// (e.g. 80) would slip through and end up driving the ORT
|
|
// session at 80x80 — which crashes YOLOv11 in /model.12/Concat
|
|
// because 2*ceil(80/32) ≠ ceil(80/16) in the FPN.
|
|
DetectionType detectionType{};
|
|
ModelType modelType{};
|
|
PrecisionType precisionType{};
|
|
int inpWidth = 0;
|
|
int inpHeight = 0;
|
|
float modelConfThreshold = 0.0f;
|
|
float modelMNSThreshold = 0.0f;
|
|
float detectionScoreThreshold = 0.0f;
|
|
int numKPS = 0; // Number of pose keypoint
|
|
float kpsThreshold = 0.0f;
|
|
bool autoGPUDetection = false;
|
|
float unknownPersonThreshold = 0.0f;
|
|
int gpuOptBatchSize = 1; // The batch size which should be optimized for.
|
|
int gpuMaxBatchSize = 1; // Maximum allowable batch size
|
|
int gpuDeviceIndex = 0; // GPU device index
|
|
|
|
// Maximum allowed input width
|
|
int32_t maxInputWidth = -1; // Default to -1 --> expecting fixed input size
|
|
// Minimum allowed input width
|
|
int32_t minInputWidth = -1; // Default to -1 --> expecting fixed input size
|
|
// Optimal input width
|
|
int32_t optInputWidth = -1; // Default to -1 --> expecting fixed input size
|
|
|
|
// Maximum allowed input height
|
|
int32_t maxInputHeight = -1; // Default to -1 --> expecting fixed input size
|
|
// Minimum allowed input height
|
|
int32_t minInputHeight = -1; // Default to -1 --> expecting fixed input size
|
|
// Optimal input height
|
|
int32_t optInputHeight = -1; // Default to -1 --> expecting fixed input size
|
|
};
|
|
|
|
struct ANSLicenseInfo {
|
|
std::string productName;
|
|
std::string licenseKey;
|
|
std::string activationKey;
|
|
std::string hardwareId;
|
|
ANSLICENSESTATUS licenseStatus;
|
|
int remainingDays;
|
|
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
|
|
{// Singleton design pattern
|
|
protected:
|
|
SPDLogger(const std::string& loggerFileName, bool consoleLoggerEnable = false)
|
|
: _loggerFileName(loggerFileName), _consoleLoggerEnable(consoleLoggerEnable) {
|
|
Init();
|
|
}
|
|
void Init();
|
|
void ConfigureLogger();
|
|
std::string _loggerFileName{};
|
|
bool _consoleLoggerEnable{true};
|
|
// Deleting copy constructor and assignment operator to ensure singleton
|
|
SPDLogger(const SPDLogger&) = delete;
|
|
SPDLogger& operator=(const SPDLogger&) = delete;
|
|
|
|
public:
|
|
bool Release();
|
|
~SPDLogger();
|
|
// Static method to get the singleton instance
|
|
static SPDLogger& GetInstance(const std::string& loggerFileName, bool consoleLoggerEnable = false) {
|
|
static SPDLogger instance(loggerFileName, consoleLoggerEnable);
|
|
return instance;
|
|
}
|
|
void Disable();
|
|
void Enable();
|
|
void LogTrace(const std::string& source, const std::string& messsage, const std::string& fileSource, int lineSource);
|
|
void LogDebug(const std::string& source, const std::string& messsage, const std::string& fileSource, int lineSource);
|
|
void LogInfo(const std::string& source, const std::string& messsage, const std::string& fileSource, int lineSource);
|
|
void LogWarn(const std::string& source, const std::string& messsage, const std::string& fileSource, int lineSource);
|
|
void LogError(const std::string& source, const std::string& messsage, const std::string& fileSource, int lineSource);
|
|
void LogFatal(const std::string& source, const std::string& messsage, const std::string& fileSource, int lineSource);
|
|
};
|
|
|
|
class ANSLICENSE_API ANSLSHelper {
|
|
private:
|
|
LicenseTemplate* _licenseTemplate = nullptr;
|
|
License* _license = nullptr;
|
|
std::wstring _licenseFilePath = _T("");
|
|
std::wstring _licenseServiceURL = _T("");
|
|
std::wstring _sdkLicenseKey = _T("");
|
|
std::wstring _privateKey = _T("");
|
|
std::wstring _publicKey = _T("");
|
|
|
|
SPDLogger& _logger = SPDLogger::GetInstance("License");
|
|
std::string LoadLicenseContent();
|
|
void Setup5x5LicenseTemplate();// This is simple case
|
|
std::wstring GetProductId(std::string licenseKey);
|
|
|
|
public:
|
|
ANSLSHelper();
|
|
ANSLSHelper(std::string licenseServiceURL);
|
|
ANSLSHelper(std::string privateKey, std::string licenseServiceURL);
|
|
ANSLSHelper(std::string privateKey, std::string publicKey, std::string licenseServiceURL);
|
|
~ANSLSHelper();
|
|
|
|
void SetupLicenseTemplate();
|
|
|
|
[[nodiscard]] bool MatchCurrentHardwareId(std::string hwid);
|
|
[[nodiscard]] bool DectectClockmanipulation(int year, int month, int date);
|
|
|
|
[[nodiscard]] std::string GetLicenseData(std::string licenseKey);
|
|
[[nodiscard]] int ActivateLicense(std::string licenseKey, std::string registrationName, std::string& activationKey); // Always activate the license (need internet connection)
|
|
[[nodiscard]] int ActivateLicenseWithCustomHWID(std::string licenseKey, std::string registrationName, std::string hardwareId, std::string& activationKey); // Always activate the license (need internet connection)
|
|
|
|
[[nodiscard]] bool LoadLicenseTemplate(std::string templateFilePath);
|
|
[[nodiscard]] std::string SaveLicenseTemplate(std::string templateFilePath, bool savePrivateKey);
|
|
|
|
// These are the common methods to be used
|
|
void SetLicenseServiceURL(std::string licenseServiceURL);
|
|
[[nodiscard]] std::string GetCurrentHardwareId();
|
|
void LoadLicense(std::string licenseKey);
|
|
[[nodiscard]] std::string SaveLicense();
|
|
[[nodiscard]] std::string GenerateKey(int productId, std::string registrationName, int productFeature, bool trialLicense);
|
|
[[nodiscard]] std::string GenerateKey(int productId, std::string registrationName, int productFeature, int expiredYear, int expiredMonth, int expiredDate);
|
|
[[nodiscard]] bool IsLicenseKeyValid(std::string licenseKey, std::string registrationName); // Only check the license key with registration name and expiration date only. This is used when developer to use internal APIs called
|
|
[[nodiscard]] bool CheckLicenseKey(std::string licenseKey, std::string registrationName, int productId, int& enabledFeatures); // Check if the license key is valid
|
|
[[nodiscard]] int ValidateLicense(std::string licenseKey, std::string registrationName, std::string& activationKey);
|
|
[[nodiscard]] int ValidateLicenseWithCustomHWID(std::string licenseKey, std::string registrationName, std::string customHWID, std::string& activationKey);
|
|
|
|
[[nodiscard]] int GenerateOfflineActivationData(std::string licenseKey, std::string registrationName, std::string& offlineActivationData);
|
|
[[nodiscard]] int InstallOfflineLicense(std::string licenseKey, std::string registrationName, std::string activationKey);
|
|
|
|
// Utilities
|
|
[[nodiscard]] static int ExtractModelZipFile(std::string modelZipFile, std::string password, std::string modelName, std::string& extractedOutputFolder);
|
|
[[nodiscard]] static bool ZipFolerWithPassword(std::string folderPath, std::string zipFilePath, std::string password);
|
|
[[nodiscard]] static int PrepareEdgeModel(std::string modelZipFile, std::string zipFilePassword, std::string edgePassword, std::string modelName, std::string edgeSerialNumber, std::string& configFilePathName, std::string& labelMapPathName, std::string& outputModelFolder);
|
|
[[nodiscard]] static std::string GetSystemHardwareInformation();
|
|
[[nodiscard]] static bool ReleaseLogger();
|
|
|
|
};
|
|
|
|
|
|
class ANSLICENSE_API ANSLicenseHelper {
|
|
private:
|
|
[[nodiscard]] static bool deleteRecursively(const std::string& pathStr, bool safeMode);
|
|
[[nodiscard]] static bool isPathSafe(const std::string& pathStr);
|
|
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);
|
|
[[nodiscard]] static int ActivateLicense(std::string productName, std::string licenseKey);
|
|
[[nodiscard]] static int ActivateLicenseWithCustomHWID(std::string productName, std::string licenseKey, std::string hwid, std::string& activationKey);
|
|
[[nodiscard]] static std::string DecodeValidationData(const char* validationData);
|
|
[[nodiscard]] static std::string GenerateActivationDataFile(std::string activationKey,std::string licenseKey, std::string hardwareId, std::string validationData);
|
|
[[nodiscard]] static std::string DecodeBase64(std::string base64String);
|
|
[[nodiscard]] static bool RemoveTrialLicenseKeys(std::string registrationName);
|
|
[[nodiscard]] static bool DeleleteRecursively(const std::string& pathStr) {
|
|
return deleteRecursively(pathStr, true);
|
|
}
|
|
|
|
};
|
|
}
|
|
extern "C" __declspec(dllexport) int CreateANSLSHandle(ANSCENTER::ANSLSHelper * *Handle, const char* privateKey, const char* publicKey, const char* licenseServiceURL);
|
|
extern "C" __declspec(dllexport) int Release(ANSCENTER::ANSLSHelper * *Handle);
|
|
extern "C" __declspec(dllexport) void SetLicenseServiceURL(ANSCENTER::ANSLSHelper * *Handle, const char* licenseServiceURL);
|
|
extern "C" __declspec(dllexport) int GetLicenseData(ANSCENTER::ANSLSHelper * *Handle, const char* licenseKey, LStrHandle licenseData);
|
|
extern "C" __declspec(dllexport) int LoadLicenseTemplate(ANSCENTER::ANSLSHelper * *Handle, const char* templateFilePath);
|
|
extern "C" __declspec(dllexport) int GetCurrentHardwareId(ANSCENTER::ANSLSHelper * *Handle, LStrHandle currentHwID);
|
|
extern "C" __declspec(dllexport) int GenerateKey(ANSCENTER::ANSLSHelper * *Handle, int productId, const char* registrationName, int productFeature, int trialLicense, LStrHandle generatedKey);
|
|
extern "C" __declspec(dllexport) int GenerateKeyWithExpiredDate(ANSCENTER::ANSLSHelper * *Handle, int productId, const char* registrationName, int productFeature, int expiredYear, int expiredMonth, int expiredDate, LStrHandle generatedKey);
|
|
extern "C" __declspec(dllexport) int CheckLicenseKey(ANSCENTER::ANSLSHelper * *Handle, const char* licenseKey, const char* registrationName, int productId);// , LStrHandle strEnableFeature); // Check if the license key is valid
|
|
extern "C" __declspec(dllexport) int ValidateLicense(ANSCENTER::ANSLSHelper * *Handle, const char* licenseKey, const char* registrationName, const char* existingActivationKey, LStrHandle activationKey);
|
|
extern "C" __declspec(dllexport) int ActivateLicense(ANSCENTER::ANSLSHelper * *Handle, const char* licenseKey, const char* registrationName, LStrHandle activationKey); // Always activate the license (need internet connection)
|
|
extern "C" __declspec(dllexport) int ActivateLicenseWithCustomHWID(ANSCENTER::ANSLSHelper * *Handle, const char* licenseKey, const char* registrationName, const char* hardwareId, LStrHandle activationKey); // Always activate the license (need internet connection)
|
|
extern "C" __declspec(dllexport) int IsLicenseKeyValid(ANSCENTER::ANSLSHelper * *Handle, const char* licenseKey, const char* registrationName); // Only check the license key with registration name and expiration date only. This is used when developer to use internal APIs called
|
|
extern "C" __declspec(dllexport) int GenerateOfflineActivationData(ANSCENTER::ANSLSHelper * *Handle, const char* licenseKey, const char* registrationName, LStrHandle offlineActivationData);
|
|
extern "C" __declspec(dllexport) int InstallOfflineLicense(ANSCENTER::ANSLSHelper * *Handle, const char* licenseKey, const char* registrationName, const char* activationKey);
|
|
|
|
|
|
// Utilities
|
|
extern "C" __declspec(dllexport) int ExtractModelZipFile(const char* modelZipFile, const char* password, const char* modelName, LStrHandle extractedOutputFolder);
|
|
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);
|
|
extern "C" __declspec(dllexport) int ActivateTrialLicense(const char* productName);
|
|
extern "C" __declspec(dllexport) int DeactivateLicense(const char* productName);
|
|
extern "C" __declspec(dllexport) int ActivateProductLicense(const char* productName, const char* licenseKey);
|
|
extern "C" __declspec(dllexport) int ActivateProductLicenseWithCustomHWID(const char* productName, const char* licenseKey, const char* hwid, LStrHandle lvActivationKey);
|
|
extern "C" __declspec(dllexport) int GetRegistrationName(const char* validationData, LStrHandle registrationName);
|
|
extern "C" __declspec(dllexport) int GenerateActivationKeyData(const char* activationKey, const char* licenseKey, const char* hardwareId, const char* validationData, LStrHandle activationData);
|
|
extern "C" __declspec(dllexport) int ANSLicenseVerification(const char* licenseKey, int productId, const char* registrationName);
|
|
extern "C" __declspec(dllexport) int ANSModelConversion(const char* zipModelFile, const char* zipModelPassword);
|
|
extern "C" __declspec(dllexport) int DeletePathRecursively(const char* pathTobeDeleted);
|
|
|
|
#endif |