コード例 #1
0
  public void setHardwareVersion(int version) {
    int newVersion = -1;

    try {
      // get version numbers
      ServiceLoader<MakelangeloHardwareProperties> knownHardware =
          ServiceLoader.load(MakelangeloHardwareProperties.class);
      Iterator<MakelangeloHardwareProperties> i = knownHardware.iterator();
      while (i.hasNext()) {
        MakelangeloHardwareProperties hw = i.next();
        if (hw.getVersion() == version) {
          hardwareProperties = hw.getClass().newInstance();
          newVersion = version;
          break;
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
      Log.error("Hardware version instance failed. Defaulting to v2");
      hardwareProperties = new Makelangelo2Properties();
      newVersion = 2;
    }
    if (newVersion == -1) {
      Log.error("Unknown hardware version requested. Defaulting to v2");
      hardwareProperties = new Makelangelo2Properties();
    }

    hardwareVersion = newVersion;
    if (!hardwareProperties.canChangeMachineSize()) {
      this.setMachineSize(
          hardwareProperties.getWidth() * 0.1f, hardwareProperties.getHeight() * 0.1f);
    }

    saveConfigToLocal();
  }
コード例 #2
0
  /**
   * These values should match
   * https://github.com/marginallyclever/makelangelo-firmware/firmware_rumba/configure.h
   *
   * @param translator
   * @param robot
   */
  public MakelangeloRobotSettings(MakelangeloRobot robot) {
    // set up number format
    DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols();
    otherSymbols.setDecimalSeparator('.');
    df = new DecimalFormat("#.###", otherSymbols);
    df.setGroupingUsed(false);

    double mh = 835 * 0.1; // mm > cm  // Makelangelo 5 is 835mm.
    double mw = 835 * 0.1; // mm > cm  // Makelangelo 5 is 835mm.

    robotUID = 0;
    isRegistered = false;
    limitTop = mh / 2;
    limitBottom = -mh / 2;
    limitRight = mw / 2;
    limitLeft = -mw / 2;

    paperColor = Color.WHITE;

    listeners = new ArrayList<MakelangeloRobotSettingsListener>();
    shouldSignName = false;

    // paper area
    double pw = 420 * 0.1; // cm
    double ph = 594 * 0.1; // cm

    paperTop = ph / 2;
    paperBottom = -ph / 2;
    paperLeft = -pw / 2;
    paperRight = pw / 2;
    paperMargin = 0.9;

    maxFeedRate = 6500;
    currentFeedRate = 6500;
    maxAcceleration = 250;

    // pen
    diameter = 0.8f;
    zRate = 50;
    zOn = 90;
    zOff = 50;
    penDownColor = Color.BLACK;
    penUpColor = Color.BLUE;

    // diameter = circumference/pi
    // circumference is 20 teeth @ 2mm/tooth
    pulleyDiameter = 20.0 * 0.2 / Math.PI;

    isLeftMotorInverted = false;
    isRightMotorInverted = true;
    reverseForGlass = false;

    startingPositionIndex = 4;

    // default hardware version is 2
    setHardwareVersion(2);

    // which configurations are available?
    try {
      configsAvailable = topLevelMachinesPreferenceNode.childrenNames();
    } catch (Exception e) {
      Log.error(e.getMessage());
      configsAvailable = new String[1];
      configsAvailable[0] = "Default";
    }

    // Load most recent config
    // loadConfig(last_machine_id);
  }