Exemplo n.º 1
0
/*
*------------------------------------------------------------------------------
* void APP_init(void)
*
* Summary	: Initialize application
*
* Input		: None
*
* Output	: None
*------------------------------------------------------------------------------
*/
void APP_init( void )
{
	UINT8 i;

	//Set Date and Time
	//WriteRtcTimeAndDate(writeTimeDateBuffer);

	//Read the value of PRESET TIME from EPROM
	for(i = 0 ; i < NO_OF_DIGITS;i++)
	{
		app.mildstone1[i] = Read_b_eep (EEPROM_MILDSTONE1_ADDRESS  + i);  
		Busy_eep();	
	}

	app.mildstone1Value = (UINT16)(((app.mildstone1[3]- '0' )* 10 )+ ( app.mildstone1[2] - '0') )* 60 +(((app.mildstone1[1]- '0' )* 10 )+ (app.mildstone1[0] - '0'));

	for(i = 0 ; i < NO_OF_DIGITS;i++)
	{
		app.mildstone2[i] = Read_b_eep (EEPROM_MILDSTONE2_ADDRESS  + i);  
		Busy_eep();	
	}

	app.mildstone2Value = (UINT16)(((app.mildstone2[3]- '0' )* 10 )+ ( app.mildstone2[2] - '0') )* 60 +(((app.mildstone2[1]- '0' )* 10 )+ (app.mildstone2[0] - '0'));
	
	APP_resetDisplayBuffer();
	DigitDisplay_updateBufferPartial(app.displayBuffer , 0, 4);

	GREEN_LAMP = RESET;
	RED_LAMP = RESET;

	CLOCK_LED = TRUE;


}
Exemplo n.º 2
0
void UI_updateDepartment(UINT8 *buffer)
{
UINT8 i ,j ;
UINT8 department_data;
UINT8 department_index = (buffer[0] - '0') - 1 ;
i = j =0;

	while(buffer[i+1] != '\0')
	{
		Write_b_eep((DEPARTMENT_START_ADD +( (department_index * 16))+ i) ,buffer[i+1] );
		Busy_eep();
		i++;
	}
	Write_b_eep((DEPARTMENT_START_ADD +(department_index * 16))+ i , '\0');
	Busy_eep();

	department_data = Read_b_eep(DEPARTMENT_START_ADD +(department_index * 16));
	Busy_eep();

	while(department_data != '\0')
	{
		ui_department[department_index +1][j] = department_data ;
		j++;
		department_data = Read_b_eep((DEPARTMENT_START_ADD +(department_index * 16))+ j);
		Busy_eep();
	}
	ui_department[department_index +1][j] = '\0';



}
Exemplo n.º 3
0
void UI_init(void)
{

	UINT8 i, j;
	UINT8 department_index;
	UINT8 department_data;
	ui.departmentNo = '0';

	setbckspc('\x08');	//Indicates LCD driver "\x08" is the symbol for backspace

	
		

	clearUIBuffer();
	clearUIInput();


//read department data from EPROM and store no of department
	for(i = 0 ; i <= MAX_DEPARTMENTS ;i++)
	{
		department_index = Read_b_eep(DEPARTMENT_START_ADD +(i * 16));
		Busy_eep();
		if(department_index != '\0')
		{
			j = 0;
			department_data = department_index;

			while(department_data != '\0')
			{
				ui_department[i+1][j] = department_data ;
				j++;
				department_data = Read_b_eep((DEPARTMENT_START_ADD +(i * 16))+ j);
				Busy_eep();
			}
			ui_department[i+1][j] = '\0';
			ui.departmentNo ++;
		}
	}

	if (loginStatus() == TRUE)
	{
		setUImsg(UI_MSG_STATION);
		ui.state = UI_STATION;
		rawWriteCommandToLcd(DISPLAY_ON_CUR_BLINK_BIG);
	}
	else
	{
		ui.state = UI_IDLE;
		setUImsg(UI_MSG_IDLE);
		rawWriteCommandToLcd(DISPLAY_ON_CUR_OFF);
	}


}
Exemplo n.º 4
0
/*
*------------------------------------------------------------------------------
* void APP-task(void)
*------------------------------------------------------------------------------
*/
void APP_task(void)
{
	UINT8 i,*ptr, data;

	UINT32 addr;
	UINT8 resetBuzzer = TRUE;
	ias.curAppTime = GetAppTime();											//Fetches the application time from timer driver
	if(ias.preAppTime != ias.curAppTime)
	{
		ias.preAppTime = ias.curAppTime;
		for(i = 0; i <MAX_ISSUES; i++)										//check for timeout of issues raised
		{
			if(ias.issues[i].state == ISSUE_RAISED )
			{
				ias.issues[i].timeout -= 1;

			

				ptr = (UINT8*)&ias.issues[i].timeout;

				data = *ptr;

				addr = (i*ISSUE_ENTRY_SIZE)+ISSUE_TIMEOUT;
				Write_b_eep((i*ISSUE_ENTRY_SIZE)+ISSUE_TIMEOUT, *ptr);
				Busy_eep();
				ClrWdt();

				data=*(ptr+1);
				addr = (i*ISSUE_ENTRY_SIZE)+ISSUE_TIMEOUT+1;
				Write_b_eep((i*ISSUE_ENTRY_SIZE)+ISSUE_TIMEOUT+1, *(ptr+1));
				Busy_eep();
				ClrWdt();

			}
		}

		if(update_timeouts() == TRUE)
		{
			LAMP_RED = 1;
			if( ias.issues_raised == 0 )
			{
				LAMP_YELLOW = 0;
				LAMP_GREEN = 0;
			}
		}
		if(ias.updateCount >= 5)
		{
			ias.updateCount = 0;
			update();
		}
	}

	++ias.updateCount;	
}
Exemplo n.º 5
0
void APP_init(void)
{
	UINT8 i = 0, j = 0;
	UINT8 receivedMsg = '1';
	UINT16 index = 0;
	UINT8 data = 0;
	UINT8 messageIndex = 0;

	//Read the receivedMsg from EEPROM and store it into 
	for( i = 0; i < MAX_PROCESS; i++ )
	{		
		j = 0;

		//store the message offset
		index = ( UINT16 ) i * INDEX_OFFSET;

		//read the data from eeprom check for null
		data = Read_b_eep( index + j );
		Busy_eep(  );

		if( data == '\0' )
			continue;

		while( data != '\0' )
		{
			data = app.msg[i][j++] = Read_b_eep( index + j );
			Busy_eep(  );
		}
		
	}



	//restore the current message
	index = ( UINT16 )MAX_PROCESS * INDEX_OFFSET;
	messageIndex = Read_b_eep( index );
	Busy_eep(  );

	app.previousInput = app.currentInput = messageIndex;
	app.currentIndex = messageIndex;

	if( messageIndex <= MAX_PROCESS )
	{
		MMD_clearSegment(0);
		mmdConfig.startAddress = 0;
		mmdConfig.length = MMD_MAX_CHARS;
		mmdConfig.symbolCount = strlen( app.msg[messageIndex] );
		mmdConfig.symbolBuffer = app.msg[messageIndex];
		mmdConfig.scrollSpeed = SCROLL_SPEED_LOW;
		MMD_configSegment( 0 , &mmdConfig);
	}


}
Exemplo n.º 6
0
/*
*------------------------------------------------------------------------------
* void APP_init(void)
*
* Summary	: Initialize application
*
* Input		: None
*
* Output	: None
*------------------------------------------------------------------------------
*/
void APP_init( void )
{
	UINT8 i;

	//	writeTimeDateBuffer[2] = SetHourMode(0X09,1,1);
	//Set Date and Time
	//WriteRtcTimeAndDate(writeTimeDateBuffer);

	//Read the value of PRESET TIME from EPROM
	for(i = 0 ; i < NO_OF_DIGITS;i++)
	{
		app.presetBuffer[i] = Read_b_eep (EEPROM_PRESET_ADDRESS  + i);  
		Busy_eep();	
	}

	app.presetValue = (UINT16)(((app.presetBuffer[3]- '0' )* 10 )+ ( app.presetBuffer[2] - '0') )* 60 +(((app.presetBuffer[1]- '0' )* 10 )+ (app.presetBuffer[0] - '0'));
	
	//Maintain the state from EPROM
	app.state = Read_b_eep (EEPROM_STATE_ADDRESS);  
	Busy_eep();


	//Read the STORED RTC value from EPROM
	for(i = 0 ; i < 6 ;i++)
	{
		app.displayBuffer[i] = Read_b_eep (EEPROM_RTC_ADDRESS + i);  
		Busy_eep();	
	}

	//update that value on RTC
	APP_updateRTC();

	//Maintain the HOOTER state from EPROM
	HOOTER = Read_b_eep (EEPROM_HOOTER_ADDRESS);  
	Busy_eep();
	//Maintain the hooter_reset value from EPROM
	app.hooter_reset = Read_b_eep (EEPROM_HOOTER_ADDRESS + 1);  
	Busy_eep();
	if(HOOTER  == TRUE)
	{
		DigitDisplay_updateBuffer(app.presetBuffer);
		CLOCK_LED = 1;	
	}
	//ON DOT_CONTROL leds
	CLOCK_LED = 0;


}
Exemplo n.º 7
0
void IAS_acknowledgeIssues(UINT8 ID)
{
	UINT8 i;
	ias.issues[ID].ackStatus = 0;

	updateLog(ias.issues[ID].data);

	


	Write_b_eep((ID*ISSUE_ENTRY_SIZE)+ISSUE_ACKSTATUS, ias.issues[ID].ackStatus);
	Busy_eep();
	ClrWdt();

	//IAS_updateIssues(ias.issues[ID].data);

	for( i = 0 ; i < MAX_ISSUES ;i++)
	{
		if( ias.issues[i].ackStatus == 1)
			return;
	}
	BUZ_OP = 0;
			
	
}
Exemplo n.º 8
0
/*---------------------------------------------------------------------------------------------------------------
*	BOOL update_timeouts(void)
*----------------------------------------------------------------------------------------------------------------
*/
BOOL update_timeouts(void)
{
	UINT8 i;
	BOOL result = FALSE;
	for(i = 0; i <MAX_ISSUES; i++)						//check for timeout of issues raised
	{
		if(ias.issues[i].state == ISSUE_RAISED)
		{
			if(ias.issues[i].timeout == 0)
			{
				ias.issues_critical++;
				ias.issues_raised--;
				ias.issues[i].state = ISSUE_CRITICAL;
				
				Write_b_eep((i*ISSUE_ENTRY_SIZE)+ISSUE_STATE,ias.issues[i].state);
				Busy_eep();
				ClrWdt();
		

				ias.state = ISSUE_CRITICAL;//put up
				result = TRUE;
			}
		}
	}
	return result;
}
Exemplo n.º 9
0
/*----------------------------------------------
Store department riase vlaue to EEPROM
------------------------------------------------*/
void writeDeptRaise(void)
{
	UINT8 i;
	for( i = 0; i < MAX_DEPARTMENTS ;i++)
	{
		Write_b_eep(DEPARTMENT_RAISE_ADD + i ,ias.department_raised[i+1] );
		Busy_eep();
		ClrWdt();
	}
}
Exemplo n.º 10
0
void APP_raiseIssues(far UINT8* data)
{
	UINT8 i,j,issueIndex;
	UINT8 *ptr;



	for(i = 0; i < MAX_ISSUES; i++)										//for each issue
		if(ias.issues[i].state != ISSUE_RESOLVED )						//if it is raised
			if(strcmp((INT8*)data,(INT8 *)ias.issues[i].data) == 0)		//if input matches				
					return;												//do nothing


	for( i = 0 ; i < MAX_ISSUES ;i++)
	{
		if( ias.issues[i].state == ISSUE_RESOLVED )
		{
			ias.issues[i].state = ISSUE_RAISED;
			ias.issues[i].timeout =  timeout;
			ias.issues[i].ackStatus = 1;
			strcpy((INT8*) ias.issues[i].data, (INT8*)data);

			ptr = (UINT8*)&ias.issues[i];
			for(j = 0; j < ISSUE_ENTRY_SIZE; j++)
			{
				Write_b_eep(j+(i*ISSUE_ENTRY_SIZE),*(ptr+j));
				Busy_eep();
				ClrWdt();
			}

			ias.issues_raised++;
            if(ias.issues_critical == 0)
            {
				if(	ias.mutualAid == 1 )
				  	updateIndication(-1,1,0,0);
				else				
			  		updateIndication(0,1,0,0);
            }
            else
            {
				if( ias.mutualAid == 1)
			  		updateIndication(-1,1,1,0);
				else
					updateIndication(0,1,1,0);
			}
			updateLog(data);
			break;
		}
	}

	if( ias.issues_critical ==  0 )
		ias.state = ISSUE_RAISED;


}
Exemplo n.º 11
0
/*----------------------------------------------
Store department riase vlaue from EEPROM
------------------------------------------------*/
void readDeptRaise(void)
{
	UINT8 i;
	for( i = 0; i < MAX_DEPARTMENTS ;i++)
	{
		ias.department_raised[i+1] = Read_b_eep( DEPARTMENT_RAISE_ADD + i );
		Busy_eep();
		ClrWdt();
	}

}
Exemplo n.º 12
0
void APP_clearIssues()
{

	UINT16 i;

	ias.state = ISSUE_RESOLVED;
	ias.issues_raised = 0;														//No. of raised issues should be 0 initially
	ias.issues_critical = 0;													//No. of critical issues should be 0 initially
	ias.preAppTime = 0;
	ias.curAppTime = 0;
	ias.openIssue = 0;
	log.index = 0;
	log.prevIndex = 0;


	for( i = 0 ; i < MAX_ISSUES; i++)
	{
		ias.issues[i].state = ISSUE_RESOLVED;
		ias.issues[i].timeout = 0;
		ias.issues[i].ackStatus = 0;
		memset(ias.issues[i].data , 0 , MAX_KEYPAD_ENTRIES + 1);
		ClrWdt();
	}



	for(i = 0; i < (ISSUE_ENTRY_SIZE * MAX_ISSUES); i++)
	{
		Write_b_eep(i,0);
		Busy_eep();
		ClrWdt();

	}

	for( i = 1 ; i <= MAX_DEPARTMENTS ; i++)
	{
		ias.department_raised[i] = 0 ;
	}

	writeDeptRaise();
/*

	if( ias.logonStatus == 1 )
	{
		updateIndication(1,0,0,0);
	}
	else
		updateIndication(0,0,0,0);
*/

	
}
Exemplo n.º 13
0
void main (void) {

	lcd_init();
	lcd_gotoxy(4,1);
	lcd_putrs("EEPROM PIC\n");

	// Busca �ltimo contador
	contador = eeprom_read(direccion);	 // TODO: Fix this

	while (1) {

		direccion = 12;

		contador++;
		eeprom_write(direccion, contador);
		Busy_eep();						// Espera a que termine de escribir NO OLVIDAR!!

		sprintf(str_int, "Contador:%03d", eeprom_read(direccion));
		lcd_puts(str_int);

	}
}
Exemplo n.º 14
0
void APP_task(void)
{

	UINT8 i = 0, j = 0;
	UINT8 writeIndex = 0;
	UINT16 eepromIndex = 0;
	//update the new string in eeprom and buffer
	if(app.eepUpdate == TRUE)
	{

		//update EEPROM with new receivedMsg string
		while( app.receivedMsg[i] != '\0' )
		{
			Write_b_eep( (app.receivedIndex+i), app.receivedMsg[i] );
			Busy_eep();
			i++;
		}	

		//Store null eeprom
		Write_b_eep( (app.receivedIndex+i), '\0' );
		Busy_eep();

		//Get the write index of buffer by dividing message length
		writeIndex = ( UINT8 ) app.receivedIndex / INDEX_OFFSET;

		for( j = 0; j < i; j++ )
		{
			app.msg[writeIndex][j] = Read_b_eep( app.receivedIndex + j );
			Busy_eep(  );
		}

		app.msg[writeIndex][j] = '\0';

		if( writeIndex == app.currentIndex )
		{
			MMD_clearSegment(0);
			mmdConfig.startAddress = 0;
			mmdConfig.length = MMD_MAX_CHARS;
			mmdConfig.symbolCount = strlen( app.msg[writeIndex] );
			mmdConfig.symbolBuffer = app.msg[writeIndex];
			mmdConfig.scrollSpeed = SCROLL_SPEED_LOW;
			MMD_configSegment( 0 , &mmdConfig);
		}

		
		app.eepUpdate = FALSE;
	}	


	//scan the input for change and update mmd based on the input
	app.currentInput = 0;

	if ( (LinearKeyPad_getKeyState(BIT_0) == 1) )
		app.currentInput |= 0X01; 						//0b00000001;
	if ( (LinearKeyPad_getKeyState(BIT_1) == 1) )
		app.currentInput |= 0X02; 						//0b00000010;
	if ( (LinearKeyPad_getKeyState(BIT_2) == 1) )
		app.currentInput |= 0X04; 						//0b00000100;
	if ( (LinearKeyPad_getKeyState(BIT_3) == 1) )
		app.currentInput |= 0X08;						//0b00001000;
	
	if( app.previousInput != app.currentInput && app.currentInput != 0x00 )
	{
		if( app.currentInput <= MAX_PROCESS )
		{
			MMD_clearSegment(0);
			mmdConfig.startAddress = 0;
			mmdConfig.length = MMD_MAX_CHARS;
			mmdConfig.symbolCount = strlen( app.msg[app.currentInput-1] );
			mmdConfig.symbolBuffer = app.msg[app.currentInput-1];
			mmdConfig.scrollSpeed = SCROLL_SPEED_LOW;
			MMD_configSegment( 0 , &mmdConfig);
			app.previousInput = app.currentInput;

			app.currentIndex = app.currentInput-1;

			//store current message index into eeprom
			Write_b_eep( (UINT16)MAX_PROCESS * INDEX_OFFSET, app.currentInput-1 );
			Busy_eep();
		}
	}
}
Exemplo n.º 15
0
void APP_resolveIssues(UINT8 id)
{
	UINT8 i,j,issueIndex;
	UINT8 *ptr;
	far UINT8* data;
	UINT8 department_type;


								
		if(ias.issues[id].state != ISSUE_RESOLVED )						//if it is raised
			if(strcmp((INT8*)data,(INT8 *)ias.issues[id].data) == 0)		//if input matches
				if(ias.issues[id].ackStatus == 1) 						//check whether acknowledged
					return;												//if not return

	data = ias.issues[id].data;
	department_type = ias.issues[id].data[2];
	ias.department_raised[department_type - '0']--;
	writeDeptRaise();


	switch(ias.state)
	{

		case ISSUE_RAISED:
			issueIndex = issueResolved(data);
			if(  issueIndex != -1)
			{
				updateLog(data);
				memset(ias.issues[issueIndex].data , 0 , MAX_KEYPAD_ENTRIES + 1);
							
				ClrWdt();
				
				ptr = (UINT8*)&ias.issues[issueIndex];
				for( j = 0; j < ISSUE_ENTRY_SIZE; j++)
				{
					Write_b_eep(j+(issueIndex*ISSUE_ENTRY_SIZE),*(ptr+j));
					Busy_eep();
					
					ClrWdt();
				}
				
				
				if(ias.issues_raised == 0)
				{
					ias.state = ISSUE_RESOLVED;
	
				//	updateIndication(1,0,0,0);
				}
				return;
			}
	
		break;

		case ISSUE_CRITICAL:
			issueIndex = issueResolved(data);
			if(  issueIndex != -1)
			{
				updateLog(data);
				memset(ias.issues[issueIndex].data , 0 , MAX_KEYPAD_ENTRIES + 1);
							
				ClrWdt();
				
				ptr = (UINT8*)&ias.issues[issueIndex];
				for( j = 0; j < ISSUE_ENTRY_SIZE; j++)
				{
					Write_b_eep(j+(issueIndex*ISSUE_ENTRY_SIZE),*(ptr+j));
					Busy_eep();
					
					ClrWdt();
				}
				
				
				if(ias.issues_critical == 0)
				{
					if(ias.issues_raised == 0)
					{
						ias.state = ISSUE_RESOLVED;
					//	updateIndication(1,0,0,0);
					}
					else
					{
						ias.state = ISSUE_RAISED;
					//	updateIndication(0,1,0,0);
					}
				}
				else
				
				{
                     if(ias.issues_raised == 0)
					{
					//	ias.state = ISSUE_RESOLVED;
					//	updateIndication(0,0,1,0);
					}
					else
					{
						//ias.state = ISSUE_RAISED;
					//	updateIndication(0,1,1,0);
					}
				
     			}                            
		
				return;
			}
		

		break;

		default:
		break;

	}
for(i=0;i<MAX_ISSUES;i++)
{
	if(ias.issues[i].ackStatus==1)
	{
	 BUZZER=1;
	 return;
	}
}

}
Exemplo n.º 16
0
void APP_task( void )
{
	UINT8 i;


		switch(app.state)
		{
			case HALT_STATE:
			

			if (LinearKeyPad_getPBState(COUNT_PB) == KEY_PRESSED)
			{
				ResetAppTime();
				app.state = COUNT_STATE;

			
			}
			
			 if (LinearKeyPad_getPBState(MILDSTONE1_PB) == KEY_PRESSED)
			{
				//Reset Target buffer which is used to hold preset data
				APP_resetBuffer1();

				//Blink first digit in the display
				app.blinkIndex = 0;
				DigitDisplay_updateBuffer(app.mildstone1);
				DigitDisplay_blinkOn_ind(500, app.blinkIndex);


				GREEN_LAMP = RESET;
				RED_LAMP = RESET;

				app.mildstone1Flag = TRUE;
				//Change state to setting state
				app.state = SETTING_STATE;
			
			}

			//Check the keypress Status of HOOTER_OFF_PB 
			 if(LinearKeyPad_getPBState(MILDSTONE2_PB) == KEY_PRESSED)
			{
				//Reset Target buffer which is used to hold preset data
				APP_resetBuffer2();

				//Blink first digit in the display
				app.blinkIndex = 0;
				DigitDisplay_updateBuffer(app.mildstone2);
				DigitDisplay_blinkOn_ind(500, app.blinkIndex);

				GREEN_LAMP = RESET;
				RED_LAMP = RESET;

				app.mildstone2Flag = TRUE;
				//Change state to setting state
				app.state = SETTING_STATE;
			}

			
			break;

			case SETTING_STATE:

			// Code to handle Digit index PB
			if (LinearKeyPad_getPBState(DIGIT_INDEX_PB ) == KEY_PRESSED) 
			{
				app.blinkIndex++;

				if(app.blinkIndex > (NO_OF_DIGITS -  1))
					app.blinkIndex = 0 ;

				DigitDisplay_blinkOn_ind(500, app.blinkIndex);

			}

			// Code to handle increment PB
			if (LinearKeyPad_getPBState(INCREMENT_PB) == KEY_PRESSED) 
			{

				if(	app.mildstone1Flag == TRUE )
				{
					app.mildstone1[app.blinkIndex]++;
					if(app.mildstone1[app.blinkIndex] > max[app.blinkIndex])
						app.mildstone1[app.blinkIndex] = '0';			
							
					DigitDisplay_updateBuffer(app.mildstone1);
				}
				if(	app.mildstone2Flag == TRUE)
				{
					app.mildstone2[app.blinkIndex]++;
					if(app.mildstone2[app.blinkIndex] > max[app.blinkIndex])
						app.mildstone2[app.blinkIndex] = '0';			
							
					DigitDisplay_updateBuffer(app.mildstone2);

				}

			}
			
			if ((LinearKeyPad_getPBState(MILDSTONE1_PB) == KEY_PRESSED) && (app.mildstone1Flag == TRUE))
			{
				app.mildstone1Flag = FALSE;
				//Turn of blink
				DigitDisplay_blinkOff();

				//Display the preset value on the display
				DigitDisplay_updateBuffer(app.mildstone1);


				//Store preset value in the EEPROM
				for(i = 0; i < NO_OF_DIGITS ; i++ )
				{
					Write_b_eep( EEPROM_MILDSTONE1_ADDRESS  + i ,app.mildstone1[i] );
					Busy_eep( );
				}

				app.mildstone1Value = (UINT16)(((app.mildstone1[3]- '0' )* 10 )+ ( app.mildstone1[2] - '0') )* 60 +(((app.mildstone1[1]- '0' )* 10 )+ (app.mildstone1[0] - '0'));
				app.state = HALT_STATE;	
				
			}
			if ((LinearKeyPad_getPBState(MILDSTONE2_PB) == KEY_PRESSED) && (app.mildstone2Flag == TRUE))
			{
				app.mildstone2Flag = FALSE;
				//Turn of blink
				DigitDisplay_blinkOff();

				//Display the preset value on the display
				DigitDisplay_updateBuffer(app.mildstone2);


				//Store preset value in the EEPROM
				for(i = 0; i < NO_OF_DIGITS ; i++ )
				{
					Write_b_eep( EEPROM_MILDSTONE2_ADDRESS  + i ,app.mildstone2[i] );
					Busy_eep( );
				}

				app.mildstone2Value = (UINT16)(((app.mildstone2[3]- '0' )* 10 )+ ( app.mildstone2[2] - '0') )* 60 +(((app.mildstone2[1]- '0' )* 10 )+ (app.mildstone2[0] - '0'));
				app.state = HALT_STATE;
				
			}


				
			break;
			
			case COUNT_STATE:

	
				if (LinearKeyPad_getPBState(HALT_PB) == KEY_PRESSED)
				{
					APP_resetDisplayBuffer();
					DigitDisplay_updateBufferPartial(app.displayBuffer , 0, 4);
					GREEN_LAMP = RESET;
					RED_LAMP = RESET;
	
					app.state = HALT_STATE;
					break;
				}


				app.currentTime = GetAppTime();

				if(app.currentTime < 6000)
				{
					APP_conversion();
					DigitDisplay_updateBufferPartial(app.displayBuffer , 0, 4); 
				
				}
				else
				{
					APP_resetDisplayBuffer();
					DigitDisplay_updateBufferPartial(app.displayBuffer , 0, 4);
					app.state = HALT_STATE;	
					break;					
				}

				if( (app.currentTime >= app.mildstone1Value ) && (app.currentTime < app.mildstone2Value) )
				{
					GREEN_LAMP = SET;
				}
				else if (app.currentTime >= app.mildstone2Value)
				{
					GREEN_LAMP = RESET;
					RED_LAMP = SET;					
				}

				break;			
		}
			
}		
Exemplo n.º 17
0
/*
*------------------------------------------------------------------------------
* void APP-task(void)
*------------------------------------------------------------------------------
*/
void APP_task(void)
{
	UINT8 i,*ptr, data;

	UINT32 addr;
	UINT8 resetBuzzer = TRUE;
	ias.curAppTime = GetAppTime();											//Fetches the application time from timer driver
	if(ias.preAppTime != ias.curAppTime)
	{
		ias.preAppTime = ias.curAppTime;
		for(i = 0; i <MAX_ISSUES; i++)										//check for timeout of issues raised
		{
			if(ias.issues[i].state == ISSUE_RAISED )
			{
				ias.issues[i].timeout -= 1;

			

				ptr = (UINT8*)&ias.issues[i].timeout;

				data = *ptr;

				addr = (i*ISSUE_ENTRY_SIZE)+ISSUE_TIMEOUT;
				Write_b_eep((i*ISSUE_ENTRY_SIZE)+ISSUE_TIMEOUT, *ptr);
				Busy_eep();
				ClrWdt();

				data=*(ptr+1);
				addr = (i*ISSUE_ENTRY_SIZE)+ISSUE_TIMEOUT+1;
				Write_b_eep((i*ISSUE_ENTRY_SIZE)+ISSUE_TIMEOUT+1, *(ptr+1));
				Busy_eep();
				ClrWdt();

			}
		}

	for(i = 1; i <= 4 ; i++)
	{
		switch(i)
		{
			case 1:
				if(ias.department_raised[i] > 0 )
					LAMP_GREEN = 1;
				else
					LAMP_GREEN = 0;	
			break;
			case 2:
				if(ias.department_raised[i] > 0 )
					LAMP_YELLOW = 1;
				else
					LAMP_YELLOW = 0;
			break;
			case 3:
				if(ias.department_raised[i] > 0 )
					LAMP_RED = 1;
				else
					LAMP_RED = 0;
			break;
			case 4:
				if ((ias.department_raised[i] > 0 ) || (ias.department_raised[i+1]  > 0 ) || (ias.department_raised[i+2]  > 0 ) )
					LAMP_BLUE = 1;
				else
					LAMP_BLUE = 0;
			break;
			default:
			break;
		}

	}

	}

}
Exemplo n.º 18
0
void APP_task( void )
{
	UINT8 i;


		switch(app.state)
		{
			case HALT_STATE:
			
			//Check the keypress Status of COUNT_PB 
			if ((LinearKeyPad_getKeyState(COUNT_PB) == TRUE) && (app.countFlag == FALSE))
			{
				app.countFlag = TRUE;
				//Reset buffer and RTC
				APP_resetDisplayBuffer();
				DigitDisplay_updateBufferPartial(app.displayBuffer , 0, 4);
				APP_updateRTC();

				//Turn off hooter
				HOOTER = RESET;
				app.hooter_reset = FALSE;
				/*
				//Store the state
				Write_b_eep( EEPROM_STATE_ADDRESS , COUNT_STATE);
				Busy_eep( );
				//ON DOT_CONTROL leds
				CLOCK_LED = 1;
				//Change the state to STOP state
				app.state = COUNT_STATE;
				*/
				
			}
			else if ((LinearKeyPad_getKeyState(COUNT_PB) == FALSE) && (app.countFlag == TRUE))
			{
				app.countFlag = FALSE;	
				//Store the state
				Write_b_eep( EEPROM_STATE_ADDRESS , COUNT_STATE);
				Busy_eep( );
				//ON DOT_CONTROL leds
				CLOCK_LED = 1;
				//Change the state to STOP state
				app.state = COUNT_STATE;
			
			}
			//Check the keypress Status of MODE_CHANGE_PB
			else if (LinearKeyPad_getKeyState(MODE_CHANGE_PB) == TRUE)
			{
				//Reset Target buffer which is used to hold preset data
				APP_resetPresetBuffer();

				//Blink first digit in the display
				app.blinkIndex = 0;
				DigitDisplay_updateBuffer(app.presetBuffer);
				DigitDisplay_blinkOn_ind(500, app.blinkIndex);


				//Change state to setting state
				app.state = SETTING_STATE;
			
			}

			//Check the keypress Status of HOOTER_OFF_PB 
			else if((LinearKeyPad_getKeyState(HOOTER_OFF_PB) == TRUE) && (app.hooter_reset == TRUE))
				{
					HOOTER = RESET;
					Write_b_eep( EEPROM_HOOTER_ADDRESS, HOOTER);
					Busy_eep( );
					app.state = HALT_STATE;	
				}

			
			break;

			case SETTING_STATE:
			
				//ON DOT_CONTROL leds
			CLOCK_LED = ~CLOCK_LED;
			// Code to handle Digit index PB
			if (LinearKeyPad_getKeyState(DIGIT_INDEX_PB ) == TRUE) 
			{
				app.blinkIndex++;

				if(app.blinkIndex > (NO_OF_DIGITS -  1))
					app.blinkIndex = 0 ;

				DigitDisplay_blinkOn_ind(500, app.blinkIndex);

			}

			// Code to handle increment PB
			if (LinearKeyPad_getKeyState(INCREMENT_PB) == 1) 
			{
				app.presetBuffer[app.blinkIndex]++;
				if(app.presetBuffer[app.blinkIndex] > max[app.blinkIndex])
					app.presetBuffer[app.blinkIndex] = '0';			
						
				DigitDisplay_updateBuffer(app.presetBuffer);

			}
			
			if (LinearKeyPad_getKeyState(MODE_CHANGE_PB) == TRUE)
			{
				//Turn of blink
				DigitDisplay_blinkOff();

				//Display the preset value on the display
				DigitDisplay_updateBuffer(app.presetBuffer);


				//Store preset value in the EEPROM
				for(i = 0; i < NO_OF_DIGITS ; i++ )
				{
					Write_b_eep( EEPROM_PRESET_ADDRESS + i ,app.presetBuffer[i] );
					Busy_eep( );
				}

				app.presetValue = (UINT16)(((app.presetBuffer[3]- '0' )* 10 )+ ( app.presetBuffer[2] - '0') )* 60 +(((app.presetBuffer[1]- '0' )* 10 )+ (app.presetBuffer[0] - '0'));
				
				//Store state in the EEPROM
				Write_b_eep( EEPROM_STATE_ADDRESS , HALT_STATE);
				Busy_eep( );
				//Switch state
				CLOCK_LED = 1;
				app.state = HALT_STATE;	
				
			}

				
			break;
			
			case COUNT_STATE:

				app.hooter_set = FALSE;
	
				// On halt PB press change the state into HALT
			if ((LinearKeyPad_getKeyState(HALT_PB) == TRUE) && (app.countFlag == FALSE))
				{
					app.countFlag = TRUE;
				}

			if ((LinearKeyPad_getKeyState(HALT_PB) == FALSE) && (app.countFlag == TRUE))
				{
					app.countFlag = FALSE;				
					Write_b_eep( EEPROM_STATE_ADDRESS ,HALT_STATE);
					Busy_eep( );
	
					app.state = HALT_STATE;
					break;
				}

				// On hooter_off PB press change hooter state by checking condition
/*
				if((LinearKeyPad_getKeyState(HOOTER_OFF_PB) == TRUE) && (app.hooter_reset == TRUE))
				{
					HOOTER = RESET;
					Write_b_eep( EEPROM_HOOTER_ADDRESS, HOOTER);
					Busy_eep( );
				}
*/

				//Read RTC data and store it in buffer
				ReadRtcTimeAndDate(readTimeDateBuffer);  

				//Convert RTC data in to ASCII
				// Separate the higher and lower nibble and store it into the display buffer 
				APP_conversion(); 

				//Store the current RTC data into EEPROM

				for(i = 0 ; i < 6  ; i++)
				{
					if( app.displayBuffer[i] !=	app.prevDisplayBuffer[i] )
					{
						Write_b_eep( (EEPROM_RTC_ADDRESS + i) , app.displayBuffer[i]);
						Busy_eep( );
					}
				}

				//manipulate the MSB_min to display upto 99m:59s 
				if(readTimeDateBuffer[2] > 0)
				{
					app.displayBuffer[3] += '6';
				}
				else 
				{
					app.displayBuffer[3] +=  '0';
				}
				//calculate and store the rtc value in the form of SEC
				app.rtcValue = (UINT16)(((	app.displayBuffer[3]- '0' )* 10 )+ ( app.displayBuffer[2] - '0') )* 60 +((( app.displayBuffer[1]- '0' )* 10 )+ ( app.displayBuffer[0] - '0'));
			
				//check rtcValue and presetValue for turn ON hooter_set
				if((app.hooter_reset == FALSE) && ( app.rtcValue >= app.presetValue ) )
				{
					app.hooter_set = TRUE;

				}

				//check hooter_set for change the HOOTER STATE
				if( app.hooter_set == TRUE) 
				{
					HOOTER = SET;
					app.hooter_reset = TRUE;
					Write_b_eep( EEPROM_HOOTER_ADDRESS, HOOTER);
					Busy_eep( );
					Write_b_eep( (EEPROM_HOOTER_ADDRESS + 1) , app.hooter_reset);
					Busy_eep( );

				}

				//Update digit display buffer with the current data of RTC
				DigitDisplay_updateBufferPartial(app.displayBuffer , 0, 4);

				if(readTimeDateBuffer[2] > 0)
				{
					app.displayBuffer[3] -= '6';
				}
				else 
				{
					app.displayBuffer[3] -=  '0';
				}

				for(	i = 0 ;	i < 6 ;	i++)
				{
					app.prevDisplayBuffer[i] = app.displayBuffer[i];
				}

				if(((readTimeDateBuffer[2] == 0x01) && (readTimeDateBuffer[1] == 0X39) &&
					(readTimeDateBuffer[0] == 0X59)) || (app.hooter_set == TRUE) )
				{
			
					//Change the state
					Write_b_eep( EEPROM_STATE_ADDRESS , HALT_STATE);
					Busy_eep( );
			
					app.state = HALT_STATE;	

					return;
				}

#if defined (RTC_DATA_ON_UART)
				for(i = 0; i < 7; i++)			
				{
					txBuffer[i] = readTimeDateBuffer[i];  //store time and date 
				}
				
				COM_txBuffer(txBuffer, 7);
#endif	

				break;			
		}
			
}		
Exemplo n.º 19
0
void resolveIssue(far UINT8* data)
{
	UINT8 i,j,issueIndex;
	UINT8 *ptr;
	if( data[2] == '0')
	{
		updateLog(data);
		return;
	}



	for(i = 0; i < MAX_ISSUES; i++)										//for each issue
		if(ias.issues[i].state != ISSUE_RESOLVED )						//if it is raised
			if(strcmp((INT8*)data,(INT8 *)ias.issues[i].data) == 0)		//if input matches
				if(ias.issues[i].ackStatus == 1) 						//check whether acknowledged
					return;												//if not return


	switch(ias.state)
	{
	

		case ISSUE_RAISED:

		for(i = 0; i< MAX_ISSUES ; i++)
		{
			issueIndex = issueResolved(data);
			if(  issueIndex != -1)
			{
				//updateLog(data);
				memset(ias.issues[issueIndex].data , 0 , MAX_KEYPAD_ENTRIES + 1);
							
				ClrWdt();
				
				ptr = (UINT8*)&ias.issues[issueIndex];
				for( j = 0; j < ISSUE_ENTRY_SIZE; j++)
				{
					Write_b_eep(j+(issueIndex*ISSUE_ENTRY_SIZE),*(ptr+j));
					Busy_eep();
					
					ClrWdt();
				}
				
				
				if(ias.issues_raised == 0)
				{
					ias.state = ISSUE_RESOLVED;
	
					updateIndication(1,0,0,0);
				}
				return;
			}
		}

		
	


		break;

		case ISSUE_CRITICAL:

		for(i = 0; i< MAX_ISSUES ; i++)
		{
			issueIndex = issueResolved(data);
			if(  issueIndex != -1)
			{
				//updateLog(data);
				memset(ias.issues[issueIndex].data , 0 , MAX_KEYPAD_ENTRIES + 1);
							
				ClrWdt();
				
				ptr = (UINT8*)&ias.issues[issueIndex];
				for( j = 0; j < ISSUE_ENTRY_SIZE; j++)
				{
					Write_b_eep(j+(issueIndex*ISSUE_ENTRY_SIZE),*(ptr+j));
					Busy_eep();
					
					ClrWdt();
				}
				
				
				if(ias.issues_critical == 0)
				{
				   	if(ias.issues_raised == 0)
					{
						ias.state = ISSUE_RESOLVED;
						updateIndication(1,0,0,0);
					}
					else
					{
						ias.state = ISSUE_RAISED;
						updateIndication(0,1,0,0);
					}
				}
				else
				
				{
                    if(ias.issues_raised == 0)
					{
					//	ias.state = ISSUE_RESOLVED;
						updateIndication(0,0,1,0);
					}
					else
					{
						//ias.state = ISSUE_RAISED;
						updateIndication(0,1,1,0);
					}
				
     			}                            
				return;
			}
		}

		break;

		default:
		break;

	}

}
Exemplo n.º 20
0
void IAS_init(void)
{

	UINT16 i;
	UINT8 j,*ptr;
	UINT8 ackStatus = 0;
	UINT8 grn =0 ,org = 0,red = 0,buz = 0; 

#ifdef __FACTORY_CONFIGURATION__

	ias.state = ISSUE_RESOLVED;
	ias.issues_raised = 0;														//No. of raised issues should be 0 initially
	ias.issues_critical = 0;													//No. of critical issues should be 0 initially
	ias.preAppTime = 0;
	ias.curAppTime = 0;
	log.index = 0;
	ias.logonStatus = 0;
	updateIndication(1,0,0,0);
	for(i = 0; i < 256; i++)
	{
		Write_b_eep(i,0);
		Busy_eep();
		ClrWdt();

	}

#else

	ias.preAppTime = 0;
	ias.curAppTime = 0;
	log.index = 0;

	for( i = 0; i < MAX_ISSUES; i++)
	{
		ptr = (UINT8*) &ias.issues[i];
		for( j = 0 ; j < ISSUE_ENTRY_SIZE; j++)
		{
			Busy_eep();
			ClrWdt();
			*(ptr+j) = Read_b_eep((i*ISSUE_ENTRY_SIZE)+j );

			Busy_eep();
			ClrWdt();

		}

		if( ias.issues[i].state == ISSUE_RAISED)
			ias.issues_raised++;
		if(ias.issues[i].state == ISSUE_CRITICAL)
			ias.issues_critical++;
		if(ias.issues[i].ackStatus == 1)
			ackStatus = 1;
	}

	if( ias.issues_critical > 0 )
		red = 1;
	else if( ias.issues_raised > 0 )
		org = 1;
	else grn = 1;
	
	if( ackStatus == 1 )
		buz = 1;


	ias.buzzerTimeout = 6;
	Busy_eep();
	ClrWdt();

	updateIndication(0,0,0,0);
	
	
	login();
	ias.logonStatus = 1;
	
	updateIndication(grn,org,red,buz);

#endif

COM_init(CMD_SOP , CMD_EOP ,RESP_SOP , RESP_EOP , APP_comCallBack);



}