Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New driver for "Ruida" class lasercutters, like ThunderLaser #180

Merged
merged 27 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fe58e10
New driver: Ruida
kkaempf May 21, 2022
575b908
New property classes for Ruida
kkaempf May 21, 2022
95b16e2
Replace lookup table with calculation
kkaempf May 25, 2022
a1ccf23
Fix network output
kkaempf May 25, 2022
d5b5103
Convert I/O to GenericGcodeDriver example
kkaempf Aug 31, 2022
1daad63
fix in.read call
kkaempf Aug 31, 2022
2e5a279
Add test output for Ruida
kkaempf Sep 14, 2022
86bda72
drop empty catch
kkaempf Sep 14, 2022
92a7eec
drop empty catch
kkaempf Sep 14, 2022
8f17673
Prefer instanceof to getClass when implementing Object#equals.
kkaempf Sep 14, 2022
6cacc2d
fix comment
kkaempf Sep 14, 2022
3fa9e7b
drop unused function mm2focus
kkaempf Sep 14, 2022
e801227
comment out unused class variables
kkaempf Sep 14, 2022
0b21573
there's only one Property type
kkaempf Sep 14, 2022
b57d900
fix Ruida network output
kkaempf Sep 14, 2022
23a5417
pass charset to InputStreamReader constructor
kkaempf Sep 14, 2022
01023fd
fix empty @return comments
kkaempf Sep 14, 2022
5e19133
fill empty @throws comment
kkaempf Sep 14, 2022
a4113cc
drop unused outputBuffer
kkaempf Sep 14, 2022
8b6a875
remove left over wait loop after serial connect
kkaempf Sep 14, 2022
c4171e7
remove unused focus2mm()
kkaempf Sep 14, 2022
8d6c672
add transient, no job estimation possible
kkaempf Sep 14, 2022
516c293
remove unused private variables
kkaempf Sep 16, 2022
76e5f94
more unused private variables removed
kkaempf Sep 16, 2022
9a95367
make 'ByteStream stream' transient
kkaempf Sep 21, 2022
1a1baa5
remove unused FOCUSWIDTH
kkaempf Sep 21, 2022
0dae000
Properly throw IOException from UdpStream
kkaempf Sep 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
/**
* This file is part of LibLaserCut.
* Copyright (C) 2011 - 2014 Thomas Oster <mail@thomas-oster.de>
* Copyright (C) 2018 - 2020 Klaus Kämpf <kkaempf@suse.de>
*
* 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 de.thomas_oster.liblasercut.drivers;

import de.thomas_oster.liblasercut.LaserProperty;
import de.thomas_oster.liblasercut.FloatPowerSpeedFrequencyProperty;
import java.util.Arrays;
import java.util.LinkedList;

/*
* Add 'min power' to FloatPowerSpeedFrequencyProperty
*/

