/* **********************************************************************
 * *                                                                    *
 * *  Routines to return the text strings for various scan parameters   *
 * *                                                                    *
 * **********************************************************************
 * File: iris/xsig/antenna_txt.c
 *
 *                  COPYRIGHT (c) 1999, 2000, 2005  BY
 *          SIGMET INCORPORATED, WESTFORD MASSACHUSETTS, U.S.A.
 * 
 * THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND  COPIED
 * ONLY  IN  ACCORDANCE WITH  THE  TERMS  OF  SUCH  LICENSE  AND WITH THE
 * INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE  OR  ANY OTHER
 * COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
 * OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY
 * TRANSFERED.
 */

#include <stdlib.h>
#include <stdio.h>
#include <Mrm/MrmAppl.h>

#include "sigtypes.h"
#include "user_lib.h"
#include "xsig_lib.h"
/* ----------------------------------------------------------------------------
*/

/* This is now reentrent */
const char* sTaskScanName4_r( SINT2 iscan_a, char sText_a[5] )
{
  switch( iscan_a )
  {	
    case TASK_SCAN_PPI:    strcpy( sText_a, "PPIS" );    break;
    case TASK_SCAN_RHI:    strcpy( sText_a, "RHI" );     break;
    case TASK_SCAN_MANUAL: strcpy( sText_a, "MAN" );     break;
    case TASK_SCAN_CONT:   strcpy( sText_a, "PPIF" );    break;
    case TASK_SCAN_FILE:   strcpy( sText_a, "FILE" );    break;
    case TASK_SCAN_EXEC:   strcpy( sText_a, "EXEC" );    break;
    default:          strcpy( sText_a, "????" );    break;
  };

  return sText_a;
}


char* sazm_txt_f( SINT2 iscan_a, SINT2 isweeps_a, UINT4 *iangs_a )
{
  static char  stxt[48];
  float rmaxang, rminang, rang;
  int    jj, kk;
  
  strcpy( stxt, "" );
  switch( iscan_a )
    {
    case  TASK_SCAN_PPI:
      strcpy( stxt, "Sector" );
      break;
      
    case  TASK_SCAN_CONT: 
      strcpy( stxt, "Full Circle" );
      break;
      
    case  TASK_SCAN_RHI:
      jj = isweeps_a;
      rmaxang = 0; rminang = 360;
      for ( kk=0; kk<jj; kk++ )
	{
	  rang = fPDegFromBin2( iangs_a[kk] );
	  if ( rang > rmaxang ) rmaxang = rang;
	  if ( rang < rminang ) rminang = rang;
	};
      if(jj==1) sprintf( stxt, "One angle at %.1f", rminang ) ;
      else sprintf( stxt, "%d angles from %.1f to %.1f", jj, rminang, rmaxang ) ;
      break;
      
    default:
      strcpy( stxt, "N/A" );
      break;
    };
  return &stxt[0];
}

char* selv_txt_f( SINT2 iscan_a, SINT2 isweeps_a, UINT4 *iangs_a )
{
  static char stxt[48]; 
  float fmaxang, fminang, fang;
  int    jj, kk;

  strcpy( stxt, "" );
  switch( iscan_a )
    {
    case  TASK_SCAN_PPI:  case  TASK_SCAN_CONT:
      jj = isweeps_a;
      fmaxang = -90.0; fminang = 270.0;
      for ( kk=0; kk<jj; kk++ )
	{
	  fang = fElDegFromBin2( iangs_a[kk] );
	  if ( fang > fmaxang ) fmaxang = fang;
	  if ( fang < fminang ) fminang = fang;
	};
      if(jj==1) sprintf( stxt, "One angle at %.1f", fminang ) ;
      else sprintf( stxt, "%d angles from %.1f to %.1f", jj, fminang, fmaxang ) ;
      break;

    case  TASK_SCAN_RHI:
      strcpy( stxt, "Sector");
      break;

    default:
      strcpy( stxt, "N/A");
      break;
    };
  return &stxt[0];
}
