summaryrefslogtreecommitdiff
path: root/trunk/software/host/src/org/reprap/Printer.java
blob: c019e4d657175c62f7141d506bdb6c83f2547df8 (plain)
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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
package org.reprap;

import java.io.IOException;

import javax.swing.JCheckBoxMenuItem;
import org.reprap.geometry.LayerRules;
import org.reprap.devices.GenericStepperMotor;

public interface Printer {
	
	/**
	 * (Re)load the preferences
	 *
	 */
	public void refreshPreferences();

	/**
	 * Method to calibrate the printer.
	 */
	public void calibrate();

//	public void printSegment(double startX, double startY,
//			double startZ, double endX, double endY, double endZ) throws ReprapException, IOException;
	
	
	/**
	 * Move the printer carriage to the give x, y and z position <b>while extruding material<b>
	 * 
	 * @param x absolute x position in millimeters relative to the home position. 
	 * Range between [0..???]
	 * @param y absolute y position in millimters relative to the home position. 
	 * Range betwen [0..???]
	 * @param z absolute z position in millimters relative to the home position.
	 * Range between [0..???]
	 * @param startUp ?
	 * @param endUp ?
	 * @throws ReprapException
	 * @throws IOException 
	 * @throws Exception 
	 */
	public void moveTo(double x, double y, double z, double feedrate, boolean startUp, boolean endUp) throws ReprapException, IOException, Exception;
	
	/**
	 * Single move for when we're moving about giong places rather than making
	 * @param x
	 * @param y
	 * @param z
	 * @param feedrate
	 */
	public void singleMove(double x, double y, double z, double feedrate);
	
	/**
	 * Move the printer carriage to the give x, y and z position <b>while extruding material<b>
	 * 
	 * @param x absolute x position in millimeters relative to the home position. 
	 * Range between [0..???]
	 * @param y absolute y position in millimters relative to the home position. 
	 * Range betwen [0..???]
	 * @param z absolute z position in millimters relative to the home position.
	 * Range between [0..???]
	 * @param lastOne True if extruder should be turned off at end of this segment.
	 * @throws ReprapException
	 * @throws IOException 
	 * @throws Exception 
	 */
	public void printTo(double x, double y, double z, double feedrate, boolean stopExtruder, boolean closeValve) throws ReprapException, IOException, Exception;
	
	/**
	 * Get the feedrate currently being used
	 * @return
	 */
	public double getCurrentFeedrate();
	
	/**
	 * Fire up the extruder for a lead-in
	 * @param firstOneInLayer (first after the layer pause, or any old polygon?)
	 */
	public void printStartDelay(boolean firstOneInLayer);	
	
	/**
	 * Maybe reverse the extruder at the end of a track
	 */
	public void printEndReverse();
	
	/**
	 * Home all axes
	 * @throws Exception 
	 *
	 */
	public void home() throws Exception;
	
	/**
	 * Sync to zero X location.
	 * @throws ReprapException
	 * @throws IOException
	 * @throws Exception 
	 */
	public void homeToZeroX() throws ReprapException, IOException, Exception;
	
	/**
	 * Sync to zero Y location.
	 * @throws ReprapException
	 * @throws IOException
	 * @throws Exception 
	 */
	public void homeToZeroY() throws ReprapException, IOException, Exception; 
	
	
	/**
	 * Home XY and zero all extruders
	 * @throws ReprapException
	 * @throws IOException
	 * @throws Exception 
	 */
	public void homeToZeroXYE() throws ReprapException, IOException, Exception; 
	
	/**
	 * Sync to zero Z location.
	 * @throws ReprapException
	 * @throws IOException
	 * @throws Exception 
	 */
	public void homeToZeroZ() throws ReprapException, IOException, Exception; 
	
	/**
	 * Select a specific material to print with
	 * @param attributes with name of the material
	 * @throws Exception 
	 */
	public void selectExtruder(Attributes att) throws Exception;
	
	/**
	 * Select a specific material to print with
	 * @param extr identifier of the material
	 * @throws Exception 
	 */
	public void selectExtruder(int extr) throws Exception;
	
	/**
	 * Start a production run (as opposed to moving the machine about
	 * interactively, for example).
	 */
	public void startRun(LayerRules lc) throws Exception;
	
	/**
	 * Indicates end of job, homes extruder, powers down etc
	 * @throws Exception
	 */
	public void terminate() throws Exception;
	
	/**
	 * Dispose of the printer
	 */
	public void dispose();
	
	
	/**
	 * @param feedrate in mm/minute
	 */
	//public void setFeedrate(double feedrate);
	
	/**
	 * @param feedrate in mm/minute
	 */
//	public void setFastFeedrateXY(double feedrate);
	
	/**
	 * @return fast XY movement feedrate in mm/minute
	 */
	public double getFastXYFeedrate();
	
