Ejemplo n.º 1
0
bsv_data_t* bsv_get_data(void)
{
	short val;
	int	  cnt, i;

	if( !state ) {
		b_st.pBuffer= (short*)samples_ping;
		state		= 1;
	} else {
		b_st.pBuffer= (short*)samples_pong;
		state		= 0;
	}
	b_st.size		= chanactivcnt*sizeof(short);
	b_st.validPoints= 0;

	if( !GT_GetData(fd, &b_st, TRUE) ) {
		GT_TranslateErrorCode(&errstr, 0);
		return NULL;
	}

	if( !b_st.validPoints ) {
		GT_TranslateErrorCode(&errstr, 0);
		return NULL;
	}

	if( dchanmask ) {
		/* expand samples from digital channels */
		val	= b_st.pBuffer[(cnt=(b_st.validPoints-1))];
		for(i=0; i<DCHANNUM; i++) {
			if( dchanmask&(1<<i) ) {
				b_st.pBuffer[cnt]	= ( (val&(1<<i)) ? (1<<15)-2 : 0 );
				cnt++;
			}
		}
	}

	data.samples	= (char*)b_st.pBuffer;
	data.size		= chanactivcnt*sizeof(short);

	return &data;
}
Ejemplo n.º 2
0
UINT DataProcess(LPVOID lprarm)
{
	CGtecDevice *pGtec = (CGtecDevice*)lprarm;
	if(pGtec==NULL)
		return 1;
	OVERLAPPED ov;
	ov.hEvent = m_hEvent;
	ov.Offset = 0;
	ov.OffsetHigh = 0;
	DWORD dwBytereceive = 0;
	DWORD dwlength = pGtec->m_bufsize;
	BYTE *pBuffer =  new BYTE[HEADER_SIZE + dwlength];
	float *pfl = NULL;
	float *pf = new float[dwlength/sizeof(float)];	//tmp buffer.
	double* pd = new double[dwlength/sizeof(float)];
	while(!pGtec->m_bExit)
	{
		GT_GetData(pGtec->m_hDevice,pBuffer , HEADER_SIZE+dwlength,&ov);
		DWORD dwOVret = WaitForSingleObject(m_hEvent , 2000);
		if(dwOVret==WAIT_TIMEOUT)
		{
			AfxMessageBox(_T("Timeout occured\n"), MB_ICONWARNING);
			pGtec->m_bExit = true;
			GT_ResetTransfer(pGtec->m_hDevice);
			break;
		}
		GetOverlappedResult(pGtec->m_hDevice,&ov,&dwBytereceive,FALSE);
		dwBytereceive -= HEADER_SIZE;
		for (size_t i=0;i<dwBytereceive/sizeof(float);i++)
		{
			pfl = (float*)(pBuffer+HEADER_SIZE+sizeof(float)*i);
			pf[i] = *pfl;
			pd[i] = pf[i];
		}
		pGtec->SaveDatatoBuf(pd , dwBytereceive/sizeof(float));
	}
	delete pf;
	delete pd;
	return 0;
}
Ejemplo n.º 3
0
bool USBamp::acquire() {
	BOOL ret;
	ret = GT_GetData(this->devptr, &(this->datbuffer), &(this->ov));
	WaitForSingleObject(this->ov.hEvent, 1000); 
	return ret;
}