/
Driver.java
323 lines (234 loc) · 8.37 KB
/
Driver.java
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
87
88
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
/*
Driver.java
Provides an interface for driving various machines.
Part of the ReplicatorG project - http://www.replicat.org
Copyright (c) 2008 Zach Smith
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package replicatorg.drivers;
import java.util.EnumSet;
import javax.vecmath.Point3d;
import org.w3c.dom.Node;
import replicatorg.app.GCodeParser;
import replicatorg.app.exceptions.BuildFailureException;
import replicatorg.app.exceptions.GCodeException;
import replicatorg.machine.model.Axis;
import replicatorg.machine.model.MachineModel;
// import org.xml.sax.*;
// import org.xml.sax.helpers.XMLReaderFactory;
public interface Driver {
/**
* High level functions
*/
/**
* parse and load configuration data from XML
*/
public void loadXML(Node xml);
/**
* parse a command. usually passes it through to the parser.
*/
public void parse(String cmd);
/**
* get our parser object
*/
public GCodeParser getParser();
/**
* are we finished with the last command?
*/
public boolean isFinished();
/**
* Is our buffer empty? If don't have a buffer, its always true.
*/
public boolean isBufferEmpty();
/**
* Wait until we've finished all commands.
*/
public void waitUntilBufferEmpty();
/**
* do we have any errors? this method handles them.
*/
public void checkErrors() throws BuildFailureException;
/**
* setup our driver for use.
*/
public void initialize() throws VersionException;
/**
* See if the driver has been successfully initialized.
*
* @return true if the driver is initialized
*/
public boolean isInitialized();
/**
* clean up the driver
*/
public void dispose();
/***************************************************************************
* Machine interface functions
**************************************************************************/
public MachineModel getMachine();
public void setMachine(MachineModel m);
/**
* execute the recently parsed GCode
*
* @throws InterruptedException
*/
public void execute() throws GCodeException, InterruptedException;
/**
* get version information from the driver
*/
public String getDriverName(); // A human-readable name for the machine
// type
public String getFirmwareInfo();
public Version getVersion();
public Version getMinimumVersion();
public Version getPreferredVersion();
/**
* Positioning Methods
*/
/**
* Tell the machine to consider its current position as being at p. Should
* not move the machine position.
*
* @param p
* the point to map the current position to
*/
public void setCurrentPosition(Point3d p);
public Point3d getCurrentPosition();
/**
* Indicate that the currently maintained position may no longer be the machine's position,
* and that the machine should be queried for its actual location.
*/
void invalidatePosition();
/**
* Queue the next point to move to.
* @param p The location to move to, in mm.
*/
public void queuePoint(Point3d p);
public Point3d getOffset(int i);
public Point3d getPosition();
/**
* Tool methods
*/
public void requestToolChange(int toolIndex);
public void selectTool(int toolIndex);
/**
* sets the feedrate in mm/minute
*/
public void setFeedrate(double feed);
/**
* sets the feedrate in mm/minute
*/
public double getCurrentFeedrate();
/**
* Home the given set of axes at the given feedrate. If the feedrate is <=0, run at
* maximum feedrate for the appropriate axes.
*/
public void homeAxes(EnumSet<Axis> axes, boolean positive, double feedrate);
/**
* delay / pause function
*/
public void delay(long millis);
/**
* functions for dealing with clamps
*/
public void openClamp(int clampIndex);
public void closeClamp(int clampIndex);
/**
* enabling/disabling our drivers (steppers, servos, etc.)
*/
public void enableDrives();
public void disableDrives();
/**
* change our gear ratio
*/
public void changeGearRatio(int ratioIndex);
/***************************************************************************
* Motor interface functions
**************************************************************************/
public void setMotorDirection(int dir);
public void setMotorRPM(double rpm);
public void setMotorSpeedPWM(int pwm);
public double getMotorRPM();
public int getMotorSpeedPWM();
public void enableMotor();
public void disableMotor();
/***************************************************************************
* Spindle interface functions
**************************************************************************/
public void setSpindleRPM(double rpm);
public void setSpindleSpeedPWM(int pwm);
public void setSpindleDirection(int dir);
public double getSpindleRPM();
public int getSpindleSpeedPWM();
public void enableSpindle();
public void disableSpindle();
/***************************************************************************
* Temperature interface functions
**************************************************************************/
public void setTemperature(double temperature);
public void readTemperature();
public double getTemperature();
public double getTemperatureSetting();
/***************************************************************************
* Platform Temperature interface functions
**************************************************************************/
public void setPlatformTemperature(double temperature);
public void readPlatformTemperature();
public double getPlatformTemperature();
public double getPlatformTemperatureSetting();
/***************************************************************************
* Build chamber interface functions
**************************************************************************/
public void setChamberTemperature(double temperature);
public void readChamberTemperature();
public double getChamberTemperature();
/***************************************************************************
* Flood Coolant interface functions
**************************************************************************/
public void enableFloodCoolant();
public void disableFloodCoolant();
/***************************************************************************
* Mist Coolant interface functions
**************************************************************************/
public void enableMistCoolant();
public void disableMistCoolant();
/***************************************************************************
* Fan interface functions
**************************************************************************/
public void enableFan();
public void disableFan();
/***************************************************************************
* Valve interface functions
**************************************************************************/
public void openValve();
public void closeValve();
/***************************************************************************
* Collet interface functions
**************************************************************************/
public void openCollet();
public void closeCollet();
/***************************************************************************
* Pause/unpause functionality for asynchronous devices
**************************************************************************/
public void pause();
public void unpause();
/***************************************************************************
* Stop and system state reset
**************************************************************************/
public void stop();
public void reset();
/***************************************************************************
* Heartbeat
**************************************************************************/
public boolean heartbeat();
}