Exemplo n.º 1
0
int bsv_start(void)
{
	int		i;
	_AIN	ain;
	_DIO	dio;

	fd	= GT_OpenDevice( c_get_devnode() );
	if( !fd ) {
		GT_TranslateErrorCode(&errstr, 0);
		return -1;
	}

	/* Analog channels */
	for(i=0, chanactivcnt=0; i<MAXCHANNUM-DCHANNUM; i++) {
		if( c_is_active(i) ) {
			chanactivcnt++;
		}
	}
	/* Digital channels */
	if( c_is_active(8) || c_is_active(9) ) {
		chanactivcnt++;
	}
	dchanmask	= ((c_is_active(8))?1:0)+((c_is_active(9))?2:0);

	ain.ain1	= (c_is_active(0)) ? TRUE : FALSE;
	ain.ain2	= (c_is_active(1)) ? TRUE : FALSE;
	ain.ain3	= (c_is_active(2)) ? TRUE : FALSE;
	ain.ain4	= (c_is_active(3)) ? TRUE : FALSE;
	ain.ain5	= (c_is_active(4)) ? TRUE : FALSE;
	ain.ain6	= (c_is_active(5)) ? TRUE : FALSE;
	ain.ain7	= (c_is_active(6)) ? TRUE : FALSE;
	ain.ain8	= (c_is_active(7)) ? TRUE : FALSE;

	if( c_is_active(8) || c_is_active(9) ) {
		dio.scan		= TRUE;
	} else {
		dio.scan		= FALSE;
	}
	dio.dio1_direction	= (c_is_active(8)) ? TRUE : FALSE;
	dio.dio2_direction	= (c_is_active(9)) ? TRUE : FALSE;

	if( !GT_InitChannels(fd, ain, dio) ) {
		GT_TranslateErrorCode(&errstr, 0);
		GT_CloseDevice(fd);
		fd	= 0;
		return -1;
	}

	if( !GT_StartAcquistion(fd) ) {
		GT_TranslateErrorCode(&errstr, 0);
		GT_CloseDevice(fd);
		fd	= 0;
		return -1;
	}

	state	= 0;

	return 0;
}
Exemplo n.º 2
0
int bsv_stop(void)
{
	if( fd != 0 ) {
		GT_StopAcquistion(fd);
		GT_CloseDevice(fd);
	}

	return 0;
}
Exemplo n.º 3
0
BOOL CGtecDevice::EB_CloseDevice()
{
	if(m_hDevice==NULL)
		return TRUE;
	if(m_bExit)
		return FALSE;
	BOOL ret =	GT_CloseDevice(&m_hDevice);
	m_hDevice = NULL;
	CloseHandle(m_hEvent);
	return ret;
}
Exemplo n.º 4
0
void print_info()
{
HANDLE hdev;

 int firstamp=-1;
 // go through all possible USB connectors to find out what we have connected
 for (int cur_amp=0; cur_amp<MAX_USBAMPS; cur_amp++)
  {
  hdev = GT_OpenDevice(cur_amp);
  if (hdev)
     {
     char buf[1000];
     GT_GetSerial(hdev, (LPSTR)buf, 1000);
     printf("Amp found at USB address %d (S/N: %s)\r\n", cur_amp, buf);
     if (firstamp < 0) firstamp=cur_amp;
     GT_CloseDevice(&hdev);
     }
  }

 // no amp detected
 if (firstamp < 0)
    {
    printf("No g.USBamp detected. Aborting ...\r\n");
    return;
    }

 printf("Printing info for first amp (USB address %d)\r\n", firstamp);
 hdev = GT_OpenDevice(firstamp);
 if (hdev)
    {
    // get filter settings
    int nof;
    FILT *filt;
    GT_GetNumberOfFilter(&nof);
    filt = new _FILT[nof];
    printf("\r\nAvailable bandpass filters\r\n");
    printf("===================================\r\n");
    printf("num| hpfr  | lpfreq |  sfr | or | type\r\n");
    printf("===================================\r\n");
    for (int no_filt=0; no_filt<nof; no_filt++)
     {
     GT_GetFilterSpec(filt);
     printf("%03d| %5.2f | %6.1f | %4.0f | %2.0f | %1.0f\r\n", no_filt, filt[no_filt].fu, filt[no_filt].fo, filt[no_filt].fs, filt[no_filt].order, filt[no_filt].type);
     }
    delete filt;
    // get notch filter settings
    GT_GetNumberOfNotch(&nof);
    filt = new _FILT[nof];
    printf("\r\nAvailable notch filters\r\n");
    printf("===================================\r\n");
    printf("num| hpfr  | lpfreq |  sfr | or | type\r\n");
    printf("===================================\r\n");
    for (int no_filt=0; no_filt<nof; no_filt++)
     {
     GT_GetNotchSpec(filt);
     printf("%03d| %5.2f | %6.1f | %4.0f | %2.0f | %1.0f\r\n", no_filt, filt[no_filt].fu, filt[no_filt].fo, filt[no_filt].fs, filt[no_filt].order, filt[no_filt].type);
     }
    delete filt;

    GT_CloseDevice(&hdev);
    }
}
Exemplo n.º 5
0
bool USBamp::close() {
	return GT_CloseDevice(this->devptr);
}