use of com.willwinder.universalgcodesender.gcode.GcodeStats 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();
}
}
}
Aggregations