/* ================================================= LIPS slitcont position setting program setpos.c Ver 1.0 2004. 8.22 K.Matsuda ================================================= */ #include #include #include #define TRUE 0 #define SW_ON 1 #define SW_OFF 0 #define MAXNDIAPH 40 #define DIAPHDEFFILE "diaphdef.dat" #define GDMRDEFFILE "gdmrdef.dat" #define TRRTDEFFILE "trrtdef.dat" #define SVTRDEFFILE "svtrdef.dat" #define CRDSDEFFILE "crdsdef.dat" #define HELPFILE "help.txt" #define SETTINGFILE "pos_set.dat" #define LOGFILE "logfile.lst" #define TEMPFILE "string.tmp" #define PAGE 22 #define STRING_MAX 256 struct name_coord { char name[30]; long coord; char comment[80]; }; void write_pos( FILE *f_set, char slit_pos[], char gdmr_pos[], char trrt_pos[], char svtr_pos[], char crds_pos[], char hct_state[] ); void cp_str( FILE *f_tmp, char in_str[], long n_pulse, char w_str[] ); void showhelp( void ); void showstatus( void ); void showlog( void ); void start_msg( void ); void read_diaphdef( int *ndiaph, struct name_coord *diaphdef, char filename[] ); long read_gdmrdef( void ); void show_diaphdef( int ndiaph, struct name_coord diaphdef[] ); /* */ /* main function */ /* */ main() { FILE *f_set, *f_tmp; unsigned int o_data; unsigned int slit_pwidth, gdmr_pwidth, trrt_pwidth, svtr_pwidth, crds_pwidth; unsigned long outdata, indata, status; long pos_slit, pos_gdmr, gdmr_inpos, pos_trrt, pos_svtr, pos_crds; long n_pulse, n_p_slit, n_p_gdmr, n_p_trrt, n_p_svtr, n_p_crds; int error, i, ndiaph, ntrrt, nsvtr, ncrds; char com_line[STRING_MAX], par_str[STRING_MAX]; char com[STRING_MAX], pos[STRING_MAX], c[STRING_MAX]; char type[STRING_MAX], equal[STRING_MAX], pos_set[STRING_MAX]; char slit_pos[STRING_MAX], gdmr_pos[STRING_MAX], trrt_pos[STRING_MAX]; char svtr_pos[STRING_MAX], crds_pos[STRING_MAX], hct_state[STRING_MAX]; char parts[STRING_MAX], param[STRING_MAX], unit[STRING_MAX]; char coord_slit[STRING_MAX]; char pulse_slit[STRING_MAX], pulse_gdmr[STRING_MAX], pulse_trrt[STRING_MAX]; char pulse_svtr[STRING_MAX], pulse_crds[STRING_MAX]; char in_str[STRING_MAX], w_str[STRING_MAX], tmpbuf[STRING_MAX]; struct name_coord diaphdef[MAXNDIAPH]; struct name_coord trrtdef[MAXNDIAPH]; struct name_coord svtrdef[MAXNDIAPH]; struct name_coord crdsdef[MAXNDIAPH]; /* start message */ start_msg(); /* initial setting */ read_diaphdef( &ndiaph, diaphdef , DIAPHDEFFILE ); /* define diaphragm names and coordinates */ gdmr_inpos = read_gdmrdef(); /* define guide-mirror in coordinate */ read_diaphdef( &ntrrt, trrtdef , TRRTDEFFILE ); /* define GT turret componet names and coordinates */ read_diaphdef( &nsvtr, svtrdef , SVTRDEFFILE ); /* define slitviewer componet names and coordinates */ read_diaphdef( &ncrds, crdsdef , CRDSDEFFILE ); /* define cross disperser componet names and coordinates */ if( ( f_set = fopen( SETTINGFILE, "r" ) ) == NULL ){ f_set = fopen( SETTINGFILE, "w" ); fprintf( f_set, "Slit_Stage = origin\n" ); fprintf( f_set, "Guide_Mirror = origin\n" ); fprintf( f_set, "GT_Turret = origin\n" ); fprintf( f_set, "Filter_Turret = origin\n" ); fprintf( f_set, "Cross_Disperser = origin\n" ); fprintf( f_set, "Hollow_Cathode_Tube = off\n" ); fclose( f_set ); f_set = fopen( SETTINGFILE, "r" ); } while( fgets( par_str, STRING_MAX, f_set ) != NULL ){ sscanf( par_str, "%s %s %s %ld", type, equal, pos_set, &n_pulse ); if( strncmp( type, "Slit_Stage", 10 ) == TRUE ){ strcpy( slit_pos, pos_set ); n_p_slit = n_pulse; if( strncmp( slit_pos, "mv", 2 ) == TRUE ){ cp_str( f_tmp, slit_pos, n_p_slit, slit_pos ); } } if( strncmp( type, "Guide_Mirror", 12 ) == TRUE ){ strcpy( gdmr_pos, pos_set ); n_p_gdmr = n_pulse; if( strncmp( gdmr_pos, "mv", 2 ) == TRUE ){ cp_str( f_tmp, gdmr_pos, n_p_gdmr, gdmr_pos ); } } if( strncmp( type, "GT_Turret", 9 ) == TRUE ){ strcpy( trrt_pos, pos_set ); n_p_trrt = n_pulse; if( strncmp( trrt_pos, "mv", 2 ) == TRUE ){ cp_str( f_tmp, trrt_pos, n_p_trrt, trrt_pos ); } } if( strncmp( type, "Filter_Turret", 13 ) == TRUE ){ strcpy( svtr_pos, pos_set ); n_p_svtr = n_pulse; if( strncmp( svtr_pos, "mv", 2 ) == TRUE ){ cp_str( f_tmp, svtr_pos, n_p_svtr, svtr_pos ); } } if( strncmp( type, "Cross_Disperser", 15 ) == TRUE ){ strcpy( crds_pos, pos_set ); n_p_crds = n_pulse; if( strncmp( crds_pos, "mv", 2 ) == TRUE ){ cp_str( f_tmp, crds_pos, n_p_crds, crds_pos ); } } if( strncmp( type, "Hollow_Cathode_Tube", 19 ) == TRUE ){ strcpy( hct_state, pos_set ); } } printf( "Set positions to origin? (y/n) " ); scanf( "%s", c ); if( strncmp( c, "y", 1 ) == TRUE ){ fclose( f_set ); f_set = fopen( SETTINGFILE, "w" ); fprintf( f_set, "Slit_Stage = origin\n" ); fprintf( f_set, "Guide_Mirror = origin\n" ); fprintf( f_set, "GT_Turret = origin\n" ); fprintf( f_set, "Filter_Turret = origin\n" ); fprintf( f_set, "Cross_Disperser = %s\n", crds_pos ); fprintf( f_set, "Hollow_Cathode_Tube = off\n" ); fclose( f_set ); f_set = fopen( SETTINGFILE, "r" ); } else{ printf( "Skipped...\n" ); } fclose( f_set ); /* main routine */ while(1){ f_set = fopen( SETTINGFILE, "r" ); while( fgets( par_str, STRING_MAX, f_set ) != NULL ){ sscanf( par_str, "%s %s %s %ld", type, equal, pos_set, &n_pulse ); if( strncmp( type, "Slit_Stage", 10 ) == TRUE ){ strcpy( slit_pos, pos_set ); n_p_slit = n_pulse; if( strncmp( slit_pos, "mv", 2 ) == TRUE ){ cp_str( f_tmp, slit_pos, n_p_slit, slit_pos ); } } if( strncmp( type, "Guide_Mirror", 12 ) == TRUE ){ strcpy( gdmr_pos, pos_set ); n_p_gdmr = n_pulse; if( strncmp( gdmr_pos, "mv", 2 ) == TRUE ){ cp_str( f_tmp, gdmr_pos, n_p_gdmr, gdmr_pos ); } } if( strncmp( type, "GT_Turret", 9 ) == TRUE ){ strcpy( trrt_pos, pos_set ); n_p_trrt = n_pulse; if( strncmp( trrt_pos, "mv", 2 ) == TRUE ){ cp_str( f_tmp, trrt_pos, n_p_trrt, trrt_pos ); } } if( strncmp( type, "Filter_Turret", 13 ) == TRUE ){ strcpy( svtr_pos, pos_set ); n_p_svtr = n_pulse; if( strncmp( svtr_pos, "mv", 2 ) == TRUE ){ cp_str( f_tmp, svtr_pos, n_p_svtr, svtr_pos ); } } if( strncmp( type, "Cross_Disperser", 15 ) == TRUE ){ strcpy( crds_pos, pos_set ); n_p_crds = n_pulse; if( strncmp( crds_pos, "mv", 2 ) == TRUE ){ cp_str( f_tmp, crds_pos, n_p_crds, crds_pos ); } } if( strncmp( type, "Hollow_Cathode_Tube", 19 ) == TRUE ){ strcpy( hct_state, pos_set ); } } printf( ">" ); fgets( com_line, STRING_MAX, stdin ); sscanf( com_line, "%s %s", com, pos ); /* diaphragm */ if ( strncmp( com, "dsmv", 4 ) == TRUE ){ n_p_slit = 0; strcpy( in_str, "mv" ); cp_str( f_tmp, in_str, n_p_slit, slit_pos ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); sleep(3); n_p_slit = atol( pos ); strcpy( in_str, "mv" ); cp_str( f_tmp, in_str, n_p_slit, slit_pos ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if ( strncmp( com, "dcmv", 4 ) == TRUE ){ n_p_slit = 0; strcpy( in_str, "set" ); cp_str( f_tmp, in_str, n_p_slit, slit_pos ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); sleep(3); n_p_slit = atol( pos ); strcpy( in_str, "set" ); cp_str( f_tmp, in_str, n_p_slit, slit_pos ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if ( strncmp( com, "dpset", 5 ) == TRUE ){ strcpy( slit_pos, pos ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "dporg", 5 ) == TRUE ){ strcpy( slit_pos, "origin" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "dpdef", 5 ) == TRUE ){ show_diaphdef( ndiaph, diaphdef ); } if( strncmp( com, "dphon", 5 ) == TRUE ){ strcpy( slit_pos, "on" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "dphoff", 6 ) == TRUE ){ strcpy( slit_pos, "off" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } /* guide mirror */ if( strncmp( com, "gdorg", 5 ) == TRUE || strncmp( com, "gdout", 5 ) == TRUE ){ strcpy( gdmr_pos, "origin" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "gdin", 4 ) == TRUE ){ strcpy( gdmr_pos, "in" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "gdmv", 4 ) == TRUE ){ n_p_gdmr = 0; strcpy( in_str, "mv" ); cp_str( f_tmp, in_str, n_p_gdmr, gdmr_pos ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); sleep(3); n_p_gdmr = atol( pos ); strcpy( in_str, "mv" ); cp_str( f_tmp, in_str, n_p_gdmr, gdmr_pos ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "gdhon", 5 ) == TRUE ){ strcpy( gdmr_pos, "on" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "gdhoff", 6 ) == TRUE ){ strcpy( gdmr_pos, "off" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } /* GT turret */ if ( strncmp( com, "trset", 5 ) == TRUE ){ strcpy( trrt_pos, pos ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "trorg", 5 ) == TRUE ){ strcpy( trrt_pos, "origin" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "trmv", 4 ) == TRUE ){ n_p_trrt = 0; strcpy( in_str, "mv" ); cp_str( f_tmp, in_str, n_p_trrt, trrt_pos ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); sleep(3); n_p_trrt = atol( pos ); strcpy( in_str, "mv" ); cp_str( f_tmp, in_str, n_p_trrt, trrt_pos ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if ( strncmp( com, "trdef", 5 ) == TRUE ){ show_diaphdef( ntrrt, trrtdef ); } if( strncmp( com, "trhon", 5 ) == TRUE ){ strcpy( trrt_pos, "on" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "trhoff", 6 ) == TRUE ){ strcpy( trrt_pos, "off" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } /* SV turret */ if( strncmp( com, "svset", 5 ) == TRUE ){ strcpy( svtr_pos, pos ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "svorg", 5 ) == TRUE ){ strcpy( svtr_pos, "origin" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "svmv", 4 ) == TRUE ){ n_p_svtr = 0; strcpy( in_str, "mv" ); cp_str( f_tmp, in_str, n_p_svtr, svtr_pos ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); sleep(3); n_p_svtr = atol( pos ); strcpy( in_str, "mv" ); cp_str( f_tmp, in_str, n_p_svtr, svtr_pos ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if ( strncmp( com, "svdef", 5 ) == TRUE ){ show_diaphdef( nsvtr, svtrdef ); } if( strncmp( com, "svhon", 5 ) == TRUE ){ strcpy( svtr_pos, "on" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "svhoff", 6 ) == TRUE ){ strcpy( svtr_pos, "off" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } /* cross disperser */ if( strncmp( com, "cdset", 5 ) == TRUE ){ strcpy( crds_pos, pos ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "cdorg", 5 ) == TRUE ){ strcpy( crds_pos, "origin" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "cdmv", 4 ) == TRUE ){ n_p_crds = 0; strcpy( in_str, "mv" ); cp_str( f_tmp, in_str, n_p_crds, crds_pos ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); sleep(3); n_p_crds = atol( pos ); strcpy( in_str, "mv" ); cp_str( f_tmp, in_str, n_p_crds, crds_pos ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if ( strncmp( com, "cddef", 5 ) == TRUE ){ show_diaphdef( ncrds, crdsdef ); } if( strncmp( com, "cdhon", 5 ) == TRUE ){ strcpy( crds_pos, "on" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "cdhoff", 6 ) == TRUE ){ strcpy( crds_pos, "off" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } /* hollow cathode tube */ if( strncmp( com, "hcton", 5 ) == TRUE ){ strcpy( hct_state, "on" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "hctoff", 6 ) == TRUE ){ strcpy( hct_state, "off" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } /* macro */ if( strncmp( com, "origin", 3 ) == TRUE ){ strcpy( slit_pos, "origin" ); strcpy( gdmr_pos, "origin" ); strcpy( trrt_pos, "origin" ); strcpy( svtr_pos, "origin" ); strcpy( hct_state, "off" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "out", 3 ) == TRUE ){ strcpy( slit_pos, "slit" ); strcpy( gdmr_pos, "out" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "in", 2 ) == TRUE ){ strcpy( slit_pos, "hole" ); strcpy( gdmr_pos, "in" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "comp", 4 ) == TRUE ){ strcpy( hct_state, "on" ); strcpy( trrt_pos, "hct" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "obs", 3 ) == TRUE ){ strcpy( hct_state, "off" ); strcpy( trrt_pos, "hole" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } /* miscellaneous */ if( strncmp( com, "help", 4 ) == TRUE || strncmp( com, "?", 1 ) == TRUE ){ showhelp(); } if( strncmp( com, "log", 3 ) == TRUE ){ showlog(); } if( strncmp( com, "status", 6 ) == TRUE || strncmp( com, "st", 2 ) == TRUE ){ showstatus(); } if( strncmp( com, "terminate", 9 ) == TRUE ){ strcpy( slit_pos, "exit" ); strcpy( gdmr_pos, "exit" ); strcpy( trrt_pos, "exit" ); strcpy( svtr_pos, "exit" ); strcpy( hct_state, "exit" ); write_pos( f_set, slit_pos, gdmr_pos, trrt_pos, svtr_pos, crds_pos, hct_state ); } if( strncmp( com, "quit", 4 ) == TRUE || strncmp( com, "exit", 4 ) == TRUE || strncmp( com, "q", 1 ) == TRUE ){ f_set = fopen( SETTINGFILE, "w" ); fprintf( f_set, "Slit_Stage = origin\n" ); fprintf( f_set, "Guide_Mirror = origin\n" ); fprintf( f_set, "GT_Turret = origin\n" ); fprintf( f_set, "Filter_Turret = origin\n" ); fprintf( f_set, "Cross_Disperser = %s\n", crds_pos ); fprintf( f_set, "Hollow_Cathode_Tube = off\n" ); fclose( f_set ); f_set = fopen( SETTINGFILE, "r" ); sleep(3); printf( "Good bye!!\n" ); exit(0); } } } /* setting list file output */ void write_pos( FILE *f_set, char slit_pos[], char gdmr_pos[], char trrt_pos[], char svtr_pos[], char crds_pos[], char hct_state[] ) { f_set = fopen( SETTINGFILE, "w" ); fprintf( f_set, "Slit_Stage = %s\n", slit_pos ); fprintf( f_set, "Guide_Mirror = %s\n", gdmr_pos ); fprintf( f_set, "GT_Turret = %s\n", trrt_pos ); fprintf( f_set, "Filter_Turret = %s\n", svtr_pos ); fprintf( f_set, "Cross_Disperser = %s\n", crds_pos ); fprintf( f_set, "Hollow_Cathode_Tube = %s\n", hct_state ); fclose( f_set ); return; } /* copy strings */ void cp_str( FILE *f_tmp, char in_str[], long n_pulse, char w_str[] ) { char tmpbuf[STRING_MAX]; f_tmp = fopen( TEMPFILE, "w" ); fprintf( f_tmp, "%s %ld", in_str, n_pulse ); fclose( f_tmp ); f_tmp = fopen( TEMPFILE, "r" ); while( fgets( tmpbuf, STRING_MAX, f_tmp ) != NULL ){ strcpy( w_str, tmpbuf ); } } /* slit position definition */ void read_diaphdef( int *ndiaph, struct name_coord *diaphdef, char filename[] ) { FILE *diaph_f; int n; if( ( diaph_f = fopen( filename, "r" ) ) == NULL ){ printf( "command file "DIAPHDEFFILE" is not found!!!\n" ); *ndiaph = 0; return; } n = 0; while( fscanf( diaph_f, "%s %li %s", diaphdef[n+1].name, &diaphdef[n+1].coord, diaphdef[n+1].comment ) != EOF ){ n++; } *ndiaph = n; return; } /* guide mirror position definition */ long read_gdmrdef( void ) { long gdmr_inpos; FILE *gdmr_f; if( ( gdmr_f = fopen( GDMRDEFFILE, "r" ) ) == NULL ){ printf( "command file "GDMRDEFFILE" is not found!!!\n" ); return; } fscanf( gdmr_f, "%i", &gdmr_inpos ); /* printf( "Guide Mirror IN: position = %i\n", gdmr_inpos ); */ return( gdmr_inpos ) ; } /* Show diaph definition */ void show_diaphdef( int ndiaph, struct name_coord diaphdef[] ) { int i; if( ndiaph == 0 ){ printf( "No component is defined !!\n" ); return; } printf( "Name Position Comment\n" ); for( i = 1; i <= ndiaph; i++ ) printf( "%-16s%10li %-s\n", diaphdef[i].name, diaphdef[i].coord, diaphdef[i].comment ); return; } /* Show command help */ void showhelp( void ){ FILE *f_help; char hlp_str[STRING_MAX]; int hlp_line; if( ( f_help = fopen( HELPFILE, "r" ) ) == NULL ){ printf( "Cannot display help!!\n" ); return; } hlp_line = 0; while( fgets( hlp_str, STRING_MAX, f_help ) != NULL ){ ++hlp_line; printf( "%s", hlp_str ); if( hlp_line == PAGE ){ printf( " -- (hit RETURN) -- " ); fgets( hlp_str, STRING_MAX, stdin ); hlp_line = 0; } } fclose( f_help ); return; } /* Show present status */ void showstatus( void ){ FILE *f_set; char st_str[STRING_MAX]; int st_line; if( ( f_set = fopen( SETTINGFILE, "r" ) ) == NULL ){ printf( "Cannot display status!!\n" ); return; } st_line = 0; while( fgets( st_str, STRING_MAX, f_set ) != NULL ){ ++st_line; printf( "%s", st_str ); if( st_line == PAGE ){ printf( "-- (hit RETURN) --" ); fgets( st_str, STRING_MAX, stdin ); st_line = 0; } } fclose( f_set ); return; } /* Show log list */ void showlog( void ){ FILE *f_log; char log_str[STRING_MAX]; int log_line; if( ( f_log = fopen( LOGFILE, "r" ) ) == NULL ){ printf( "Cannot display logfile!!\n" ); return; } log_line = 0; while( fgets( log_str, STRING_MAX, f_log ) != NULL ){ ++log_line; printf( "%s", log_str ); if( log_line == PAGE ){ printf( " -- (hit RETURN) -- " ); fgets( log_str, STRING_MAX, stdin ); log_line = 0; } } fclose( f_log ); return; } /* startup messages */ void start_msg( void ){ printf( "==========================================\n" ); printf( " LIPS slitcont position setting program \n" ); printf( " \n" ); printf( " Ver 1.00 \n" ); printf( "==========================================\n" ); return; }