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
|
package org.reprap.devices;
import java.io.IOException;
import org.reprap.comms.GCodeReaderAndWriter;
import org.reprap.Printer;
import org.reprap.Preferences;
public class GCodeExtruder extends GenericExtruder
{
GCodeReaderAndWriter gcode;
/**
* @param prefs
* @param extruderId
*/
public GCodeExtruder(GCodeReaderAndWriter writer, int extruderId, Printer p)
{
super(extruderId, p);
es.setSpeed(0);
gcode = writer;
}
/**
* Zero the extruded length
*
*/
public void zeroExtrudedLength()
{
if(es.length() > 0)
{
super.zeroExtrudedLength();
gcode.queue("G92 E0 ;zero the extruded length");
}
}
/**
* Purge the extruder
*/
public void purge()
{
if(purgeTime <= 0)
return;
getPrinter().moveToPurge();
try
{
heatOn(true);
setExtrusion(getFastXYFeedrate(), false);
getPrinter().machineWait(purgeTime);
setExtrusion(0, false);
} catch (Exception e)
{}
getPrinter().home();
zeroExtrudedLength();
}
public void setTemperature(double temperature, boolean wait) throws Exception
{
if(wait)
gcode.queue("M109 S" + temperature + " ;set temperature and wait");
else
gcode.queue("M104 S" + temperature + " ;set temperature and return");
super.setTemperature(temperature, wait);
}
public void setHeater(int heat, double maxTemp) {}
public double getTemperature()
{
es.setCurrentTemperature(Double.parseDouble(gcode.queueRespond("M105; get temperature").substring(2))); // Throw away "T:"
return es.currentTemperature();
}
public void setExtrusion(double speed, boolean reverse) throws IOException
{
if(getExtruderSpeed() < 0)
return;
if (speed < Preferences.tiny())
{
if(!fiveD)
gcode.queue("M103" + " ;extruder off");
} else
{
if(!fiveD)
{
if (speed != es.speed())
gcode.queue("M108 S" + speed + " ;extruder speed in RPM");
if (es.reverse())
gcode.queue("M102" + " ;extruder on, reverse");
else
gcode.queue("M101" + " ;extruder on, forward");
}
}
super.setExtrusion(speed, reverse);
}
//TODO: make these real G codes.
public void setCooler(boolean coolerOn) throws IOException
{
if (coolerOn)
gcode.queue("M106 ;cooler on");
else
gcode.queue("M107 ;cooler off");
}
public void setValve(boolean valveOpen) throws IOException
{
if(valvePulseTime <= 0)
return;
if (valveOpen)
gcode.queue("M126 P" + valvePulseTime + ";valve open");
else
gcode.queue("M127 P" + valvePulseTime + ";valve closed");
}
public boolean isEmpty()
{
return false;
}
}
|