Search in sources :

Example 1 with FileStats

use of com.willwinder.universalgcodesender.utils.Settings.FileStats in project Universal-G-Code-Sender by winder.

the class GUIBackend method initializeProcessedLines.

private void initializeProcessedLines(boolean forceReprocess, File startFile, GcodeParser gcodeParser) throws Exception {
    if (startFile != null) {
        try (FileReader fr = new FileReader(startFile)) {
            Charset.forName(fr.getEncoding());
        }
        logger.info("Start preprocessing");
        long start = System.currentTimeMillis();
        if (this.processedGcodeFile == null || forceReprocess) {
            gcp.reset();
            String name = startFile.getName();
            // If this is being re-processed, strip the ugs postfix and try again.
            Pattern word = Pattern.compile("(.*)_ugs_[\\d]+$");
            Matcher match = word.matcher(name);
            if (match.matches()) {
                name = match.group(1);
            }
            this.processedGcodeFile = new File(this.getTempDir(), name + "_ugs_" + System.currentTimeMillis());
            this.preprocessAndExportToFile(gcodeParser, startFile, this.processedGcodeFile);
            // Store gcode file stats.
            GcodeStats gs = gcp.getCurrentStats();
            this.settings.setFileStats(new FileStats(gs.getMin(), gs.getMax(), gs.getCommandCount()));
        }
        long end = System.currentTimeMillis();
        logger.info("Took " + (end - start) + "ms to preprocess");
        if (this.isConnected()) {
            this.estimatedSendDuration = -1L;
            Thread estimateThread = new Thread(() -> estimatedSendDuration = controller.getJobLengthEstimate(processedGcodeFile));
            estimateThread.start();
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) GcodeStats(com.willwinder.universalgcodesender.gcode.GcodeStats) Matcher(java.util.regex.Matcher) FileStats(com.willwinder.universalgcodesender.utils.Settings.FileStats) FileReader(java.io.FileReader) File(java.io.File)

Example 2 with FileStats

use of com.willwinder.universalgcodesender.utils.Settings.FileStats in project Universal-G-Code-Sender by winder.

the class RendererInputHandler method updateBounds.

/**
 * Pass new bounds (after interpolating arcs) in case of weird arcs.
 */
private void updateBounds(Point3d min, Point3d max) {
    // Update bounds.
    FileStats fs = settings.getFileStats();
    fs.minCoordinate = new Position(min.x, min.y, min.z, Units.MM);
    fs.maxCoordinate = new Position(max.x, max.y, max.z, Units.MM);
    settings.setFileStats(fs);
}
Also used : Position(com.willwinder.universalgcodesender.model.Position) FileStats(com.willwinder.universalgcodesender.utils.Settings.FileStats)

Example 3 with FileStats

use of com.willwinder.universalgcodesender.utils.Settings.FileStats in project Universal-G-Code-Sender by winder.

the class AutoLevelerTopComponent method useLoadedFileActionPerformed.

// GEN-LAST:event_settingsButtonActionPerformed
private void useLoadedFileActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_useLoadedFileActionPerformed
    if (backend.getProcessedGcodeFile() == null) {
        return;
    }
    FileStats fs = backend.getSettings().getFileStats();
    Units u = this.unitMM.isSelected() ? Units.MM : Units.INCH;
    Position min = fs.minCoordinate.getPositionIn(u);
    Position max = fs.maxCoordinate.getPositionIn(u);
    this.xMin.setValue(min.x);
    this.yMin.setValue(min.y);
    this.zMin.setValue(min.z);
    this.xMax.setValue(max.x);
    this.yMax.setValue(max.y);
    this.zMax.setValue(max.z);
}
Also used : Position(com.willwinder.universalgcodesender.model.Position) FileStats(com.willwinder.universalgcodesender.utils.Settings.FileStats) Units(com.willwinder.universalgcodesender.model.UnitUtils.Units)

Aggregations

FileStats (com.willwinder.universalgcodesender.utils.Settings.FileStats)3 Position (com.willwinder.universalgcodesender.model.Position)2 GcodeStats (com.willwinder.universalgcodesender.gcode.GcodeStats)1 Units (com.willwinder.universalgcodesender.model.UnitUtils.Units)1 File (java.io.File)1 FileReader (java.io.FileReader)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1