/**************************************************************************/
/**	File:  		Screen.C										                   **/
/**	Author:  	Terry W. Jackson													 **/
/**	Company:		U. S. Nuclear Regulatory Comm.								 **/
/**	Date:			February 28, 1997													 **/
/**----------------------------------------------------------------------**/
/**	Description:  The screen file contains the program statements to   **/
/**		completely draw the four user screens minus the variable values.**/
/**************************************************************************/
#include <conio.h>
#include <stdio.h>
#include <stdarg.h>

/************************** Function Prototypes ***************************/
void RCP_Turbine_Screen(void);  /* Draws RCP and Turbine Screen           */
void Coolant_SG_Screen(void);   /* Draws Coolant and Steam Gen. Screen    */
void Temp_Press_Screen(void);   /* Draws Temperature and Pressure Screen  */
void Neutron_Flux_Screen(void); /* Draws Neutron Flux Screen              */
void print(char c, int num);	  /* Recursively prints characters			  */
double Average(unsigned num, ...);
										  /* Uses variable parameter lists			  */


/**************************************************************************/
/************************** RCP_Turbine_Screen ****************************/
/**************************************************************************/
/*  Inputs:  none                                                         */
/*                                                                        */
/*  Outputs:  none                                                        */
/*                                                                        */
/*  Description:  Draws out the screen for displaying the RCP Bus Voltage */
/*    RCP Bus Frequency, Turbine A/S Oil Pressure, Turbine Stop Valves    */
/*    ESF Actuation Signal, and Manual Trip Signal as identified in       */
/*    requirements 46-57.                                                 */
/**************************************************************************/

