コード例 #1
0
ファイル: aochannels.c プロジェクト: gicmo/relacs
int main( int argc, char *argv[] )
{
  int ao, pfi;
  signed short *buf;

  buf = malloc( 4*MAXPOINTS);

  ao = open( "/dev/niao0", O_WRONLY );
  pfi = open( "/dev/nipfi0", 0 );

  ioctl( ao, NIDAQAODELAY, 0 );
  ioctl( ao, NIDAQAORATE, UPDATERATE );
  ioctl( ao, NIDAQAOBUFFERS, MAXBUFFERS );
  ioctl( pfi, NIDAQPFIOUT, 6 );

  AO_add_channel( ao, 0, 1, 0, 0, 0 );
  init_ramp( buf, MAXPOINTS );
  write( ao, buf, 2*MAXPOINTS );

  sleep( 1 );
  ioctl( ao, NIDAQAOCLEARCONFIG, 0 );
  init_sine( buf, MAXPOINTS );
  AO_add_channel( ao, 1, 1, 0, 0, 0 );
  write( ao, buf, 2*MAXPOINTS );
   
  close( ao );
  close( pfi );
  free( buf );

  return 0;
}
コード例 #2
0
ファイル: gamma.cpp プロジェクト: Artoria2e5/GDJ
const BYTE *gamma::get_ramp(double gamma)
{
	std::map<double, BYTE *>::const_iterator iter = _gamma_ramps.find(gamma);
	if (iter == _gamma_ramps.end())
	{
		// double-check lock
		const scoped_rw_lock lock_w(scoped_rw_lock::CLIENT_GAMMA, false);
		iter = _gamma_ramps.find(gamma);
		if (iter == _gamma_ramps.end())
			init_ramp(gamma);
	}

	return _gamma_ramps[gamma];
}
コード例 #3
0
ファイル: Acquarium.c プロジェクト: jerome2echopen/Perso_C
int main(int argc, char** argv)
{
	//close server and RedPitaya if CTRL+C
	signal(SIGINT, signal_callback_handler);

	//client TCP initialisation
	unsigned int MaxClient=5;
	sock=0;

	init_TCP_server(&sock, PORT, &client_list, MaxClient);
	launch_server(&sock, &client_list);

	//RedPitaya and settings initialisation
	init_RP();
	uint32_t buffer_length=0;
	float  level0=0.80, levelf=1.0;
	int delay;

	float *buffer_float=NULL;
	char *buffer_char=NULL;

	set_acquisition(dec);
	init_ramp(1, level0, x0, levelf, xf);
	init_variable(x0, xf, dec, &buffer_length, &delay);
	printf("length = %i\n",(int)buffer_length);

	buffer_float=(float *)malloc(((int)buffer_length)*sizeof(float));
	buffer_char=(char *)malloc(((int)buffer_length+1)*sizeof(char));

	//stepper initialisation
	init_stepper(&stepper);
	set_mode(&stepper, full_16);
	double angle=0.0, speed=3.0;
	angle=sector/((double)Nline);
	init_position(&stepper, 160.0-sector/2.0);

	int i=0;

	while(1)
	{
		for (i=0 ; i<Nline ; i++)
		{
			move(&stepper, &angle, &speed, sens1);
			trigg(delay);
			pulse();
			on_trigger_acquisition(buffer_float, buffer_length);
			send_via_tcp(i+1, buffer_char, buffer_float, buffer_length, &client_list);
			pulse();
		}
		for (i=Nline ; i>0 ; i--)
		{
			move(&stepper, &angle, &speed, sens2);
			trigg(delay);
			pulse();
			on_trigger_acquisition(buffer_float, buffer_length);
			send_via_tcp(i, buffer_char, buffer_float, buffer_length, &client_list);
			pulse();
		}
		
	}

	free(buffer_float);
	free(buffer_char);
	end_ramp();
	disable_stepper(&stepper);
	printf("Process done\n");

	//close TCP client
	close_TCP_client(&sock);
	//close RedPitaya
	close_RP();

	return 0;
}