summaryrefslogtreecommitdiff
path: root/trunk/users/adrian/host/src/org/reprap/machines/Simulator.java
blob: 502e425de4d8f9b1851e67bb424b3810e4fffc5e (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
package org.reprap.machines;

import java.io.IOException;

import org.reprap.Extruder;
import org.reprap.devices.NullStepperMotor;
import org.reprap.devices.NullExtruder;

/**
 *
 */
public class Simulator extends GenericRepRap {
	
	/**
	 * @param config
	 */
	public Simulator() throws Exception {
		super();
	}
	
	public void loadMotors()
	{
		motorX = new NullStepperMotor(1);
		motorY = new NullStepperMotor(2);
		motorZ = new NullStepperMotor(3);
	}
	
	public Extruder extruderFactory(int count)
	{
		return new NullExtruder(count, this);
	}
	
	public void startRun()
	{
		
	}
	
	/**
	 * Go to the purge point
	 */
	public void moveToPurge()
	{
		singleMove(dumpX, dumpY, currentZ, getExtruder().getFastXYFeedrate());
	}
	
	public void waitTillNotBusy() throws IOException {}
	public void finishedLayer(int layerNumber) throws Exception {}
	public void betweenLayers(int layerNumber) throws Exception{}
	public void startingLayer(int layerNumber) throws Exception {}

	public void printTo(double x, double y, double z, double feedRate, boolean stopExtruder, boolean closeValve) 
	{
		//if (previewer != null)
		//	previewer.addSegment(currentX, currentY, currentZ, x, y, z);
		if (isCancelled())
			return;

		double distance = segmentLength(x - currentX, y - currentY);
		if (z != currentZ)
			distance += Math.abs(currentZ - z);

		totalDistanceExtruded += distance;
		totalDistanceMoved += distance;
		currentX = x;
		currentY = y;
		currentZ = z;
	}
	
	public void delay(long millis) {}
	
	//TODO: make this work normally.
	public void stopValve() throws IOException
	{
	}
	
	//TODO: make this work normally.
	public void stopMotor() throws IOException
	{
	}
	
	/**
	 * 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.
	 * 
	 * Here do no delay; it makes no sense for the simulation machine
	 * @param milliseconds
	 */
	public void machineWait(double milliseconds)
	{
	}
	
	public void waitWhileBufferNotEmpty()
	{
	}
	
	public void slowBuffer()
	{
	}
	
	public void speedBuffer()
	{
	}
	
	/**
	 * Load a GCode file to be made.
	 * @return the name of the file
	 */
	public String loadGCodeFileForMaking()
	{
		System.err.println("Simulator: attempt to load GCode file.");
		//super.loadGCodeFileForMaking();
		return null;
	}
	
	/**
	 * Set an output file
	 * @return
	 */
	public String setGCodeFileForOutput(String fileRoot)
	{
		System.err.println("Simulator: cannot generate GCode file.");
		return null;		
	}
	
	public boolean filePlay()
	{
		return false;
	}
}