Subversion Repositories svn1

Rev

Rev 226 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 226 Rev 380
Line 36... Line 36...
36
#include    "mainwindow.h"
36
#include    "mainwindow.h"
37
#include    "consts.h"
37
#include    "consts.h"
38
#include    "structs.h"
38
#include    "structs.h"
39
#include    "proto.h"
39
#include    "proto.h"
40
 
40
 
-
 
41
 
-
 
42
void ls_timer_short( t_legs * ptr, int num, bool suppress );
-
 
43
void ls_team_short( t_legs * ptr, int num, bool suppress );
-
 
44
int sort_team( const void * aa, const void * bb );
-
 
45
 
41
/*========================================================================
46
/*========================================================================
42
 *
47
 *
43
 *  Set up the leg start times for leg
48
 *  Set up the leg start times for leg
44
 *
49
 *
45
 *  Purpose:
50
 *  Purpose:
Line 120... Line 125...
120
    /*
125
    /*
121
    **  Release the data
126
    **  Release the data
122
    */
127
    */
123
    free( data );
128
    free( data );
124
 
129
 
125
    if( report_it )
130
    if( report_it ) {
126
        legs_start_report(leg);
131
        legs_start_report(leg);
-
 
132
    }
127
 
133
 
128
    if ( clear_it )
134
    if ( clear_it ) {
129
        tm_clearleg_specified( leg, TRUE);
135
        tm_clearleg_specified( leg, TRUE);
-
 
136
    }
130
}
137
}
131
 
138
 
132
/*========================================================================
139
/*========================================================================
133
 *
140
 *
134
 *  Set up the leg start times for leg
141
 *  Set up the leg start times for leg
Line 475... Line 482...
475
        }
482
        }
476
        team++;
483
        team++;
477
    }
484
    }
478
}
485
}
479
 
486
 
-
 
487
void tm_recalcElapsed (int leg)
-
 
488
{
-
 
489
    team_type   team_buf;
-
 
490
    int team = config.min_team;                      /* Team we are working with */
-
 
491
    while( team <= config.max_team )
-
 
492
    {
-
 
493
        if( valid_field( team ) )
-
 
494
        {
-
 
495
            g_record( team, &team_buf );
-
 
496
            set_times( &team_buf );
-
 
497
            test_times( &team_buf, leg );
-
 
498
            put_team_record( team, &team_buf );
-
 
499
        }
-
 
500
        team++;
-
 
501
    }
-
 
502
}
480
 
503
 
481
/*========================================================================
504
/*========================================================================
482
 *
505
 *
483
 *  Generate starters report
506
 *  Generate starters report
484
 *
507
 *
485
 *  Purpose:
508
 *  Purpose:
486
 *      This routine is used to generate a list of leg start times
509
 *      This routine is used to generate a list of leg start times
487
 *      This system can cope with a break at the start of leg
510
 *      This system can cope with a break at the start of each leg
488
 *
511
 *
489
 *  Parameters:
512
 *  Parameters:
490
 *      None
513
 *      None
491
 *
514
 *
492
 *  Returns:
515
 *  Returns:
Line 539... Line 562...
539
    /*
562
    /*
540
    **  Now print the data on the printer
563
    **  Now print the data on the printer
541
    **      - Generte the name of the printer file
564
    **      - Generte the name of the printer file
542
    **      - Open the printer
565
    **      - Open the printer
543
    */
566
    */
-
 
