public
Created

daq_test.cpp

  • Download Gist
gistfile1.cpp
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
// 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;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.