Subversion Repositories svn1-original

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
95 - 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
const 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;                       /* Option to use */
60
    int         i;                          /* List counter */
61
    int         count_bad;                  /* Counter of bad teams */
62
 
63
    cur( 0, 5 );
64
    printf( "Leg times data consistency testing" );
65
    while( TRUE )
66
    {
67
        if ( last_loaded_leg > 0 && last_loaded_leg <= config.num_legs )
68
            leg_end = last_loaded_leg;
69
        else
70
            leg_end = config.num_legs;
71
 
72
        d_field( 0, 6, "Enter leg to test :", D_NUMBER, 1,
73
                 ( char * ) &leg_end, TRUE, M_UPDATE );
74
        if( abort_flag )
75
            return;
76
        if( leg_end > 0 && leg_end <= config.num_legs )
77
            break;                               /* Got what I need */
78
        beep();
79
    }
80
 
81
    last_loaded_leg = leg_end;
82
    for ( ; ; )
83
    {
84
        printf( "\n(L)ist, (E)xamine or (Q)uit teams with bad times :" );
85
        list = 0;
86
        count_bad = 0;
87
        i = 0;
88
        switch ( getfnc( "LEQ" ) )
89
        {
90
        case 'Q' :
91
        case 0:
92
            return;                                  /* Abort exit */
93
 
94
        case 'L':
95
            list++;
96
            printf( "List" );
97
            break;
98
 
99
        case 'E':
100
            printf( "Examine" );
101
        }
102
 
103
        /*
104
         * Start the testing
105
         * Read each team into memory and start the testing
106
         */
107
        printf( "\nScanning all team records\n" );
108
 
109
        for( tm = config.min_team; tm <= config.max_team; tm++ )
110
        {
111
            abort_flag = FALSE;
112
            if( valid_field( tm ) )
113
            {
114
                ( void ) g_record( tm, &team_buf );
115
                if( team_buf.flags.disqualified == FALSE
116
                    && test_times( &team_buf, leg_end ) )
117
                {
118
                    count_bad++;
119
                    if( !list )
120
                    {
121
                        if( correct_times( tm, list ) )
122
                        {
123
                            tm--;
124
                            count_bad--;
125
                        }
126
                        else if( abort_flag )
127
                            break;;
128
                    }
129
                    else
130
                    {
131
                        printf( "%4d ", tm );
132
                        if( ++i > 10 )
133
                        {
134
                            printf( "\n" );
135
                            i = 0;
136
                        }
137
                        flush_out();
138
                    }
139
                }
140
            }
141
        }
142
        if( count_bad )
143
            printf( "\n%d teams with inconsistent data", count_bad );
144
        else
145
            printf( "\nAll team data correct" );
146
        beep();
147
    }
148
}
149
 
150
/*========================================================================
151
 *
152
 *  Allow the operator to modify data
153
 *
154
 *  Purpose:
155
 *      This function is called to Allow the operator to modify data
156
 *
157
 *  Parameters:
158
 *      tm      Team to process
159
 *      list    Mode: TRUE : Just list data
160
 *                    FALSE: Modify data
161
 *
162
 *  Returns:
163
 *      This routine will return TRUE if the data was modified 
164
 *
165
 *========================================================================*/
166
 
167
bool correct_times( int tm, int list )
168
{
169
    int         mods_done = FALSE;
170
 
171
    list = list;                                 /* Keep lint quiet for now */
172
    printf( "Team %4d,Leg %d: %s ", tm, check_error.leg,
173
            ck_err_mess[check_error.type] );
174
    printf( " Ign/Disq/NoEquest/Exam :" );
175
    switch ( getfnc( "IDNE" ) )
176
    {
177
    case 0:
178
    case 'I':
179
        mods_done = FALSE;
180
        break;
181
    case 'D':
182
        team_buf.flags.disqualified = TRUE;
183
        printf( "Disqualified" );
184
        mods_done = TRUE;
185
        break;
186
    case 'N':
187
        team_buf.flags.disqualified = TRUE;
188
        team_buf.flags.non_equestrian = TRUE;
189
        printf( "No Equestrian" );
190
        mods_done = TRUE;
191
        break;
192
 
193
    case 'E':
194
        clearscreen();
195
        if( check_error.type == 4 )
196
            d_display( M_TEAM );
197
        else
198
            d_display( M_LEGS );
199
        mods_done = TRUE;
200
        break;
201
    }
202
    put_team_record( tm, &team_buf );
203
    printf( "\n" );
204
    return ( mods_done );
205
}
206
 
207
/********************************* EOF ***********************************/