示例#1
0
 /**
  * Get the path to the persistence file.
  *
  * @param sysFlag If true, return the system path, otherwise the user path.
  * @return The path.
  */
 public String getPersistenceFilePath(boolean sysFlag) {
   if (sysFlag) {
     return m_master.getSysTuneDir() + "/" + getMotorName();
   } else {
     return m_master.getUsrTuneDir() + "/" + getMotorName();
   }
 }
示例#2
0
  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;
  }
示例#3
0
 protected void sendToGui(String msg) {
   m_master.sendToGui(msg);
 }