Пример #1
0
 public void receivedSample(SourceId sourceId, Sample sample) {
   Vector<Double> sampleValue = (Vector<Double>) sample.getValue();
   FileWriter writer;
   if (console) {
     try {
       writer = new FileWriter(fileName, true);
       writer.write("SENSOR: " + sourceId.toString());
       writer.write("\tPERIOD: " + sample.getSamplingPeriod());
       writer.write("\tMEANTEMPERATURE: " + sampleValue.get(0));
       writer.write(" (" + sampleValue.get(1).longValue() + ")");
       writer.write("\tTIMESTAMP:" + sample.getTimestamp());
       writer.write("\n");
       writer.flush();
       writer.close();
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
   if (gui && panel != null) {
     panel.addPoint(sourceId, sample.getTimestamp().getTime(), sampleValue.get(0).doubleValue());
   }
 }