567
    {
-
 
568
        sprintf( l_s, "l_%d", leg );
-
 
569
        if( !open_printer( "", l_s, 80, text, "Starters Report" ) )
-
 
570
            return;
-
 
571
 
-
 
572
        /*
-
 
573
         * Print out the header for the file 
-
 
574
         */
-
 
575
        print( "\nStarters report for leg:%d %-*s\n", leg, 18, config.leg_name[leg - 1] );
-
 
576
        print( "Time order listing\n\n" );
-
 
577
 
-
 
578
        print_underline (TRUE);
-
 
579
        print( "%-8s   %-5s   %-8s   |   %-5s   %-8s", "Time", "Team", "DeltaT", "Team", "Time" );
-
 
580
        print_underline (FALSE);
-
 
581
        print( "\n" );
544
 
582
 
-
 
583
        last_team = 0;
-
 
584
        for( dptr = data, i = 0; i < num_records; i++ )
-
 
585
        {
-
 
586
            ls_timer( dptr++, i, FALSE );
-
 
587
            print( "   |   " );
-
 
588
            ls_team( &last_team, data );
-
 
589
            print( "\n" );
-
 
590
        }
-
 
591
 
-
 
592
        print( "\nTeams without marked times will be started when ALL marked teams\n" );
-
 
593
        print( "have been started.\n" );
-
 
594
        close_printer();
-
 
595
 
-
 
596
        /*
-
 
597
         ** Tell the main system about this new report
-
 
598
         */
-
 
599
        MainWindow::registerReport(getPrinterFile(), "Leg Start");
-
 
600
    }
-
 
601
 
-
 
602
    /*
-
 
603
    **  Alternate report format
-
 
604
    */
-
 
605
    {
-
 
606
        int c1, c2, c3,c4, c1stop;
545
    sprintf( l_s, "l_%d", leg );
607
        sprintf( l_s, "l2_%d", leg );
546
    if( !open_printer( "", l_s, 80, text, "Starters Report" ) )
608
        if( !open_printer( "", l_s, 80, text, "Starters Report (2)" ) )
547
        return;
609
            return;
-
 
610
 
-
 
611
        /*
-
 
612
         * Print out the header for the file 
-
 
613
         */
-
 
614
        print( "\nStarters report for leg:%d %-*s\n", leg, 18, config.leg_name[leg - 1] );
-
 
615
        print( "Starting order listing\n\n" );
-
 
616
 
-
 
617
        print_underline (TRUE);
-
 
618
        print( "%-8s   %-5s |   ", "Time", "Team");
-
 
619
        print( "%-8s   %-5s |   ", "Time", "Team");
-
 
620
        print( "%-8s   %-5s |   ", "Time", "Team");
-
 
621
        print( "%-8s   %-5s"  ,  "Time", "Team");
-
 
622
        print_underline (FALSE);
-
 
623
        print( "\n" );
-
 
624
 
-
 
625
        /*
-
 
626
        **  Print in Two columns
-
 
627
        **  Need to figure out where the 2nd column starts
-
 
628
        */
-
 
629
        c1 = 0;
-
 
630
        c2 = c1stop = (num_records + 3)/4;
-
 
631
        c3 = c2 * 2;
-
 
632
        c4 = c2 * 3;
-
 
633
 
-
 
634
        for( ; c1 < c1stop; c1++, c2++, c3++, c4++ )
-
 
635
        {
-
 
636
            ls_timer_short( &data[c1], c1, c1 > c1stop );
-
 
637
            print( " |   " );
-
 
638
            ls_timer_short( &data[c2], c2, c1 > c1stop);
-
 
639
            print( " |   " );
-
 
640
            ls_timer_short( &data[c3], c3, c1 > c1stop);
-
 
641
            print( " |   " );
-
 
642
            ls_timer_short( &data[c4], c4, c4 >= num_records);
-
 
643
            print( "\n" );
-
 
644
        }
-
 
645
 
-
 
646
        print( "\nTeams without marked times will be started when ALL marked teams\n" );
-
 
647
        print( "have been started.\n" );
-
 
648
        close_printer();
-
 
649
 
-
 
650
        /*
-
 
651
         ** Tell the main system about this new report
-
 
652
         */
-
 
653
        MainWindow::registerReport(getPrinterFile(), "Leg Start(2)");
-
 
654
    }
548
 
655
 
549
    /*
656
    /*
-
 
657
    **  Alternate report format - by Team Number
-
 
658
    */
-
 
659
#if 1
-
 
660
    /*
550
     * Print out the header for the file 
661
     * Sort the data into some logical order 
551
     */
662
     */
552
    print( "\nStarters report for leg:%d %-*s\n", leg, 18, config.leg_name[leg - 1] );
663
    qsort( ( char * ) data, num_records, sizeof( t_legs ), sort_team );
553
    print( "Team order listing\n\n" );
-
 
554
 
664
 
-
 