	/**
	 * @return slow XY movement feedrate in mm/minute
	 */
	public double getSlowXYFeedrate();
	
	/**
	 * @return slow Z movement feedrate in mm/minute
	 */
	public double getSlowZFeedrate();	
	
	/**
	 * @return the fastest the machine can accelerate
	 */
	public double getMaxXYAcceleration();
	
	/**
	 * @return the fastest the machine can accelerate
	 */
	public double getMaxZAcceleration();
	
	/**
	 * @param feedrate in mm/minute
	 */
	//public void setFastFeedrateZ(double feedrate);
	
	/**
	 * @return the extruder feedrate in mm/minute
	 */
	public double getFastFeedrateZ();
	
	/**
	 * The location of the dump for purging extruders
	 * @return
	 */
	public double getDumpX();
	public double getDumpY();
	
	/**
	 * The location to go to at the end
	 * @return
	 */
	public double getFinishX();
	public double getFinishY();
	
	/**
	 * Move to the purge point
	 *
	 */
	public void moveToPurge();
	
	/**
	 * @param previewer
	 */
	//public void setPreviewer(Previewer previewer);
	
	/**
	 * @return is cancelled when ...?
	 */
	public boolean isCancelled();
	
//	/**
//	 * @throws Exception
//	 */
//	public void initialise() throws Exception;
	
	/**
	 * @return current X position
	 */
	public double getX();
	
	/**
	 * @return current Y position
	 */
	public double getY();
	
	/**
	 * @return current Z position
	 */
	public double getZ();
	
	/**
	 * Get X, Y, Z and E (if supported) coordinates in an array
	 * @return
	 * @throws Exception 
	 */
	public double[] getCoordinates() throws Exception;
	
	/**
	 * Tell the printer class it's Z position.  Only to be used if
	 * you know what you're doing...
	 * @param z
	 */
	public void setZ(double z);
	
	/**
	 * Set the position at the end of the topmost layer
	 * @param x
	 * @param y
	 * @param z
	 */
	public void setTop(double x, double y, double z);
	
	/**
	 * The next time an extruder is changed, force the change to be
	 * sent to the RepRap, even if it's changed to the same as it just was.
	 */
	public void forceNextExtruder();

	/**
	 * @return the extruder currently in use
	 */
	public Extruder getExtruder();
	
	/**
	 * @return the index of the extruder currently in use
	 */
	public int getExtruderNumber();
	
	/**
	 * @param name
	 * @return the extruder for the material called name; null if not found.
	 */
	public Extruder getExtruder(String name);
	
	/**
	 * Get the list of all the extruders
	 * @return
	 */
	public Extruder[] getExtruders();
	
	/**
	 * Stop the extrude motor (if any)
	 * @throws IOException
	 * @throws Exception 
	 */
	public void stopMotor() throws IOException, Exception;
	
	/**
	 * Close the extrude valve (if any)
	 * @throws IOException
	 * @throws Exception 
	 */
	public void stopValve() throws IOException, Exception;

	/**
	 * Allow the user to manually calibrate the Z axis position to deal
	 * with special circumstances like different extruder sizes, platform
	 * additions or subtractive fabrication.
	 * 
	 * @throws IOException
	 */
	public void setZManual() throws IOException;

	/**
	 * Allow the user to manually calibrate the Z axis position to deal
	 * with special circumstances like different extruder sizes, platform
	 * additions or subtractive fabrication.
	 * 
	 * @param zeroPoint The point the user selects will be treated as the
	 * given Z value rather than 0.0 
	 */
	public void setZManual(double zeroPoint) throws IOException;
	
	/**
	 * Get the total distance moved (whether extruding or not)
	 * @return a double representing the distance travelled (mm)
	 */
	public double getTotalDistanceMoved();
	
	/**
	 * Get the total distance moved while extruding
	 * @return a double representing the distance travelled (mm)
	 */
	public double getTotalDistanceExtruded();

	/**
	 * @return total time the extruder has been moving in seconds
	 */
	public double getTotalElapsedTime();
	
//	/**
//	 * The bits of the parts made so for for the simulation
//	 * @param ls
//	 */
//	public void setLowerShell(BranchGroup ls);
	
	
	/**
	 * Just finished a layer. Do whatever needs to be done then.
	 * @param layerNumber
	 */
	public void finishedLayer(LayerRules lc) throws Exception;
	
	/**
	 * Do whatever needs to be done between one layer and the next
	 * @param layerNumber
	 */
	public void betweenLayers(LayerRules lc) throws Exception;
	
	/**
	 * Just about to start the next layer
	 * @param layerNumber
	 */
	public void startingLayer(LayerRules lc) throws Exception;
	
