QTrk
Classes | Enumerations | Functions
LabVIEW datatypes and helper functions

Definitions of datatypes and helper functions required for communication with LabVIEW. More...

Classes

struct  ErrorCluster
 
struct  LVArray< T >
 LabVIEW Array template. More...
 
struct  LVArray2D< T >
 LabVIEW 2D Array template. More...
 
struct  LVArray3D< T >
 LabVIEW 3D Array template. More...
 
struct  LVArrayND< T, N >
 LabVIEW N dimensions array template. More...
 
struct  CUDADeviceInfo
 

Enumerations

enum  QueueFrameFlags { QFF_Force32Bit = 0x7fffffff }
 

Functions

template<typename T >
void ResizeLVArray2D (LVArray2D< T > **&d, int rows, int cols)
 
template<typename T >
void ResizeLVArray3D (LVArray3D< T > **&d, int depth, int rows, int cols)
 
template<typename T , int N>
void ResizeLVArray (LVArrayND< T, N > **&d, int *dims)
 
template<typename T >
void ResizeLVArray (LVArray< T > **&d, int elems)
 
void ArgumentErrorMsg (ErrorCluster *e, const std::string &msg)
 
void SetLVString (LStrHandle str, const char *text)
 
MgErr FillErrorCluster (MgErr err, const char *message, ErrorCluster *error)
 
std::vector< std::string > LVGetStringArray (int count, LStrHandle *str)
 
bool ValidateTracker (QueuedTracker *tracker, ErrorCluster *e, const char *funcname)
 Verify the referenced tracker is a valid QueuedTracker instance. More...
 
static bool CheckCUDAErrorLV (cudaError err, ErrorCluster *e)
 
static bool ValidRM (ResultManager *rm, ErrorCluster *err)
 Verify the referenced resultmanager is a valid ResultManager instance. More...
 

Detailed Description

Definitions of datatypes and helper functions required for communication with LabVIEW.

Wrappers around LabVIEW's cintools function calls and data types. lv_prolog.h and lv_epilog.h set up the correct alignment for LabVIEW data. See https://zone.ni.com/reference/en-XX/help/371361L-01/lvexcodeconcepts/configuring_the_clf_node/ for some more information.

Enumeration Type Documentation

§ QueueFrameFlags

Enumerator
QFF_Force32Bit 

???

Definition at line 10 of file lv_qtrk_api.h.

10  {
11  QFF_Force32Bit = 0x7fffffff
12 };

Function Documentation

§ ArgumentErrorMsg()

void ArgumentErrorMsg ( ErrorCluster e,
const std::string &  msg 
)

Definition at line 61 of file lv_queuetrk_api.cpp.

62 {
63  FillErrorCluster(mgArgErr, msg.c_str(), e);
64 }
MgErr FillErrorCluster(MgErr err, const char *message, ErrorCluster *error)

§ CheckCUDAErrorLV()

static bool CheckCUDAErrorLV ( cudaError  err,
ErrorCluster e 
)
static

Definition at line 26 of file lv_qtrk_api.h.

27 {
28  if (err != cudaSuccess) {
29  const char* errstr = cudaGetErrorString(err);
30  FillErrorCluster(kAppErrorBase, SPrintf("CUDA error: %s", errstr).c_str(), e);
31  return false;
32  }
33  return true;
34 }
std::string SPrintf(const char *fmt,...)
Definition: utils.cpp:132
MgErr FillErrorCluster(MgErr err, const char *message, ErrorCluster *error)

§ FillErrorCluster()

MgErr FillErrorCluster ( MgErr  err,
const char *  message,
ErrorCluster error 
)

Definition at line 50 of file lv_queuetrk_api.cpp.

51 {
52  if (err)
53  {
54  error->status = LVBooleanTrue;
55  error->code = err;
56  SetLVString ( error->message, message );
57  }
58  return err;
59 }
int32 code
Definition: labview.h:27
void SetLVString(LStrHandle str, const char *text)
LVBoolean status
Definition: labview.h:26
LStrHandle message
Definition: labview.h:28

§ LVGetStringArray()

std::vector<std::string> LVGetStringArray ( int  count,
LStrHandle *  str 
)

Definition at line 38 of file lv_queuetrk_api.cpp.

39 {
40  std::vector<std::string> result(count);
41 
42  for (int x=0;x<count;x++) {
43  uChar *val = LHStrBuf(str[x]);
44  int len = LHStrLen (str[x]);
45  result[x]=std::string((const char*)val, (size_t)len );
46  }
47  return result;
48 }

§ ResizeLVArray() [1/2]