665
    {
555
    print_underline (TRUE);
666
        int c1, c2, c3,c4, c1stop;
556
    print( "%-8s   %-5s   %-8s   |   %-5s   %-8s", "Time", "Team", "DeltaT", "Team", "Time" );
667
        sprintf( l_s, "l3_%d", leg );
557
    print_underline (FALSE);
668
        if( !open_printer( "", l_s, 80, text, "Starters Report (3)" ) )
558
    print( "\n" );
669
            return;
559
 
670
 
560
    last_team = 0;
671
        /*
561
    for( dptr = data, i = 0; i < num_records; i++ )
672
         * Print out the header for the file 
562
    {
673
         */
-
 
674
        print( "\nStarters report for leg:%d %-*s\n", leg, 18, config.leg_name[leg - 1] );
563
        ls_timer( dptr++, i );
675
        print( "Team order listing\n\n" );
-
 
676
 
564
        print( "   |   " );
677
        print_underline (TRUE);
-
 
678
        print( "%-5s   %-8s |   ", "Team", "Time");
-
 
679
        print( "%-5s   %-8s |   ", "Team", "Time");
-
 
680
        print( "%-5s   %-8s |   ", "Team", "Time");
-
 
681
        print( "%-5s   %-8s"   , "Team", "Time");
565
        ls_team( &last_team, data );
682
        print_underline (FALSE);
566
        print( "\n" );
683
        print( "\n" );
567
    }
-
 
568
 
684
 
-
 
685
        /*
-
 
686
        **  Print in Two columns
-
 
687
        **  Need to figure out where the 2nd column starts
-
 
688
        */
-
 
689
        c1 = 0;
-
 
690
        c2 = c1stop = (num_records + 3)/4;
-
 
691
        c3 = c2 * 2;
-
 
692
        c4 = c2 * 3;
-
 
693
 
-
 
694
        for( ; c1 < c1stop; c1++, c2++, c3++, c4++ )
-
 
695
        {
-
 
696
            ls_team_short( &data[c1], c1, c1 > c1stop );
-
 
697
            print( " |   " );
-
 
698
            ls_team_short( &data[c2], c2, c1 > c1stop);
-
 
699
            print( " |   " );
-
 
700
            ls_team_short( &data[c3], c3, c1 > c1stop);
-
 
701
            print( " |   " );
-
 
702
            ls_team_short( &data[c4], c4, c4 >= num_records);
-
 
703
            print( "\n" );
-
 
704
        }
-
 
705
 
569
    print( "\nTeams without marked times will be started when ALL marked teams\n" );
706
        print( "\nTeams without marked times will be started when ALL marked teams\n" );
570
    print( "have been started.\n" );
707
        print( "have been started.\n" );
-
 
708
        close_printer();
-
 
709
 
-
 
710
        /*
-
 
711
         ** Tell the main system about this new report
-
 
712
         */
-
 
713
        MainWindow::registerReport(getPrinterFile(), "Leg Start(3)");
-
 
714
    }
-
 
715
#endif
-
 
716
    
571
 
717
 
572
    /*
718
    /*
573
    **  Release the resources
719
    **  Release the resources
574
    **      - Printer
-
 
575
    **      - Memory
720
    **  Release the data
576
    */
721
    */
577
    close_printer();
-
 
578
    free( data );
722
    free( data );
579
 
723
 
580
    /*
-
 
581
     ** Tell the main system about this new report
-
 
582
     */
-
 
583
    MainWindow::registerReport(getPrinterFile(), "Leg Start");
-
 
584
 
-
 
585
}
724
}
586
 
725
 
587
/*========================================================================
726
/*========================================================================
588
 *
727
 *
589
 *  print the current leg entry
728
 *  print the current leg entry
Line 591... Line 730...
591
 *  Purpose:
730
 *  Purpose:
592
 *      This function is a helper routine to print the current leg entry
731
 *      This function is a helper routine to print the current leg entry
593
 *      in time : Team number order
732
 *      in time : Team number order
594
 *
733
 *
595
 *  Parameters:
734
 *  Parameters:
596
 *      ptr     Pointer to entry
735
 *      ptr         Pointer to entry
597
 *      num     Entry index
736
 *      num         Entry index
-
 
737
 *      supress     True: Entry is empty
598
 *
738
 *
599
 *  Returns:
739
 *  Returns:
600
 *      Nothing
740
 *      Nothing
601
 *
741
 *
602
 *========================================================================*/
