From b7c0fe68bb42b6ec9f9a83b67252b2e82c1d1a17 Mon Sep 17 00:00:00 2001 From: James Kao Date: Sat, 6 Aug 2016 21:09:32 -0700 Subject: [PATCH] Add non-shutter optimized version of performPostSlice that will delay showing the slice image until after calculations are done --- .../resinprinter/job/AbstractPrintFileProcessor.java | 10 ++++++++++ .../resinprinter/job/ZipImagesFileProcessor.java | 9 ++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/host/src/main/java/org/area515/resinprinter/job/AbstractPrintFileProcessor.java b/host/src/main/java/org/area515/resinprinter/job/AbstractPrintFileProcessor.java index 82ae9ea4b..876b59d7d 100644 --- a/host/src/main/java/org/area515/resinprinter/job/AbstractPrintFileProcessor.java +++ b/host/src/main/java/org/area515/resinprinter/job/AbstractPrintFileProcessor.java @@ -148,7 +148,12 @@ public JobStatus performPreSlice(DataAid aid, List errors) throws Inap return null; } + public JobStatus performPostSlice(DataAid aid) throws ExecutionException, InterruptedException, InappropriateDeviceException, ScriptException { + return this.performPostSlice(aid, null); + } + + public JobStatus performPostSlice(DataAid aid, BufferedImage sliceImage) throws ExecutionException, InterruptedException, InappropriateDeviceException, ScriptException { if (aid == null) { throw new IllegalStateException("initializeDataAid must be called before this method"); } @@ -171,6 +176,11 @@ public JobStatus performPostSlice(DataAid aid) throws ExecutionException, Interr aid.printer.getGCodeControl().executeGCodeWithTemplating(aid.printJob, aid.slicingProfile.getgCodeShutter()); } + if (sliceImage != null) { + logger.info("ExposureStart:{}", ()->Log4jTimer.startTimer(EXPOSURE_TIMER)); + aid.printer.showImage(sliceImage); + } + //Sleep for the amount of time that we are exposing the resin. Thread.sleep(aid.printJob.getExposureTime()); diff --git a/host/src/main/java/org/area515/resinprinter/job/ZipImagesFileProcessor.java b/host/src/main/java/org/area515/resinprinter/job/ZipImagesFileProcessor.java index e5f86a72a..aca002406 100644 --- a/host/src/main/java/org/area515/resinprinter/job/ZipImagesFileProcessor.java +++ b/host/src/main/java/org/area515/resinprinter/job/ZipImagesFileProcessor.java @@ -5,7 +5,6 @@ import java.io.IOException; import java.util.Collection; import java.util.HashMap; -import java.util.List; import java.util.Iterator; import java.util.Map; import java.util.SortedMap; @@ -26,7 +25,7 @@ import org.area515.resinprinter.printer.Printer; import org.area515.resinprinter.server.Main; import org.area515.resinprinter.services.PrinterService; -import org.area515.util.Log4jTimer; +//import org.area515.util.Log4jTimer; import se.sawano.java.text.AlphanumericComparator; @@ -112,11 +111,11 @@ public JobStatus processFile(PrintJob printJob) throws Exception { currentImageByJob.put(printJob, imageData); //Start the exposure timer - logger.info("ExposureStart:{}", ()->Log4jTimer.startTimer(EXPOSURE_TIMER)); + //logger.info("ExposureStart:{}", ()->Log4jTimer.startTimer(EXPOSURE_TIMER)); - dataAid.printer.showImage(imageData.getImage()); + //dataAid.printer.showImage(imageData.getImage()); - status = performPostSlice(dataAid); + status = performPostSlice(dataAid, imageData.getImage()); if (oldImage != null) { oldImage.getImage().flush();