Пример #1
0
int check_signals_d(size_t ns, const double* sig, const double* exg, const int32_t* tri)
{
	size_t i=0;
	int nchtri = grp[2].nch;
	int neeg = grp[0].nch;
	int nexg = grp[1].nch;
	int ich;
	double expval;
	int32_t exptri, stateval = tri[0] & 0x00FF0000;
	int retval = 0;


	// Identify the beginning of the expected sequence
	if (!checking) {
		for (i=0; i<ns; i++)
			if (tri[i] == get_trigger_val(0, stateval)) {
				checking = 1;
				break;
			}
		if (!checking && nsread > PERIOD) {
			fprintf(stderr, "\tCannot find the beginning of the sequence\n");
			retval = -1;
		}
	}

	for (; i<ns && !retval; i++) {
		// Verify the values in the analog channels
		for (ich=0; ich<neeg && !retval; ich++) {
			expval = get_analog_vald(nstot, ich, 0);
			if (sig[i*neeg+ich] != expval) {
				fprintf(stderr, "\tEEG value (%f) different from the one expected (%f) at sample %zu ch:%u\n", sig[i*neeg+ich], expval, i+nsread, ich);
				retval = -1;
			}
		}

		// Verify the values in the analog channels
		for (ich=0; ich<nexg && !retval; ich++) {
			expval = get_analog_vald(nstot, ich, 1);
			if (exg[i*nexg+ich] != expval) {
				fprintf(stderr, "\tEXG value (%f) different from the one expected (%f) at sample %zu ch:%u\n", exg[i*nexg+ich], expval, i+nsread, ich);
				retval = -1;
			}
		}
		
		// Verify the values in the trigger channels
		for (ich=0; ich<nchtri && !retval; ich++) {
			exptri = get_trigger_val(nstot, stateval);
			if (tri[i] != exptri) {
				fprintf(stderr, "\tTrigger value (0x%08x) different from the one expected (0x%08x) at sample %zu ch:%u\n", tri[i], exptri, i+nsread, ich);
				retval = -1;
			}
		}
		nstot++;
	}


	nsread += ns;
	return retval;
}
Пример #2
0
API_EXPORTED
int  GT_GetData( const char* device_name, unsigned char* buffer, gt_size num_samples )
{
	unsigned int last, j, s, ns;
	struct gtec_device* gtdev;
	float* data = (float*)buffer;
	int idev = 0;
	
	gtdev = get_dev(device_name, &idev);
	if (!gtdev)
		return -1;
	
	ns = num_samples/(sizeof(*data)*17);
	last = gtdev->lastsample;
	
	/*if (ns+last > 1024)
		ns = 1024 - last;
	if (ns <= 0)
		exit(EXIT_FAILURE);
	num_samples = ns * (sizeof(*data)*17);*/

	for (s=0; s<ns; s++) {
		for (j=0; j<16; j++)
			data[s*17 + j] = get_analog_val(s+last, idev*16+j);
		data[s*17+16] = get_trigger_val(s+last, idev);
	}

	gtdev->lastsample += ns;
	return num_samples;
}