742
 *========================================================================*/
603
 
743
 
604
void ls_timer( t_legs * ptr, int num )
744
void ls_timer( t_legs * ptr, int num, bool suppress )
605
{
745
{
606
    time_t      time;
746
    time_t      time;
607
    time_t      delta;
747
    time_t      delta;
608
    bool        flags;
748
    bool        flags;
609
 
749
 
-
 
750
    if ( suppress )
-
 
751
    {
-
 
752
        print( "%-8s   %-5s", "","");
-
 
753
        print( "   %-8s", "");
-
 
754
        return;
-
 
755
    }
-
 
756
 
610
    if( num == 0 )
757
    if( num == 0 )
611
        delta = ( time_t ) - 1;
758
        delta = ( time_t ) - 1;
612
    else
759
    else
613
        delta = ptr[0].start - ptr[-1].start;
760
        delta = ptr[0].start - ptr[-1].start;
614
 
761
 
615
    time = ptr->start;
762
    time = ptr->start;
616
    flags =  ptr->flags.disqualified || ptr->flags.non_equestrian || ptr->flags.vet_check;
763
    flags =  ptr->flags.disqualified;
617
    if(flags)
764
    if(flags)
618
        time = ( time_t ) - 1;
765
        time = ( time_t ) - 1;
619
 
766
 
620
    print( "%-8s   %-5d", time_fa( time, flags ), ptr->numb );
767
    print( "%-8s   %-5d", time_fa( time, flags ), ptr->numb );
621
    print( "   %-8s", time_fa( delta, TRUE ) );
768
    print( "   %-8s", time_fa( delta, TRUE ) );
622
}
769
}
623
 
770
 
-
 
771
/*========================================================================
-
 
772
 *
-
 
773
 *  print the current leg entry  - short form
-
 
774
 *
-
 
775
 *  Purpose:
-
 
776
 *      This function is a helper routine to print the current leg entry
-
 
777
 *      in time : Team number order
-
 
778
 *
-
 
779
 *  Parameters:
-
 
780
 *      ptr         Pointer to entry
-
 
781
 *      num         Entry index
-
 
782
 *      supress     True: Entry is empty
-
 
783
 *
-
 
784
 *  Returns:
-
 
785
 *      Nothing
-
 
786
 *
-
 
787
 *========================================================================*/
-
 
788
 
-
 
789
void ls_timer_short( t_legs * ptr, int num, bool suppress )
-
 
790
{
-
 
791
    time_t      time;
-
 
792
    bool        flags;
-
 
793
 
-
 
794
    if ( suppress )
-
 
795
    {
-
 
796
        print( "%-8s   %-5s", "","");
-
 
797
        return;
-
 
798
    }
-
 
799
 
-
 
800
    time = ptr->start;
-
 
801
    flags =  ptr->flags.disqualified;
-
 
802
    if(flags)
-
 
803
        time = ( time_t ) - 1;
-
 
804
 
-
 
805
    print( "%-8s   %-5d", time_fa( time, flags ), ptr->numb );
-
 
806
}
-
 
807
 
624
 
808
 
625
/*========================================================================
809
/*========================================================================
626
 *
810
 *
627
 *  print next ( numeric ) leg entry
811
 *  print next ( numeric ) leg entry
628
 *
812
 *
Line 652... Line 836...
652
            min = data;
836
            min = data;
653
    }
837
    }
654
    *last = min->numb;                           /* Save current team as done */
838
    *last = min->numb;                           /* Save current team as done */
655
 
839
 
656
    time = min->start;
840
    time = min->start;
657
    flags =  min->flags.disqualified || min->flags.non_equestrian || min->flags.vet_check;
841
    flags =  min->flags.disqualified;
658
    if( flags )
842
    if( flags )
659
        time = ( time_t ) - 1;
843
        time = ( time_t ) - 1;
660
    print( "%-5d   %-8s", min->numb, time_fa( time, flags ) );
844
    print( "%-5d   %-8s", min->numb, time_fa( time, flags ) );