void RCP_Turbine_Screen(void)
{
	int i;								/* Intermediate variable					  */

	textbackground(BLUE);  			/* Set background to blue                */
	textcolor(WHITE);                                                               /* Set text color to white              */

	/************ Display RCP bus voltage and frequency info. **************/
	gotoxy(1,1);                                                                                                                    /* 1st line     */
	cprintf("       RCP BUS VOLTAGE AND FREQUENCY");
	cprintf("            Generic Westinghouse Reactor   ");
	gotoxy(44,1); putch(0xba);

	gotoxy(1,2);                                                                                                                    /* 2nd line     */
	cprintf("1A:      V     Hz                         ");
	cprintf("           Protection System         ");
	gotoxy(44,2); putch(0xba);

	gotoxy(1,3);                                                                                                               /* 3rd line  */
	cprintf("1B:      V     Hz                         ");
	cprintf("                                     ");
	gotoxy(44,3); putch(0xba);

	gotoxy(1,4);                                                                                                                    /* 4th line     */
	cprintf("2A:      V     Hz                         ");
	cprintf("     ");
	for (i = 1; i <= 31; i++)
		putch(0xcd);
	gotoxy(44,4); putch(0xba);
	gotoxy(47,4); putch(0xc9);
	gotoxy(79,4); putch(0xbb);

	gotoxy(1,5);                                                                                                                    /* 5th line     */
	cprintf("2B:      V     Hz                          ");
	cprintf("     Message:                       ");
	gotoxy(44,5); putch(0xba);
	gotoxy(47,5); putch(0xba);
	gotoxy(79,5); putch(0xba);

	gotoxy(1,6);                                                                                                                    /* 6th line     */
	cprintf("Volt. Setpoint:      V      P-7    TRIP     ");
	cprintf("                                   ");
	gotoxy(44,6); putch(0xba);
	gotoxy(47,6); putch(0xba);
	gotoxy(79,6); putch(0xba);

	gotoxy(1,7);                                                                                                                    /* 7th line     */
	cprintf("Freq. Setpoint:      Hz     P-7    TRIP    ");
	cprintf("                                    ");
	gotoxy(44,7); putch(0xba);
	gotoxy(47,7); putch(0xba);
	gotoxy(79,7); putch(0xba);

	gotoxy(1,8);                                                                                                                    /* 8th line     */
	for (i=1; i <= 43; i++)
		putch(0xcd);
	cprintf("                                    ");
	gotoxy(44,8); putch(0xb9);
	gotoxy(47,8); putch(0xba);
	gotoxy(79,8); putch(0xba);

	/************ Display turbine a/s oil pressure information *************/
	gotoxy(1,9);                                                                                                                    /* 9th line     */
	cprintf("         TURBINE A/S OIL PRESSURE");
	cprintf("                                             ");
	gotoxy(44,9); putch(0xba);
	gotoxy(47,9); putch(0xba);
	gotoxy(79,9); putch(0xba);

	gotoxy(1,10);                                                                                                                   /* 10th line    */
	cprintf("A:     psig     Setpoint:     psig TRIP");
	cprintf("         Command:                       ");
	gotoxy(15,10); putch(0xb3);
	gotoxy(44,10); putch(0xba);
	gotoxy(47,10); putch(0xba);
	gotoxy(79,10); putch(0xba);

	gotoxy(1,11);
	cprintf("B:     psig                            ");
	cprintf("        ");
	for (i = 1; i <= 31; i++)
		putch(0xcd);
	gotoxy(15,11); putch(0xb3);
	gotoxy(44,11); putch(0xba);
	gotoxy(47,11); putch(0xc8);
	gotoxy(79,11); putch(0xbc);

	gotoxy(1,12);                                                                                                                   /* 12th line    */
	cprintf("C:     psig                            ");
	cprintf("                                        ");
	gotoxy(15,12); putch(0xb3);
	gotoxy(44,12); putch(0xba);

	gotoxy(1,13);                                                                                                                   /* 13th line    */
	cprintf("                                        ");
	cprintf("             ");
	for (i = 1; i <= 21; i++)
		putch(0xcd);
	cprintf("     ");
	gotoxy(44,13); putch(0xba);
	gotoxy(53,13); putch(0xc9);
	gotoxy(75,13); putch(0xbb);

	/**************** Display turbine stop valve information ***************/
	gotoxy(1,14);                                                                                                                   /* 14th line    */
	cprintf("           TURBINE STOP VALVES     ");
	cprintf("                     RCP and Turbine    ");
	gotoxy(44,14); putch(0xba);
	gotoxy(53,14); putch(0xba);
	gotoxy(75,14); putch(0xba);

	gotoxy(1,15);                                                                                                                   /* 15th line    */
	cprintf("A:          B:          C:          D:  ");
	cprintf("             ");
	for (i = 1; i <= 21; i++)
		putch(0xcd);
	cprintf("     ");
	gotoxy(44,15); putch(0xba);
	gotoxy(53,15); putch(0xc8);
	gotoxy(75,15); putch(0xbc);

	gotoxy(1,16);                                                                                                                   /* 16th line    */
	for (i = 1; i <= 43; i++)
	  putch(0xcd);
	cprintf("                                    ");
	gotoxy(44,16); putch(0xb9);

	/******************* Display ESF actuation information *****************/
	gotoxy(1,17);                                                                                                                   /* 17th line    */
	cprintf("           ESF ACTUATION SIGNAL              ");
	cprintf("                                  ");
	gotoxy(44,17); putch(0xba);

	gotoxy(1,18);                                                                                                                   /* 18th line    */
	cprintf("ESF Actuation:                     TRIP     ");
	cprintf(" Neutron Flux      Temp/Press      ");
	gotoxy(44,18); putch(0xba);

	gotoxy(1,19);                                                                                                                   /* 19th line    */
	cprintf("                                            ");
	cprintf("                                   ");
	gotoxy(44,19); putch(0xba);

	/****************** Display manual trip information ********************/
	gotoxy(1,20);                                                                                                                   /* 20th line    */
	cprintf("            MANUAL TRIP SIGNAL            ");
	cprintf("   Coolant/SG        ");
	textbackground(YELLOW);
	textcolor(BLACK);
	cprintf("RCP/Turbine");
	textbackground(BLUE);
	textcolor(WHITE);
	cprintf("     ");
	gotoxy(44,20); putch(0xba);

	gotoxy(1,21);                                                                                                                   /* 21st line    */
	cprintf("Manual Trip:                       TRIP");
	cprintf("                                        ");
	gotoxy(44,21); putch(0xba);

	/***************** Make message box and command box ********************/
	textbackground(BLACK);
	textcolor(LIGHTGRAY);
	gotoxy(58,5); cprintf("                    ");
	gotoxy(58,6); cprintf("                    ");
	gotoxy(58,7); cprintf("                    ");
	gotoxy(58,8); cprintf("                    ");
	gotoxy(58,10); cprintf("                    ");
}


