コード例 #1
0
ファイル: SCOPE.C プロジェクト: MelBartels/scope
void InputEquatSlewDat( void)
{
	/* read (rb) slew.dat where:
	R <Ra degrees>
	D <Dec degrees>
	p <Alt degrees>
	q <Az degrees>
	...
	t <time()> <JD>
	L <lat> <long> */
	Input = fopen( FullyQualifiedSlewFile, "r");
	if( Input == NULL)
		PressKeyToContMsg( "Could not read slew file");
	else
	{
		do
			fscanf( Input, "%s", Name);
		while( strcmpi( Name, "R") != 0);
		FReadDouble( Input, &In.Ra);
		In.Ra /= RadToDeg;
		do
			fscanf( Input, "%s", Name);
		while( strcmpi( Name, "D") != 0);
		FReadDouble( Input, &In.Dec);
		In.Dec /= RadToDeg;
		fclose( Input);
		DisplayIn( "from guide (Ra, Dec)", NameBlanks);
	}
}
コード例 #2
0
ファイル: SCOPE.C プロジェクト: MelBartels/scope
void WriteAltazSlewOutFile( void)
{
	Output = fopen( FullyQualifiedSlewOutFile, "w");
	if( Output == NULL)
		PressKeyToContMsg( "Could not write slew out file");
	/* az, then alt */
	fprintf( Output, "%f %f", Current.Az*RadToDeg, Current.Alt*RadToDeg);
	fclose( Output);
}
コード例 #3
0
ファイル: SCOPE.C プロジェクト: MelBartels/scope
void WriteEquatSlewOutFile( void)
{
	Output = fopen( FullyQualifiedSlewOutFile, "w");
	if( Output == NULL)
		PressKeyToContMsg( "Could not write slew out file");
	else
	{
		/* az, then alt */
		fprintf( Output, "R %f %f", Current.Ra*RadToDeg, Current.Dec*RadToDeg);
		fclose( Output);
	}
}
コード例 #4
0
ファイル: KBGUIDE.C プロジェクト: garlick/bartels-scope
Flag WriteGuideStartup( void)
{
	char B[3];
	int Ix;

	/* read in file, saving lines from third on */
	Input = fopen( GuideStartupMarFilePtr, "r");
	if( Input == NULL)
	{
		PressKeyToContMsg( strcat( "WriteGuideStartup(): Could not open ", GuideStartupMarFilePtr));
		return False;
	}
	else
	{
		Output = fopen( ScopeStartupMarFilePtr, "w");
		if( Output == NULL)
			BadExit( strcat( "WriteGuideStartup(): Could not open ", ScopeStartupMarFilePtr));

		/* fill Buffer */
		for( Ix = 0; Ix < 3; Ix++)
			fread( &B[Ix], 1, 1, Input);

		/* read/write until 'ra ' by writing out left most char of buffer, then left shifting buffer,
		then reading in right most char of buffer */
		while( B[0] != 'r' || B[1] != 'a' || B[2] != ' ')
		{
			fprintf( Output, "%c", B[0]);
			B[0] = B[1];
			B[1] = B[2];
			fread( &B[2], 1, 1, Input);
		}
		/* write Ra, Dec */
		fprintf( Output, "ra       %f\n", 360. - Current.Ra*RadToDeg);
		fprintf( Output, "2  dec      %f\n", Current.Dec*RadToDeg);
		/* throw away these two lines since these lines have been replaced with new coordinates */
		FReadToNewLine( Input);
		FReadToNewLine( Input);
		/* read/write until eof */
		while( !feof( Input))
		{
			fread( &B[0], 1, 1, Input);
			fprintf( Output, "%c", B[0]);
		}
		fclose( Output);
		fclose( Input);
		return True;
	}
}
コード例 #5
0
ファイル: TRACK.C プロジェクト: garlick/bartels-scope
void TrackEncoder( void)
{
	const int MaxTries = 9;
	int count = 0;
	int step;
	double StepsPerSec;
	int rate;

	TE = (struct AZLong*) malloc( MsInWindings * sizeof( struct AZLong));
	if( TE == NULL)
		BadExit( "Problem with malloc of TE in TrackEncoder()");

	WriteWindow( MsgFrame);

	gotoxy( MsgFrame.Left + 2, MsgFrame.Top + 1);
	printf( "moving motors to start position...");
	/* attempt to move both motors to microstep '0' on winding 'A' */
	do
	{
		Steps.A = (MsIx.A/MaxPWM) % MsInWindings;
		if( Steps.A && Dir.A == CW)
			Steps.A = MsInWindings - Steps.A;
		Steps.Z = (MsIx.Z/MaxPWM) % MsInWindings;
		if( Steps.Z && Dir.Z == CW)
			Steps.Z = MsInWindings - Steps.Z;
		MoveMs_f_ptr();
		count++;
	}while( count < MaxTries && (Steps.A || Steps.Z));

	/* get rate of motion */
	gotoxy( MsgFrame.Left + 2, MsgFrame.Top + 2);
	printf( "Please enter speed in microsteps per second ");
	if( !GetDouble( &StepsPerSec))
		/* if user aborts, then set it up so that no more execution occurs */
		count = MaxTries;
	else
		/* split rate in half bec. encoders read halfway through */
		rate = (int) (.5 + ClockTicksSec / (2.*StepsPerSec));

	if( count < MaxTries)
	{
		/* move MsInWindings microsteps, taking encoder readings as we go */
		for( step = 0; step < MsInWindings; step++)
		{
			Steps.A = Steps.Z = 1;
			for( Ix = 0; Ix < rate; Ix++)
				MoveMs_f_ptr();
			QueryEncoders_f_ptr();
			for( Ix = 0; Ix < rate; Ix++)
				MoveMs_f_ptr();
			if( EncoderState == ReadReady)
				ReadEncoders_f_ptr();
			TE[step].A = EncoderCount.A;
			TE[step].Z = EncoderCount.Z;
			gotoxy( MsgFrame.Left + 2, MsgFrame.Top + 3);
			printf( "microstep %d: encA %ld encZ %ld", step, TE[step].A, TE[step].Z);
		}
		gotoxy( MsgFrame.Left + 2, MsgFrame.Top + 4);
		printf( "writing %s file", TrackEncodersFile);
		Output = fopen( TrackEncodersFile, "w");
		if( Input == NULL)
			BadExit( strcat( "Could not open ", TrackEncodersFile));
		for( step = 0; step < MsInWindings; step++)
			fprintf( Output, "%d %ld %ld\n", step, TE[step].A, TE[step].Z);
		fclose( Output);
		gotoxy( MsgFrame.Left + 2, MsgFrame.Top + 5);
		ContMsgRoutine();
		RemoveWindow( MsgFrame);
	}
	else
	{
		RemoveWindow( MsgFrame);
		PressKeyToContMsg( "could not move motors to start position");
	}
	free( TE);
	PauseUntilNewSidTime();
	HPEventGetEquat();
}