コード例 #1
0
 /**
  * Add a measurement set to this Sats store
  *
  * @param id
  * @param m
  * @return
  * @throws IOException
  */
 public boolean add(int id, Measurement m) throws IOException {
   if (m instanceof RtMeasurement) {
     try {
       save(m, rtFileName);
     } catch (IOException e) {
       // NEED TO SET A FLAG HERE THAT IS THEN SEEN BY THE GUI WHEN IT POLLS FOR RESULTS
       e.printStackTrace(Log.getWriter());
     }
     rtRecords.add(m);
     updatedRt = true;
     return true;
   } else if (m instanceof PassMeasurement) {
     try {
       save(m, passFileName);
     } catch (IOException e) {
       // NEED TO SET A FLAG HERE THAT IS THEN SEEN BY THE GUI WHEN IT POLLS FOR RESULTS
       e.printStackTrace(Log.getWriter());
     }
     passRecords.add(m);
     updatedPass = true;
     return true;
   }
   return false;
 }
コード例 #2
0
  /**
   * Load a file from disk
   *
   * @param log
   * @throws FileNotFoundException
   */
  public void load(String log) throws FileNotFoundException {
    String line;
    if (!Config.logFileDirectory.equalsIgnoreCase("")) {
      log = Config.logFileDirectory + File.separator + log;
      Log.println("Loading: " + log);
    }
    File aFile = new File(log);
    if (!aFile.exists()) {
      try {
        aFile.createNewFile();
      } catch (IOException e) {
        JOptionPane.showMessageDialog(
            MainWindow.frame,
            e.toString(),
            "ERROR creating file " + log,
            JOptionPane.ERROR_MESSAGE);
        e.printStackTrace(Log.getWriter());
      }
    }

    BufferedReader dis = new BufferedReader(new FileReader(log));

    try {
      while ((line = dis.readLine()) != null) {
        if (line != null) {
          StringTokenizer st = new StringTokenizer(line, ",");
          String date = st.nextToken();
          int id = Integer.valueOf(st.nextToken()).intValue();
          int reset = Integer.valueOf(st.nextToken()).intValue();
          long uptime = Long.valueOf(st.nextToken()).longValue();
          int type = Integer.valueOf(st.nextToken()).intValue();

          // We should never get this situation, but good to check..
          if (Config.satManager.getSpacecraft(id) == null) {
            Log.errorDialog(
                "FATAL",
                "Attempting to Load payloads from the Payload store for satellite with Fox Id: "
                    + id
                    + "\n when no sattellite with that FoxId is configured.  Add this spacecraft to the satellite directory and restart FoxTelem."
                    + "\nProgram will now exit");
            System.exit(1);
          }
          if (type == RT_MEASUREMENT_TYPE) {
            RtMeasurement rt = new RtMeasurement(id, date, reset, uptime, type, st);
            rtRecords.add(rt);
            updatedRt = true;
          }
          if (type == PASS_MEASUREMENT_TYPE) {
            PassMeasurement rt = new PassMeasurement(id, date, reset, uptime, type, st);
            passRecords.add(rt);
            updatedPass = true;
          }
        }
      }
    } catch (IOException e) {
      e.printStackTrace(Log.getWriter());

    } catch (NumberFormatException n) {
      n.printStackTrace(Log.getWriter());
    } finally {
      try {
        dis.close();
      } catch (IOException e) {
        e.printStackTrace(Log.getWriter());
      }
    }
  }