	/**
	 * Set the source checkbox used to determine if there should
	 * be a pause between segments.
	 * 
	 * @param segmentPause The source checkbox used to determine
	 * if there should be a pause.  This is a checkbox rather than
	 * a boolean so it can be changed on the fly. 
	 */
	public void setSegmentPause(JCheckBoxMenuItem segmentPause);
	
	/**
	 * Set the source checkbox used to determine if there should
	 * be a pause between layers.
	 * 
	 * @param layerPause The source checkbox used to determine
	 * if there should be a pause.  This is a checkbox rather than
	 * a boolean so it can be changed on the fly.
	 */
	public void setLayerPause(JCheckBoxMenuItem layerPause);
	
	/**
	 * How many layers of foundation to build
	 * @return
	 */
	public int getFoundationLayers();
	
	/**
	 * Tell the printer it's been cancelled
	 * @param c
	 */
	public void setCancelled(boolean c);
	
	/**
	 * Wait while the motors move about
	 * @throws IOException
	 */
	public void waitTillNotBusy() throws IOException;
	
	/**
	 * Get the X stepper
	 * @return
	 */
	public GenericStepperMotor getXMotor();
	
	/**
	 * Get the Y stepper
	 * @return
	 */
	public GenericStepperMotor getYMotor();
	
	/**
	 * Get the Z stepper
	 * @return
	 */
	public GenericStepperMotor getZMotor();
	
//	/**
//	 * Convert XY feedrates in mm/min to internal units
//	 * @param feedrate
//	 * @return
//	 */
//	public int convertFeedrateToSpeedXY(double feedrate);
	
//	/**
//	 * Convert Z feedrates in mm/min to internal units
//	 * @param feedrate
//	 * @return
//	 */	
//	public int convertFeedrateToSpeedZ(double feedrate);
	
	/**
	 * The X discretisation
	 * @return
	 */
	public double getXStepsPerMM();
	
	/**
	 * The Y discretisation
	 * @return
	 */
	public double getYStepsPerMM();
	
	/**
	 * The Z discretisation
	 * @return
	 */
	public double getZStepsPerMM();
	
	/**
	 * If we are using an output buffer, it's a good idea to wait till
	 * it's empty between layers before computing the next one.
	 */
	public void waitWhileBufferNotEmpty();
	
	/**
	 * It's also useful to be able to change its priority
	 *
	 */
	public void slowBuffer();
	public void speedBuffer();
	
	/**
	 * All machine dwells and delays are routed via this function, rather than 
	 * calling Thread.sleep - this allows them to generate the right G codes (G4) etc.
	 * 
	 * The RS232/USB etc comms system doesn't use this - it sets its own delays.
	 * @param milliseconds
	 * @throws Exception 
	 */
	public void machineWait(double milliseconds, boolean fastExtrude) throws Exception;
	
	/**
	 * Load a file to be made.
	 * Currently these can be STLs (more than one can be loaded) or
	 * a GCode file, or an .rfo file.
	 * @return the name of the file
	 */
	public String addSTLFileForMaking();
	public String loadGCodeFileForMaking();
	public String loadRFOFileForMaking();
	public String saveRFOFile(String fileRoot);
	
	/**
	 * Set an output file
	 * @return
	 */
	public String setGCodeFileForOutput(String fileRoot);
	
	/**
	 * If a file replay is being done, do it and return true
	 * otherwise return false.
	 * @return
	 */
	public boolean filePlay();
	
	/**
	 * Stop the printer building.
	 * This _shouldn't_ also stop it being controlled interactively.
	 */
	public void pause();
	
	
	/**
	 * Query the paused status
	 * @return
	 */
	public boolean iAmPaused();
	
	/**
	 * Resume building.
	 *
	 */
	public void resume();
	
	/**
	 * Set the flag that decided which direction to compute the layers
	 * @param td
	 */
	public void setTopDown(boolean td);
	
	/**
	 * @return the flag that decided which direction to compute the layers
	 */
	public boolean getTopDown();
	
	/**
	 * Set all the extruders' separating mode
	 * @param s
	 */
	public void setSeparating(boolean s);
	
	
	/**
	 * Set the bed temperature. This value is given
	 * in centigrade, i.e. 100 equals 100 centigrade. 
	 * @param temperature The temperature of the extruder in centigrade
	 * @param wait - wait till it gets there (or not).
	 * @throws Exception 
	 * @throws Exception
	 */
	public void setBedTemperature(double temperature) throws Exception;
	
	/**
	 * Return the current temperature of the bed
	 * @return
	 * @throws Exception 
	 */
	public double getBedTemperature() throws Exception;
	
	/**
	 * The temperature we want the bed to be at
	 * @return
	 */
	public double getBedTemperatureTarget();
	
	/**
	 * Wait till the entire machine is ready to print.  That is that such things as
	 * extruder and bed temperatures are at the values set and stable.
	 * @throws Exception 
	 */
	public void stabilise() throws Exception;
}