661
}
845
}
662
 
846
 
663
/*========================================================================
847
/*========================================================================
664
 *
848
 *
-
 
849
 *  print next ( numeric ) leg entry - Short Form
-
 
850
 *
-
 
851
 *  Purpose:
-
 
852
 *      This helper function is called to print next ( numeric ) leg entry
-
 
853
 *      in Team # time order
-
 
854
 *
-
 
855
 *  Parameters:
-
 
856
 *      last        Last one found
-
 
857
 *                  Used to relocate my self
-
 
858
 *      data        Start of data
-
 
859
 *
-
 
860
 *  Returns:
-
 
861
 *      Nothing
-
 
862
 *
-
 
863
 *========================================================================*/
-
 
864
 
-
 
865
void ls_team_short( t_legs * ptr, int num, bool suppress )
-
 
866
{
-
 
867
    time_t      time;
-
 
868
    bool        flags;
-
 
869
 
-
 
870
    if ( suppress )
-
 
871
    {
-
 
872
        print( "%-5s   %-8s", "","");
-
 
873
        return;
-
 
874
    }
-
 
875
 
-
 
876
    time = ptr->start;
-
 
877
    flags =  ptr->flags.disqualified;
-
 
878
    if(flags)
-
 
879
        time = ( time_t ) - 1;
-
 
880
 
-
 
881
    print( "%-5d   %-8s", ptr->numb, time_fa( time, flags ) );
-
 
882
}
-
 
883
 
-
 
884
 
-
 
885
/*========================================================================
-
 
886
 *
665
 *  Qsort callback function
887
 *  Qsort callback function
666
 *
888
 *
667
 *  Purpose:
889
 *  Purpose:
668
 *      This function is provided to Qsort() to sort the teams
890
 *      This function is provided to Qsort() to sort the teams
669
 *
891
 *
Line 686... Line 908...
686
    const t_legs * b = (const t_legs *)bb;
908
    const t_legs * b = (const t_legs *)bb;
687
 
909
 
688
    int         a_bad;
910
    int         a_bad;
689
    int         b_bad;
911
    int         b_bad;
690
 
912
 
691
    a_bad = a->flags.disqualified || a->flags.non_equestrian || a->start <= 0;
913
    a_bad = a->flags.disqualified || a->start <= 0;
692
    b_bad = b->flags.disqualified || b->flags.non_equestrian || b->start <= 0;
914
    b_bad = b->flags.disqualified || b->start <= 0;
693
 
915
 
694
    if( a_bad || b_bad )                         /* Valid data has precedence */
916
    if( a_bad || b_bad )                         /* Valid data has precedence */
695
    {
917
    {
696
        if( a_bad && b_bad )
918
        if( a_bad && b_bad )
697
            return ( a->numb - b->numb );
919
            return ( a->numb - b->numb );
Line 708... Line 930...
708
        else
930
        else
709
            return ( ( a->start > 0 ) ? -1 : 1 );
931
            return ( ( a->start > 0 ) ? -1 : 1 );
710
    }
932
    }
711
}
933
}
712
 
934
 
-
 
935
/*========================================================================
-
 
936
 *
-
 
937
 *  Qsort callback function
-
 
938
 *
-
 
939
 *  Purpose:
-
 
940
 *      This function is provided to Qsort() to sort the teams
-
 
941
 *
-
 
942
 *  Parameters:
-
 
943
 *      a           - Leg entry to compare
-
 
944
 *      b           - Leg entry to compare
-
 
945
 *
-
 
946
 *
-
 
947
 *  Returns:
-
 
948
 *      -1      a < b
-
 
949
 *       0      a = b
-
 
950
 *       1      a > b
-
 
951
 *
-
 
952
 *========================================================================*/
-
 
953
 
-
 
954
int sort_team( const void * aa, const void * bb )
-
 
955
{
-
 
956
 
-
 
957
    const t_legs * a = (const t_legs *)aa;
-
 
958
    const t_legs * b = (const t_legs *)bb;
-
 
959
 
-
 
960
    return ( a->numb - b->numb );
-
 
961
}
-
 
962
 
-
 
963
 
713
/********************************* EOF ***********************************/
964
/********************************* EOF ***********************************/