Skip to content
Snippets Groups Projects
Commit 49adc513 authored by Thomas Oster's avatar Thomas Oster
Browse files

Merge pull request #33 from mrzl/export_gcode

Export gcode
parents cbb65794 5a3f5bea
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,8 @@ package com.t_oster.liblasercut; ...@@ -24,6 +24,8 @@ package com.t_oster.liblasercut;
import com.t_oster.liblasercut.platform.Point; import com.t_oster.liblasercut.platform.Point;
import com.t_oster.liblasercut.platform.Util; import com.t_oster.liblasercut.platform.Util;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
...@@ -80,6 +82,11 @@ public abstract class LaserCutter implements Cloneable, Customizable { ...@@ -80,6 +82,11 @@ public abstract class LaserCutter implements Cloneable, Customizable {
*/ */
public abstract void sendJob(LaserJob job, ProgressListener pl, List<String> warnings) throws IllegalJobException, Exception; public abstract void sendJob(LaserJob job, ProgressListener pl, List<String> warnings) throws IllegalJobException, Exception;
public void saveJob(java.io.PrintStream fileOutputStream, LaserJob job) throws NotImplementedException, IllegalJobException, Exception {
System.err.println("Your driver does not implement saveJob(LaserJob job)");
throw new NotImplementedException();
}
/** /**
* If you lasercutter supports autofocus, override this method, * If you lasercutter supports autofocus, override this method,
* to let programs like VisiCut know, that they don't need to focus. * to let programs like VisiCut know, that they don't need to focus.
......
...@@ -23,19 +23,27 @@ import com.t_oster.liblasercut.platform.Util; ...@@ -23,19 +23,27 @@ import com.t_oster.liblasercut.platform.Util;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.File;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.PrintStream; import java.io.PrintStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.lang.Exception;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.Socket; import java.net.Socket;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import purejavacomm.*; import purejavacomm.*;
import java.util.*; import java.util.*;
import net.sf.corn.httpclient.HttpClient; import net.sf.corn.httpclient.HttpClient;
import net.sf.corn.httpclient.HttpResponse; import net.sf.corn.httpclient.HttpResponse;
/** /**
* This class implements a driver for a generic GRBL GCode Lasercutter. * This class implements a driver for a generic GRBL GCode Lasercutter.
* It should contain all possible options and is inteded to be the superclass * It should contain all possible options and is inteded to be the superclass
...@@ -377,6 +385,7 @@ public class GenericGcodeDriver extends LaserCutter { ...@@ -377,6 +385,7 @@ public class GenericGcodeDriver extends LaserCutter {
} }
} }
private void writeShutdownCode() throws IOException { private void writeShutdownCode() throws IOException {
if (postJobGcode != null) if (postJobGcode != null)
{ {
...@@ -408,7 +417,7 @@ public class GenericGcodeDriver extends LaserCutter { ...@@ -408,7 +417,7 @@ public class GenericGcodeDriver extends LaserCutter {
} }
} }
} }
protected void http_upload(URI url, String data, String filename) throws IOException protected void http_upload(URI url, String data, String filename) throws IOException
{ {
HttpClient client = new HttpClient(url); HttpClient client = new HttpClient(url);
...@@ -651,6 +660,43 @@ public class GenericGcodeDriver extends LaserCutter { ...@@ -651,6 +660,43 @@ public class GenericGcodeDriver extends LaserCutter {
pl.taskChanged(this, "sent."); pl.taskChanged(this, "sent.");
pl.progressChanged(this, 100); pl.progressChanged(this, 100);
} }
@Override
public void saveJob(java.io.PrintStream fileOutputStream, LaserJob job) throws IllegalJobException, Exception {
checkJob(job);
this.out = fileOutputStream;
boolean wasSetWaitingForOk = isWaitForOKafterEachLine();
setWaitForOKafterEachLine( false );
writeInitializationCode();
int i = 0;
int max = job.getParts().size();
for (JobPart p : job.getParts())
{
if (p instanceof RasterPart)
{
RasterPart rp = (RasterPart) p;
LaserProperty black = rp.getLaserProperty();
LaserProperty white = black.clone();
white.setProperty("power", 0.0f);
p = convertRasterToVectorPart((RasterPart) p, black, white, p.getDPI(), false);
}
if (p instanceof VectorPart)
{
//TODO: in direct mode use progress listener to indicate progress
//of individual job
writeVectorGCode((VectorPart) p, p.getDPI());
}
i++;
}
writeShutdownCode();
this.out.flush();
setWaitForOKafterEachLine(wasSetWaitingForOk);
}
private List<Double> resolutions; private List<Double> resolutions;
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment