예제 #1
0
파일: Tracker.java 프로젝트: jascase901/MMT
 /**
  * Attempts to disconnect from the tracker.
  *
  * @return "Tracker disconnected.\n" if the disconnect was successful
  * @throws TrackerException thrown if not connected, or if the disconnect attempt failed
  */
 String disconnect() throws TrackerException {
   isConnected();
   trk.disconnect();
   Bookkeeper.getInstance().toggleTrkCon();
   if (trk.connected()) {
     throw new TrackerException("Failed to disconnect from the tracker.\n");
   }
   return "Tracker disconnected.\n";
 }
예제 #2
0
파일: Tracker.java 프로젝트: jascase901/MMT
  /**
   * Connects to the tracker. Also checks to see if the tracker is ready to be initialized and
   * checks the measurement mode of the tracker.
   *
   * @return ready to be initialized Y/N, measurement mode
   * @throws TrackerException thrown if already connected, or if the connect attempt failed
   */
  String connect() throws TrackerException {
    String info;

    if (trk.connected()) {
      throw new TrackerException("Already connected to the tracker.\n");
    }

    trk.connect(ipAddress, name, password);
    if (trk.connected()) {
      Bookkeeper.getInstance().toggleTrkCon();
      info = "Connected to tracker on IP address: " + ipAddress + "\n";
      if (trk.initialized(false)) {
        info += "Tracker initialized.\n";
      } else {
        if (trk.readyToInitialize(false)) {
          info += "Tracker ready to be initialized.\n";
        } else {
          info += "Tracker not ready to be initialized.\n";
        }
      }
      String s = trk.distanceMeasureMode().toString();

      if (s.contains("ADM") && s.contains("Only")) {
        info += "Distance Measure Mode is ADM only.\n";
        Bookkeeper.getInstance().setTrkMeasmode(TrackerMeasureMode.ADM);
      } else if (s.contains("Interferometer")) {
        if (s.contains("ADM")) {
          info += "Distance Measure Mode is IFM set by ADM.\n";
          Bookkeeper.getInstance().setTrkMeasmode(TrackerMeasureMode.IFMBYADM);
        } else {
          info += "Distance Measure Mode is IFM.\n";
          Bookkeeper.getInstance().setTrkMeasmode(TrackerMeasureMode.IFM);
        }
      }
      return info;
    } else {
      throw new TrackerException("Connection to the tracker failed.\n");
    }
  }
예제 #3
0
파일: Tracker.java 프로젝트: jascase901/MMT
 /**
  * Checks to make sure we're already connected to the tracker before attempting further tracker
  * calls.
  *
  * @throws TrackerException
  */
 void isConnected() throws TrackerException {
   if (!trk.connected()) {
     throw new TrackerException(NOT_CONNECTED);
   }
 }