コード例 #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
  /**
   * Set the tracker's measurement mode.
   *
   * @param mode must be one of: "ADM", "IFM", "IFM set by ADM"
   * @return confirmation that the mode was changed
   * @throws TrackerException thrown if not connected
   */
  String setMeasureMode(TrackerMeasureMode mode) throws TrackerException {
    if (mode == null) throw new NullPointerException("New measurement mode is null.");
    isConnected();

    switch (mode) {
      case IFM:
        trk.changeDistanceMeasureMode(new InterferometerOnly());
        Bookkeeper.getInstance().setTrkMeasmode(TrackerMeasureMode.IFM);
        break;
      case ADM:
        trk.changeDistanceMeasureMode(new ADMOnly());
        Bookkeeper.getInstance().setTrkMeasmode(TrackerMeasureMode.ADM);
        break;
      case IFMBYADM:
        trk.changeDistanceMeasureMode(new InterferometerSetByADM());
        Bookkeeper.getInstance().setTrkMeasmode(TrackerMeasureMode.IFMBYADM);
        break;
      default:
        assert false; // There are only three measurement modes.
    }

    return "Measure mode set to: " + mode + ".\n";
  }