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

Imodela improvements

parent 10c3c999
No related branches found
No related tags found
No related merge requests found
/**
* This file is part of VisiCut.
* This file is part of LibLaserCut.
* Copyright (C) 2011 - 2013 Thomas Oster <thomas.oster@rwth-aachen.de>
* RWTH Aachen University - 52062 Aachen, Germany
*
* VisiCut is free software: you can redistribute it and/or modify
* 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.
*
* VisiCut is distributed in the hope that it will be useful,
* 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 VisiCut. If not, see <http://www.gnu.org/licenses/>.
* along with LibLaserCut. If not, see <http://www.gnu.org/licenses/>.
**/
package com.t_oster.liblasercut.drivers;
......@@ -58,10 +58,12 @@ public class IModelaMill extends LaserCutter
out.println("%");
out.println("G90");//absolute positioning
out.println("G21");//select mm as input unit
out.println("M03");//start spindle
}
private void writeFinalizationCode(PrintStream out)
{
out.println("M05");//stop spindle
out.println("M02");//END_OF_PROGRAM
out.println("%");
}
......@@ -69,7 +71,12 @@ public class IModelaMill extends LaserCutter
private void writeVectorCode(VectorPart p, PrintStream out)
{
double dpi = p.getDPI();
boolean spindleOn = false;
boolean headDown = false;
double olddepth = 0;
double depth = 0;
int spindleSpeed = -1;
double feedRate = -1;
int tool = -1;
for (VectorCommand c : p.getCommandList())
{
switch (c.getType())
......@@ -78,10 +85,10 @@ public class IModelaMill extends LaserCutter
{
double x = Util.px2mm(c.getX(), dpi);
double y = Util.px2mm(c.getY(), dpi);
if (spindleOn)
if (headDown)
{
out.println("M05");//stop spindle
spindleOn = false;
out.printf("G00 Z0\n");
headDown = false;
}
out.printf("G00 X%f Y%f\n", x, y);
break;
......@@ -90,16 +97,35 @@ public class IModelaMill extends LaserCutter
{
double x = Util.px2mm(c.getX(), dpi);
double y = Util.px2mm(c.getY(), dpi);
if (!spindleOn)
if (!headDown || depth != olddepth)
{
out.println("M03");//start spindle
spindleOn = true;
out.printf("G01 Zf\n", depth);
headDown = true;
olddepth = depth;
}
out.printf("G01 X%f Y%f\n", x, y);
break;
}
case SETPROPERTY:
{
IModelaProperty pr = (IModelaProperty) c.getProperty();
depth = pr.getDepth();
if (pr.getSpindleSpeed() != spindleSpeed)
{
spindleSpeed = pr.getSpindleSpeed();
out.printf("S%d\n", spindleSpeed);
}
if (pr.getFeedRate() != feedRate)
{
feedRate = pr.getFeedRate();
out.printf("F%f\n", feedRate);
}
if (pr.getTool() != tool)
{
tool = pr.getTool();
out.printf("M06T0\n");//return current tool
out.printf("M06T%d\n", tool);
}
break;
}
}
......
/**
* This file is part of VisiCut.
* This file is part of LibLaserCut.
* Copyright (C) 2011 - 2013 Thomas Oster <thomas.oster@rwth-aachen.de>
* RWTH Aachen University - 52062 Aachen, Germany
*
* VisiCut is free software: you can redistribute it and/or modify
* 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.
*
* VisiCut is distributed in the hope that it will be useful,
* 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 VisiCut. If not, see <http://www.gnu.org/licenses/>.
* along with LibLaserCut. If not, see <http://www.gnu.org/licenses/>.
**/
package com.t_oster.liblasercut.drivers;
......@@ -28,13 +28,35 @@ import com.t_oster.liblasercut.LaserProperty;
public class IModelaProperty implements LaserProperty
{
private static String FEED_RATE = "feedRate";
private static String SPINDLE_SPEED = "spindleSpeed";
private static String DEPTH = "milling depth";
private static String FEED_RATE = "feed rate";
private static String SPINDLE_SPEED = "spindle speed";
private static String TOOL = "tool";
private double feedRate = 0;
private double spindleSpeed = 0;
private double depth = 0;
private double feedRate = 1;
private int spindleSpeed = 100;
private int tool = 1;
public double getDepth()
{
return depth;
}
public double getFeedRate()
{
return feedRate;
}
public int getSpindleSpeed()
{
return spindleSpeed;
}
public int getTool()
{
return tool;
}
@Override
public Object getMinimumValue(String name)
......@@ -43,6 +65,10 @@ public class IModelaProperty implements LaserProperty
{
return (Integer) 1;
}
else if (SPINDLE_SPEED.equals(name))
{
return (Integer) 100;
}
else
{
return (Double) 0d;
......@@ -65,24 +91,29 @@ public class IModelaProperty implements LaserProperty
public LaserProperty clone()
{
IModelaProperty result = new IModelaProperty();
result.feedRate = feedRate;
result.spindleSpeed = spindleSpeed;
result.tool = tool;
for (String k : getPropertyKeys())
{
result.setProperty(k, getProperty(k));
}
return result;
}
@Override
public String[] getPropertyKeys()
{
return new String[]{SPINDLE_SPEED,FEED_RATE,TOOL};
return new String[]{DEPTH, SPINDLE_SPEED, FEED_RATE, TOOL};
}
@Override
public void setProperty(String key, Object value)
{
if (SPINDLE_SPEED.equals(key))
if (DEPTH.equals(key))
{
depth = (Double) value;
}
else if (SPINDLE_SPEED.equals(key))
{
spindleSpeed = (Double) value;
spindleSpeed = (Integer) value;
}
else if (FEED_RATE.equals(key))
{
......@@ -97,7 +128,11 @@ public class IModelaProperty implements LaserProperty
@Override
public Object getProperty(String key)
{
if (SPINDLE_SPEED.equals(key))
if (DEPTH.equals(key))
{
return depth;
}
else if (SPINDLE_SPEED.equals(key))
{
return spindleSpeed;
}
......
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