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

import org.reprap.Preferences;
import org.reprap.Printer;
import org.reprap.ReprapException;

/**
 * Returns an appropriate Printer object based on the current properties
 */
public class MachineFactory {

	/**
	 * 
	 */
	private MachineFactory() {
	}
	
	/**
	 * Currently this just always assumes we're building
	 * a 3-axis cartesian printer.  It should build an
	 * appropriate type based on the local configuration.
	 * @return new machine
	 * @throws Exception
	 */
	static public Printer create() throws Exception {
		
		
		Preferences prefs = Preferences.getGlobalPreferences();

		String geometry = prefs.loadString("Geometry");
		
		if (geometry.compareToIgnoreCase("cartesian") == 0)
		  	return new CartesianSNAP(prefs);
		else if (geometry.compareToIgnoreCase("gcodewriter") == 0)
		  	return new CartesianGCode(prefs);
		else if (geometry.compareToIgnoreCase("nullcartesian") == 0)
		    return new NullCartesianMachine(prefs);		
		else
			throw new ReprapException("Invalid geometry in properties file");
		
	}
	
}