Programmer's Guide
RaDeKL Radar API Programmer’s Guide 29
© Multispectral Solutions, Inc. 2006
Example 2:
Process continuous radar detections until user stops. This requires 2 threads, one to handle the GUI and
the other to read and process the radar range bin data.
// Global data
RaDeKL_HANDLE handle;
HANDLE g_hthread;
BOOL running = false;
>>> Thread 1 (GUI):
// Assume we have an open radar with a valid handle AND a secondary thread
// User signals to START continuous detection
status = RaDeKL_StartContinuousDetection (handle);
// Check status . . .
// Wake up secondary thread
running = true;
ResumeThread (g_hthread);
// Return to the GUI message loop . . .
// User signals to STOP continuous detection
running = false;
status = RaDeKL_StopContinuousDetection (handle);
// Check status . . .
// Flush the buffers
status = RaDeKL_FlushIO (handle);
// Check status . . .
>>> Thread 2 (read and process loop):
ULONG status;
BYTE data[2048]; // Make this sufficiently large
// Assume we have an open radar with a valid handle
while (true) // Loop this thread forever until the program terminates
{
while (running) // Loop until the GUI sets running to false
{
status = RaDeKL_ReadDetectionData (handle, data);
// Check status. Ignore a timeout if running is false
if ((status == RADEKL_OK) || ((!running) && (status == RADEKL_READ_TIMEOUT)))
{
// Do something with the data . . .
}
else
{
printf (“Bad read: %s\n”, RaDeKL_GetStatusText (status));
running = false;
break;
}
}
// No longer running - go to sleep
SuspendThread (GetCurrentThread ());
}