/**************************************************************************/
/************************** Coolant_SG_Screen *****************************/
/**************************************************************************/
/*  Inputs:  none                                                         */
/*                                                                        */
/*  Outputs:  none                                                        */
/*                                                                        */
/*  Description:  Draws out the screen for displaying the Reactor Coolant */
/*    Flow, Steam Generator Water Level, Steam Generator Feed Flow, and   */
/*    Steam Generator Steam Flow as identified in requirements 39-45.     */
/**************************************************************************/

void Coolant_SG_Screen(void)
{
	int i;
	int new;
   int fclose;

	textbackground(BLUE);   			/* Set background to blue             */
	textcolor(WHITE);                                                               /* Set text color to white              */

	/************* Display reactor coolant flow information ****************/
	gotoxy(1,1);                                                                                                                    /* 1st line     */
	cprintf("            REACTOR COOLANT FLOW");
	cprintf("                Generic Westinghouse Reactor   ");
	gotoxy(44,1); putch(0xba);

	gotoxy(1,2);                                                                                                                    /* 2nd line     */
	cprintf("1A:     %%  2A:     %%  3A:     %%  4A:     %%");
	cprintf("           Protection System         ");
	gotoxy(44,2); putch(0xba);

	gotoxy(1,3);                                                                                                                    /* 3rd line     */
	cprintf("1B:     %%  2B:     %%  3B:     %%  4B:     %%");
	cprintf("                                     ");
	gotoxy(44,3); putch(0xba);

	gotoxy(1,4);                                                                                                                    /* 4th line     */
	cprintf("1C:     %%  2C:     %%  3C:     %%  4C:     %%");
	cprintf("     ");
	for (i = 1; i <= 31; i++)
		putch(0xcd);
	gotoxy(44,4); putch(0xba);
	gotoxy(47,4); putch(0xc9);
	gotoxy(79,4); putch(0xbb);

	gotoxy(1,5);                                                                                                                    /* 5th line     */
	cprintf("                                           ");
	cprintf("     Message:                       ");
	gotoxy(44,5); putch(0xba);
	gotoxy(47,5); putch(0xba);
	gotoxy(79,5); putch(0xba);

	gotoxy(1,6);                                                                                                                    /* 6th line     */
	cprintf("Setpoint:     %%      P-7      P-8   TRIP    ");
	cprintf("                                   ");
	gotoxy(44,6); putch(0xba);
	gotoxy(47,6); putch(0xba);
	gotoxy(79,6); putch(0xba);

	gotoxy(1,7);                                                                                                                    /* 7th line     */
	for (i = 1; i <= 43; i++)
		putch(0xcd);
	cprintf("                                    ");
	gotoxy(44,7); putch(0xb9);
	gotoxy(47,7); putch(0xba);
	gotoxy(79,7); putch(0xba);

	/*********** Display steam generator water level information ***********/
	gotoxy(1,8);                                                                                                                    /* 8th line     */
	cprintf("        STEAM GENERATOR WATER LEVEL       ");
	cprintf("                                     ");
	gotoxy(44,8); putch(0xba);
	gotoxy(47,8); putch(0xba);
	gotoxy(79,8); putch(0xba);

	gotoxy(1,9);                                                                                                                    /* 9th line     */
	cprintf("1A:     %%  2A:     %%  3A:     %%  4A:     %%");
	cprintf("                                    ");
	gotoxy(44,9); putch(0xba);
	gotoxy(47,9); putch(0xba);
	gotoxy(79,9); putch(0xba);

	gotoxy(1,10);                                                                                                                   /* 10th line    */
	cprintf("1B:     %%  2B:     %%  3B:     %%  4B:     %%");
	cprintf("      Command:                       ");
	gotoxy(44,10); putch(0xba);
	gotoxy(47,10); putch(0xba);
	gotoxy(79,10); putch(0xba);

	gotoxy(1,11);
	cprintf("1C:     %%  2C:     %%  3C:     %%  4C:     %%");
	cprintf("     ");
	for (i = 1; i <= 31; i++)
		putch(0xcd);
	gotoxy(44,11); putch(0xba);
	gotoxy(47,11); putch(0xc8);
	gotoxy(79,11); putch(0xbc);

	gotoxy(1,12);                                                                                                                   /* 12th line    */
	cprintf("Low-Low Setpoint:     %%             TRIP");
	cprintf("                                       ");
	gotoxy(44,12); putch(0xba);

	gotoxy(1,13);                                                                                                                   /* 13th line    */
	cprintf("                                        ");
	cprintf("             ");
	for (i = 1; i <= 21; i++)
		putch(0xcd);
	cprintf("     ");
	gotoxy(44,13); putch(0xba);
	gotoxy(53,13); putch(0xc9);
	gotoxy(75,13); putch(0xbb);

	/************ Display steam generator feed flow information ************/
	gotoxy(1,14);                                                                                                                   /* 14th line    */
	cprintf("         STEAM GENERATOR FEED FLOW    ");
	cprintf("                  Coolant and SG         ");
	gotoxy(44,14); putch(0xba);
	gotoxy(53,14); putch(0xba);
	gotoxy(75,14); putch(0xba);

	gotoxy(1,15);                                                                                                                   /* 15th line    */
	cprintf("1A:     %%  2A:     %%  3A:     %%  4A:     %%");
	cprintf("           ");
	for (i = 1; i <= 21; i++)
		putch(0xcd);
	cprintf("     ");
	gotoxy(44,15); putch(0xba);
	gotoxy(53,15); putch(0xc8);
	gotoxy(75,15); putch(0xbc);

	gotoxy(1,16);                                                                                                                   /* 16th line    */
	cprintf("1B:     %%  2B:     %%  3B:     %%  4B:     %%");
	cprintf("                                     ");
	gotoxy(44,16); putch(0xba);

	gotoxy(1,17);                                                                                                                   /* 17th line    */
	cprintf("                                             ");
	cprintf("                                  ");
	gotoxy(44,17); putch(0xba);

	/*********** Display steam generator steam flow information ************/
	gotoxy(1,18);                                                                                                                   /* 18th line    */
	cprintf("         STEAM GENERATOR STEAM FLOW         ");
	cprintf(" Neutron Flux      Temp/Press      ");
	gotoxy(44,18); putch(0xba);

	gotoxy(1,19);                                                                                                                   /* 19th line    */
	cprintf("1A:     %%  2A:     %%  3A:     %%  4A:     %%");
	cprintf("                                     ");
	gotoxy(44,19); putch(0xba);

	gotoxy(1,20);                                                                                                                   /* 20th line    */
	cprintf("1B:     %%  2B:     %%  3B:     %%  4B:     %%");
	cprintf("   ");
	textbackground(YELLOW);
	textcolor(BLACK);
	cprintf("Coolant/SG");
	textbackground(BLUE);
	textcolor(WHITE);
	cprintf("        RCP/Turbine     ");
	gotoxy(44,20); putch(0xba);

	gotoxy(1,21);                                                                                                                   /* 21st line    */
	cprintf("Low Setpoint:     %%                 TRIP");
	cprintf("                                       ");
	gotoxy(44,21); putch(0xba);

	/***************** Making message and command box **********************/
	textbackground(BLACK);
	textcolor(LIGHTGRAY);
	gotoxy(58,5); cprintf("                    ");
	gotoxy(58,6); cprintf("                    ");
	gotoxy(58,7); cprintf("                    ");
	gotoxy(58,8); cprintf("                    ");
	gotoxy(58,10); cprintf("                    ");
}


