Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* This file is part of VisiCut. Copyright (C) 2012 Thomas Oster
* <thomas.oster@rwth-aachen.de> RWTH Aachen University - 52062 Aachen, Germany
*
* VisiCut 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, 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/>.
*
*/
package com.t_oster.liblasercut.drivers;
import com.t_oster.liblasercut.*;
import java.io.BufferedOutputStream;
import java.util.*;
import java.lang.System;
/**
* This class implements a driver for the LAOS Lasercutter board. Currently it
* supports the simple code and the G-Code, which may be used in the future.
*
* @author Thomas Oster <thomas.oster@rwth-aachen.de>
*/
public class Dummy extends LaserCutter {
private static final String SETTING_BEDWIDTH = "Laserbed width";
private static final String SETTING_BEDHEIGHT = "Laserbed height";
@Override
public String getModelName() {
return "Dummy";
}
@Override
public void sendJob(LaserJob job, ProgressListener pl) throws IllegalJobException, Exception {
pl.progressChanged(this, 0);
BufferedOutputStream out;
pl.taskChanged(this, "checking job");
checkJob(job);
pl.taskChanged(this, "sending");
pl.taskChanged(this, "sent.");
System.out.println("dummy-driver got LaserJob: ");
for (JobPart p : job.getParts())
{
if (p instanceof VectorPart)
{
System.out.println("VectorPart");
for (VectorCommand cmd : ((VectorPart) p).getCommandList())
{
if (cmd.getType() == VectorCommand.CmdType.SETPROPERTY)
{
if (!(cmd.getProperty() instanceof PowerSpeedFocusFrequencyProperty))
{
throw new IllegalJobException("This driver expects Power,Speed,Frequency and Focus as settings");
}
System.out.println(((PowerSpeedFocusFrequencyProperty) cmd.getProperty()).toString());
}
}
}
if (p instanceof RasterPart)
{
RasterPart rp = ((RasterPart) p);
if (rp.getLaserProperty() != null && !(rp.getLaserProperty() instanceof PowerSpeedFocusProperty))
{
throw new IllegalJobException("This driver expects Power,Speed and Focus as settings");
}
System.out.println(((PowerSpeedFocusProperty) rp.getLaserProperty()).toString());
}
if (p instanceof Raster3dPart)
{
Raster3dPart rp = (Raster3dPart) p;
if (rp.getLaserProperty() != null && !(rp.getLaserProperty() instanceof PowerSpeedFocusProperty))
{
throw new IllegalJobException("This driver expects Power,Speed and Focus as settings");
}
System.out.println(((PowerSpeedFocusProperty) rp.getLaserProperty()).toString());
}
}
System.out.println("end of job.");
pl.progressChanged(this, 100);
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
}
@Override
public int estimateJobDuration(LaserJob job)
{
return 1234;
}
private List<Double> resolutions;
@Override
public boolean canEstimateJobDuration() {
return true;
}
@Override
public List<Double> getResolutions() {
if (resolutions == null) {
resolutions = Arrays.asList(new Double[]{
500d
});
}
return resolutions;
}
protected double bedWidth = 250;
/**
* Get the value of bedWidth
*
* @return the value of bedWidth
*/
@Override
public double getBedWidth() {
return bedWidth;
}
/**
* Set the value of bedWidth
*
* @param bedWidth new value of bedWidth
*/
public void setBedWidth(double bedWidth) {
this.bedWidth = bedWidth;
}
protected double bedHeight = 280;
/**
* Get the value of bedHeight
*
* @return the value of bedHeight
*/
@Override
public double getBedHeight() {
return bedHeight;
}
/**
* Set the value of bedHeight
*
* @param bedHeight new value of bedHeight
*/
public void setBedHeight(double bedHeight) {
this.bedHeight = bedHeight;
}
private static String[] settingAttributes = new String[]{
SETTING_BEDWIDTH,
SETTING_BEDHEIGHT
};
@Override
public String[] getPropertyKeys() {
return settingAttributes;
}
@Override
public Object getProperty(String attribute) {
if (SETTING_BEDWIDTH.equals(attribute)) {
return this.getBedWidth();
} else if (SETTING_BEDHEIGHT.equals(attribute)) {
return this.getBedHeight();
}
return null;
}
@Override
public void setProperty(String attribute, Object value) {
if (SETTING_BEDWIDTH.equals(attribute)) {
this.setBedWidth((Double) value);
} else if (SETTING_BEDHEIGHT.equals(attribute)) {
this.setBedHeight((Double) value);
}
}
@Override
public LaserCutter clone() {
Dummy clone = new Dummy();
clone.bedHeight = bedHeight;
clone.bedWidth = bedWidth;
return clone;
}
}