Package org.LiveGraph.dataFile.write

Examples of org.LiveGraph.dataFile.write.DataStreamWriter


 
  // Print a welcome message:
  System.out.println("Welcome to the LiveLog demo.");
 
  // Setup a data writer object:
  DataStreamWriter out = DataStreamWriterFactory.createDataWriter(DEMO_DIR, "LiveGraphDemo");
 
  // Set a values separator:
  out.setSeparator(";");
 
  // Add a file description line:
  out.writeFileInfo("LiveGraph demo file.");
 
  // Set-up the data series:
  out.addDataSeries("Time");
  out.addDataSeries("Dataset number");
  out.addDataSeries("Burst number");
  out.addDataSeries("Random value");
 
  // Loop until enough datasets a written:
  int datasetNumber = 0;
  int burstNumber = 0;
  long startMillis = System.currentTimeMillis();
  while (MAX_DATASETS > datasetNumber) {
 
    // Status message:
    System.out.println("Datasets written so far: " + datasetNumber + ". "
             + "Now writing burst " + burstNumber + "...");
   
    // Write a few datasets to the file:
    int burstSize = (int) (MIN_BURST + (Math.random() * (double) (MAX_BURST - MIN_BURST)));
    for (int b = 0; b < burstSize && MAX_DATASETS > datasetNumber; b++) {
     
      // Set-up the data values:
      out.setDataValue(System.currentTimeMillis() - startMillis);
      out.setDataValue(datasetNumber);
      out.setDataValue(burstNumber);
      out.setDataValue(Math.random());
     
      // Write dataset to disk:
      out.writeDataSet();
     
      // Check for IOErrors:     
      if (out.hadIOException()) {
        out.getIOException().printStackTrace();
        out.resetIOException();
      }
     
      datasetNumber++;
    }
    burstNumber++;
   
   
    // Pause:
    Thread.yield();
    long sleep = (long) (MIN_SLEEP + (Math.random() * (double) (MAX_SLEEP - MIN_SLEEP)));
    SystemTools.sleep(sleep);
    Thread.yield();
  }   
 
  // Finish:
  out.close();
  System.out.println("Demo finished. Cheers.");
}
View Full Code Here

TOP

Related Classes of org.LiveGraph.dataFile.write.DataStreamWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.