
static char acRcs[] =
    "$Id: sband.c,v 1.1 96/06/13 22:34:35 k2mm Exp $";

#include <stdio.h>

#define tPGM		"sband"
#define tLOGDIR		"rlogs"
#define nBAND		4
#define nTESTMIN	120
#define nLINE		1000

FILE			*pfLog;

int			iBegTestGmt;
int			iBegTestMin;
int			aaiBand[ nBAND][ nTESTMIN + 1];

#define iGMTtoMIN( x)	(60 * ((int)(x) / 100) + ((int)(x) % 100))

int
main( nArg, atArg)
int			nArg;
char*			atArg[];
{   char		*tCall, acLog[ nLINE];

    if( nArg != 3)
	Usage();
    if( sscanf( atArg[ 1], "%d", &iBegTestGmt) != 1)
	Usage();
    iBegTestMin = iGMTtoMIN( iBegTestGmt);
    tCall = atArg[ 2];
    sprintf( acLog, "%s/%s", tLOGDIR, tCall);
    pfLog = fopen( acLog, "r");
    if( pfLog == 0)
    {   fprintf( stderr, "%s: %s: can't open %s\n", tPGM, tCall, acLog);
	return 1;
    }
    ReadLog();
    PrintBand( 0, '2');
    PrintBand( 1, '4');
    PrintBand( 2, '8');
    return 0;
}

Usage()
{
    fprintf( stderr, "usage: %s BegTestGmt Call\n", tPGM);
    exit( -1);
}

ReadLog()
{   char		acLine[ nLINE];
    int			iWave, iBand, iGmt, iMin;
    int			iLastBand = -1, iLastMin = 0;

    re_comp( "-..-");
    while( fgets( acLine, nLINE, pfLog))
    {   if( ! re_exec( acLine))
	    continue;
	sscanf( acLine, "%d %d", &iWave, &iGmt);
	iBand = iWave == 20 ? 0 : iWave == 40 ? 1 : iWave == 80 ? 2 : 3;
	iMin = iGMTtoMIN( iGmt) - iBegTestMin;
	/* printf( "b%d=%d t%04d=%d\n", iWave, iBand, iGmt, iMin); */
	if( iLastBand >= 0)
	{   while( iLastMin < iMin)
		aaiBand[ iLastBand][ iLastMin++] = 1;
	}
	aaiBand[ iLastBand = iBand][ iLastMin = iMin] = 1;
    }
}

PrintBand( iBand, cBand)
int			iBand;
char			cBand;
{   int			iMin;

    for( iMin = 0; iMin <= nTESTMIN; iMin++)
	if( aaiBand[ iBand][ iMin])
	    putchar( cBand);
	else if( iMin % 10 == 0)
	    putchar( '|');
	else
	    putchar( ' ');
    putchar( '\n');
}


