public static void main(String[] args) {

		int ipar=0;
		boolean showbox= true;
		int mode=1;
		
		if(args.length > 0){

			try{
				mode			= Integer.parseInt(args[ipar++]); 	
				showbox			= Boolean.parseBoolean(args[ipar++]);
				PIDREG   				= args[ipar++]; 				
				
				if(mode==0){//MODO 0- exit only 
					handleAnotherProcessRunging();
					System.exit(0);
				}
				
				INPUTDATA 				= args[ipar++];
				OUTPUTDATA				= args[ipar++]; 
				APPLOG	    			= args[ipar++]; 

		

				
				switch(Integer.parseInt(args[ipar++])){
					case 1:	LoggerThread.NEW_LINE ="\n"; break;
					case 2: LoggerThread.NEW_LINE ="\r\n"; break;
					default:LoggerThread.NEW_LINE ="\n"; break;						
				}
				
				BusScanThread.proxy 	= Boolean.parseBoolean(args[ipar++]); 
				BusScanThread.proxyhost	= args[ipar++]; 
				BusScanThread.proxyport	= Integer.parseInt(args[ipar++]); 		
				
				BusScanThread.RETRIES        = Integer.parseInt(args[ipar++]);  //retries para get infos do setups
				BusScanThread.RETRIES_GETPOS = Integer.parseInt(args[ipar++]); // retries para get pos antes de acusar possivel inexistencia da linha
				BusScanThread.TIMEOUT        = Integer.parseInt(args[ipar++]);
				BusScanThread.HORA_START     = Integer.parseInt(args[ipar++]);
				BusScanThread.TCP_TIMEOUT    = Integer.parseInt(args[ipar++]);
				
			} catch (Throwable e){
				JOptionPane.showMessageDialog(null,"ERRO PARAMETRO ENTRADA : " + ipar + " size= " + args.length,"SCAN BUS", JOptionPane.ERROR_MESSAGE);
				System.exit(0);
			}
		}else{//Default
			
			
		}
		
		/*
		INPUTDATA  = "in.txt";
		OUTPUTDATA = "out.txt";
		APPLOG     = "error.txt";
		PIDREG     = "pid.txt";
		
		

		LoggerThread.NEW_LINE   = "\n"; //"\r\n";

		//proxy
		BusScanThread.proxy     = false;
		BusScanThread.proxyhost = "localhost";
		BusScanThread.proxyport = 8080;
		
		//
		BusScanThread.RETRIES        = 20; //retries para get infos do setups
		BusScanThread.RETRIES_GETPOS = 200; // retries para get pos antes de acusar possivel inexistencia da linha
		BusScanThread.TIMEOUT        = 30000;
		BusScanThread.HORA_START     = 5;
		BusScanThread.TCP_TIMEOUT = 10000;
		*/
		
		Center center = new Center();
		center.logError("Inicio SCAN BUS "+ VERSION + " ("+ (new File(".").getAbsolutePath()) + " " + ManagementFactory.getRuntimeMXBean().getName());
		handleAnotherProcessRunging();
		
		//--> Processo para Shutdown
		ShutdownInterceptor shutdownint = new ShutdownInterceptor(center);
		Runtime.getRuntime().addShutdownHook(shutdownint);
		//<--
		
		
		Vector<String> initdata = readFile(INPUTDATA);
		if(initdata.size()<=0){
			System.err.println("initdata com tamanho zero.");
			center.logError("erro : initdata com tamanho zero.");
			
			JOptionPane.showMessageDialog(null,"SEM ARQUIVO OU DADOS EM " + INPUTDATA + "\n" + (new File(".").getAbsolutePath()),"SCAN BUS " + VERSION , JOptionPane.ERROR_MESSAGE);
			
			System.exit(0);
		}
		
		
		try {
			center.logger = LoggerThread.getLogger(OUTPUTDATA,center);
		} catch (Throwable e) {
			System.err.println("Erro ao iniciar log.");
			center.logError("erro ao iniciar log.");
			System.exit(0);
		}
		
		Iterator<String> it = initdata.iterator();
		String lines="";
		while(it.hasNext()){
			String line = it.next();
			lines=lines+ line + ";";
			new BusScanThread(line, center);
		}
		
		center.logError("Linhas a iniciar : " + lines);
		
		if(showbox)
			JOptionPane.showMessageDialog(null,
					ManagementFactory.getRuntimeMXBean().getName() + "\n" + 
					"HOME= " + (new File(".").getAbsolutePath()),"SCAN BUS " + VERSION 
					
					,JOptionPane.PLAIN_MESSAGE);
		
		
	}