package org.vaadin.hackathonofthings.visual;

import org.vaadin.hackathonofthings.data.DataSink;
import org.vaadin.hackathonofthings.data.Topic;
import org.vaadin.hackathonofthings.io.FileLogger;

public class FileReadingThread extends Thread {
	// public static final String DATA_FILE = "d:\\elmot_cut1.log";
	public static final String DATA_FILE = "com9";

    private DataSink sink;

	public FileReadingThread(DataSink sink) {
        this.sink = sink;
		setDaemon(true);
    }

    @Override
    public void run() {
        ReadSwordDataWorker chartUpdateWorker = new ReadSwordDataWorker();
        chartUpdateWorker.addSink(sink);
		while (!isInterrupted()) {
            try {
                FileLogger store = new FileLogger(new Topic("captured"));
        		chartUpdateWorker.addSink(store);

        		// read the contents
        		chartUpdateWorker.readFile(DATA_FILE);
    			
        		store.close();
                chartUpdateWorker.removeSink(store);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
@@ -39,16 +39,45 @@
 isual;%0A%0A
+import java.io.IOException;%0A%0A
 import o
@@ -119,16 +119,16 @@
 taSink;%0A
-
 import o
@@ -217,16 +217,74 @@
 eLogger;
+%0Aimport org.vaadin.hackathonofthings.io.LogFileDataSource;
 %0A%0Apublic
@@ -576,16 +576,16 @@
 verride%0A
-
     publ
@@ -596,24 +596,268 @@
 oid run() %7B%0A
+//    %09LogFileDataSource source = new LogFileDataSource(new Topic(%22capture_log%22));%0A//    %09source.addSink(sink);%0A//    %09try %7B%0A//%09%09%09source.readFile(%22captured5382031613984702956.log%22);%0A//%09%09%7D catch (IOException e) %7B%0A//%09%09%09e.printStackTrace();%0A//%09%09%7D%0A
         Read

Test for reading logs