template<typename T , int N>
void ResizeLVArray ( LVArrayND< T, N > **&  d,
int *  dims 
)

Definition at line 118 of file labview.h.

119 {
120  for (int i=0;i<N;i++)
121  (*d)->dimSizes[i]=dims[i];
122  NumericArrayResize(LVDataType<T>::code, N, (UHandle*)&d, sizeof(T)*(*d)->numElem());
123 }
int numElem()
Definition: labview.h:70

§ ResizeLVArray() [2/2]

template<typename T >
void ResizeLVArray ( LVArray< T > **&  d,
int  elems 
)

Definition at line 126 of file labview.h.

127 {
128  if (NumericArrayResize(LVDataType<T>::code, 1, (UHandle*)&d, sizeof(T)*elems) != mgNoErr)
129  throw std::runtime_error( SPrintf("NumericArrayResize(1D array, %d) returned error.", elems));
130  (*d)->dimSize = elems;
131 }
std::string SPrintf(const char *fmt,...)
Definition: utils.cpp:132

§ ResizeLVArray2D()

template<typename T >
void ResizeLVArray2D ( LVArray2D< T > **&  d,
int  rows,
int  cols 
)

Definition at line 98 of file labview.h.

99 {
100  if (NumericArrayResize(LVDataType<T>::code, 2, (UHandle*)&d, sizeof(T)*rows*cols) != mgNoErr)
101  throw std::runtime_error( SPrintf("NumericArrayResize(2D array, %d, %d) returned error.", rows,cols));
102  (*d)->dimSizes[0] = rows;
103  (*d)->dimSizes[1] = cols;
104 }
std::string SPrintf(const char *fmt,...)
Definition: utils.cpp:132

§ ResizeLVArray3D()

template<typename T >
void ResizeLVArray3D ( LVArray3D< T > **&  d,
int  depth,
int  rows,
int  cols 
)

Definition at line 107 of file labview.h.

108 {
109  if (NumericArrayResize(LVDataType<T>::code, 3, (UHandle*)&d, sizeof(T)*rows*cols*depth) != mgNoErr)
110  throw std::runtime_error( SPrintf("NumericArrayResize(3D array, %d, %d, %d) returned error.", depth,rows,cols));
111 
112  (*d)->dimSizes[0] = depth;
113  (*d)->dimSizes[1] = rows;
114  (*d)->dimSizes[2] = cols;
115 }
std::string SPrintf(const char *fmt,...)
Definition: utils.cpp:132

§ SetLVString()

void SetLVString ( LStrHandle  str,
const char *  text 
)

Definition at line 27 of file lv_queuetrk_api.cpp.

28 {
29  int msglen = strlen(text);
30  MgErr err = NumericArrayResize(uB, 1, (UHandle*)&str, msglen);
31  if (!err)
32  {
33  MoveBlock(text, LStrBuf(*str), msglen);
34  LStrLen(*str) = msglen;
35  }
36 }

§ ValidateTracker()

bool ValidateTracker ( QueuedTracker tracker,
ErrorCluster e,
const char *  funcname 
)

Verify the referenced tracker is a valid QueuedTracker instance.

Parameters
[in]trackerThe instance to verify.
[in]eThe LabVIEW error cluster for this call.
[in]funcnameThe name of the desired function.
Returns
True if the supplied pointer can be used.

Definition at line 66 of file lv_queuetrk_api.cpp.

67 {
68  if (std::find(trackerList.begin(), trackerList.end(), tracker)==trackerList.end()) {
69  ArgumentErrorMsg(e, SPrintf("QTrk C++ function %s called with invalid tracker pointer: %p", funcname, tracker));
70  return false;
71  }
72  return true;
73 }
void ArgumentErrorMsg(ErrorCluster *e, const std::string &msg)
static std::vector< QueuedTracker * > trackerList
std::string SPrintf(const char *fmt,...)
Definition: utils.cpp:132

§ ValidRM()

static bool ValidRM ( ResultManager rm,
ErrorCluster err 
)
static

Verify the referenced resultmanager is a valid ResultManager instance.

Parameters
[in]rmThe instance to verify.
[in]errThe LabVIEW error cluster for this call.
Returns
True if the supplied pointer can be used.

Definition at line 22 of file lv_resultmanager_api.cpp.

23 {
24  if(rm_instances.find(rm) == rm_instances.end()) {
25  ArgumentErrorMsg(err, "Invalid ResultManager instance passed.");
26  return false;
27  }
28  return true;
29 }
void ArgumentErrorMsg(ErrorCluster *e, const std::string &msg)
static std::unordered_set< ResultManager * > rm_instances