/**************************************************************************/
/************************** Temp_Press_Screen *****************************/
/**************************************************************************/
/*  Inputs:  none                                                         */
/*                                                                        */
/*  Outputs:  none                                                        */
/*                                                                        */
/*  Description:  Draws out the screen for displaying the Delta Tempera-  */
/*    ture, Pressurizer Pressure, and Pressurizer Water Level as identi-  */
/*    fied in requirements 26-38.                                         */
/**************************************************************************/

void Temp_Press_Screen(void)
{
	int i;

	/* Set text and background colors */
	textbackground(BLUE);
	textcolor(WHITE);

	/* Display source range neutron flux info. */
	gotoxy(1,1);                                                                                                                            /* 1st line */
	cprintf("             DELTA TEMPERATURE  ");
	cprintf("                Generic Westinghouse Reactor   ");
	gotoxy(44,1); putch(0xba);

	gotoxy(1,2);                                                                                                                            /* 2nd line */
	cprintf("A:      deg C    OT Setpoint:      deg C    ");
	cprintf("         Protection System         ");
	gotoxy(44,2); putch(0xba);
	gotoxy(16,2); putch(0xb3);

	gotoxy(1,3);                                                                                                                            /* 3rd line */
	cprintf("B:      deg C                       TRIP    ");
	cprintf("                                   ");
	gotoxy(44,3); putch(0xba);
	gotoxy(16,3); putch(0xb3);

	gotoxy(1,4);                                                                                                                            /* 4th line */
	cprintf("C:      deg C   ");
	for (i = 1; i <= 27; i++)
		putch(0xc4);
	cprintf("    ");
	for (i = 1; i <= 31; i++)
		putch(0xcd);
	gotoxy(16,4); putch(0xc3);
	gotoxy(44,4); putch(0xb6);
	gotoxy(47,4); putch(0xc9);
	gotoxy(79,4); putch(0xbb);

	gotoxy(1,5);                                                                                                                            /* 5th line */
	cprintf("D:      deg C  ");
	cprintf("  OP Setpoint:      deg C   ");
	cprintf("     Message:                       ");
	gotoxy(16,5); putch(0xb3);
	gotoxy(44,5); putch(0xba);
	gotoxy(47,5); putch(0xba);
	gotoxy(79,5); putch(0xba);

	gotoxy(1,6);                                                                                                                            /* 6th line */
	cprintf("                                    TRIP    ");
	cprintf("                                   ");
	gotoxy(16,6); putch(0xb3);
	gotoxy(44,6); putch(0xba);
	gotoxy(47,6); putch(0xba);
	gotoxy(79,6); putch(0xba);

	gotoxy(1,7);                                                                                                                            /* 7th line */
	for (i = 1; i <= 43; i++)
		putch(0xcd);
	cprintf("                                    ");
	gotoxy(16,7); putch(0xcf);
	gotoxy(44,7); putch(0xb9);
	gotoxy(47,7); putch(0xba);
	gotoxy(79,7); putch(0xba);

	gotoxy(1,8);                                                                                                                            /* 8th line */
	cprintf("           PRESSURIZER PRESSURE          ");
	cprintf("                                      ");
	gotoxy(44,8); putch(0xba);
	gotoxy(47,8); putch(0xba);
	gotoxy(79,8); putch(0xba);

	gotoxy(1,9);                                                                                                                            /* 9th line */
	cprintf("A:       psig    LP Setpoint:       psig     ");
	cprintf("                                  ");
	gotoxy(16,9); putch(0xb3);
	gotoxy(44,9); putch(0xba);
	gotoxy(47,9); putch(0xba);
	gotoxy(79,9); putch(0xba);

	gotoxy(1,10);                                                                                                                           /* 10th line */
	cprintf("B:       psig      P-10             TRIP        ");
	cprintf("Command:                       ");
	gotoxy(16,10); putch(0xb3);
	gotoxy(44,10); putch(0xba);
	gotoxy(47,10); putch(0xba);
	gotoxy(79,10); putch(0xba);

	gotoxy(1,11);
	cprintf("C:       psig   ");
	for (i = 1; i <= 27; i++)
		putch(0xc4);
	cprintf("    ");
	for (i = 1; i <= 31; i++)
		putch(0xcd);
	gotoxy(16,11); putch(0xc3);
	gotoxy(44,11); putch(0xb6);
	gotoxy(47,11); putch(0xc8);
	gotoxy(79,11); putch(0xbc);

	gotoxy(1,12);                                                                                                                           /* 12th line */
	cprintf("D:       psig    HP Setpoint:       psig    ");
	cprintf("                                   ");
	gotoxy(16,12); putch(0xb3);
	gotoxy(44,12); putch(0xba);

	gotoxy(1,13);                                                                                                                           /* 13th line */
	cprintf("                                    TRIP");
	cprintf("             ");
	for (i = 1; i <= 21; i++)
		putch(0xcd);
	cprintf("     ");
	gotoxy(16,13); putch(0xb3);
	gotoxy(44,13); putch(0xba);
	gotoxy(53,13); putch(0xc9);
	gotoxy(75,13); putch(0xbb);

	gotoxy(1,14);                                                                                                                           /* 14th line */
	for (i = 1; i <= 43; i++)
		putch(0xcd);
	cprintf("            Temp. and Pressure      ");
	gotoxy(16,14); putch(0xcf);
	gotoxy(44,14); putch(0xb9);
	gotoxy(53,14); putch(0xba);
	gotoxy(75,14); putch(0xba);

	gotoxy(1,15);                                                                                                                           /* 15th line */
	cprintf("         PRESSURIZER WATER LEVEL              ");
	cprintf("       ");
	for (i = 1; i <= 21; i++)
		putch(0xcd);
	cprintf("     ");
	gotoxy(44,15); putch(0xba);
	gotoxy(53,15); putch(0xc8);
	gotoxy(75,15); putch(0xbc);

	gotoxy(1,16);                                                                                                                           /* 16th line */
	cprintf("A:      %%        Setpoint:             %%     ");
	cprintf("                                  ");
	gotoxy(16,16); putch(0xb3);
	gotoxy(44,16); putch(0xba);

	gotoxy(1,17);                                                                                                                           /* 17th line */
	cprintf("B:      %%          P-7              TRIP    ");
	cprintf("                                   ");
	gotoxy(16,17); putch(0xb3);
	gotoxy(44,17); putch(0xba);

	gotoxy(1,18);                                                                                                                           /* 18th line */
	cprintf("C:      %%                                    ");
	cprintf("Neutron Flux      ");
	textbackground(YELLOW);
	textcolor(BLACK);
	cprintf("Temp/Press");
	textbackground(BLUE);
	textcolor(WHITE);
	cprintf("      ");
	gotoxy(16,18); putch(0xb3);
	gotoxy(44,18); putch(0xba);

	gotoxy(1,19);                                                                                                                           /* 19th line */
	for (i = 1; i <= 43; i++)
		putch(0xc4);
	cprintf("                                    ");
	gotoxy(16,19); putch(0xc1);
	gotoxy(44,19); putch(0xb6);

	gotoxy(1,20);                                                                                                                           /* 20th line */
	cprintf("                                            ");
	cprintf(" Coolant/SG        RCP/Turbine     ");
	gotoxy(44,20); putch(0xba);

	gotoxy(1,21);                                                                                                                           /* 21st line */
	cprintf("                                            ");
	cprintf("                                   ");
	gotoxy(44,21); putch(0xba);

	/***************** Making message and command box **********************/
	textbackground(BLACK);
	textcolor(LIGHTGRAY);
	gotoxy(58,5); cprintf("                    ");
	gotoxy(58,6); cprintf("                    ");
	gotoxy(58,7); cprintf("                    ");
	gotoxy(58,8); cprintf("                    ");
	gotoxy(58,10); cprintf("                    ");
}


