Subversion Repositories svn1

Rev

Rev 46 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 root 1
/*************************************************************************
2
*           Copyright (C) 1995 Embedded Solutions
3
*                       All rights reserved
4
*
5
* file:     src\dcheck.c
6
*
7
* purpose:  This module contains routines used to test the consitency
8
*           of the time data.
9
*
10
*           It will test data for one or more legs generating displays of
11
*           inconsitent data. The system will then allow the operator to
12
*           correct the data or to disqualify the team.
13
*
14
* functions
15
*       data_check              - Start the data consistency testing
16
*       correct_times           - Allow the operator to modify data
17
*
18
* programmer: David Purdie
19
*
20
* revision  date        by      reason
21
*   00.0    27/01/95    DDP     Tidies up the program and formatted the file
22
*
23
**************************************************************************/
24
 
25
#include    "consts.h"
26
#include    "structs.h"
27
#include    "proto.h"
28
 
29
 
30
/* Internal definition */
31
 
32
int         leg_end = 0;                         /* Legs to test */
33
char       *ck_err_mess[] = {
34
    "No error",
35
    "Invalid start time",
36
    "Invalid end time",
37
    "End before start",
38
    "Team data not entered"
39
};
40
 
41
/*========================================================================
42
 *
43
 *  Start the data consistency testing
44
 *
45
 *  Purpose:
46
 *      This function is called to start the data consistency testing
47
 *
48
 *  Parameters:
49
 *      None
50
 *
51
 *  Returns:
52
 *      Nothing
53
 *
54
 *========================================================================*/
55
 
56
void data_check(void)
57
{
58
    int         tm;
59
    int         list = 0;                        /* Option to use */
60
    int         i = 0;                           /* List counter */
61
    int         count_bad = 0;                   /* Counter of bad teams */
62
 
63
    cur( 0, 5 );
64
    printf( "Leg times data consistency testing" );
65
    while( TRUE )
66
    {
67
        leg_end = config.num_legs;
68
        d_field( 0, 6, "Enter leg to test :", D_NUMBER, 1,
69
                 ( char * ) &leg_end, TRUE, M_UPDATE );
70
        if( abort_flag )
71
            return;
72
        if( leg_end > 0 && leg_end <= config.num_legs )
73
            break;                               /* Got what I need */
74
        beep();
75
    }
76
 
77
    printf( "\nList or Examine teams with bad times :" );
78
    switch ( getfnc( "LE" ) )
79
    {
80
    case 0:
81
        return;                                  /* Abort exit */
82
 
83
    case 'L':
84
        list++;
85
        printf( "List" );
86
        break;
87
 
88
    default:
89
        printf( "Examine" );
90
    }
91
 
92
    /*
93
     * Start the testing
94
     * Read each team into memory and start the testing
95
     */
96
    printf( "\n\nScanning all team records\n" );
97
 
98
    for( tm = config.min_team; tm <= config.max_team; tm++ )
99
    {
100
        abort_flag = FALSE;
101
        if( valid_field( tm ) )
102
        {
103
            ( void ) g_record( tm, &team_buf );
104
            if( team_buf.flags.disqualified == FALSE
105
                && test_times( &team_buf, leg_end ) )
106
            {
107
                count_bad++;
108
                if( !list )
109
                {
110
                    if( correct_times( tm, list ) )
111
                    {
112
                        tm--;
113
                        count_bad--;
114
                    }
115
                    else if( abort_flag )
116
                        return;
117
                }
118
                else
119
                {
120
                    printf( "%4d ", tm );
121
                    if( ++i > 10 )
122
                    {
123
                        printf( "\n" );
124
                        i = 0;
125
                    }
126
                    flush_out();
127
                }
128
            }
129
        }
130
    }
131
    if( count_bad )
132
        printf( "\n%d teams with inconsistent data\n", count_bad );
133
    else
134
        printf( "\nAll team data correct\n" );
135
    beep();
136
    printf( "Any key to return to main menu : " );
137
    getinp();
138
}
139
 
140
/*========================================================================
141
 *
142
 *  Allow the operator to modify data
143
 *
144
 *  Purpose:
145
 *      This function is called to Allow the operator to modify data
146
 *
147
 *  Parameters:
148
 *      tm      Team to process
149
 *      list    Mode: TRUE : Just list data
150
 *                    FALSE: Modify data
151
 *
152
 *  Returns:
153
 *      This routine will return TRUE if the data was modified 
154
 *
155
 *========================================================================*/
156
 
157
bool correct_times( int tm, int list )
158
{
159
    int         mods_done = FALSE;
160
 
161
    list = list;                                 /* Keep lint quiet for now */
162
    printf( "Team %4d,Leg %d: %s ", tm, check_error.leg,
163
            ck_err_mess[check_error.type] );
164
    printf( " Ign/Disq/NoEquest/Exam :" );
165
    switch ( getfnc( "IDNE" ) )
166
    {
167
    case 0:
168
    case 'I':
169
        mods_done = FALSE;
170
        break;
171
    case 'D':
172
        team_buf.flags.disqualified = TRUE;
173
        printf( "Disqualified" );
174
        mods_done = TRUE;
175
        break;
176
    case 'N':
177
        team_buf.flags.disqualified = TRUE;
178
        team_buf.flags.non_equestrian = TRUE;
179
        printf( "No Equestrian" );
180
        mods_done = TRUE;
181
        break;
182
 
183
    case 'E':
184
        clearscreen();
185
        if( check_error.type == 4 )
186
            d_display( M_TEAM );
187
        else
188
            d_display( M_LEGS );
189
        mods_done = TRUE;
190
        break;
191
    }
192
    put_team_record( tm, &team_buf );
193
    printf( "\n" );
194
    return ( mods_done );
195
}
196
 
197
/********************************* EOF ***********************************/