- Remove ALPR_OD Tracker and voting system.

- Disable debugview
This commit is contained in:
2026-04-19 23:15:50 +10:00
parent 51fe507dfd
commit 3418090042
13 changed files with 1266 additions and 129 deletions

View File

@@ -18,6 +18,8 @@
#include <unordered_map>
#include <condition_variable>
// DebugView: filter on "[ANSTRE]" — gated by ANSCORE_DEBUGVIEW in ANSLicense.h.
// Handle registry with refcount — prevents use-after-free when
// ReleaseANSTREHandle is called while an operation is still running.
// destructionStarted: set by the first Unregister caller; blocks new Acquires
@@ -40,14 +42,30 @@ static std::condition_variable& TREHandleRegistryCV() {
static void RegisterTREHandle(ANSCENTER::ANSTRE* h) {
std::lock_guard<std::mutex> lk(TREHandleRegistryMutex());
TREHandleRegistry()[h] = { 1, false };
ANS_DBG("ANSTRE","Register: handle=%p (uint=%llu) registrySize=%zu",
(void*)h, (unsigned long long)(uintptr_t)h, TREHandleRegistry().size());
}
static ANSCENTER::ANSTRE* AcquireTREHandle(ANSCENTER::ANSTRE* h) {
std::lock_guard<std::mutex> lk(TREHandleRegistryMutex());
auto it = TREHandleRegistry().find(h);
if (it == TREHandleRegistry().end()) return nullptr;
if (it->second.destructionStarted) return nullptr;
if (it == TREHandleRegistry().end()) {
ANS_DBG("ANSTRE","Acquire FAIL: handle=%p (uint=%llu) NOT in registry. registrySize=%zu",
(void*)h, (unsigned long long)(uintptr_t)h, TREHandleRegistry().size());
size_t i = 0;
for (auto& kv : TREHandleRegistry()) {
ANS_DBG("ANSTRE"," registry[%zu] = %p (uint=%llu) refcount=%d destructionStarted=%d",
i++, (void*)kv.first, (unsigned long long)(uintptr_t)kv.first,
kv.second.refcount, kv.second.destructionStarted ? 1 : 0);
}
return nullptr;
}
if (it->second.destructionStarted) {
ANS_DBG("ANSTRE","Acquire FAIL: handle=%p is being destroyed (destructionStarted=true)", (void*)h);
return nullptr;
}
it->second.refcount++;
ANS_DBG("ANSTRE","Acquire OK: handle=%p refcount=%d", (void*)h, it->second.refcount);
return h;
}
@@ -65,10 +83,15 @@ static bool ReleaseTREHandleRef(ANSCENTER::ANSTRE* h) {
static bool UnregisterTREHandle(ANSCENTER::ANSTRE* h) {
std::unique_lock<std::mutex> lk(TREHandleRegistryMutex());
auto it = TREHandleRegistry().find(h);
if (it == TREHandleRegistry().end()) return false;
if (it == TREHandleRegistry().end()) {
ANS_DBG("ANSTRE","Unregister: handle=%p NOT in registry (already gone)", (void*)h);
return false;
}
if (it->second.destructionStarted) {
ANS_DBG("ANSTRE","Unregister: handle=%p already being destroyed by another thread, returning false", (void*)h);
return false; // Another thread already owns the delete.
}
ANS_DBG("ANSTRE","Unregister: handle=%p starting (refcount before=%d)", (void*)h, it->second.refcount);
it->second.destructionStarted = true;
it->second.refcount--;
bool ok = TREHandleRegistryCV().wait_for(lk, std::chrono::seconds(30), [&]() {
@@ -76,6 +99,7 @@ static bool UnregisterTREHandle(ANSCENTER::ANSTRE* h) {
return it2 == TREHandleRegistry().end() || it2->second.refcount <= 0;
});
if (!ok) {
ANS_DBG("ANSTRE","WARNING: Unregister timed out waiting for in-flight operations on handle=%p", (void*)h);
OutputDebugStringA("WARNING: UnregisterTREHandle timed out waiting for in-flight operations\n");
}
TREHandleRegistry().erase(h);
@@ -327,8 +351,14 @@ namespace ANSCENTER
}
extern "C" ANSTRE_API int CreateANSTREHandle(ANSCENTER::ANSTRE** Handle, const char* licenseKey, const char* projectDirectory, const char* engineDirectory, const char* modelTemplateDirectory, const char* modelZipPassword, int trainingEngineType, int latestEngine) {
if (Handle == nullptr) return 0;
if (licenseKey == nullptr || projectDirectory == nullptr || engineDirectory == nullptr || modelTemplateDirectory == nullptr || modelZipPassword == nullptr) return 0;
ANS_DBG("ANSTRE","Create called: HandlePtr=%p, *Handle(in)=%p, engineType=%d, latestEngine=%d, projectDir=%s, engineDir=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), trainingEngineType, latestEngine,
projectDirectory ? projectDirectory : "(null)", engineDirectory ? engineDirectory : "(null)");
if (Handle == nullptr) { ANS_DBG("ANSTRE","Create FAIL: Handle is null"); return 0; }
if (licenseKey == nullptr || projectDirectory == nullptr || engineDirectory == nullptr || modelTemplateDirectory == nullptr || modelZipPassword == nullptr) {
ANS_DBG("ANSTRE","Create FAIL: one of the string params is null");
return 0;
}
// Pure constructor: ignore *Handle(in). LabVIEW's CLF Node marshalling
// reuses the same temp buffer per call site, so *Handle(in) often holds
// leftover bytes from the previous Create's output even when the actual
@@ -360,36 +390,51 @@ extern "C" ANSTRE_API int CreateANSTREHandle(ANSCENTER::ANSTRE** Handle, const
(*Handle) = new ANSCENTER::ANSODTRE();
break;
}
if (*Handle == nullptr) return 0;
if (*Handle == nullptr) { ANS_DBG("ANSTRE","Create FAIL: new returned null"); return 0; }
ANS_DBG("ANSTRE","Create: allocated handle=%p (uint=%llu), calling Init...",
(void*)*Handle, (unsigned long long)(uintptr_t)*Handle);
bool isLatestEngine = (latestEngine == 1) ? true : false;
if ((*Handle)->Init(licenseKey, projectDirectory, engineDirectory, modelTemplateDirectory, modelZipPassword, isLatestEngine)) {
RegisterTREHandle(*Handle);
ANS_DBG("ANSTRE","Create OK: handle=%p (uint=%llu)", (void*)*Handle, (unsigned long long)(uintptr_t)*Handle);
return 1;
}
ANS_DBG("ANSTRE","Create FAIL: Init returned false, deleting handle=%p", (void*)*Handle);
delete *Handle; *Handle = nullptr;
return 0;
}
catch (std::exception& e) {
ANS_DBG("ANSTRE","Create EXCEPTION (std::exception): %s", e.what());
if (*Handle != nullptr) { delete *Handle; *Handle = nullptr; }
return 0;
}
catch (...) {
ANS_DBG("ANSTRE","Create EXCEPTION (unknown)");
if (*Handle != nullptr) { delete *Handle; *Handle = nullptr; }
return 0;
}
}
static int ReleaseANSTREHandle_Impl(ANSCENTER::ANSTRE** Handle) {
try {
if (!Handle || !*Handle) return 1;
if (!UnregisterTREHandle(*Handle)) {
if (!Handle || !*Handle) {
ANS_DBG("ANSTRE","Release: HandlePtr or *Handle is null, no-op");
return 1;
}
ANSCENTER::ANSTRE* h = *Handle;
ANS_DBG("ANSTRE","Release called: handle=%p (uint=%llu)", (void*)h, (unsigned long long)(uintptr_t)h);
if (!UnregisterTREHandle(h)) {
ANS_DBG("ANSTRE","Release: Unregister returned false (already gone or being destroyed by another thread), handle=%p", (void*)h);
*Handle = nullptr;
return 1;
}
delete *Handle;
delete h;
*Handle = nullptr;
ANS_DBG("ANSTRE","Release OK: handle=%p deleted, registry now has %zu entries",
(void*)h, TREHandleRegistry().size());
return 1;
}
catch (...) {
ANS_DBG("ANSTRE","Release EXCEPTION (unknown)");
if (Handle) *Handle = nullptr;
return 0;
}
@@ -400,11 +445,13 @@ extern "C" ANSTRE_API int ReleaseANSTREHandle(ANSCENTER::ANSTRE** Handle) {
return ReleaseANSTREHandle_Impl(Handle);
}
__except (EXCEPTION_EXECUTE_HANDLER) {
ANS_DBG("ANSTRE","ReleaseANSTREHandle: SEH exception caught");
if (Handle) *Handle = nullptr;
return 0;
}
}
extern "C" ANSTRE_API int ANSTRE_GetProjects(ANSCENTER::ANSTRE** Handle, LStrHandle strProjects) {
ANS_DBG("ANSTRE","ANSTRE_GetProjects: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
if (Handle == nullptr || strProjects == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -427,6 +474,8 @@ extern "C" ANSTRE_API int ANSTRE_GetProjects(ANSCENTER::ANSTRE** Handle, LStrHa
}
}
extern "C" ANSTRE_API int ANSTRE_GetProjectExperiments(ANSCENTER::ANSTRE** Handle, const char* projectName, LStrHandle strProjectExperiments) {
ANS_DBG("ANSTRE","ANSTRE_GetProjectExperiments: HandlePtr=%p, *Handle=%p, project=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), projectName ? projectName : "(null)");
if (Handle == nullptr || projectName == nullptr || strProjectExperiments == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -449,6 +498,8 @@ extern "C" ANSTRE_API int ANSTRE_GetProjectExperiments(ANSCENTER::ANSTRE** Hand
}
}
extern "C" ANSTRE_API int ANSTRE_CreateProject(ANSCENTER::ANSTRE** Handle, const char* projectName) {
ANS_DBG("ANSTRE","ANSTRE_CreateProject: HandlePtr=%p, *Handle=%p, project=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), projectName ? projectName : "(null)");
if (Handle == nullptr || projectName == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -462,6 +513,8 @@ extern "C" ANSTRE_API int ANSTRE_CreateProject(ANSCENTER::ANSTRE** Handle, cons
}
}
extern "C" ANSTRE_API int ANSTRE_DeleteProject(ANSCENTER::ANSTRE** Handle, const char* projectName) {
ANS_DBG("ANSTRE","ANSTRE_DeleteProject: HandlePtr=%p, *Handle=%p, project=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), projectName ? projectName : "(null)");
if (Handle == nullptr || projectName == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -475,6 +528,8 @@ extern "C" ANSTRE_API int ANSTRE_DeleteProject(ANSCENTER::ANSTRE** Handle, cons
}
}
extern "C" ANSTRE_API int ANSTRE_SetWorkingDirectory(ANSCENTER::ANSTRE** Handle, const char* workingDirectory) {
ANS_DBG("ANSTRE","ANSTRE_SetWorkingDirectory: HandlePtr=%p, *Handle=%p, dir=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), workingDirectory ? workingDirectory : "(null)");
if (Handle == nullptr || workingDirectory == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -488,6 +543,8 @@ extern "C" ANSTRE_API int ANSTRE_SetWorkingDirectory(ANSCENTER::ANSTRE** Handle
}
}
extern "C" ANSTRE_API int ANSTRE_UploadTrainingData(ANSCENTER::ANSTRE** Handle, const char* projectName) {
ANS_DBG("ANSTRE","ANSTRE_UploadTrainingData: HandlePtr=%p, *Handle=%p, project=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), projectName ? projectName : "(null)");
if (Handle == nullptr || projectName == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -501,6 +558,9 @@ extern "C" ANSTRE_API int ANSTRE_UploadTrainingData(ANSCENTER::ANSTRE** Handle,
}
}
extern "C" ANSTRE_API int ANSTRE_CreateTrainingEngine(ANSCENTER::ANSTRE** Handle, const char* projectName, int experimentNumber, int extractorType, long numberStep, int batchSize, double learningRate) {
ANS_DBG("ANSTRE","ANSTRE_CreateTrainingEngine: HandlePtr=%p, *Handle=%p, project=%s, exp=%d, extractor=%d, steps=%ld, batch=%d, lr=%f",
(void*)Handle, (void*)(Handle ? *Handle : nullptr),
projectName ? projectName : "(null)", experimentNumber, extractorType, numberStep, batchSize, learningRate);
if (Handle == nullptr || projectName == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -514,6 +574,8 @@ extern "C" ANSTRE_API int ANSTRE_CreateTrainingEngine(ANSCENTER::ANSTRE** Handl
}
}
extern "C" ANSTRE_API int ANSTRE_GetProjectExperimentStatus(ANSCENTER::ANSTRE** Handle, const char* projectName, int experimentNumber, LStrHandle projectStatus) {
ANS_DBG("ANSTRE","ANSTRE_GetProjectExperimentStatus: HandlePtr=%p, *Handle=%p, project=%s, exp=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), projectName ? projectName : "(null)", experimentNumber);
if (Handle == nullptr || projectName == nullptr || projectStatus == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -536,6 +598,8 @@ extern "C" ANSTRE_API int ANSTRE_GetProjectExperimentStatus(ANSCENTER::ANSTRE**
}
}
extern "C" ANSTRE_API int ANSTRE_GenerateTrainingCommand(ANSCENTER::ANSTRE** Handle, const char* projectName, int experimentNumber, int extractorType, LStrHandle trainingCommand) {
ANS_DBG("ANSTRE","ANSTRE_GenerateTrainingCommand: HandlePtr=%p, *Handle=%p, project=%s, exp=%d, extractor=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), projectName ? projectName : "(null)", experimentNumber, extractorType);
if (Handle == nullptr || projectName == nullptr || trainingCommand == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -558,6 +622,8 @@ extern "C" ANSTRE_API int ANSTRE_GenerateTrainingCommand(ANSCENTER::ANSTRE** Ha
}
}
extern "C" ANSTRE_API int ANSTRE_GenerateCustomTrainingCommand(ANSCENTER::ANSTRE** Handle, const char* projectName, int experimentNumber, int extractorType, const char* pretrainedModel, LStrHandle trainingCommand) {
ANS_DBG("ANSTRE","ANSTRE_GenerateCustomTrainingCommand: HandlePtr=%p, *Handle=%p, project=%s, exp=%d, extractor=%d, pretrained=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), projectName ? projectName : "(null)", experimentNumber, extractorType, pretrainedModel ? pretrainedModel : "(null)");
if (Handle == nullptr || projectName == nullptr || pretrainedModel == nullptr || trainingCommand == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -580,6 +646,8 @@ extern "C" ANSTRE_API int ANSTRE_GenerateCustomTrainingCommand(ANSCENTER::ANSTR
}
}
extern "C" ANSTRE_API int ANSTRE_EvaluateModel(ANSCENTER::ANSTRE** Handle, const char* projectName, int experimentNumber, LStrHandle mAPResult) {
ANS_DBG("ANSTRE","ANSTRE_EvaluateModel: HandlePtr=%p, *Handle=%p, project=%s, exp=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), projectName ? projectName : "(null)", experimentNumber);
if (Handle == nullptr || projectName == nullptr || mAPResult == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -603,6 +671,9 @@ extern "C" ANSTRE_API int ANSTRE_EvaluateModel(ANSCENTER::ANSTRE** Handle, cons
}
extern "C" ANSTRE_API int ANSTRE_DownloadModel(ANSCENTER::ANSTRE** Handle, const char* projectName, int experimentNumber, const char* downloadDirDestination, int modelMode)
{
ANS_DBG("ANSTRE","ANSTRE_DownloadModel: HandlePtr=%p, *Handle=%p, project=%s, exp=%d, dest=%s, mode=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), projectName ? projectName : "(null)", experimentNumber,
downloadDirDestination ? downloadDirDestination : "(null)", modelMode);
if (Handle == nullptr || projectName == nullptr || downloadDirDestination == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -617,6 +688,7 @@ extern "C" ANSTRE_API int ANSTRE_DownloadModel(ANSCENTER::ANSTRE** Handle, cons
}
}
extern "C" ANSTRE_API int ANSTRE_GetProjectDirectory(ANSCENTER::ANSTRE** Handle, LStrHandle strProjectDir) {
ANS_DBG("ANSTRE","ANSTRE_GetProjectDirectory: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
if (Handle == nullptr || strProjectDir == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -638,6 +710,8 @@ extern "C" ANSTRE_API int ANSTRE_GetProjectDirectory(ANSCENTER::ANSTRE** Handle
}
}
extern "C" ANSTRE_API int ANSTRE_ZipExperiment(ANSCENTER::ANSTRE** Handle, const char* projectName, int experimentNumber) {
ANS_DBG("ANSTRE","ANSTRE_ZipExperiment: HandlePtr=%p, *Handle=%p, project=%s, exp=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), projectName ? projectName : "(null)", experimentNumber);
if (Handle == nullptr || projectName == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -651,6 +725,7 @@ extern "C" ANSTRE_API int ANSTRE_ZipExperiment(ANSCENTER::ANSTRE** Handle, cons
}
}
extern "C" ANSTRE_API double ANSTRE_ParseMAP(ANSCENTER::ANSTRE** Handle, const char* evaluationResult) {
ANS_DBG("ANSTRE","ANSTRE_ParseMAP: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
if (Handle == nullptr || evaluationResult == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -663,6 +738,7 @@ extern "C" ANSTRE_API double ANSTRE_ParseMAP(ANSCENTER::ANSTRE** Handle, const
}
}
extern "C" ANSTRE_API int ANSTRE_ParseTrainingResults(ANSCENTER::ANSTRE** Handle, const char* trainingResult, LStrHandle strResult) {
ANS_DBG("ANSTRE","ANSTRE_ParseTrainingResults: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
if (Handle == nullptr || trainingResult == nullptr || strResult == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -687,6 +763,7 @@ extern "C" ANSTRE_API int ANSTRE_ParseTrainingResults(ANSCENTER::ANSTRE** Handl
//CPP interface
extern "C" ANSTRE_API int ANSTRE_GetProjects_CPP(ANSCENTER::ANSTRE** Handle, std::string& strProjects) {
ANS_DBG("ANSTRE","ANSTRE_GetProjects_CPP: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
if (Handle == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -700,6 +777,8 @@ extern "C" ANSTRE_API int ANSTRE_GetProjects_CPP(ANSCENTER::ANSTRE** Handle, st
}
}
extern "C" ANSTRE_API int ANSTRE_GetProjectExperiments_CPP(ANSCENTER::ANSTRE** Handle, const char* projectName, std::string& strProjectExperiments) {
ANS_DBG("ANSTRE","ANSTRE_GetProjectExperiments_CPP: HandlePtr=%p, *Handle=%p, project=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), projectName ? projectName : "(null)");
if (Handle == nullptr || projectName == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -713,6 +792,8 @@ extern "C" ANSTRE_API int ANSTRE_GetProjectExperiments_CPP(ANSCENTER::ANSTRE**
}
}
extern "C" ANSTRE_API int ANSTRE_GetProjectExperimentStatus_CPP(ANSCENTER::ANSTRE** Handle, const char* projectName, int experimentNumber, std::string& projectStatus) {
ANS_DBG("ANSTRE","ANSTRE_GetProjectExperimentStatus_CPP: HandlePtr=%p, *Handle=%p, project=%s, exp=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), projectName ? projectName : "(null)", experimentNumber);
if (Handle == nullptr || projectName == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -726,6 +807,8 @@ extern "C" ANSTRE_API int ANSTRE_GetProjectExperimentStatus_CPP(ANSCENTER::ANST
}
}
extern "C" ANSTRE_API int ANSTRE_GenerateTrainingCommand_CPP(ANSCENTER::ANSTRE** Handle, const char* projectName, int experimentNumber, int extractorType, std::string& trainingCommand) {
ANS_DBG("ANSTRE","ANSTRE_GenerateTrainingCommand_CPP: HandlePtr=%p, *Handle=%p, project=%s, exp=%d, extractor=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), projectName ? projectName : "(null)", experimentNumber, extractorType);
if (Handle == nullptr || projectName == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -739,6 +822,8 @@ extern "C" ANSTRE_API int ANSTRE_GenerateTrainingCommand_CPP(ANSCENTER::ANSTRE*
}
}
extern "C" ANSTRE_API int ANSTRE_GenerateCustomTrainingCommand_CPP(ANSCENTER::ANSTRE** Handle, const char* projectName, int experimentNumber, int extractorType, const char* pretrainedModel, std::string& trainingCommand) {
ANS_DBG("ANSTRE","ANSTRE_GenerateCustomTrainingCommand_CPP: HandlePtr=%p, *Handle=%p, project=%s, exp=%d, extractor=%d, pretrained=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), projectName ? projectName : "(null)", experimentNumber, extractorType, pretrainedModel ? pretrainedModel : "(null)");
if (Handle == nullptr || projectName == nullptr || pretrainedModel == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -752,6 +837,8 @@ extern "C" ANSTRE_API int ANSTRE_GenerateCustomTrainingCommand_CPP(ANSCENTER::A
}
}
extern "C" ANSTRE_API int ANSTRE_EvaluateModel_CPP(ANSCENTER::ANSTRE** Handle, const char* projectName, int experimentNumber, std::string& mAPResult) {
ANS_DBG("ANSTRE","ANSTRE_EvaluateModel_CPP: HandlePtr=%p, *Handle=%p, project=%s, exp=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), projectName ? projectName : "(null)", experimentNumber);
if (Handle == nullptr || projectName == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -765,6 +852,8 @@ extern "C" ANSTRE_API int ANSTRE_EvaluateModel_CPP(ANSCENTER::ANSTRE** Handle,
}
}
extern "C" ANSTRE_API int ANSTRE_EvaluateModelOnTestData_CPP(ANSCENTER::ANSTRE** Handle, const char* projectName, int experimentNumber, const char* dataFolder,std::string& evaluationCommand) {
ANS_DBG("ANSTRE","ANSTRE_EvaluateModelOnTestData_CPP: HandlePtr=%p, *Handle=%p, project=%s, exp=%d, dataFolder=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), projectName ? projectName : "(null)", experimentNumber, dataFolder ? dataFolder : "(null)");
if (Handle == nullptr || projectName == nullptr || dataFolder == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -784,6 +873,8 @@ extern "C" ANSTRE_API int ANSTRE_EvaluateModelOnTestData_CPP(ANSCENTER::ANSTRE*
}
}
extern "C" ANSTRE_API int ANSTRE_EvaluateModelOnTestData(ANSCENTER::ANSTRE** Handle, const char* projectName, int experimentNumber, const char* dataFolder, LStrHandle evaluationCommand) {
ANS_DBG("ANSTRE","ANSTRE_EvaluateModelOnTestData: HandlePtr=%p, *Handle=%p, project=%s, exp=%d, dataFolder=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), projectName ? projectName : "(null)", experimentNumber, dataFolder ? dataFolder : "(null)");
if (Handle == nullptr || projectName == nullptr || dataFolder == nullptr || evaluationCommand == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -809,6 +900,7 @@ extern "C" ANSTRE_API int ANSTRE_EvaluateModelOnTestData(ANSCENTER::ANSTRE** Ha
extern "C" ANSTRE_API int ANSTRE_GetProjectDirectory_CPP(ANSCENTER::ANSTRE** Handle, std::string& strProjectDir) {
ANS_DBG("ANSTRE","ANSTRE_GetProjectDirectory_CPP: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
if (Handle == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -821,6 +913,7 @@ extern "C" ANSTRE_API int ANSTRE_GetProjectDirectory_CPP(ANSCENTER::ANSTRE** Ha
}
}
extern "C" ANSTRE_API int ANSTRE_ParseTrainingResults_CPP(ANSCENTER::ANSTRE** Handle, const char* trainingResult, std::string& strResult) {
ANS_DBG("ANSTRE","ANSTRE_ParseTrainingResults_CPP: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
if (Handle == nullptr || trainingResult == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -834,6 +927,7 @@ extern "C" ANSTRE_API int ANSTRE_ParseTrainingResults_CPP(ANSCENTER::ANSTRE** H
}
}
extern "C" ANSTRE_API int ANSTRE_CheckEngineStatus(ANSCENTER::ANSTRE** Handle) {
ANS_DBG("ANSTRE","ANSTRE_CheckEngineStatus: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
if (Handle == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -847,6 +941,7 @@ extern "C" ANSTRE_API int ANSTRE_CheckEngineStatus(ANSCENTER::ANSTRE** Handle)
}
}
extern "C" ANSTRE_API int ANSTRE_CheckEngine(ANSCENTER::ANSTRE** Handle) {
ANS_DBG("ANSTRE","ANSTRE_CheckEngine: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
if (Handle == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(*Handle));
if (!guard) return 0;
@@ -868,6 +963,7 @@ extern "C" ANSTRE_API int ANSTRE_CheckEngine(ANSCENTER::ANSTRE** Handle) {
extern "C" ANSTRE_API int ANSTRE_GetProjects_V2(uint64_t handleVal, LStrHandle strProjects) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_GetProjects_V2: handleVal=%llu handle=%p", (unsigned long long)handleVal, (void*)_v2h);
if (!_v2h) return 0;
if (strProjects == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
@@ -892,6 +988,8 @@ extern "C" ANSTRE_API int ANSTRE_GetProjects_V2(uint64_t handleVal, LStrHandle
}
extern "C" ANSTRE_API int ANSTRE_GetProjectExperiments_V2(uint64_t handleVal, const char* projectName, LStrHandle strProjectExperiments) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_GetProjectExperiments_V2: handleVal=%llu handle=%p, project=%s",
(unsigned long long)handleVal, (void*)_v2h, projectName ? projectName : "(null)");
if (!_v2h) return 0;
if (projectName == nullptr || strProjectExperiments == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
@@ -916,6 +1014,8 @@ extern "C" ANSTRE_API int ANSTRE_GetProjectExperiments_V2(uint64_t handleVal, c
}
extern "C" ANSTRE_API int ANSTRE_CreateProject_V2(uint64_t handleVal, const char* projectName) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_CreateProject_V2: handleVal=%llu handle=%p, project=%s",
(unsigned long long)handleVal, (void*)_v2h, projectName ? projectName : "(null)");
if (!_v2h) return 0;
if (projectName == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
@@ -931,6 +1031,8 @@ extern "C" ANSTRE_API int ANSTRE_CreateProject_V2(uint64_t handleVal, const cha
}
extern "C" ANSTRE_API int ANSTRE_DeleteProject_V2(uint64_t handleVal, const char* projectName) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_DeleteProject_V2: handleVal=%llu handle=%p, project=%s",
(unsigned long long)handleVal, (void*)_v2h, projectName ? projectName : "(null)");
if (!_v2h) return 0;
if (projectName == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
@@ -946,6 +1048,8 @@ extern "C" ANSTRE_API int ANSTRE_DeleteProject_V2(uint64_t handleVal, const cha
}
extern "C" ANSTRE_API int ANSTRE_SetWorkingDirectory_V2(uint64_t handleVal, const char* workingDirectory) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_SetWorkingDirectory_V2: handleVal=%llu handle=%p, dir=%s",
(unsigned long long)handleVal, (void*)_v2h, workingDirectory ? workingDirectory : "(null)");
if (!_v2h) return 0;
if (workingDirectory == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
@@ -961,6 +1065,8 @@ extern "C" ANSTRE_API int ANSTRE_SetWorkingDirectory_V2(uint64_t handleVal, con
}
extern "C" ANSTRE_API int ANSTRE_UploadTrainingData_V2(uint64_t handleVal, const char* projectName) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_UploadTrainingData_V2: handleVal=%llu handle=%p, project=%s",
(unsigned long long)handleVal, (void*)_v2h, projectName ? projectName : "(null)");
if (!_v2h) return 0;
if (projectName == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
@@ -976,6 +1082,8 @@ extern "C" ANSTRE_API int ANSTRE_UploadTrainingData_V2(uint64_t handleVal, cons
}
extern "C" ANSTRE_API int ANSTRE_CreateTrainingEngine_V2(uint64_t handleVal, const char* projectName, int experimentNumber, int extractorType, long numberStep, int batchSize, double learningRate) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_CreateTrainingEngine_V2: handleVal=%llu handle=%p, project=%s, exp=%d, extractor=%d, steps=%ld, batch=%d, lr=%f",
(unsigned long long)handleVal, (void*)_v2h, projectName ? projectName : "(null)", experimentNumber, extractorType, numberStep, batchSize, learningRate);
if (!_v2h) return 0;
if (projectName == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
@@ -991,6 +1099,8 @@ extern "C" ANSTRE_API int ANSTRE_CreateTrainingEngine_V2(uint64_t handleVal, co
}
extern "C" ANSTRE_API int ANSTRE_GetProjectExperimentStatus_V2(uint64_t handleVal, const char* projectName, int experimentNumber, LStrHandle projectStatus) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_GetProjectExperimentStatus_V2: handleVal=%llu handle=%p, project=%s, exp=%d",
(unsigned long long)handleVal, (void*)_v2h, projectName ? projectName : "(null)", experimentNumber);
if (!_v2h) return 0;
if (projectName == nullptr || projectStatus == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
@@ -1015,6 +1125,8 @@ extern "C" ANSTRE_API int ANSTRE_GetProjectExperimentStatus_V2(uint64_t handleV
}
extern "C" ANSTRE_API int ANSTRE_GenerateTrainingCommand_V2(uint64_t handleVal, const char* projectName, int experimentNumber, int extractorType, LStrHandle trainingCommand) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_GenerateTrainingCommand_V2: handleVal=%llu handle=%p, project=%s, exp=%d, extractor=%d",
(unsigned long long)handleVal, (void*)_v2h, projectName ? projectName : "(null)", experimentNumber, extractorType);
if (!_v2h) return 0;
if (projectName == nullptr || trainingCommand == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
@@ -1039,6 +1151,8 @@ extern "C" ANSTRE_API int ANSTRE_GenerateTrainingCommand_V2(uint64_t handleVal,
}
extern "C" ANSTRE_API int ANSTRE_GenerateCustomTrainingCommand_V2(uint64_t handleVal, const char* projectName, int experimentNumber, int extractorType, const char* pretrainedModel, LStrHandle trainingCommand) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_GenerateCustomTrainingCommand_V2: handleVal=%llu handle=%p, project=%s, exp=%d, extractor=%d, pretrained=%s",
(unsigned long long)handleVal, (void*)_v2h, projectName ? projectName : "(null)", experimentNumber, extractorType, pretrainedModel ? pretrainedModel : "(null)");
if (!_v2h) return 0;
if (projectName == nullptr || pretrainedModel == nullptr || trainingCommand == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
@@ -1063,6 +1177,8 @@ extern "C" ANSTRE_API int ANSTRE_GenerateCustomTrainingCommand_V2(uint64_t hand
}
extern "C" ANSTRE_API int ANSTRE_EvaluateModel_V2(uint64_t handleVal, const char* projectName, int experimentNumber, LStrHandle mAPResult) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_EvaluateModel_V2: handleVal=%llu handle=%p, project=%s, exp=%d",
(unsigned long long)handleVal, (void*)_v2h, projectName ? projectName : "(null)", experimentNumber);
if (!_v2h) return 0;
if (projectName == nullptr || mAPResult == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
@@ -1087,6 +1203,8 @@ extern "C" ANSTRE_API int ANSTRE_EvaluateModel_V2(uint64_t handleVal, const cha
}
extern "C" ANSTRE_API int ANSTRE_EvaluateModelOnTestData_V2(uint64_t handleVal, const char* projectName, int experimentNumber, const char* dataFolder, LStrHandle evaluationCommand) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_EvaluateModelOnTestData_V2: handleVal=%llu handle=%p, project=%s, exp=%d, dataFolder=%s",
(unsigned long long)handleVal, (void*)_v2h, projectName ? projectName : "(null)", experimentNumber, dataFolder ? dataFolder : "(null)");
if (!_v2h) return 0;
if (projectName == nullptr || dataFolder == nullptr || evaluationCommand == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
@@ -1112,6 +1230,9 @@ extern "C" ANSTRE_API int ANSTRE_EvaluateModelOnTestData_V2(uint64_t handleVal,
}
extern "C" ANSTRE_API int ANSTRE_DownloadModel_V2(uint64_t handleVal, const char* projectName, int experimentNumber, const char* downloadDirDestination, int modelMode) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_DownloadModel_V2: handleVal=%llu handle=%p, project=%s, exp=%d, dest=%s, mode=%d",
(unsigned long long)handleVal, (void*)_v2h, projectName ? projectName : "(null)", experimentNumber,
downloadDirDestination ? downloadDirDestination : "(null)", modelMode);
if (!_v2h) return 0;
if (projectName == nullptr || downloadDirDestination == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
@@ -1128,6 +1249,7 @@ extern "C" ANSTRE_API int ANSTRE_DownloadModel_V2(uint64_t handleVal, const cha
}
extern "C" ANSTRE_API int ANSTRE_GetProjectDirectory_V2(uint64_t handleVal, LStrHandle strProjectDir) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_GetProjectDirectory_V2: handleVal=%llu handle=%p", (unsigned long long)handleVal, (void*)_v2h);
if (!_v2h) return 0;
if (strProjectDir == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
@@ -1151,6 +1273,8 @@ extern "C" ANSTRE_API int ANSTRE_GetProjectDirectory_V2(uint64_t handleVal, LSt
}
extern "C" ANSTRE_API int ANSTRE_ZipExperiment_V2(uint64_t handleVal, const char* projectName, int experimentNumber) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_ZipExperiment_V2: handleVal=%llu handle=%p, project=%s, exp=%d",
(unsigned long long)handleVal, (void*)_v2h, projectName ? projectName : "(null)", experimentNumber);
if (!_v2h) return 0;
if (projectName == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
@@ -1166,6 +1290,7 @@ extern "C" ANSTRE_API int ANSTRE_ZipExperiment_V2(uint64_t handleVal, const cha
}
extern "C" ANSTRE_API double ANSTRE_ParseMAP_V2(uint64_t handleVal, const char* evaluationResult) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_ParseMAP_V2: handleVal=%llu handle=%p", (unsigned long long)handleVal, (void*)_v2h);
if (!_v2h) return 0.0;
if (evaluationResult == nullptr) return 0.0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
@@ -1180,6 +1305,7 @@ extern "C" ANSTRE_API double ANSTRE_ParseMAP_V2(uint64_t handleVal, const char*
}
extern "C" ANSTRE_API int ANSTRE_ParseTrainingResults_V2(uint64_t handleVal, const char* trainingResult, LStrHandle strResult) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_ParseTrainingResults_V2: handleVal=%llu handle=%p", (unsigned long long)handleVal, (void*)_v2h);
if (!_v2h) return 0;
if (trainingResult == nullptr || strResult == nullptr) return 0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
@@ -1204,6 +1330,7 @@ extern "C" ANSTRE_API int ANSTRE_ParseTrainingResults_V2(uint64_t handleVal, co
}
extern "C" ANSTRE_API int ANSTRE_CheckEngineStatus_V2(uint64_t handleVal) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_CheckEngineStatus_V2: handleVal=%llu handle=%p", (unsigned long long)handleVal, (void*)_v2h);
if (!_v2h) return 0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
if (!guard) return 0;
@@ -1218,6 +1345,7 @@ extern "C" ANSTRE_API int ANSTRE_CheckEngineStatus_V2(uint64_t handleVal) {
}
extern "C" ANSTRE_API int ANSTRE_CheckEngine_V2(uint64_t handleVal) {
auto* _v2h = reinterpret_cast<ANSCENTER::ANSTRE*>(handleVal);
ANS_DBG("ANSTRE","ANSTRE_CheckEngine_V2: handleVal=%llu handle=%p", (unsigned long long)handleVal, (void*)_v2h);
if (!_v2h) return 0;
TREHandleGuard guard(AcquireTREHandle(_v2h));
if (!guard) return 0;