summaryrefslogtreecommitdiff
path: root/trunk/users/adrian/host/src/org/reprap/machines/MachineFactory.java
blob: 36c0c8e0c7483ee3632e76faaf03252446f59994 (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
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
	{
		String machine = Preferences.loadGlobalString("RepRap_Machine");

		if (machine.compareToIgnoreCase("SNAPRepRap") == 0)
		  	return new SNAPReprap();
		if (machine.compareToIgnoreCase("GCodeRepRap") == 0)
		  	return new GCodeRepRap();
		else if (machine.compareToIgnoreCase("simulator") == 0)
		    return new Simulator();		
		else
			throw new ReprapException("Invalid RepRap machine in properties file: " + machine);
	}
	
}