public static void main(String[] args) throws Exception {
		long time = System.currentTimeMillis();
		SerialTestClone main = new SerialTestClone();
		main.initialize();
		System.out.println("Started");
		Thread t = new Thread() {
			public void run() {
				// the following line will keep this app alive for 1000 seconds,
				// waiting for events to occur and responding to them (printing
				// incoming messages to console).
				try {
					Thread.sleep(10000);
				} catch (InterruptedException ie) {
				}
			}
		};
		t.start();
		t.join();
		main.close();
		PrintWriter pw = null;
		try {
			pw = new PrintWriter("abc.txt");
		} catch (IOException e) {
			e.printStackTrace();
		}
		for (Double a : main.data) {
			pw.println(a);
		}
		pw.close();

		Plot2DPanel plot = new Plot2DPanel();

		// add a line plot to the PlotPanel
		double[] x = new double[main.xaxis.size()];
		double[] y = new double[main.data.size()];
		double[] der = new double[main.data.size()];
		for (int a = 0; a < main.xaxis.size(); a++) {
			x[a] = main.xaxis.get(a) - time;
			y[a] = main.data.get(a);
			if (a != 0) {
				double val = (y[a] - y[a - 1]) * 1000 / (x[a] - x[a - 1]);
				if (val > 0) {
					der[a] = 1023;
				} else if (val < 0) {
					der[a] = 0;
				} else {
					der[a] = 512;
				}
			}

		}
		plot.addLinePlot("my plot", x, y);
		plot.addLinePlot("my plot", x, der);

		// put the PlotPanel in a JFrame, as a JPanel
		JFrame frame = new JFrame("a plot panel");
		frame.setContentPane(plot);
		frame.setSize(400, 400);
		frame.setVisible(true);
		Thread.sleep(2000);
		// plot.removeAllPlots();
		// plot.addLinePlot("my plot", y, x);

	}