예제 #1
0
static void ECG_ProbeDetect(void)
{
    static u32 u32NextChangeTime = 0;
    
    if(IsOnTime(u32NextChangeTime))
    {
        g_u8ecg_status = 0xFF;//defalut is alarm
        if (Is_ecgPorbe_narmal(pECGResult->RA_OFF_Val))
        {
            RESETBIT(g_u8ecg_status, RA_OFF);
        }
        else
        {
            ECG_DBG_INFO("RA_OFF");
        }
        
        if (Is_ecgPorbe_narmal(pECGResult->LA_OFF_Val))
        {
            RESETBIT(g_u8ecg_status, LA_OFF);
        }
        else
        {
            ECG_DBG_INFO("LA_OFF");
        }
        
        if (Is_ecgPorbe_narmal(pECGResult->LL_OFF_Val))
        {
            RESETBIT(g_u8ecg_status, LL_OFF);
        }
        else
        {
            ECG_DBG_INFO("LL_OFF");
        }
        
        if (Is_ecgPorbe_narmal(pECGResult->V1_OFF_Val))
        {
            RESETBIT(g_u8ecg_status, V1_OFF);
        }
        else
        {
            ECG_DBG_INFO("V1_OFF");
        }
        
        if (Is_ecgPorbeRL_narmal(pECGResult->RL_OFF_Val))
        {
            RESETBIT(g_u8ecg_status, RL_OFF);
        }
        else
        {
            ECG_DBG_INFO("RL_OFF");
        }
        
        //pECGResult->ECG1_OVERLOAD_Val;
        //pECGResult->ECG2_OVERLOAD_Val;
        //pECGResult->ECGV_OVERLOAD_Val;
        //SETBIT(g_u8ecg_status, RA_OFF);
        u32NextChangeTime += getNextTimeByMS(ECG_PROBE_PERIOD);
    }
}
예제 #2
0
void main()
{
	int p,q,n=10,bit,i;
	printf("Enter the position P&Q:");
	scanf("%d%d",&p,&q);
	getchar();
	bit=sizeof(n)*8;
	for(i=0;i<bit;i++)
	{	
		if((p<=i)&&(i<=q))
			SETBIT(n,i);
		else
			RESETBIT(n,i);
	}
	printf("Bit repersentaion: ");
	PrintBit(n,bit);		
}
예제 #3
0
/* ======================================================================== */
IMaze *OriginalMazeFactory::MakeMaze(int width, int height, int depth)
{
	int		ok_to_continue;  /*  flag set to one when maze is completed */
	int		count = 0;
	char	Mask;	/*  status variable:  see above for description.    */
	location	p = { 1, 1, 1 };
	
	Array3D		maze = NULL;
	location	size = { width, height, depth };
	location	in   = { width/2+1, height/2+1, 1 };
	location	out  = { width, height, depth+1 };
//	location	out  = { width/2+1, height/2+1, depth+2 };

	//time_t now;	/*  used with "time" to randomize seed for "rand"  */
	//time(&now);
	srand(time(0) % 0xFFFF );
	
	AllocateMaze( &maze, size );

	OriginalMaze *originalMaze = new OriginalMaze;
	originalMaze->SetMaze(maze);
	originalMaze->SetSize(size);
	originalMaze->SetEntrance(in);
	originalMaze->SetExit(out);


	/* -------------- */
	/* Now trace maze */
	/* -------------- */
	SETBIT( maze[1][1][1], USEDBIT );
	++count;
	SETBIT( maze[1][1][1], RIGHTBIT  );
	SETBIT( maze[1][1][1], BOTTOMBIT );
	SETBIT( maze[1][1][1], FRONTBIT  );
	SETBIT( maze[0][1][1], RIGHTBIT  );
	SETBIT( maze[1][0][1], BOTTOMBIT );
	SETBIT( maze[1][1][0], FRONTBIT  );


	ok_to_continue = 1;

	while (ok_to_continue)
	{
		Mask = 63;  /*  111111  */
		if ( p.w==1		 || GETBIT(maze[p.w-1][ p.h ][ p.d ],USEDBIT) )	Mask -=  1;
		if ( p.h==1		 || GETBIT(maze[ p.w ][p.h-1][ p.d ],USEDBIT) )	Mask -=  2;
		if ( p.d==1		 || GETBIT(maze[ p.w ][ p.h ][p.d-1],USEDBIT) )	Mask -=  4;
		if ( p.w==size.w || GETBIT(maze[p.w+1][ p.h ][ p.d ],USEDBIT) )	Mask -=  8;
		if ( p.h==size.h || GETBIT(maze[ p.w ][p.h+1][ p.d ],USEDBIT) )	Mask -= 16;
		if ( p.d==size.d || GETBIT(maze[ p.w ][ p.h ][p.d+1],USEDBIT) )	Mask -= 32;

		if ( Mask )
			ok_to_continue = Move( Mask, maze, size, &p, &count );
		else
			Relocate( maze, size, &p );
	}

	if ( in.d == 0 )
		RESETBIT( maze[in.w][in.h][0], FRONTBIT );
	else if ( in.d == size.d+1 )
		RESETBIT( maze[in.w][in.h][size.d], FRONTBIT );
	else if ( in.w == 0 )
		RESETBIT( maze[0][in.h][in.d], RIGHTBIT );
	else if ( in.w == size.w+1 )
		RESETBIT( maze[size.w][in.h][in.d], RIGHTBIT );
	else if ( in.h == 0 )
		RESETBIT( maze[in.w][0][in.d], BOTTOMBIT );
	else if ( in.h == size.h+1 )
		RESETBIT( maze[in.w][size.h][in.d], BOTTOMBIT );

	if ( out.d == 0 )
		RESETBIT( maze[out.w][out.h][0], FRONTBIT );
	else if ( out.d == size.d+1 )
		RESETBIT( maze[out.w][out.h][size.d], FRONTBIT );
	else if ( out.w == 0 )
		RESETBIT( maze[0][out.h][out.d], RIGHTBIT );
	else if ( out.w == size.w+1 )
		RESETBIT( maze[size.w][out.h][out.d], RIGHTBIT );
	else if ( out.h == 0 )
		RESETBIT( maze[out.w][0][out.d], BOTTOMBIT );
	else if ( out.h == size.h+1 )
		RESETBIT( maze[out.w][size.h][out.d], BOTTOMBIT );

	originalMaze->BuildWalls();

	return originalMaze;
}
예제 #4
0
/* ======================================================================== */
int OriginalMazeFactory::Move(char mask, Array3D maze, location size, location *p, int *count)
{
	int q;		/*  q:  choice of direction of motion
			    (see above for bit/direction relationship)      */


	for ( q=0; q==0; q = ( 1 << (rand()%6) ) & mask );

	switch (q)
	{
		case 1:		/*  move LEFT  */
			++*count;
			--p->w;
			SETBIT(maze[p->w][p->h][p->d],USEDBIT);
			/* turn off right wall in new cell.  */
		  RESETBIT( maze[ p->w ][ p->h ][ p->d ], RIGHTBIT  );
			SETBIT( maze[ p->w ][ p->h ][ p->d ], BOTTOMBIT );
			SETBIT( maze[ p->w ][ p->h ][ p->d ], FRONTBIT  );
			SETBIT( maze[p->w-1][ p->h ][ p->d ], RIGHTBIT  );
			SETBIT( maze[ p->w ][p->h-1][ p->d ], BOTTOMBIT );
			SETBIT( maze[ p->w ][ p->h ][p->d-1], FRONTBIT  );
			break;

		case 2:		/*  move UP  */
			++*count;
			--p->h;
			SETBIT( maze[p->w][p->h][p->d], USEDBIT );
			/* turn off bottom wall in new cell.  */
			SETBIT( maze[ p->w ][ p->h ][ p->d ], RIGHTBIT  );
		  RESETBIT( maze[ p->w ][ p->h ][ p->d ], BOTTOMBIT );
			SETBIT( maze[ p->w ][ p->h ][ p->d ], FRONTBIT  );
			SETBIT( maze[p->w-1][ p->h ][ p->d ], RIGHTBIT  );
			SETBIT( maze[ p->w ][p->h-1][ p->d ], BOTTOMBIT );
			SETBIT( maze[ p->w ][ p->h ][p->d-1], FRONTBIT  );
			break;

		case 4:		/*  move BACK  */
			++*count;
			--p->d;
			SETBIT( maze[p->w][p->h][p->d], USEDBIT );
			/* turn off front wall in new cell.  */
			SETBIT( maze[ p->w ][ p->h ][ p->d ], RIGHTBIT  );
			SETBIT( maze[ p->w ][ p->h ][ p->d ], BOTTOMBIT );
		  RESETBIT( maze[ p->w ][ p->h ][ p->d ], FRONTBIT  );
			SETBIT( maze[p->w-1][ p->h ][ p->d ], RIGHTBIT  );
			SETBIT( maze[ p->w ][p->h-1][ p->d ], BOTTOMBIT );
			SETBIT( maze[ p->w ][ p->h ][p->d-1], FRONTBIT  );
			break;

		case 8:		/*  move RIGHT  */
			++*count;
			++p->w;
			SETBIT( maze[p->w][p->h][p->d], USEDBIT );
			/* turn off right wall in last cell.  */
			SETBIT( maze[ p->w ][ p->h ][ p->d ], RIGHTBIT  );
			SETBIT( maze[ p->w ][ p->h ][ p->d ], BOTTOMBIT );
			SETBIT( maze[ p->w ][ p->h ][ p->d ], FRONTBIT  );
		  RESETBIT( maze[p->w-1][ p->h ][ p->d ], RIGHTBIT  );
			SETBIT( maze[ p->w ][p->h-1][ p->d ], BOTTOMBIT );
			SETBIT( maze[ p->w ][ p->h ][p->d-1], FRONTBIT  );
			break;

		case 16:	/*  move DOWN  */
			++*count;
			++p->h;
			SETBIT( maze[p->w][p->h][p->d], USEDBIT );
			/* turn off bottom wall in last cell.*/
			SETBIT( maze[ p->w ][ p->h ][ p->d ], RIGHTBIT  );
			SETBIT( maze[ p->w ][ p->h ][ p->d ], BOTTOMBIT );
			SETBIT( maze[ p->w ][ p->h ][ p->d ], FRONTBIT  );
			SETBIT( maze[p->w-1][ p->h ][ p->d ], RIGHTBIT  );
		  RESETBIT( maze[ p->w ][p->h-1][ p->d ], BOTTOMBIT );
			SETBIT( maze[ p->w ][ p->h ][p->d-1], FRONTBIT  );
			break;

		case 32:	/*  move FRONT  */
			++*count;
			++p->d;
			SETBIT( maze[p->w][p->h][p->d], USEDBIT );
			/* turn off front wall in last cell.*/
			SETBIT( maze[ p->w ][ p->h ][ p->d ], RIGHTBIT  );
			SETBIT( maze[ p->w ][ p->h ][ p->d ], BOTTOMBIT );
			SETBIT( maze[ p->w ][ p->h ][ p->d ], FRONTBIT  );
			SETBIT( maze[p->w-1][ p->h ][ p->d ], RIGHTBIT  );
			SETBIT( maze[ p->w ][p->h-1][ p->d ], BOTTOMBIT );
		  RESETBIT( maze[ p->w ][ p->h ][p->d-1], FRONTBIT  );
			break;
	}

	return( *count < size.w * size.h * size.d );
}