/**************************************************************************/
/************************* Neutron_Flux_Screen ****************************/
/**************************************************************************/
/*  Inputs:  none                                                         */
/*                                                                        */
/*  Outputs:  none                                                        */
/*                                                                        */
/*  Description:  Draws out the screen for displaying the Source Range    */
/*    Neutron Flux, Intermediate Range Neutron Flux, Power Range Neutron  */
/*    Flux, and Delta Neutron Flux as identified in requirements 5-25.    */
/**************************************************************************/

void Neutron_Flux_Screen(void)
{
	int i;
	double result;

	/* Make a function call with indefinite number of parameters			  */
	result = Average(4 + i, 7.5, 89, 62.5, 98.2);

	/* Set text and background colors */
	textbackground(BLUE);
	textcolor(WHITE);

	/* Display source range neutron flux info. */
	gotoxy(1,1);                                                                                                                            /* 1st line */
	cprintf("       SOURCE RANGE NEUTRON FLUX");
	cprintf("                Generic Westinghouse Reactor   ");
	gotoxy(44,1); putch(0xba);

	gotoxy(1,2);                                                                                                                            /* 2nd line */
	cprintf("A:      e  cps     Setpoint:      e  cps    ");
	cprintf("         Protection System         ");
	gotoxy(44,2); putch(0xba);
	gotoxy(16,2); putch(0xb3);

	gotoxy(1,3);                                                                                                                            /* 3rd line */
	cprintf("B:      e  cps       P-6    BLOCK   TRIP    ");
	cprintf("                                   ");
	gotoxy(44,3); putch(0xba);
	gotoxy(16,3); putch(0xb3);

	gotoxy(1,4);
	print(0xcd, 42);                                                                                                                            /* 4th line */
	cprintf("    ");
	for (i = 1; i <= 31; i++)
		putch(0xcd);
	gotoxy(44,4); putch(0xb9);
	gotoxy(16,4); putch(0xcf);
	gotoxy(47,4); putch(0xc9);
	gotoxy(79,4); putch(0xbb);

	gotoxy(1,5);                                                                                                                            /* 5th line */
	cprintf("    INTERMEDIATE RANGE NEUTRON FLUX ");
	cprintf("            Message:                       ");
	gotoxy(44,5); putch(0xba);
	gotoxy(47,5); putch(0xba);
	gotoxy(79,5); putch(0xba);

	gotoxy(1,6);                                                                                                                            /* 6th line */
	cprintf("A:     %%           Setpoint:           %%    ");
	cprintf("                                   ");
	gotoxy(16,6); putch(0xb3);
	gotoxy(44,6); putch(0xba);
	gotoxy(47,6); putch(0xba);
	gotoxy(79,6); putch(0xba);

	gotoxy(1,7);                                                                                                                            /* 7th line */
	cprintf("B:     %%             P-10   BLOCK   TRIP    ");
	cprintf("                                   ");
	gotoxy(16,7); putch(0xb3);
	gotoxy(44,7); putch(0xba);
	gotoxy(47,7); putch(0xba);
	gotoxy(79,7); putch(0xba);

	gotoxy(1,8);                                                                                                                            /* 8th line */
	for (i = 1; i <= 43; i++)
		putch(0xcd);
	cprintf("                                    ");
	gotoxy(16,8); putch(0xcf);
	gotoxy(44,8); putch(0xb9);
	gotoxy(47,8); putch(0xba);
	gotoxy(79,8); putch(0xba);

	gotoxy(1,9);                                                                                                                            /* 9th line */
	cprintf("        POWER RANGE NEUTRON FLUX");
	cprintf("                                               ");
	gotoxy(44,9); putch(0xba);
	gotoxy(47,9); putch(0xba);
	gotoxy(79,9); putch(0xba);

	gotoxy(1,10);                                                                                                                           /* 10th line */
	cprintf("A:      %%          Low Setpoint:       %%    ");
	cprintf("    Command:                       ");
	gotoxy(16,10); putch(0xb3);
	gotoxy(44,10); putch(0xba);
	gotoxy(47,10); putch(0xba);
	gotoxy(79,10); putch(0xba);

	gotoxy(1,11);
	cprintf("B:      %%            P-10   BLOCK   TRIP       ");
	for (i = 1; i <= 31; i++)
		putch(0xcd);
	gotoxy(16,11); putch(0xb3);
	gotoxy(44,11); putch(0xba);
	gotoxy(47,11); putch(0xc8);
	gotoxy(79,11); putch(0xbc);

	gotoxy(1,12);                                                                                                                           /* 12th line */
	cprintf("C:      %%       ");
	for (i = 1; i <= 27; i++)
		putch(0xc4);
	cprintf("                                    ");
	gotoxy(16,12); putch(0xc3);
	gotoxy(44,12); putch(0xb6);

	gotoxy(1,13);                                                                                                                           /* 13th line */
	cprintf("D:      %%          High Setpoint:      %%    ");
	cprintf("         ");
	for (i = 1; i <= 21; i++)
		putch(0xcd);
	cprintf("     ");
	gotoxy(16,13); putch(0xb3);
	gotoxy(44,13); putch(0xba);
	gotoxy(53,13); putch(0xc9);
	gotoxy(75,13); putch(0xbb);

	gotoxy(1,14);                                                                                                                           /* 14th line */
	cprintf("                                    TRIP");
	cprintf("                  Neutron Flux         ");
	gotoxy(16,14); putch(0xb3);
	gotoxy(44,14); putch(0xba);
	gotoxy(53,14); putch(0xba);
	gotoxy(75,14); putch(0xba);

	gotoxy(1,15);                                                                                                                           /* 15th line */
	for (i = 1; i <= 43; i++)
		putch(0xcd);
	cprintf("          ");
	for (i = 1; i <= 21; i++)
		putch(0xcd);
	cprintf("     ");
	gotoxy(16,15); putch(0xcf);
	gotoxy(44,15); putch(0xb9);
	gotoxy(53,15); putch(0xc8);
	gotoxy(75,15); putch(0xbc);

	gotoxy(1,16);                                                                                                                           /* 16th line */
	cprintf("           DELTA NEUTRON FLUX               ");
	cprintf("                                   ");
	gotoxy(44,16); putch(0xba);

	gotoxy(1,17);                                                                                                                           /* 17th line */
	cprintf("A:  xxx %%          Neg. Setpoint:  xxx %%    ");
	cprintf("                                   ");
	gotoxy(16,17); putch(0xb3);
	gotoxy(44,17); putch(0xba);

	gotoxy(1,18);                                                                                                                           /* 18th line */
	cprintf("B:  xxx %%                           TRIP     ");
	textbackground(YELLOW);
	textcolor(BLACK);
	cprintf("Neutron Flux");
	textbackground(BLUE);
	textcolor(WHITE);
	cprintf("      Temp/Press      ");
	gotoxy(16,18); putch(0xb3);
	gotoxy(44,18); putch(0xba);

	gotoxy(1,19);                                                                                                                           /* 19th line */
	cprintf("C:  xxx %%       ");
	for (i = 1; i <= 27; i++)
		putch(0xc4);
	cprintf("                                    ");
	gotoxy(16,19); putch(0xc3);
	gotoxy(44,19); putch(0xb6);

	gotoxy(1,20);                                                                                                                           /* 20th line */
	cprintf("D:  xxx %%          Pos. Setpoint:  xxx %%    ");
	cprintf(" Coolant/SG        RCP/Turbine     ");
	gotoxy(16,20); putch(0xb3);
	gotoxy(44,20); putch(0xba);

	gotoxy(1,21);                                                                                                                           /* 21st line */
	cprintf("                                    TRIP    ");
	cprintf("                                   ");
	gotoxy(16,21); putch(0xb3);
	gotoxy(44,21); putch(0xba);

	/***************** Making message and command box **********************/
	textbackground(BLACK);
	textcolor(LIGHTGRAY);
	gotoxy(58,5); cprintf("                    ");
	gotoxy(58,6); cprintf("                    ");
	gotoxy(58,7); cprintf("                    ");
	gotoxy(58,8); cprintf("                    ");
	gotoxy(58,10); cprintf("                    ");
}