public class FloatMinMaxPowerSpeedFrequencyProperty extends FloatPowerSpeedFrequencyProperty {

private float min_power = 10.0f;
private static final String MIN_POWER = "min power";

public FloatMinMaxPowerSpeedFrequencyProperty()
{
super();
}

public FloatMinMaxPowerSpeedFrequencyProperty(LaserProperty o)
{
for (String k : o.getPropertyKeys())
{
Object p;
p = o.getProperty(k);
if (p != null) {
this.setProperty(k, p);
}
}
}

/**
* Get the value of min power
*
* @return float
*/
public float getMinPower()
{
return min_power;
}

/**
* Set the value of min power
*
* @param min power
kkaempf marked this conversation as resolved.
Show resolved Hide resolved
*/
public void setMinPower(float power)
{
if (power > this.getPower()) { /* minimum must not be larger than maximum */
power = this.getPower();
}
this.min_power = power;
}

@Override
public String[] getPropertyKeys()
{
LinkedList<String> result = new LinkedList<String>();
kkaempf marked this conversation as resolved.
Show resolved Hide resolved
result.add(MIN_POWER);
result.addAll(Arrays.asList(super.getPropertyKeys()));
return result.toArray(new String[0]);
}

@Override
public Object getProperty(String name)
{
if (MIN_POWER.equals(name)) {
return (Float) this.getMinPower();
}
else {
return super.getProperty(name);
}
}

@Override
public Object getMinimumValue(String name)
{
if (MIN_POWER.equals(name)) {
return 0f;
}
else {
return super.getProperty(name);
}
}

@Override
public Object getMaximumValue(String name)
{
if (MIN_POWER.equals(name)) {
return 100f;
}
else {
return super.getProperty(name);
}
}

@Override
public void setProperty(String name, Object value)
{
if (MIN_POWER.equals(name)) {
this.setMinPower((Float) value);
}
else {
super.setProperty(name, value);
}
}

@Override
public FloatMinMaxPowerSpeedFrequencyProperty clone()
{
FloatMinMaxPowerSpeedFrequencyProperty result = new FloatMinMaxPowerSpeedFrequencyProperty();
Object p;
for (String s:this.getPropertyKeys())
{
p = this.getProperty(s);
if (p != null) {
result.setProperty(s, p);
}
}
return result;
}

@Override
public boolean equals(Object obj) {
kkaempf marked this conversation as resolved.
Show resolved Hide resolved
if (obj == null) {
return false;
}
if (!(obj instanceof FloatMinMaxPowerSpeedFrequencyProperty)) {
return false;
}
final FloatMinMaxPowerSpeedFrequencyProperty other = (FloatMinMaxPowerSpeedFrequencyProperty) obj;
if (this.min_power != other.min_power) {
return false;
}
return super.equals(other);
}

@Override
public int hashCode() {
int hash = 5;
hash = 97 * hash + (int)min_power;
hash = 97 * hash + super.hashCode();
return hash;
}

public String toString()
{
return "FloatMinMaxPowerSpeedFrequencyProperty(min power="+getMinPower()+", max power="+getPower()+", speed="+getSpeed()+", frequency="+getFrequency()+")";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
/*
This file is part of LibLaserCut.
Copyright (C) 2011 - 2014 Thomas Oster <mail@thomas-oster.de>

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 de.thomas_oster.liblasercut;

/**
* The LaserProperty holds all the parameters for parts of the LaserJob.
* The Frequency value is ignored for Engraving operations
*
* @author oster
*/
public class FloatPowerSpeedFrequencyProperty implements LaserProperty
{

private float power = 0;
private float speed = 100;
private int frequency = 500;

public FloatPowerSpeedFrequencyProperty()
{
}

/**
* Sets the Laserpower. Valid values are from 0 to 100.
* In 3d-Raster mode, the intensity is scaled to this power setting
*/
@Override
public void setPower(float power)
{
power = power < 0 ? 0 : power;
power = power > 100 ? 100 : power;
this.power = power;
}

@Override
public float getPower()
{
return power;
}

/**
* Sets the speed for the Laser. Valid values is from 0 to 100
*/
public void setSpeed(float speed)
{
speed = speed < 0 ? 0 : speed;
speed = speed > 100 ? 100 : speed;
this.speed = speed;
}

@Override
public float getSpeed()
{
return speed;
}

public void setFrequency(int f)
{
this.frequency = f;
}

public int getFrequency()
{
return this.frequency;
}

@Override
public FloatPowerSpeedFrequencyProperty clone()
{
FloatPowerSpeedFrequencyProperty p = new FloatPowerSpeedFrequencyProperty();
p.frequency = frequency;
p.power = power;
p.speed = speed;
return p;
}

private static final String[] propertyNames = new String[]{"power", "speed", "frequency"};

@Override
public String[] getPropertyKeys()
{
return propertyNames;
}

@Override
public Object getProperty(String name)
{
if ("power".equals(name))
{
return this.getPower();
}
else if ("speed".equals(name))
{
return this.getSpeed();
}
else if ("frequency".equals(name))
{
return this.getFrequency();
}
return null;
}

@Override
public void setProperty(String name, Object value)
{
if ("power".equals(name))
{
this.setPower((Float) value);
}
else if ("speed".equals(name))
{
this.setSpeed((Float) value);
}
else if ("frequency".equals(name))
{
this.setFrequency((Integer) value);
}
else
{
throw new IllegalArgumentException("Unknown setting '"+name+"'");
}
}

@Override
public Object getMinimumValue(String name)
{
if ("power".equals(name))
{
return 0f;
}
else if ("speed".equals(name))
{
return 0f;
}
else if ("frequency".equals(name))
{
return null;
}
else
{
throw new IllegalArgumentException("Unknown setting '"+name+"'");
}
}

@Override
public Object getMaximumValue(String name)
{
if ("power".equals(name))
{
return 100f;
}
else if ("speed".equals(name))
{
return 100f;
}
else if ("frequency".equals(name))
{
return null;
}
else
{
throw new IllegalArgumentException("Unknown setting '"+name+"'");
}
}

@Override
public Object[] getPossibleValues(String name)
{
return null;
}

@Override
public boolean equals(Object obj) {
kkaempf marked this conversation as resolved.
Show resolved Hide resolved
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final FloatPowerSpeedFrequencyProperty other = (FloatPowerSpeedFrequencyProperty) obj;
if (Float.floatToIntBits(this.power) != Float.floatToIntBits(other.power)) {
return false;
}
if (Float.floatToIntBits(this.speed) != Float.floatToIntBits(other.speed)) {
return false;
}
return this.frequency == other.frequency;
}

@Override
public int hashCode() {
int hash = 7;
hash = 67 * hash + Float.floatToIntBits(this.power);
hash = 67 * hash + Float.floatToIntBits(this.speed);
hash = 67 * hash + this.frequency;
return hash;
}


}
3 changes: 2 additions & 1 deletion src/main/java/de/thomas_oster/liblasercut/LibInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public static List<Class<? extends LaserCutter>> getSupportedDrivers()
FullSpectrumCutter.class,
LaserToolsTechnicsCutter.class,
K40NanoDriver.class,
K3EngraverDriver.class
K3EngraverDriver.class,
Ruida.class
);
}
}
Loading