コード例 #1
0
ファイル: MotorInfo.java プロジェクト: OpenVnmrJ/OpenVnmrJ
 public void addEotDatum(int nSteps) {
   m_eotCount += nSteps;
   Messages.postDebug("AllTuneAlgorithm", "Motor " + m_gmi + " EOT count=" + m_eotCount);
   if (Math.abs(m_eotCount) > 5) {
     setEot(m_eotCount);
   }
 }
コード例 #2
0
ファイル: MotorInfo.java プロジェクト: OpenVnmrJ/OpenVnmrJ
 /**
  * Set flag indicating if this motor is at the end of it's travel. Typically called after making a
  * motion of "step" motor steps. A positive value of "step" indicates are at the positive EOT. A
  * negative value of "step" indicates are at the negative EOT. A zero value for "step" indicates
  * are not at EOT.
  *
  * @param step Flag that we are at EOT for steps in this direction.
  */
 public void setEot(int step) {
   m_eotStatus = step;
   if (step == 0) {
     m_eotCount = 0;
   } else if (DebugOutput.isSetFor("TuneAlgorithm")) {
     Messages.postDebug("Setting EOT=" + step + " on motor " + m_gmi);
   }
 }
コード例 #3
0
ファイル: MotorInfo.java プロジェクト: OpenVnmrJ/OpenVnmrJ
 private boolean readPersistence(boolean sysFlag) {
   String path = getPersistenceFilePath(sysFlag);
   boolean ok = readPersistence(path);
   if (!ok && sysFlag) {
     Messages.postError("Cannot read persistence file: " + path);
   }
   return ok;
 }
コード例 #4
0
ファイル: MotorInfo.java プロジェクト: OpenVnmrJ/OpenVnmrJ
 /**
  * Update the motor position, based on increment from last position. Also updates the backlash
  * tracking.
  *
  * @param n The number of steps from the previous position.
  */
 public void incrementPosition(int n) {
   Messages.postDebug("BacklashTracking", "incrementPosition(" + n + ") called");
   if (n != 0) {
     m_position += n;
     if (!isSameDirection(n)) {
       m_distanceThisDirection = 0; // Reversed direction
     }
     m_distanceThisDirection += Math.abs(n);
     if (n != 0) {
       m_lastStep = n;
     }
   }
 }
コード例 #5
0
ファイル: MotorInfo.java プロジェクト: OpenVnmrJ/OpenVnmrJ
  public boolean readPersistence(String path) {
    BufferedReader input = TuneUtilities.getReader(path);

    String line = null;
    boolean rtn = true;
    try {
      while ((line = input.readLine()) != null) {
        StringTokenizer toker = new StringTokenizer(line);
        if (toker.hasMoreTokens()) {
          String key = toker.nextToken().toLowerCase();
          if (key.equals("backlash")) {
            double backlash = Double.parseDouble(toker.nextToken());
            // backlash = Math.max(MIN_BACKLASH, backlash);/*CMP*/
            // backlash = Math.min(MAX_BACKLASH, backlash);/*CMP*/
            setBacklash(backlash);
            m_backlashGroup.clear();
            while (toker.hasMoreTokens()) {
              m_backlashGroup.add(new Integer(toker.nextToken()));
            }
          } else if (key.equals("backlashlimits")) {
            m_maxBacklash = Double.parseDouble(toker.nextToken());
            if (toker.hasMoreTokens()) {
              m_minBacklash = Double.parseDouble(toker.nextToken());
            }
          } else if (key.equals("steps/rev")) {
            m_stepsPerRev = Integer.parseInt(toker.nextToken());
          } else if (key.equals("limit")) {
            m_minLimit = Integer.parseInt(toker.nextToken());
            if (toker.hasMoreTokens()) {
              m_maxLimit = Integer.parseInt(toker.nextToken());
            }

          } else if (key.equals("odom")) {
            m_odometerCW = Long.parseLong(toker.nextToken());
            m_odometerCCW = Long.parseLong(toker.nextToken());

          } else if (key.equals("mincalstep")) {
            m_minCalStep = Integer.valueOf(toker.nextToken());
          } else if (key.equals("indexdirection")) {
            int dir = Integer.parseInt(toker.nextToken());
            m_indexDirection = dir > 0 ? 1 : -1;
          } else if (key.equals("indexdistance")) {
            m_indexDistance = Integer.parseInt(toker.nextToken());
          } else if (key.equals("reqswversion")) {
            // Verify version of software and persistence file
            m_minSWVersion = toker.nextToken();
            if (!ProbeTune.isSwVersionAtLeast(m_minSWVersion)) {
              String msg =
                  "Require software version "
                      + m_minSWVersion
                      + "<br>"
                      + " to operate on the file "
                      + path;
              Messages.postError(msg);
              String title = "Incompatible_Motor_File";
              m_master.sendToGui("popup error title " + title + " msg " + msg);
            }
          }
        }
      }
    } catch (NumberFormatException nfe) {
      Messages.postError("Bad number in persistence file: " + path + ", line: \"" + line + "\"");
      rtn = false;
    } catch (NoSuchElementException nsee) {
      Messages.postError("Bad line in persistence file: " + path + ", line: \"" + line + "\"");
      rtn = false;
    } catch (Exception e) {
      rtn = false;
    } finally {
      try {
        input.close();
      } catch (Exception e) {
      }
    }
    return rtn;
  }