/************************************************************************* * Copyright (C) 1995 Embedded Solutions * All rights reserved * * file: src\dcheck.c * * purpose: This module contains routines used to test the consitency * of the time data. * * It will test data for one or more legs generating displays of * inconsitent data. The system will then allow the operator to * correct the data or to disqualify the team. * * functions * data_check - Start the data consistency testing * correct_times - Allow the operator to modify data * * programmer: David Purdie * * revision date by reason * 00.0 27/01/95 DDP Tidies up the program and formatted the file * **************************************************************************/ #include "consts.h" #include "structs.h" #include "proto.h" /* Internal definition */ int leg_end = 0; /* Legs to test */ char *ck_err_mess[] = { "No error", "Invalid start time", "Invalid end time", "End before start", "Team data not entered" }; /*======================================================================== * * Start the data consistency testing * * Purpose: * This function is called to start the data consistency testing * * Parameters: * None * * Returns: * Nothing * *========================================================================*/ void data_check(void) { int tm; int list; /* Option to use */ int i; /* List counter */ int count_bad; /* Counter of bad teams */ cur( 0, 5 ); printf( "Leg times data consistency testing" ); while( TRUE ) { if ( last_loaded_leg > 0 && last_loaded_leg <= config.num_legs ) leg_end = last_loaded_leg; else leg_end = config.num_legs; d_field( 0, 6, "Enter leg to test :", D_NUMBER, 1, ( char * ) &leg_end, TRUE, M_UPDATE ); if( abort_flag ) return; if( leg_end > 0 && leg_end <= config.num_legs ) break; /* Got what I need */ beep(); } last_loaded_leg = leg_end; for ( ; ; ) { printf( "\n(L)ist, (E)xamine or (Q)uit teams with bad times :" ); list = 0; count_bad = 0; i = 0; switch ( getfnc( "LEQ" ) ) { case 'Q' : case 0: return; /* Abort exit */ case 'L': list++; printf( "List" ); break; case 'E': printf( "Examine" ); } /* * Start the testing * Read each team into memory and start the testing */ printf( "\nScanning all team records\n" ); for( tm = config.min_team; tm <= config.max_team; tm++ ) { abort_flag = FALSE; if( valid_field( tm ) ) { ( void ) g_record( tm, &team_buf ); if( team_buf.flags.disqualified == FALSE && test_times( &team_buf, leg_end ) ) { count_bad++; if( !list ) { if( correct_times( tm, list ) ) { tm--; count_bad--; } else if( abort_flag ) break;; } else { printf( "%4d ", tm ); if( ++i > 10 ) { printf( "\n" ); i = 0; } flush_out(); } } } } if( count_bad ) printf( "\n%d teams with inconsistent data", count_bad ); else printf( "\nAll team data correct" ); beep(); } } /*======================================================================== * * Allow the operator to modify data * * Purpose: * This function is called to Allow the operator to modify data * * Parameters: * tm Team to process * list Mode: TRUE : Just list data * FALSE: Modify data * * Returns: * This routine will return TRUE if the data was modified * *========================================================================*/ bool correct_times( int tm, int list ) { int mods_done = FALSE; list = list; /* Keep lint quiet for now */ printf( "Team %4d,Leg %d: %s ", tm, check_error.leg, ck_err_mess[check_error.type] ); printf( " Ign/Disq/NoEquest/Exam :" ); switch ( getfnc( "IDNE" ) ) { case 0: case 'I': mods_done = FALSE; break; case 'D': team_buf.flags.disqualified = TRUE; printf( "Disqualified" ); mods_done = TRUE; break; case 'N': team_buf.flags.disqualified = TRUE; team_buf.flags.non_equestrian = TRUE; printf( "No Equestrian" ); mods_done = TRUE; break; case 'E': clearscreen(); if( check_error.type == 4 ) d_display( M_TEAM ); else d_display( M_LEGS ); mods_done = TRUE; break; } put_team_record( tm, &team_buf ); printf( "\n" ); return ( mods_done ); } /********************************* EOF ***********************************/