Skip to content

Commit

Permalink
Add ability to set LVRT module path (#331)
Browse files Browse the repository at this point in the history
* Add functions to allow setting path to the LVRT module used for callback functions.

* Add LV function to set LVRT Module Path

Signed-off-by: Jeff Plotzke <jplotzke@konrad-technologies.com>

* Revert "Add LV function to set LVRT Module Path" (accidently saved in LV2021)

This reverts commit fe19e8a.

* Add LabVIEW functions to set LVRT module path

Signed-off-by: Jeff Plotzke <jplotzke@konrad-technologies.com>

---------

Signed-off-by: Jeff Plotzke <jplotzke@konrad-technologies.com>
Co-authored-by: pratheekshasn <37623222+pratheekshasn@users.noreply.github.com>
  • Loading branch information
kt-jplotzke and pratheekshasn authored Jan 10, 2024
1 parent 5c1cbb6 commit 1cf129f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 10 deletions.
Binary file not shown.
1 change: 1 addition & 0 deletions labview source/gRPC lv Support/grpc-lvsupport.lvlib
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
<Item Name="Shared" Type="Folder">
<Item Name="grpcId.ctl" Type="VI" URL="../Shared/grpcId.ctl"/>
<Item Name="Any.ctl" Type="VI" URL="../Shared/Any.ctl"/>
<Item Name="Set LVRT Module Path.vi" Type="VI" URL="../Shared/Set LVRT Module Path.vi"/>
<Item Name="Wait On Occurence.vi" Type="VI" URL="../Shared/Wait On Occurence.vi"/>
<Item Name="TranslateGrpcError.vi" Type="VI" URL="../Shared/TranslateGrpcError.vi"/>
</Item>
Expand Down
16 changes: 16 additions & 0 deletions src/grpc_interop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,19 @@ LIBRARY_EXPORT int32_t IsCancelled(grpc_labview::gRPCid** id)
}
return data->_call->IsCancelled();
}

//---------------------------------------------------------------------
// Allows for definition of the LVRT DLL path to be used for callback functions
// This function should be called prior to any other gRPC functions in this library
//---------------------------------------------------------------------
LIBRARY_EXPORT int32_t SetLVRTModulePath(const char* modulePath)
{
if (modulePath == nullptr)
{
return -1;
}

grpc_labview::SetLVRTModulePath(modulePath);

return 0;
}
39 changes: 30 additions & 9 deletions src/lv_interop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,21 @@ static PostLVUserEvent_T PostLVUserEvent = nullptr;
static Occur_T Occur = nullptr;
static RTSetCleanupProc_T RTSetCleanupProc = nullptr;

static std::string ModulePath = "";

namespace grpc_labview
{
grpc_labview::PointerManager<grpc_labview::gRPCid> gPointerManager;

//---------------------------------------------------------------------
// Allows for definition of the LVRT DLL path to be used for callback functions
// This function should be called prior to calling InitCallbacks()
//---------------------------------------------------------------------
void SetLVRTModulePath(std::string modulePath)
{
ModulePath = modulePath;
}

#ifdef _WIN32

//---------------------------------------------------------------------
Expand All @@ -45,15 +56,25 @@ namespace grpc_labview
return;
}

auto lvModule = GetModuleHandle("LabVIEW.exe");
if (lvModule == nullptr)
{
lvModule = GetModuleHandle("lvffrt.dll");
}
if (lvModule == nullptr)
{
lvModule = GetModuleHandle("lvrt.dll");
}
HMODULE lvModule;

if(ModulePath != "")
{
lvModule = GetModuleHandle(ModulePath.c_str());
}
else
{
lvModule = GetModuleHandle("LabVIEW.exe");
if (lvModule == nullptr)
{
lvModule = GetModuleHandle("lvffrt.dll");
}
if (lvModule == nullptr)
{
lvModule = GetModuleHandle("lvrt.dll");
}
}

NumericArrayResizeImp = (NumericArrayResize_T)GetProcAddress(lvModule, "NumericArrayResize");
PostLVUserEvent = (PostLVUserEvent_T)GetProcAddress(lvModule, "PostLVUserEvent");
Occur = (Occur_T)GetProcAddress(lvModule, "Occur");
Expand Down
3 changes: 2 additions & 1 deletion src/lv_interop.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ namespace grpc_labview

//---------------------------------------------------------------------
//---------------------------------------------------------------------
void InitCallbacks();
void SetLVRTModulePath(std::string modulePath);
void InitCallbacks();
void SetLVString(LStrHandle* lvString, std::string str);
std::string GetLVString(LStrHandle lvString);
int NumericArrayResize(int32_t typeCode, int32_t numDims, void* handle, size_t size);
Expand Down

0 comments on commit 1cf129f

Please sign in to comment.