示例#1
0
文件: signal.cpp 项目: TheDgtl/osrose
void HandleSignal( int num )
{
    switch(num)
    {
        case SIGINT:/* Interactive attention */        
            Log( MSG_ERROR, "Starting console..." );   
            GServer->startConsole( );
            // restart signals
            StopSignal( );
            StartSignal( );
        break;        
        case SIGILL:/* Illegal instruction */
            Log( MSG_ERROR, "Signal received: SIGILL, Server will be closed, Trying to save..." );                          
            GServer->isActive = false;       
    	    #ifdef _WIN32
                Sleep(1000);
    	    #else
    	    usleep(1000);
    	    #endif
            raise(num);          
        break;        
        case SIGFPE:/* Floating point error */
            Log( MSG_ERROR, "Signal received: SIGFPE, Server will be closed, Trying to save..." );                          
            GServer->isActive = false;               
            raise(num);                     
        break;        
        case SIGSEGV:/* Segmentation violation */
            Log( MSG_ERROR, "Signal received: SIGSEGV, Server will be closed, Trying to save..." );                          
            GServer->isActive = false;
    	    #ifdef _WIN32
                Sleep(1000);
    	    #else
    	    usleep(1000);
    	    #endif            
            raise(num);                     
        break;                       
                                              
        case SIGTERM:/* Termination request */
            Log( MSG_INFO, "Signal received: SIGTERM, Server will be closed" );
            GServer->isActive = false;
        break;   
    	#ifdef _WIN32
        case SIGBREAK:/* Control-break */
            Log( MSG_INFO, "Signal received: SIGBREAK, Server will be closed" );        
            GServer->isActive = false;            
        break;     
    	#endif          
        default:
            cout << "Unknown Signal Number: " << num << endl;
            raise(num);
    }
}
示例#2
0
文件: main.cpp 项目: osROSE/osrose
// Main server function
int main(int argc, char *argv[]) 
{
    srand( (unsigned)time(NULL) );
    srand( rand()*time(NULL) );         
    StartSignal( );
	LOG_THISSERVER = LOG_WORLD_SERVER;
    InitWinSocket( );
    string fileconf = "worldserver.conf";   
    if(argc>1)
    {
        fileconf = argv[1];
    }              
	CWorldServer *server = new (nothrow) CWorldServer( fileconf );
    if(server==NULL)
        return -1;
    pthread_attr_init(&server->at);
    pthread_attr_setdetachstate(&server->at, PTHREAD_CREATE_JOINABLE);   
    // Connect mysql
    MYSQL mysql;
	server->DB = new CDatabase( server->Config.SQLServer.pcServer,
	                    server->Config.SQLServer.pcUserName,
	                    server->Config.SQLServer.pcPassword,
	                    server->Config.SQLServer.pcDatabase,
	                    server->Config.SQLServer.pcPort, &mysql );
    server->port = server->Config.CharPort;     
	if(server->Config.usethreads)
	   Log( MSG_INFO, "Using Threads" );	
	// Start server
	server->port = server->Config.WorldPort;
	
	if(server->DB->Connect( )==0) Log( MSG_INFO, "Connected to MySQL server" ); 
	else
	{
        delete server;
        server = NULL;
        #ifdef _WIN32
		system("pause");
		#endif
		return -1;
	} 	
	server->StartServer();
	// Close server
    pthread_attr_destroy(&server->at);	
    server->DB->Disconnect( );
	CloseWinSocket( );
	StopSignal( );	
	Log(MSG_INFO, "Cleaning memory, please wait..." );
	delete server;         	
	server = NULL;
	return EXIT_SUCCESS;
}
示例#3
0
// Main function
int main(int argc, char *argv[])
{
    //LMA: deactivating signal tracker.
    StartSignal( );


	LOG_THISSERVER = LOG_CHARACTER_SERVER;
    InitWinSocket( );
    string fileconf = "charserver.conf";
    if(argc>1)
    {
        fileconf = argv[1];
    }
	CCharServer *server = new (nothrow) CCharServer( fileconf );
	if(server==NULL)
	   return -1;
    MYSQL mysql;
	server->DB = new CDatabase( server->Config.SQLServer.pcServer,
	                    server->Config.SQLServer.pcUserName,
	                    server->Config.SQLServer.pcPassword,
	                    server->Config.SQLServer.pcDatabase,
	                    server->Config.SQLServer.pcPort, &mysql );
    server->port = server->Config.CharPort;
	if(server->Config.usethreads)
	   Log( MSG_INFO, "Using Threads" );
	if(server->DB->Connect( )==0) Log( MSG_INFO, "Connected to MySQL server" );
    else
	{
        delete server;
        #ifdef _WIN32
		system("pause");
		#endif
		return -1;
	}
	// Start server
	server->StartServer();
	// Close server
    server->DB->Disconnect( );

    //LMA: deleting stuff.
    server->chatroom_list.clear();

	delete server;
	CloseWinSocket( );
	StopSignal( );
	return EXIT_SUCCESS;
}
示例#4
0
// Main server function
int main(int argc, char *argv[])
{
	//LMA: Opening log.
	LogHandleSp(1);
	LogDebugPriority(0,true);   //LMA: LogDebug won't appear in Logs or screen.

    srand( (unsigned)time(NULL) );
    srand( rand()*time(NULL) );

    //LMA: TEST DEACTIVATING ERROR TRAPPING
    //Uncomment following line to use "console" mode (control+C).
    //StartSignal( );

	LOG_THISSERVER = LOG_WORLD_SERVER;
    InitWinSocket( );
    string fileconf = "worldserver.conf";
    if(argc>1)
    {
        fileconf = argv[1];
    }
	CWorldServer *server = new (nothrow) CWorldServer( fileconf );
    if(server==NULL)
        return -1;
    pthread_attr_init(&server->at);
    pthread_attr_setdetachstate(&server->at, PTHREAD_CREATE_JOINABLE);
    // Connect mysql
    MYSQL mysql;
	server->DB = new CDatabase( server->Config.SQLServer.pcServer,
	                    server->Config.SQLServer.pcUserName,
	                    server->Config.SQLServer.pcPassword,
	                    server->Config.SQLServer.pcDatabase,
	                    server->Config.SQLServer.pcPort, &mysql );
    server->port = server->Config.CharPort;
	if(server->Config.usethreads)
	   Log( MSG_INFO, "Using Threads" );
	// Start server
	server->port = server->Config.WorldPort;

	if(server->DB->Connect( )==0) Log( MSG_INFO, "Connected to MySQL server" );
	else
	{
        delete server;
        server = NULL;
        #ifdef _WIN32
		system("pause");
		#endif
		return -1;
	}

	server->StartServer();
	// Close server
    pthread_attr_destroy(&server->at);
    server->DB->Disconnect( );
	CloseWinSocket( );
	StopSignal( );
	Log(MSG_INFO, "Cleaning memory, please wait..." );
	delete server;
	server = NULL;

	//LMA: closing log.
	LogHandleSp(0);

	return EXIT_SUCCESS;
}
/*********************************************
receive a SLAM data and begin to plan
Output:
*********************************************/
bool MINI_PLANNING::Planning()
{
	//first grab useful data
	//include SLAM data, Object data, 
	PosVector=PLANNINGDATA.grabDataRef(0, 1);    //get udp SLAM  only one
	LaserVector=PLANNINGDATA.grabDataRef(1, 1); 
	//get Pos data and objectdata
	DepackLaser();
	DepackPos();
	// get the recent gps data
	//at the same time make sure that there are data from laser

	if(Realbuf.size()&&NO_COLLISION.laserdata.size())
	{
		//emit VoiceSignal(0);
		//timer->stop();
		SLAM_DATA Pos_now=Realbuf.last();
		NO_COLLISION.Cord_Projection(Pos_now); //first project laser point
		double heading_x=cos(Pos_now.ang.z+PI/2);
		double heading_y=sin(Pos_now.ang.z+PI/2);
		trajec_state Real_Pos;
		Real_Pos.x=Pos_now.shv.x;
		Real_Pos.y=Pos_now.shv.y;
		Real_Pos.theta=Pos_now.ang.z+PI/2;
		Real_Pos.curvature=0;
		//now the Pos_now data become the real location 
		//of the back axle
		//find the coorespond point in the aim trajectory
		if(OFFLINE_Trajectory.size())
		{
			uint aim_num =	find_neibour_point(Pos_now);
			aim_point = aim_num;
			trajec_state Aim_Pos;
			Aim_Pos.x=OFFLINE_Trajectory.at(aim_num).x;
			Aim_Pos.y=OFFLINE_Trajectory.at(aim_num).y;
			Aim_Pos.theta=OFFLINE_Trajectory.at(aim_num).yaw;
			bool flag=Path_Generate.Path_saving(Real_Pos,Aim_Pos,0);
			//generate trajectory 0  if no collision ,use it
			if(flag)  //规划成功
			{//collision detect  
				NO_COLLISION.Collision_detection(&Path_Generate.traj_sets[0]);
				Path_Generate.traj_sets[0].dist_to_init_trajectory=0; //least dist
				
			}
			if(Path_Generate.traj_sets[0].feasible==false)
			{
				//timer->stop();
				// need to stop every time that there are collision
				emit StopSignal();
				
				//then begin to calculate or search.....
				//first try 6 trajectory
				if(waitcounter++>3)
				{
					waitcounter=0;
					timer->stop();
					emit StopSignal();
					if(TrajectorySetsGenerate(Real_Pos,Aim_Pos)==false)
					{	//not even one trajectory that satisfied
						//emit stop signal.
						//emit StopSignal();
						emit VoiceSignal(6);
						timer->start();
						return false;
					}
					else   //at last one in 6 can be used
					{
						emit VoiceSignal(1);
						FinalTrackingTrajectory(aim_num);
					}
					timer->start();
				}
			}
			//第一条可用  Path_Generate.traj_sets[0].feasible==true
			else
			{
				FinalTrackingTrajectory(aim_num);
				waitcounter=0;
			}
		}
	}

}
示例#6
0
文件: Signal.cpp 项目: karlseven/ROED
void HandleSignal( int num )
{
    switch(num)
    {
        case SIGINT:/* Interactive attention */
            Log( MSG_ERROR, "Starting console..." );
            if(!GServer->console_started)
            {
                GServer->console_started=true;
                GServer->startConsole( );
                // restart signals
                StopSignal( );
                StartSignal( );
            }
            else
            {
                //LMA: restart signals
                StopSignal( );
                StartSignal( );
            }
        break;
        case SIGILL:/* Illegal instruction */
            Log( MSG_ERROR, "Signal received: SIGILL, Server will be closed, Trying to save..." );
            GServer->DisconnectAll();
    	    #ifdef _WIN32
                Sleep(1000);
    	    #else
    	    usleep(1000);
    	    #endif
      	    delete GServer;
            raise(num);
        break;
        case SIGFPE:/* Floating point error */
            Log( MSG_ERROR, "Signal received: SIGFPE, Server will be closed, Trying to save..." );
            GServer->DisconnectAll();
            delete GServer;
            raise(num);
        break;
        case SIGSEGV:/* Segmentation violation */
            Log( MSG_ERROR, "Signal received: SIGSEGV, Server will be closed, Trying to save..." );
            GServer->DisconnectAll();
    	    #ifdef _WIN32
                Sleep(1000);
    	    #else
    	    usleep(1000);
    	    #endif
    	    delete GServer;
            raise(num);
        break;

        case SIGTERM:/* Termination request */
            Log( MSG_INFO, "Signal received: SIGTERM, Server will be closed" );
            pthread_create( &GServer->WorldThread[SHUTDOWN_THREAD], NULL, ShutdownServer, (PVOID)0);
        break;
    	#ifdef _WIN32
        case SIGBREAK:/* Control-break */
            Log( MSG_INFO, "Signal received: SIGBREAK, Server will be closed" );
            pthread_create( &GServer->WorldThread[SHUTDOWN_THREAD], NULL, ShutdownServer, (PVOID)0);
        break;
    	#endif
        default:
            cout << "Unknown Signal Number: " << num << endl;
            raise(num);
    }
}