Exemple #1
0
static INT32 internal_check(TIMER_SET_CONTENT *timer, TIMER_SET_CONTENT *timer_existed)
{
	INT32 ret;
	date_time dt,dt2;
	TIMER_SET_CONTENT *timer1,*timer2;

	MEMSET(&dt, 0, sizeof(date_time));
	MEMSET(&dt2, 0, sizeof(date_time));

	dt.year = timer->wakeup_year;
	dt.month = timer->wakeup_month;
	dt.day = timer->wakeup_day;
	dt.hour = timer->wakeup_time/60;
	dt.min = timer->wakeup_time%60;

    	dt2.year = timer_existed->wakeup_year;
    	dt2.month = timer_existed->wakeup_month;
    	dt2.day = timer_existed->wakeup_day;
    	dt2.hour = timer_existed->wakeup_time/60;
    	dt2.min = timer_existed->wakeup_time%60;
		
	ret = api_compare_day_time(&dt,&dt2);
	if(ret == 0)
            return 0;
	ret = api_compare_timer(timer, timer_existed);

	if(ret <=0) return 0;

	// timer1: [a,b]; timer2: [c,d]; b<c
	if(ret == 1) 
	{
		timer1 = timer;
		timer2 = timer_existed;
	}
	else
	{
		timer1 = timer_existed;
		timer2 = timer;
	}
	
	if(api_check_timer(timer1,timer2)==0)
		return 0;	

	return ret;
}
Exemple #2
0
/*************************************
function: IsValidTimer
parameter: 
return:
	0	- valid
	1-MAX_TIMER_NUM   	- conflict timer idx
**************************************/
INT32 IsValidTimer(TIMER_SET_CONTENT *timer)
{
	INT32 ret,i;
	SYSTEM_DATA *sys_data;
	TIMER_SET_CONTENT *timer1,*timer2;
	date_time time1,time2;
	INT32 time_span =0;

	if(timer->timer_mode == TIMER_MODE_OFF)
		return 0;

	sys_data = sys_data_get();
	
	for(i=0; i<MAX_TIMER_NUM; i++)
	{
		//if(i == sys_data->timer_set.timer_num-1) continue;

		if(sys_data->timer_set.TimerContent[i].timer_mode == TIMER_MODE_OFF) continue;

		switch(timer->timer_mode)
		{
			case TIMER_MODE_WEEKLY:
				switch(sys_data->timer_set.TimerContent[i].timer_mode)
				{
					case TIMER_MODE_MONTHLY:
					case TIMER_MODE_YEARLY:
						break;
					default:
						goto CHECKTIMER;
				}
				break;
			case TIMER_MODE_MONTHLY:
			case TIMER_MODE_YEARLY:
				switch(sys_data->timer_set.TimerContent[i].timer_mode)
				{
					case TIMER_MODE_WEEKLY:
						break;
					default:
						goto CHECKTIMER;
				}
				break;
			default:
CHECKTIMER:
#if 0	// check duration	
				ret = api_compare_timer(timer,&sys_data->timer_set.TimerContent[i]);

				if(ret <=0) return (i+1);

				// timer1: [a,b]; timer2: [c,d]; b<c
				if(ret == 1) 
				{
					timer1 = timer;
					timer2 = &sys_data->timer_set.TimerContent[i];
				}
				else
				{
					timer1 = &sys_data->timer_set.TimerContent[i];
					timer2 = timer;
				}
				
				if(api_check_timer(timer1,timer2)==0)
					return (i+1);
#else 	// only check start time
				timer1 = timer;
				timer2 = &sys_data->timer_set.TimerContent[i];
				
				MEMSET(&time1, 0, sizeof(date_time));
				MEMSET(&time2, 0, sizeof(date_time));

				time1.year  = timer1->wakeup_year;
				time1.month = timer1->wakeup_month;
				time1.day = timer1->wakeup_day;
				time1.hour = timer1->wakeup_time/3600;
				time1.min = timer1->wakeup_time/60%60;
				time1.sec = timer1->wakeup_time%60;

				time2.year  = timer2->wakeup_year;
				time2.month = timer2->wakeup_month;
				time2.day = timer2->wakeup_day;
				time2.hour = timer2->wakeup_time/3600;
				time2.min = timer2->wakeup_time/60%60;
				time2.sec = timer2->wakeup_time%60;

				/* two start time can not in one min */
				api_get_time_len(&time1,&time2,&time_span);
				if(time_span<0)
					time_span = -time_span;
				if(time_span <= 60)	return (i+1);
#endif
				break;
		}
		
		
	}
	
	return 0;
}