/**************************************************************************/
/******************************** Print ***********************************/
/**************************************************************************/
/*  Inputs:  c - the character to print											  */
/*				 num - the number of characters to print							  */
/*                                                                        */
/*  Outputs:  none                                                        */
/*                                                                        */
/*  Description:  Prints out a series of the same characters by recursion.*/
/**************************************************************************/

void print(char c, int num)
{
	putch(c);
	if (num != 0)
		print(c, num - 1);
}


/**************************************************************************/
/******************************* Average **********************************/
/**************************************************************************/
/*  Inputs:  num - variable number of values to average						  */
/*                                                                        */
/*  Outputs:  return average                                              */
/*                                                                        */
/*  Description:  Finds average of undetermined number of values.			  */
/**************************************************************************/

double Average(unsigned num, ...)
{

	#define temp1_sensor 10
	#define flow1_sensor 11
	#define flow2_sensor 12

	float _sum = 0.0;
	unsigned int a = 1;
	signed int b = -1;
	int i;
	float i;
	void p;
	int result;
	float total_energy;
	float stations;
	va_list vap;

	result = (total_energy / stations + 0.5) + 1;
	result = 5/3;
	p = a + b;
	va_start(vap, num);

	for (i = 0; i < num; i++)
		_sum += va_arg(vap, double);
	va_end(vap);
	if (_sum/num == 1)
		return 0;
	else
		return _sum/num;
}
