Created
November 2, 2010 16:11
-
-
Save threadhead/659856 to your computer and use it in GitHub Desktop.
daq_test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DAQROUTINES.CPP | |
// | |
// uses 32bit enh API | |
// | |
// This file contains functions created for the Daq* examples | |
#include <windows.h> | |
#include <stdio.h> | |
#include <conio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
//#include "..\Cinclude\daqx.h" | |
//#include "..\Cinclude\daqroutines.h" | |
#include "Daqx.h" | |
#include "DaqRoutines.h" | |
DaqHandleT handle; | |
DaqDeviceListT *devList; | |
DaqDevicePropsT devProps; | |
DWORD devCount, deviceMask; | |
char *deviceName; | |
BOOL deviceFound = FALSE; | |
DWORD deviceIndex = 0; | |
#include "daq_test.h" | |
//GetDeviceName accepts a mask of compatible devices defined in daqroutines.h | |
//It polls through the currently configured devices and returns the name of the | |
//first one that is compatible as defined in the mask. The flag is overwritten | |
//as the returned device type | |
DWORD capabilityMask = daq2000DIO|daqboard; | |
//char* GetDeviceName(DWORD& capabilityMask) //the device type is returned in the | |
char* GetDeviceName() //the device type is returned in the | |
//flag to aid in scaling | |
{ | |
deviceName = ""; | |
// Find out how many devices are installed and allocate memory for device list | |
daqGetDeviceCount(&devCount); | |
devList = (DaqDeviceListT*)malloc(sizeof(DaqDeviceListT)*devCount); | |
// Get the names of all installed devices and the device count | |
daqGetDeviceList(devList, &devCount); | |
// Loop | |
while ( (deviceIndex < devCount) && !deviceFound ) | |
{ | |
daqGetDeviceProperties(devList[deviceIndex].daqName, &devProps); | |
deviceMask = (DWORD)pow(2, devProps.deviceType); | |
if ( capabilityMask & deviceMask ) | |
{ | |
capabilityMask &= deviceMask; | |
deviceName = devProps.daqName; | |
deviceFound = TRUE; | |
} | |
deviceIndex++; | |
} | |
//release allocated memory | |
free(devList); | |
return deviceName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment