Esempio n. 1
0
  private void generateGcodeProgram() {

    LOG.debug("generateGcodeProgram:");

    gcodeProgram.clear();

    gcodeProgram.appendLine("(Macro for " + getTitle() + ")");
    gcodeProgram.appendLine("(generated " + getTimestamp() + ")");
    gcodeProgram.appendLine("G21");
    gcodeProgram.appendLine("G90");

    generateGcodeCore(gcodeProgram);

    if (gcodeGenerationError) {

      clear();

    } else {

      gcodeProgram.appendLine(
          "G0 Z"
              + String.format(
                  IConstant.FORMAT_COORDINATE, getDoublePreference(IPreferenceKey.Z_CLEARANCE)));
      gcodeProgram.appendLine("M5");

      gcodeProgram.parse();

      Text gcodeText = (Text) context.get(IConstant.MACRO_TEXT_ID);
      if (gcodeText != null) toolbox.gcodeToText(gcodeText, gcodeProgram);
    }

    eventBroker.send(IEvent.GCODE_MACRO_GENERATED, null);
    eventBroker.send(IEvent.REDRAW, null);
  }
  private void updateGrid() {

    // probeDataCleared is called after closing a editor part and the next one is not initialized
    // on gcode loading the probe data are always reseted
    if (gcodeProgram != null) {

      int xSteps = toolbox.parseIntegerField(scanStepXText, 1);
      int ySteps = toolbox.parseIntegerField(scanStepYText, 1);

      gcodeProgram.prepareAutolevelScan(xSteps, ySteps); // resets scan completed
      scanStepWidthXLabel.setText(
          String.format(IConstant.FORMAT_COORDINATE, gcodeProgram.getStepWidthX()));
      scanStepWidthYLabel.setText(
          String.format(IConstant.FORMAT_COORDINATE, gcodeProgram.getStepWidthY()));
    }

    redrawGcode(); // redraw gcode every time, if gcodeProgram is null, then the view is "cleared"
  }
  private void setGridFields() {

    if (gcodeProgram == null) return;

    ignoreStepTextModifyListener = true;
    if (scanStepXText != null && !scanStepXText.isDisposed())
      scanStepXText.setText("" + gcodeProgram.getXSteps());
    if (scanStepYText != null && !scanStepYText.isDisposed())
      scanStepYText.setText("" + gcodeProgram.getYSteps());
    ignoreStepTextModifyListener = false;

    if (scanStepWidthXLabel != null && !scanStepWidthXLabel.isDisposed())
      scanStepWidthXLabel.setText(
          String.format(IConstant.FORMAT_COORDINATE, gcodeProgram.getStepWidthX()));
    if (scanStepWidthYLabel != null && !scanStepWidthYLabel.isDisposed())
      scanStepWidthYLabel.setText(
          String.format(IConstant.FORMAT_COORDINATE, gcodeProgram.getStepWidthY()));
  }
  private void setControlsEnabled(boolean enabled) {

    scanStepXText.setEnabled(enabled);
    scanStepYText.setEnabled(enabled);
    scanMinZText.setEnabled(enabled);
    scanMaxZText.setEnabled(enabled);
    scanClearanceZText.setEnabled(enabled);
    scanFeedrateText.setEnabled(enabled);

    // @formatter:off
    scanStartButton.setEnabled(
        enabled
            && gcodeProgram != null
            && gcodeProgram.getGcodeProgramFile() != null
            && gcodeProgram.isLoaded()
            && !gcodeProgram.isAutolevelScanComplete()
            && (serialService.isOpen() || IConstant.AUTOLEVEL_ENABLE_WITHOUT_SERIAL));

    scanClearButton.setEnabled(
        enabled
            && gcodeProgram != null
            && gcodeProgram.getGcodeProgramFile() != null
            && gcodeProgram.isAutolevelScanComplete());

    loadProbeDataButton.setEnabled(
        enabled
            && gcodeProgram != null
            && gcodeProgram.getGcodeProgramFile() != null
            && gcodeProgram.isLoaded()
            && gcodeProgram.getAutolevelDataFile() != null
            && gcodeProgram.getAutolevelDataFile().isFile());

    saveProbeDataButton.setEnabled(
        enabled
            && gcodeProgram != null
            && gcodeProgram.getGcodeProgramFile() != null
            && gcodeProgram.isAutolevelScanComplete());
    // @formatter:on

  }
Esempio n. 5
0
  protected void spindleOn(int spindleSpeed) {

    gcodeProgram.appendLine("M3 S" + spindleSpeed);
    wait(2);
  }
Esempio n. 6
0
  protected void wait(int sec) {

    gcodeProgram.appendLine("G4 P" + sec);
  }
Esempio n. 7
0
  protected void motionLinearZ(double z, int feedrate) {

    gcodeProgram.appendLine("G1 Z" + formatCoordinate(z) + " F" + feedrate);
  }
Esempio n. 8
0
  protected void motionLinearXY(double x, double y, int feedrate) {

    gcodeProgram.appendLine("G1 " + generateXY(x, y) + " F" + feedrate);
  }
Esempio n. 9
0
  protected void motionSeekZ(double z) {

    gcodeProgram.appendLine("G0 Z" + formatCoordinate(z));
  }
Esempio n. 10
0
  protected void motionSeekXY(double x, double y) {

    gcodeProgram.appendLine("G0 " + generateXY(x, y));
  }
Esempio n. 11
0
  protected void clear() {

    gcodeProgram.clear();
  }