summaryrefslogtreecommitdiff
path: root/trunk/users/hoeken/gcode-host-old/src/org/reprap/devices/GCodeExtruder.java
blob: ddfa397d698a9f70a2377079f507e4c6537e96dc (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
package org.reprap.devices;

import java.io.IOException;
import org.reprap.Device;
import org.reprap.Extruder;
import org.reprap.Preferences;
import org.reprap.ReprapException;
import org.reprap.utilities.Debug;

import javax.media.j3d.Appearance;
import javax.vecmath.Color3f;
import javax.media.j3d.Material;
import org.reprap.comms.GCodeWriter;


public class GCodeExtruder extends GenericExtruder
{
	GCodeWriter gcode;
	
	int currentSpeed = 0;
	
	/**
	 * @param prefs
	 * @param extruderId
	 */
	public GCodeExtruder(GCodeWriter writer, Preferences prefs, int extruderId)
	{
		super(prefs, extruderId);

		gcode = writer;
		isCommsAvailable = true;
	}
	
	public void setTemperature(double temperature) throws Exception
	{
		gcode.queue("M104 S" + temperature);
	}
	
	public void setExtrusion(int speed, boolean reverse) throws IOException
	{
		if (speed == 0)
			gcode.queue("M103");
		else
		{
			if (speed != currentSpeed)
			{
				gcode.queue("M108 R" + speed);
				currentSpeed = speed;
			}
			if (reverse)
				gcode.queue("M102");
			else
				gcode.queue("M101");
		}
	}
	
	public void setCooler(boolean f) throws IOException
	{
		if (f)
			gcode.queue("M106");
		else
			gcode.queue("M107");
	}
	
	public boolean isEmpty()
	{
		return false;
	} 
}