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

Added: Laos supports bottom-up engraving and unidirectional is property of the engrave-profile now.

parent 804b3b10
No related branches found
No related tags found
No related merge requests found
......@@ -36,7 +36,6 @@ import java.net.Socket;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import org.apache.commons.net.tftp.TFTP;
......@@ -61,7 +60,6 @@ public class LaosCutter extends LaserCutter
private static final String SETTING_MMPERSTEP = "mm per Step (for SimpleMode)";
private static final String SETTING_TFTP = "Use TFTP instead of TCP";
private static final String SETTING_RASTER_WHITESPACE = "Additional space per Raster line";
private static final String SETTING_UNIDIR = "Engrave unidirectional";
private static final String SETTING_DEBUGFILE = "Debug output file";
private static final String SETTING_SUPPORTS_PURGE = "Supports purge";
private static final String SETTING_SUPPORTS_VENTILATION = "Supports ventilation";
......@@ -116,7 +114,8 @@ public class LaosCutter extends LaserCutter
this.supportsVentilation = supportsVentilation;
}
private boolean unidir = false;
//only kept for backwards compatibility. unused
private transient boolean unidir = false;
private String debugFilename = "";
@Override
......@@ -126,25 +125,15 @@ public class LaosCutter extends LaserCutter
}
@Override
public LaosCutterProperty getLaserPropertyForRasterPart()
public LaosEngraveProperty getLaserPropertyForRasterPart()
{
return new LaosCutterProperty(!this.supportsPurge, !this.supportsVentilation, !this.supportsFocus, !this.supportsFrequency);
return new LaosEngraveProperty(!this.supportsPurge, !this.supportsVentilation, !this.supportsFocus, !this.supportsFrequency);
}
@Override
public LaosCutterProperty getLaserPropertyForRaster3dPart()
{
return new LaosCutterProperty(!this.supportsPurge, !this.supportsVentilation, !this.supportsFocus, !this.supportsFrequency);
}
public void setEngraveUnidirectional(boolean uni)
{
this.unidir = uni;
}
public boolean isEngraveUnidirectional()
public LaosEngraveProperty getLaserPropertyForRaster3dPart()
{
return this.unidir;
return new LaosEngraveProperty(!this.supportsPurge, !this.supportsVentilation, !this.supportsFocus, !this.supportsFrequency);
}
private double addSpacePerRasterLine = 5;
......@@ -451,9 +440,11 @@ public class LaosCutter extends LaserCutter
PrintStream out = new PrintStream(result, true, "US-ASCII");
boolean dirRight = true;
Point rasterStart = rp.getRasterStart();
this.setCurrentProperty(out, rp.getLaserProperty());
LaosEngraveProperty prop = rp.getLaserProperty() instanceof LaosEngraveProperty ? (LaosEngraveProperty) rp.getLaserProperty() : new LaosEngraveProperty(rp.getLaserProperty());
this.setCurrentProperty(out, prop);
float maxPower = this.currentPower;
for (int line = 0; line < rp.getRasterHeight(); line++)
boolean bu = prop.isEngraveBottomUp();
for (int line = bu ? rp.getRasterHeight()-1 : 0; bu ? line >= 0 : line < rp.getRasterHeight(); line += bu ? -1 : 1 )
{
Point lineStart = rasterStart.clone();
lineStart.y += line;
......@@ -524,7 +515,7 @@ public class LaosCutter extends LaserCutter
line(out, lineStart.x, lineStart.y, resolution);
}
}
if (!this.isEngraveUnidirectional())
if (!prop.isEngraveUnidirectional())
{
dirRight = !dirRight;
}
......@@ -581,8 +572,10 @@ public class LaosCutter extends LaserCutter
PrintStream out = new PrintStream(result, true, "US-ASCII");
boolean dirRight = true;
Point rasterStart = rp.getRasterStart();
this.setCurrentProperty(out, rp.getLaserProperty());
for (int line = 0; line < rp.getRasterHeight(); line++)
LaosEngraveProperty prop = rp.getLaserProperty() instanceof LaosEngraveProperty ? (LaosEngraveProperty) rp.getLaserProperty() : new LaosEngraveProperty(rp.getLaserProperty());
this.setCurrentProperty(out, prop);
boolean bu = prop.isEngraveBottomUp();
for (int line = bu ? rp.getRasterHeight()-1 : 0; bu ? line >= 0 : line < rp.getRasterHeight(); line += bu ? -1 : 1)
{
Point lineStart = rasterStart.clone();
lineStart.y += line;
......@@ -633,7 +626,7 @@ public class LaosCutter extends LaserCutter
line(out, lineStart.x, lineStart.y, resolution);
}
}
if (!this.isEngraveUnidirectional())
if (!prop.isEngraveUnidirectional())
{
dirRight = !dirRight;
}
......@@ -807,7 +800,6 @@ public class LaosCutter extends LaserCutter
private static String[] settingAttributes = new String[]{
SETTING_HOSTNAME,
SETTING_PORT,
SETTING_UNIDIR,
SETTING_BEDWIDTH,
SETTING_BEDHEIGHT,
//SETTING_FLIPX,
......@@ -855,10 +847,6 @@ public class LaosCutter extends LaserCutter
{
return (Boolean) this.supportsFocus;
}
else if (SETTING_UNIDIR.equals(attribute))
{
return (Boolean) this.isEngraveUnidirectional();
}
else if (SETTING_HOSTNAME.equals(attribute))
{
return this.getHostname();
......@@ -921,10 +909,6 @@ public class LaosCutter extends LaserCutter
{
this.setSupportsFocus((Boolean) value);
}
else if (SETTING_UNIDIR.endsWith(attribute))
{
this.setEngraveUnidirectional((Boolean) value);
}
else if (SETTING_HOSTNAME.equals(attribute))
{
this.setHostname((String) value);
......@@ -973,7 +957,6 @@ public class LaosCutter extends LaserCutter
clone.mmPerStep = mmPerStep;
clone.useTftp = useTftp;
clone.addSpacePerRasterLine = addSpacePerRasterLine;
clone.unidir = unidir;
clone.supportsFrequency = supportsFrequency;
clone.supportsPurge = supportsPurge;
clone.supportsVentilation = supportsVentilation;
......
/**
* This file is part of LibLaserCut.
* Copyright (C) 2011 - 2013 Thomas Oster <thomas.oster@rwth-aachen.de>
* RWTH Aachen University - 52062 Aachen, Germany
*
* LibLaserCut is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LibLaserCut is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with LibLaserCut. If not, see <http://www.gnu.org/licenses/>.
**/
package com.t_oster.liblasercut.drivers;
import com.t_oster.liblasercut.LaserProperty;
import java.util.Arrays;
import java.util.LinkedList;
/**
*
* @author Thomas Oster <thomas.oster@rwth-aachen.de>
*/
public class LaosEngraveProperty extends LaosCutterProperty
{
public LaosEngraveProperty(boolean hidePurge, boolean hideVentilation, boolean hideFocus, boolean hideFrequency)
{
super(hidePurge, hideVentilation, hideFocus, hideFrequency);
}
public LaosEngraveProperty()
{};
public LaosEngraveProperty(LaserProperty o)
{
for (String k : o.getPropertyKeys())
{
try
{
this.setProperty(k, o.getProperty(k));
}
catch (Exception e)
{
}
}
}
private static final String BOTTOM_UP = "engrave bottom up";
private boolean engraveBottomUp = false;
public boolean isEngraveBottomUp()
{
return engraveBottomUp;
}
private static final String UNIDIRECTIONAL = "engrave unidirectional";
private boolean engraveUnidirectional = false;
public boolean isEngraveUnidirectional()
{
return engraveUnidirectional;
}
@Override
public String[] getPropertyKeys()
{
LinkedList<String> result = new LinkedList<String>();
result.addAll(Arrays.asList(super.getPropertyKeys()));
result.add(BOTTOM_UP);
result.add(UNIDIRECTIONAL);
return result.toArray(new String[0]);
}
@Override
public Object getProperty(String name)
{
if (BOTTOM_UP.equals(name))
{
return (Boolean) engraveBottomUp;
}
else if (UNIDIRECTIONAL.equals(name))
{
return (Boolean) engraveUnidirectional;
}
else
{
return super.getProperty(name);
}
}
@Override
public void setProperty(String name, Object value)
{
if (BOTTOM_UP.equals(name))
{
engraveBottomUp = (Boolean) value;
}
else if (UNIDIRECTIONAL.equals(name))
{
engraveUnidirectional = (Boolean) value;
}
else
{
super.setProperty(name, value);
}
}
}
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