Beispiel #1
0
int main()
{
    char buf[BUFSIZE], high_ch = TEST4CHAR;
    int n1 = TESTNUMBER1;
    long long n2 = TESTNUMBER1;
    long long n3 = TESTNUMBER1;

    /* check standard %d conversion */
    cleanbuffer(buf);
    TEST((sprintf(buf, "%d", n1) == TESTNUMBER1STRLEN));
    TEST((stringsame(buf, TEST1RESULT, TESTNUMBER1STRLEN) == 1));

    /* check standard %qd conversion */
    cleanbuffer(buf);
    TEST((sprintf(buf, "%qd", n2) == TESTNUMBER1STRLEN));
    TEST((stringsame(buf, TEST2RESULT, TESTNUMBER1STRLEN) == 1));

    /* check standard %lld conversion */
    cleanbuffer(buf);
    TEST((sprintf(buf, "%lld", n3) == TESTNUMBER1STRLEN));
    TEST((stringsame(buf, TEST3RESULT, TESTNUMBER1STRLEN) == 1));

    /* check standard %c insertion */
    cleanbuffer(buf);
    TEST((sprintf(buf, "%c etc.", high_ch) == TEST4STRLEN));
    TEST((stringsame(buf, TEST4RESULT, TEST4STRLEN) == 1));

    return OK;
}
Beispiel #2
0
void askForInput(char* prompt, char* buffer) {
    
    if (prompt != NULL) {
        printf(prompt);
    }

    scanf("%s", buffer);
    cleanbuffer();

    return;
}
Beispiel #3
0
int screenAdd( char c ) {
    if( count == BUFSIZ ) {
        CLLINE;
        PRINT( "Input buffer full!" ); /* This should signal when its near full  */
        cleanbuffer();
        return -1;
    }
    parsebuffer[front] = c;
    front = (front + 1) % BUFSIZ;
    count += 1;
    PRINT( "%c", c );
    return 0;
}
Beispiel #4
0
void acquire_scans (void)
{
	int color;
	int Nleft=0;
	char file [ FILENAME_MAX ];
	char filename[FILENAME_MAX];
	int data_file;

	SetCtrlAttribute (ERG_panel, ERG_panel_acquire, ATTR_DIMMED, 1);
	SetCtrlAttribute (ERG_panel, ERG_panel_abortscan, ATTR_DIMMED, 1);
	GetCtrlVal (ERG_panel, ERG_panel_nscans, &Nscans);

	DirSelectPopup ("d:\\data\\test", "Select Directory", 1, 1, pathname);

//acquire preambule
	strcpy(filename, pathname);
	sprintf(file, "\\scope_info.txt");
	strcat(filename, file);
	IO_output = fopen (filename, "w");
	wavepreamble();
	fclose(IO_output);

//acquire scaling coefficients
	strcpy(filename, pathname);
	sprintf(file, "\\scope_xinterval.txt");
	strcat(filename, file);
	IO_output = fopen (filename, "w");
	wavexinterval();
	fclose(IO_output);

	strcpy(filename, pathname);
	sprintf(file, "\\scope_yscaling.txt");
	strcat(filename, file);
	IO_output = fopen (filename, "w");
	waveyscaling();
	fclose(IO_output);

	strcpy(filename, pathname);
	sprintf(file, "\\scope_x0.txt");
	strcat(filename, file);
	IO_output = fopen (filename, "w");
	wavex0();
	fclose(IO_output);

	i=0;
	SetCtrlAttribute (ERG_panel, ERG_panel_pause, ATTR_DIMMED, 0);
	SetCtrlAttribute (ERG_panel, ERG_panel_abortscan, ATTR_DIMMED, 0);
	
// start trigger 
	SRS_flag=2;
	SRS_onoff();

// prepare file for intensity values, mask type and scan ref
	strcpy(filename, pathname);
	sprintf(file, "\\intensity.txt");
	strcat(filename, file);
	IO_intensity = fopen (filename, "w"); 
	
	 
	
//prepare file name for acquiring data
	while ( i < Nscans )
	{
		strcpy(filename, pathname);
		sprintf(file, "\\scope_data%d.txt", i);
		strcat(filename, file);

		data_file=OpenFile (filename, VAL_WRITE_ONLY, VAL_OPEN_AS_IS, VAL_BINARY);

		color=floor(256/Nscans)*i;
		waveform(color, data_file);
		
//the increment is done within the waveform function
		i++;

		Nleft=Nscans-i+1;
		SetCtrlVal (ERG_panel, ERG_panel_nremain, Nleft);
		ProcessSystemEvents();
		if (pause_flag)
		{
			while (pause_flag)
				ProcessSystemEvents();
		}
	}
	SetCtrlVal (ERG_panel, ERG_panel_nremain, 0);
	SetCtrlAttribute (ERG_panel, ERG_panel_pause, ATTR_DIMMED, 1);
	SetCtrlAttribute (ERG_panel, ERG_panel_abortscan, ATTR_DIMMED, 1);
	SetCtrlAttribute (ERG_panel, ERG_panel_acquire, ATTR_DIMMED, 0);
	
// stop trigger 	
	SRS_flag=0;
	SRS_onoff();

//clean buffer
	strcpy(filename, pathname);
	sprintf(file, "\\junk.txt");
	strcat(filename, file);
	IO_output = fopen (filename, "w");
	cleanbuffer();
	fclose(IO_output);

//close file 
	if (Nscans==0)
	{
	fclose(IO_intensity);
	}
	
	return;
}
Beispiel #5
0
void screenClearInputLine() {
    POS( SCREEN_INPUT_ROW, SCREEN_INPUT_COL );      CLTOEND; /* Erase from cursor to EOL */
    POS( SCREEN_INPUT_ROW, SCREEN_INPUT_COL + 64 ); PRINT( "|" );
    POS( SCREEN_INPUT_ROW, SCREEN_INPUT_COL );
    cleanbuffer();
}
Beispiel #6
0
void screenInit() {
    cleanbuffer();
    CLS;    /* Clear screen */
    screenMenu();
}