Example #1
0
 void processChannel(WinstonUtil winston, WinstonSCNL channel)
     throws SeisFileException, SQLException, DataFormatException, FileNotFoundException,
         IOException, URISyntaxException {
   List<TraceBuf2> tbList = winston.extractData(channel, params.getBegin(), params.getEnd());
   for (TraceBuf2 traceBuf2 : tbList) {
     List<DataRecord> mseedList = traceBuf2.toMiniSeed(recordSize, doSteim1);
     for (DataRecord dr : mseedList) {
       dr.write(params.getDataOutputStream());
     }
   }
 }
Example #2
0
 void outputRawTraceBuf2s(
     WinstonUtil winston, WinstonSCNL channel, ZipOutputStream zip, String dir)
     throws SeisFileException, SQLException, DataFormatException, FileNotFoundException,
         IOException, URISyntaxException {
   List<TraceBuf2> tbList = winston.extractData(channel, params.getBegin(), params.getEnd());
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH_mm_ss.SSS");
   sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
   for (TraceBuf2 tb : tbList) {
     ZipEntry tbzip =
         new ZipEntry(
             dir
                 + "/"
                 + tb.getNetwork().trim()
                 + "."
                 + tb.getStation().trim()
                 + "."
                 + tb.getLocId().trim()
                 + "."
                 + tb.getChannel().trim()
                 + "."
                 + sdf.format(tb.getStartDate())
                 + ".tb");
     zip.putNextEntry(tbzip);
     byte[] outBytes = tb.toByteArray();
     zip.write(outBytes, 0, outBytes.length);
     zip.closeEntry();
   }
 }
Example #3
0
 Date exportChannel(
     WinstonUtil winston, WinstonSCNL channel, Date begin, Date end, EarthwormExport exporter)
     throws SeisFileException, SQLException, DataFormatException, FileNotFoundException,
         IOException, URISyntaxException {
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
   sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
   List<TraceBuf2> tbList = winston.extractData(channel, begin, end);
   Date lastSentEnd = end;
   double sampRate = 1;
   TraceBuf2 prev = null;
   for (TraceBuf2 traceBuf2 : tbList) {
     if (params.isVerbose()) {
       System.out.println(
           "Tracebuf: "
               + traceBuf2.getNetwork()
               + "."
               + traceBuf2.getStation()
               + "."
               + traceBuf2.getLocId()
               + "."
               + traceBuf2.getChannel()
               + " "
               + sdf.format(traceBuf2.getStartDate())
               + " "
               + traceBuf2.getNumSamples()
               + " "
               + sdf.format(traceBuf2.getEndDate()));
     }
     if (prev != null && prev.getEndDate().after(traceBuf2.getStartDate())) {
       System.out.println("WARNING: current tracebuf overlaps previous: ");
       System.out.println("  prev: " + prev);
       System.out.println("  curr: " + traceBuf2);
     }
     boolean notSent = true;
     while (notSent) {
       try {
         exporter.export(traceBuf2);
         notSent = false;
       } catch (IOException e) {
         exporter.closeClient();
         if (params.isVerbose()) {
           System.out.println("Caught exception, waiting for reconnect, will resend tracebuf" + e);
         }
         logger.warn("Caught exception, waiting for reconnect, will resend tracebuf", e);
         exporter.waitForClient();
         if (params.isVerbose()) {
           System.out.println(
               "Resend Tracebuf: "
                   + traceBuf2.getNetwork()
                   + "."
                   + traceBuf2.getStation()
                   + "."
                   + traceBuf2.getLocId()
                   + "."
                   + traceBuf2.getChannel()
                   + " "
                   + sdf.format(traceBuf2.getStartDate())
                   + " "
                   + traceBuf2.getNumSamples()
                   + " "
                   + sdf.format(traceBuf2.getEndDate()));
         }
       }
     }
     if (lastSentEnd.before(traceBuf2.getPredictedNextStartDate())) {
       lastSentEnd = traceBuf2.getPredictedNextStartDate();
       sampRate = traceBuf2.getSampleRate();
     }
     if (params.isVerbose()) {
       System.out.print(
           "sleep: " + sleepMillis + " milliseconds " + sdf.format(new Date()) + " ...");
     }
     try {
       Thread.sleep(sleepMillis);
     } catch (InterruptedException e) {
     }
     if (params.isVerbose()) {
       System.out.println("...back to work at " + sdf.format(new Date()) + ".");
     }
   }
   return lastSentEnd;
 }