Subversion Repositories svn1-original

Rev

Rev 244 | Rev 285 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 244 Rev 261
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 498... Line 505...
498
 *
505
 *
499
 *  Generate starters report
506
 *  Generate starters report
500
 *
507
 *
501
 *  Purpose:
508
 *  Purpose:
502
 *      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
503
 *      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
504
 *
511
 *
505
 *  Parameters:
512
 *  Parameters:
506
 *      None
513
 *      None
507
 *
514
 *
508
 *  Returns:
515
 *  Returns:
Line 555... Line 562...
555
    /*
562
    /*
556
    **  Now print the data on the printer
563
    **  Now print the data on the printer
557
    **      - Generte the name of the printer file
564
    **      - Generte the name of the printer file
558
    **      - Open the printer
565
    **      - Open the printer
559
    */
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" );
560
 
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;
561
    sprintf( l_s, "l_%d", leg );
607
        sprintf( l_s, "l2_%d", leg );
562
    if( !open_printer( "", l_s, 80, text, "Starters Report" ) )
608
        if( !open_printer( "", l_s, 80, text, "Starters Report (2)" ) )
563
        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( "Team 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
    }
564
 
655
 
565
    /*
656
    /*
-
 
657
    **  Alternate report format - by Team Number
-
 
658
    */
-
 
659
#if 1
-
 
660
    /*
566
     * Print out the header for the file 
661
     * Sort the data into some logical order 
567
     */
662
     */
568
    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 );
569
    print( "Team order listing\n\n" );
-
 
570
 
664
 
-
 
665
    {
571
    print_underline (TRUE);
666
        int c1, c2, c3,c4, c1stop;
572
    print( "%-8s   %-5s   %-8s   |   %-5s   %-8s", "Time", "Team", "DeltaT", "Team", "Time" );
667
        sprintf( l_s, "l3_%d", leg );
573
    print_underline (FALSE);
668
        if( !open_printer( "", l_s, 80, text, "Starters Report (3)" ) )
574
    print( "\n" );
669
            return;
575
 
670
 
576
    last_team = 0;
671
        /*
577
    for( dptr = data, i = 0; i < num_records; i++ )
672
         * Print out the header for the file 
578
    {
673
         */
-
 
674
        print( "\nStarters report for leg:%d %-*s\n", leg, 18, config.leg_name[leg - 1] );
579
        ls_timer( dptr++, i );
675
        print( "Team order listing\n\n" );
-
 
676
 
580
        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");
581
        ls_team( &last_team, data );
682
        print_underline (FALSE);
582
        print( "\n" );
683
        print( "\n" );
583
    }
-
 
584
 
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
 
585
    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" );
586
    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
    
587
 
717
 
588
    /*
718
    /*
589
    **  Release the resources
719
    **  Release the resources
590
    **      - Printer
-
 
591
    **      - Memory
720
    **  Release the data
592
    */
721
    */
593
    close_printer();
-
 
594
    free( data );
722
    free( data );
595
 
723
 
596
    /*
-
 
597
     ** Tell the main system about this new report
-
 
598
     */
-
 
599
    MainWindow::registerReport(getPrinterFile(), "Leg Start");
-
 
600
 
-
 
601
}
724
}
602
 
725
 
603
/*========================================================================
726
/*========================================================================
604
 *
727
 *
605
 *  print the current leg entry
728
 *  print the current leg entry
Line 607... Line 730...
607
 *  Purpose:
730
 *  Purpose:
608
 *      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
609
 *      in time : Team number order
732
 *      in time : Team number order
610
 *
733
 *
611
 *  Parameters:
734
 *  Parameters:
612
 *      ptr     Pointer to entry
735
 *      ptr         Pointer to entry
613
 *      num     Entry index
736
 *      num         Entry index
-
 
737
 *      supress     True: Entry is empty
614
 *
738
 *
615
 *  Returns:
739
 *  Returns:
616
 *      Nothing
740
 *      Nothing
617
 *
741
 *
618
 *========================================================================*/
742
 *========================================================================*/
619
 
743
 
620
void ls_timer( t_legs * ptr, int num )
744
void ls_timer( t_legs * ptr, int num, bool suppress )
621
{
745
{
622
    time_t      time;
746
    time_t      time;
623
    time_t      delta;
747
    time_t      delta;
624
    bool        flags;
748
    bool        flags;
625
 
749
 
-
 
750
    if ( suppress )
-
 
751
    {
-
 
752
        print( "%-8s   %-5s", "","");
-
 
753
        print( "   %-8s", "");
-
 
754
        return;
-
 
755
    }
-
 
756
 
626
    if( num == 0 )
757
    if( num == 0 )
627
        delta = ( time_t ) - 1;
758
        delta = ( time_t ) - 1;
628
    else
759
    else
629
        delta = ptr[0].start - ptr[-1].start;
760
        delta = ptr[0].start - ptr[-1].start;
630
 
761
 
Line 635... Line 766...
635
 
766
 
636
    print( "%-8s   %-5d", time_fa( time, flags ), ptr->numb );
767
    print( "%-8s   %-5d", time_fa( time, flags ), ptr->numb );
637
    print( "   %-8s", time_fa( delta, TRUE ) );
768
    print( "   %-8s", time_fa( delta, TRUE ) );
638
}
769
}
639
 
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 || ptr->flags.non_equestrian || ptr->flags.vet_check;
-
 
802
    if(flags)
-
 
803
        time = ( time_t ) - 1;
-
 
804
 
-
 
805
    print( "%-8s   %-5d", time_fa( time, flags ), ptr->numb );
-
 
806
}
-
 
807
 
640
 
808
 
641
/*========================================================================
809
/*========================================================================
642
 *
810
 *
643
 *  print next ( numeric ) leg entry
811
 *  print next ( numeric ) leg entry
644
 *
812
 *
Line 676... Line 844...
676
    print( "%-5d   %-8s", min->numb, time_fa( time, flags ) );
844
    print( "%-5d   %-8s", min->numb, time_fa( time, flags ) );
677
}
845
}
678
 
846
 
679
/*========================================================================
847
/*========================================================================
680
 *
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 || ptr->flags.non_equestrian || ptr->flags.vet_check;
-
 
878
    if(flags)
-
 
879
        time = ( time_t ) - 1;
-
 
880
 
-
 
881
    print( "%-5d   %-8s", ptr->numb, time_fa( time, flags ) );
-
 
882
}
-
 
883
 
-
 
884
 
-
 
885
/*========================================================================
-
 
886
 *
681
 *  Qsort callback function
887
 *  Qsort callback function
682
 *
888
 *
683
 *  Purpose:
889
 *  Purpose:
684
 *      This function is provided to Qsort() to sort the teams
890
 *      This function is provided to Qsort() to sort the teams
685
 *
891
 *
Line 724... Line 930...
724
        else
930
        else
725
            return ( ( a->start > 0 ) ? -1 : 1 );
931
            return ( ( a->start > 0 ) ? -1 : 1 );
726
    }
932
    }
727
}
933
}
728
 
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
 
729
/********************************* EOF ***********************************/
964
/********************************* EOF ***********************************/