public static void main(String[] args) {

		if(args.length > 0){
			try{

				for(String arg : args){
					switch(arg){
					case ARG_NO_FPS:
						shouldPollFPS = false;
						break;
					case ARG_NO_UTIL:
						shouldPollUtil = false;
						break;
					case ARG_NO_FREQ:
						shouldPollFreq = false;
						break;
					case ARG_NO_POWER:
						shouldPollPower = false;
						break;
					case ARG_NO_CHART:
						shouldShowChart = false;
						break;
					case ARG_HELP:
						printToScreen(TEXT_HELP);
						return;
					default:
						if(arg.startsWith(ARG_EXT_POWER)){
							serialPortname = arg.replaceAll(ARG_EXT_POWER, "");
							shouldPollExtPower = true;
						} else {
							totalSamplesRequired = Long.parseLong(arg);
							if(totalSamplesRequired < 0){
								throw new NumberFormatException();
							}
						}
					}
				}

				printToScreen(TEXT_HELP_OFFER);
				
				if(!shouldPollPower){
					shouldPollExtPower = false;
				}
				if(!shouldPollFPS && !shouldPollFreq && !shouldPollPower && !shouldPollUtil && !shouldPollExtPower){
					printToScreen(String.format(TEXT_HELP_NO_POLL));
					return;
				}

				if(totalSamplesRequired >= 0){
					printToScreen(String.format(TEXT_SAMPLES_REQUIRED, totalSamplesRequired));
				} else {
					printToScreen(TEXT_INDEFINITE_SAMPLING);
				}

				printToScreen(String.format(TEXT_SAMPLE_TYPES, shouldPollFPS, shouldPollUtil, shouldPollFreq, shouldPollPower, shouldShowChart, shouldPollExtPower, serialPortname));

			} catch (NumberFormatException e){
				printToScreen(TEXT_HELP_INVALID_NUMBER);
				return;
			}

		} else {
			printToScreen(TEXT_HELP_OFFER);
			printToScreen(TEXT_INDEFINITE_SAMPLING);
		}

		printToScreen("");

		fpsData = new ArrayList<Integer>();

		if(shouldPollExtPower && shouldPollPower){
			boolean serialPortStartStatus = ExternalPowerRetrieval.startSystemPowerRetrieval(serialPortname);

			if(!serialPortStartStatus){
				shouldPollExtPower = false;
				printToScreen(TEXT_SERIAL_PORT_CANNOT_OPEN);
			}
		} else {
			shouldPollExtPower = false;
		}


		if(shouldShowChart){
			if(shouldPollFPS){
				initFPSChart();
			}

			if(shouldPollUtil){
				initCPUUtilChart();
				initGPUUtilChart();
			}

			if(shouldPollFreq){
				initCPUFreqChart();
				initGPUFreqChart();
			}

			if(shouldPollPower){
				initPowerChart();
			}

		}

		InitADB.initADB();


		printToScreen("Press enter to begin...");
		Scanner keyboard = new Scanner(System.in);
		keyboard.nextLine();
		keyboard.close();


		ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor();
		exec.scheduleAtFixedRate(new Runnable() {
			@Override
			public void run() {
				if(!isPreviousCommandStillRunning){
					isPreviousCommandStillRunning = true;

					if(shouldContinueSampling()){


						int currentSample = numSamples;
						numSamples++;
						try{
							if(shouldPollFPS){
								String fpsStr = pollFPS();
								printToScreen(fpsStr);
							}

							if(shouldPollUtil){
								String utilStr = pollUtil();
								printToScreen(utilStr);
							}

							if(shouldPollFreq){
								String freqString = pollFreq();
								printToScreen(freqString);
							}

							if(shouldPollPower){
								String powerString = pollPower();
								printToScreen(powerString);
								String total = String.format(TEXT_TOTAL_FORMAT, numSamples, totalA15Power, totalA7Power, totalGPUPower, totalMemPower);
								printToScreen(total);
							}

							printToScreen("");
						} catch(Exception e){
							numSamples = currentSample;
						}

					} else {
						endMessages();
						ExternalPowerRetrieval.stopSystemPowerRetrieval();
						System.exit(0);
					}
					isPreviousCommandStillRunning = false;
				}
			}
		}, 0, SAMPLE_RATE, TimeUnit.MILLISECONDS);

	}