MOOS 0.2375
|
00001 00002 // 00003 // MOOS - Mission Oriented Operating Suite 00004 // 00005 // A suit of Applications and Libraries for Mobile Robotics Research 00006 // Copyright (C) 2001-2005 Massachusetts Institute of Technology and 00007 // Oxford University. 00008 // 00009 // This software was written by Paul Newman at MIT 2001-2002 and Oxford 00010 // University 2003-2005. email: pnewman@robots.ox.ac.uk. 00011 // 00012 // This file is part of a MOOS Core Component. 00013 // 00014 // This program is free software; you can redistribute it and/or 00015 // modify it under the terms of the GNU General Public License as 00016 // published by the Free Software Foundation; either version 2 of the 00017 // License, or (at your option) any later version. 00018 // 00019 // This program is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00022 // General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with this program; if not, write to the Free Software 00026 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00027 // 02111-1307, USA. 00028 // 00030 00031 #include <MOOSLIB/MOOSLib.h> 00032 #include "MOOSLogger.h" 00033 00034 #include <signal.h> 00035 CMOOSLogger gLogger; 00036 00037 #ifdef _WIN32 00038 BOOL CatchMeBeforeDeath( DWORD fdwCtrlType ) 00039 #else 00040 void CatchMeBeforeDeath(int sig) 00041 #endif 00042 { 00043 00044 gLogger.ShutDown(); 00045 exit(0); 00046 00047 00048 } 00049 00050 00051 00052 00053 int main(int argc ,char * argv[]) 00054 { 00055 00056 00057 const char * sMissionFile = "Mission.moos"; 00058 const char * sMOOSName = "pLogger"; 00059 switch(argc) 00060 { 00061 case 3: 00062 sMOOSName = argv[2]; 00063 case 2: 00064 sMissionFile = argv[1]; 00065 } 00066 00067 00068 //set up some control handling 00069 #ifndef _WIN32 00070 //register a handler for shutdown 00071 signal(SIGINT, CatchMeBeforeDeath); 00072 signal( SIGQUIT, CatchMeBeforeDeath); 00073 signal( SIGTERM, CatchMeBeforeDeath); 00074 #else 00075 if( !SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CatchMeBeforeDeath, TRUE )) 00076 { 00077 MOOSTrace("this is bad"); 00078 } 00079 #endif 00080 00081 00082 //GO! 00083 gLogger.Run(sMOOSName,sMissionFile); 00084 00085 return 0; 00086 }