diff options
author | smcauliffe <smcauliffe> | 2006-05-07 09:32:58 +0000 |
---|---|---|
committer | smcauliffe <smcauliffe@cb376a5e-1013-0410-a455-b6b1f9ac8223> | 2006-05-07 09:32:58 +0000 |
commit | 4cc0c90a56c87216ced890a8ae78e5323920e0a6 (patch) | |
tree | 3dc1ef2004a35d4776accb80882414644d5f7970 | |
parent | c7ca2c7be76326c33290080d9cde5b739c5ddc9f (diff) | |
download | reprap-4cc0c90a56c87216ced890a8ae78e5323920e0a6.tar.gz reprap-4cc0c90a56c87216ced890a8ae78e5323920e0a6.zip |
Start of unit testing
git-svn-id: https://reprap.svn.sourceforge.net/svnroot/reprap@281 cb376a5e-1013-0410-a455-b6b1f9ac8223
26 files changed, 364 insertions, 76 deletions
diff --git a/branches/sm-unittesting/TestNG context suite.launch b/branches/sm-unittesting/TestNG context suite.launch new file mode 100644 index 00000000..8808c17c --- /dev/null +++ b/branches/sm-unittesting/TestNG context suite.launch @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<launchConfiguration type="org.testng.eclipse.launchconfig">
+<listAttribute key="org.testng.eclipse.PACKAGE_TEST_LIST"/>
+<listAttribute key="org.testng.eclipse.GROUP_LIST_CLASS"/>
+<listAttribute key="org.testng.eclipse.GROUP_LIST"/>
+<intAttribute key="org.testng.eclipse.TYPE" value="4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.testng.eclipse.runner.RemoteTestNG"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Reprap"/>
+<listAttribute key="org.testng.eclipse.METHOD_TEST_LIST">
+<listEntry value="testPoint"/>
+</listAttribute>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<listAttribute key="org.testng.eclipse.CLASS_TEST_LIST">
+<listEntry value="org.reprap.geometry.polygons.PolygonTest"/>
+</listAttribute>
+<stringAttribute key="org.testng.eclipse.LOG_LEVEL" value="2"/>
+<stringAttribute key="org.testng.eclipse.COMPLIANCE_LEVEL" value="1.4"/>
+</launchConfiguration>
diff --git a/branches/sm-unittesting/tests/Reprap_org.reprap.geometry.polygons.PolygonTest_7ab75393.xml b/branches/sm-unittesting/tests/Reprap_org.reprap.geometry.polygons.PolygonTest_7ab75393.xml new file mode 100644 index 00000000..9b0d4fa5 --- /dev/null +++ b/branches/sm-unittesting/tests/Reprap_org.reprap.geometry.polygons.PolygonTest_7ab75393.xml @@ -0,0 +1,8 @@ +<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> +<suite name="org.reprap.geometry.polygons.PolygonTest"> + <test verbose="2" name="org.reprap.geometry.polygons.PolygonTest" annotations="javadoc"> + <classes> + <class name="org.reprap.geometry.polygons.PolygonTest"/> + </classes> + </test> +</suite> diff --git a/trunk/reprap/host/.settings/org.eclipse.jdt.core.prefs b/trunk/reprap/host/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..9703373e --- /dev/null +++ b/trunk/reprap/host/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,57 @@ +#Sun May 07 00:33:08 NZST 2006
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.3
diff --git a/trunk/reprap/host/.settings/org.eclipse.jdt.ui.prefs b/trunk/reprap/host/.settings/org.eclipse.jdt.ui.prefs index be0618f2..0ab8a5b0 100755 --- a/trunk/reprap/host/.settings/org.eclipse.jdt.ui.prefs +++ b/trunk/reprap/host/.settings/org.eclipse.jdt.ui.prefs @@ -1,3 +1,4 @@ -#Sun Aug 21 21:12:42 NZST 2005 +#Sat May 06 23:51:02 NZST 2006 eclipse.preferences.version=1 formatter_settings_version=8 +internal.default.compliance=default diff --git a/trunk/reprap/host/src/org/reprap/comms/CommsTest.java b/trunk/reprap/host/src/org/reprap/comms/CommsTest.java new file mode 100644 index 00000000..a0a8c9ab --- /dev/null +++ b/trunk/reprap/host/src/org/reprap/comms/CommsTest.java @@ -0,0 +1,19 @@ +package org.reprap.comms;
+
+import org.testng.Assert;
+
+public class CommsTest {
+
+ public void setup() {
+ }
+
+ public void teardown() {
+
+ }
+ /**
+ * @testng.test groups = "comms,all,all-offline"
+ */
+ public void testXXX() {
+
+ }
+}
diff --git a/trunk/reprap/host/src/org/reprap/comms/IncomingMessage.java b/trunk/reprap/host/src/org/reprap/comms/IncomingMessage.java index 4d63bdac..04e6b0bb 100755 --- a/trunk/reprap/host/src/org/reprap/comms/IncomingMessage.java +++ b/trunk/reprap/host/src/org/reprap/comms/IncomingMessage.java @@ -45,14 +45,14 @@ public abstract class IncomingMessage { /** * Called by the framework to provide data to the IncomingMessage. * This should not normally be called by a user. - * @param payload The completed message to insert into the IncomingMessage + * @param payloadData The completed message to insert into the IncomingMessage * @return true is the data was accepted, otherwise false. */ - public boolean receiveData(byte [] payload) { + public boolean receiveData(byte [] payloadData) { // We assume the packet was for us, etc. But we need to // know it contains the correct contents - if (isExpectedPacketType(payload[0])) { - this.payload = (byte[])payload.clone(); + if (isExpectedPacketType(payloadData[0])) { + this.payload = (byte[])payloadData.clone(); return true; } else { // That's not what we were after, so discard and wait for more diff --git a/trunk/reprap/host/src/org/reprap/comms/port/Port.java b/trunk/reprap/host/src/org/reprap/comms/port/Port.java new file mode 100644 index 00000000..9fd530f5 --- /dev/null +++ b/trunk/reprap/host/src/org/reprap/comms/port/Port.java @@ -0,0 +1,11 @@ +package org.reprap.comms.port;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public interface Port {
+ public OutputStream getOutputStream() throws IOException;
+ public InputStream getInputStream() throws IOException;
+ public void close();
+}
diff --git a/trunk/reprap/host/src/org/reprap/comms/port/SerialPort.java b/trunk/reprap/host/src/org/reprap/comms/port/SerialPort.java new file mode 100644 index 00000000..cff2e373 --- /dev/null +++ b/trunk/reprap/host/src/org/reprap/comms/port/SerialPort.java @@ -0,0 +1,56 @@ +package org.reprap.comms.port;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import javax.comm.CommPortIdentifier;
+import javax.comm.NoSuchPortException;
+
+public class SerialPort implements Port {
+
+ private javax.comm.SerialPort port;
+
+ public SerialPort(String portName, int baudRate) throws Exception {
+ try {
+ CommPortIdentifier commId = CommPortIdentifier.getPortIdentifier(portName);
+ port = (javax.comm.SerialPort)commId.open(portName, 30000);
+ }
+ catch (NoSuchPortException ex) {
+ }
+
+ // Workround for javax.comm bug.
+ // See http://forum.java.sun.com/thread.jspa?threadID=673793
+ try {
+ port.setSerialPortParams(baudRate,
+ javax.comm.SerialPort.DATABITS_8,
+ javax.comm.SerialPort.STOPBITS_1,
+ javax.comm.SerialPort.PARITY_NONE);
+ }
+ catch (Exception e) {
+ port.setSerialPortParams(baudRate,
+ javax.comm.SerialPort.DATABITS_8,
+ javax.comm.SerialPort.STOPBITS_1,
+ javax.comm.SerialPort.PARITY_NONE);
+ }
+ // End of workround
+
+ try {
+ port.setFlowControlMode(javax.comm.SerialPort.FLOWCONTROL_NONE);
+ } catch (Exception e) {
+ // Um, Linux USB ports don't do this. What can I do about it?
+ }
+
+ }
+
+ public OutputStream getOutputStream() throws IOException {
+ return port.getOutputStream();
+ }
+
+ public InputStream getInputStream() throws IOException {
+ return port.getInputStream();
+ }
+
+ public void close() {
+ port.close();
+ }
+}
diff --git a/trunk/reprap/host/src/org/reprap/comms/port/TestPort.java b/trunk/reprap/host/src/org/reprap/comms/port/TestPort.java new file mode 100644 index 00000000..3d3848ad --- /dev/null +++ b/trunk/reprap/host/src/org/reprap/comms/port/TestPort.java @@ -0,0 +1,40 @@ +package org.reprap.comms.port;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.reprap.comms.snap.SNAPAddress;
+import org.reprap.devices.TestDevice;
+
+public class TestPort implements Port {
+
+ private HashMap deviceMap;
+
+ public TestPort() {
+ deviceMap = new HashMap();
+ }
+
+ public OutputStream getOutputStream() throws IOException {
+ return System.out;
+ }
+
+ public InputStream getInputStream() throws IOException {
+ return System.in;
+ }
+
+ public void close() {
+ }
+
+ /**
+ * Called by a device to register itself on the TestPort
+ * @param device
+ * @param address
+ */
+ public void addDevice(TestDevice device, SNAPAddress address) {
+ deviceMap.put(address, device);
+ }
+
+}
diff --git a/trunk/reprap/host/src/org/reprap/comms/snap/SNAPCommunicator.java b/trunk/reprap/host/src/org/reprap/comms/snap/SNAPCommunicator.java index 32e7799e..7f4d73f8 100755 --- a/trunk/reprap/host/src/org/reprap/comms/snap/SNAPCommunicator.java +++ b/trunk/reprap/host/src/org/reprap/comms/snap/SNAPCommunicator.java @@ -6,24 +6,19 @@ import java.io.OutputStream; import java.net.URL; import java.util.Properties; -import javax.comm.CommPortIdentifier; -import javax.comm.NoSuchPortException; -import javax.comm.PortInUseException; -import javax.comm.SerialPort; -import javax.comm.UnsupportedCommOperationException; - import org.reprap.Device; import org.reprap.comms.Address; import org.reprap.comms.Communicator; import org.reprap.comms.IncomingContext; import org.reprap.comms.IncomingMessage; import org.reprap.comms.OutgoingMessage; +import org.reprap.comms.port.Port; public class SNAPCommunicator implements Communicator { private Address localAddress; - private SerialPort port; + private Port port; private OutputStream writeStream; private InputStream readStream; @@ -31,39 +26,11 @@ public class SNAPCommunicator implements Communicator { private CommsLock lock = new CommsLock(); - public SNAPCommunicator(String portName, int baudRate, Address localAddress) - throws NoSuchPortException, PortInUseException, IOException, UnsupportedCommOperationException { + public SNAPCommunicator(Port port, Address localAddress) + throws Exception { this.localAddress = localAddress; - CommPortIdentifier commId = CommPortIdentifier.getPortIdentifier(portName); - port = (SerialPort)commId.open(portName, 30000); - - - // Workround for javax.comm bug. - // See http://forum.java.sun.com/thread.jspa?threadID=673793 - - try { - port.setSerialPortParams(baudRate, - SerialPort.DATABITS_8, - SerialPort.STOPBITS_1, - SerialPort.PARITY_NONE); - } - catch (Exception e) { - - } - - port.setSerialPortParams(baudRate, - SerialPort.DATABITS_8, - SerialPort.STOPBITS_1, - SerialPort.PARITY_NONE); + this.port = port; - // End of workround - - try { - port.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); - } catch (Exception e) { - // Um, Linux USB ports don't do this. What can I do about it? - } - writeStream = port.getOutputStream(); readStream = port.getInputStream(); diff --git a/trunk/reprap/host/src/org/reprap/comms/snap/SNAPTest.java b/trunk/reprap/host/src/org/reprap/comms/snap/SNAPTest.java new file mode 100644 index 00000000..1cf97621 --- /dev/null +++ b/trunk/reprap/host/src/org/reprap/comms/snap/SNAPTest.java @@ -0,0 +1,31 @@ +package org.reprap.comms.snap;
+
+import org.reprap.comms.port.Port;
+import org.reprap.comms.port.TestPort;
+import org.reprap.devices.TestDevice;
+import org.testng.Assert;
+
+public class SNAPTest {
+
+ private Port port;
+
+ public void setup() {
+ TestPort testport;
+ port = testport = new TestPort();
+
+ //new TestDevice(testport, new SNAPAddress(2));
+ }
+
+ public void teardown() {
+
+ }
+
+ /**
+ * @testng.test groups = "comms,all,all-offline"
+ */
+ public void testXXX() {
+
+ }
+
+
+}
diff --git a/trunk/reprap/host/src/org/reprap/devices/GenericExtruder.java b/trunk/reprap/host/src/org/reprap/devices/GenericExtruder.java index 755a9bbf..1ac25b30 100644 --- a/trunk/reprap/host/src/org/reprap/devices/GenericExtruder.java +++ b/trunk/reprap/host/src/org/reprap/devices/GenericExtruder.java @@ -307,7 +307,7 @@ public class GenericExtruder extends Device { * @param ref Set reference voltage (0-63) * @throws IOException */ - private void setVref(int ref) throws IOException { + protected void setVref(int ref) throws IOException { lock(); try { sendMessage(new OutgoingByteMessage(MSG_SetVRef, (byte)ref)); @@ -324,7 +324,7 @@ public class GenericExtruder extends Device { * @param scale * @throws IOException */ - private void setTempScaler(int scale) throws IOException { + protected void setTempScaler(int scale) throws IOException { lock(); try { sendMessage(new OutgoingByteMessage(MSG_SetTempScaler, (byte)scale)); diff --git a/trunk/reprap/host/src/org/reprap/devices/TestDevice.java b/trunk/reprap/host/src/org/reprap/devices/TestDevice.java new file mode 100644 index 00000000..5119ab10 --- /dev/null +++ b/trunk/reprap/host/src/org/reprap/devices/TestDevice.java @@ -0,0 +1,19 @@ +package org.reprap.devices;
+
+import org.reprap.Device;
+import org.reprap.comms.Address;
+import org.reprap.comms.Communicator;
+import org.reprap.comms.port.TestPort;
+import org.reprap.comms.snap.SNAPAddress;
+
+public class TestDevice extends Device {
+
+ private TestPort port;
+
+ public TestDevice(Communicator communicator, Address address) {
+ super(communicator, address);
+ this.port = port;
+ //port.addDevice(this, address);
+ }
+
+}
diff --git a/trunk/reprap/host/src/org/reprap/devices/pseudo/LinePrinter.java b/trunk/reprap/host/src/org/reprap/devices/pseudo/LinePrinter.java index 4dfe456e..d8a4b0a6 100644 --- a/trunk/reprap/host/src/org/reprap/devices/pseudo/LinePrinter.java +++ b/trunk/reprap/host/src/org/reprap/devices/pseudo/LinePrinter.java @@ -44,7 +44,7 @@ public class LinePrinter { GenericStepperMotor master, slave; - int x0, x1, y0, y1; + int x1, y0, y1; // Whichever is the greater distance will be the master // From an algorithmic point of view, we'll just consider @@ -53,14 +53,12 @@ public class LinePrinter { if (Math.abs(endX - currentX) > Math.abs(endY - currentY)) { master = motorX; slave = motorY; - x0 = currentX; x1 = endX; y0 = currentY; y1 = endY; } else { master = motorY; slave = motorX; - x0 = currentY; x1 = endY; y0 = currentX; y1 = endX; diff --git a/trunk/reprap/host/src/org/reprap/geometry/LayerProducer.java b/trunk/reprap/host/src/org/reprap/geometry/LayerProducer.java index d984466d..625c34c5 100644 --- a/trunk/reprap/host/src/org/reprap/geometry/LayerProducer.java +++ b/trunk/reprap/host/src/org/reprap/geometry/LayerProducer.java @@ -31,10 +31,6 @@ public class LayerProducer { private RrPolygonList borderPolygons; private RrCSGPolygon csg_p; - private double scale; - private Rr2Point p_0; - private Rr2Point pos; - /** * @param reprap @@ -56,24 +52,22 @@ public class LayerProducer { csg_p = null; - RrBox big = hatchedPolygons.box.scale(1.1); + //RrBox big = hatchedPolygons.box.scale(1.1); - double width = big.x().length(); - double height = big.y().length(); + //double width = big.x().length(); + //double height = big.y().length(); } private void plot(Rr2Point a) throws ReprapException, IOException { if (printer.isCancelled()) return; printer.printTo(a.x(), a.y(), printer.getZ()); - pos = a; } private void move(Rr2Point a) throws ReprapException, IOException { if (printer.isCancelled()) return; printer.moveTo(a.x(), a.y(), printer.getZ()); - pos = a; } diff --git a/trunk/reprap/host/src/org/reprap/geometry/polygons/PolygonTest.java b/trunk/reprap/host/src/org/reprap/geometry/polygons/PolygonTest.java new file mode 100644 index 00000000..e171bace --- /dev/null +++ b/trunk/reprap/host/src/org/reprap/geometry/polygons/PolygonTest.java @@ -0,0 +1,20 @@ +package org.reprap.geometry.polygons;
+
+import org.testng.Assert;
+
+public class PolygonTest {
+
+ /**
+ * @testng.test groups = "geometry,all,all-offline"
+ */
+ public void testPoint() {
+ Rr2Point testPoint = new Rr2Point(10, 5);
+ Assert.assertEquals(testPoint.x(), 10.0, 0.0, "x");
+ Assert.assertEquals(testPoint.y(), 5.0, 0.0, "y");
+
+ Rr2Point negPoint = testPoint.neg();
+ Assert.assertEquals(negPoint.x(), -10.0, 0.0, "neg x");
+ Assert.assertEquals(negPoint.y(), -5.0, 0.0, "neg x");
+ }
+
+}
diff --git a/trunk/reprap/host/src/org/reprap/geometry/polygons/RrCSG.java b/trunk/reprap/host/src/org/reprap/geometry/polygons/RrCSG.java index 280f92f1..1c7bfcc0 100755 --- a/trunk/reprap/host/src/org/reprap/geometry/polygons/RrCSG.java +++ b/trunk/reprap/host/src/org/reprap/geometry/polygons/RrCSG.java @@ -601,17 +601,17 @@ public class RrCSG case RrCSGOp.UNION: case RrCSGOp.INTERSECTION: - RrHalfPlane hp = leaf.hp; + RrHalfPlane halfPlane = leaf.hp; if(c1.op == RrCSGOp.LEAF) { - if(RrHalfPlane.same(hp, c1.hp, tolerance)) + if(RrHalfPlane.same(halfPlane, c1.hp, tolerance)) c1 = leaf; } else c1.replace_all_same_leaves(leaf, tolerance); if(c2.op == RrCSGOp.LEAF) { - if(RrHalfPlane.same(hp, c2.hp, tolerance)) + if(RrHalfPlane.same(halfPlane, c2.hp, tolerance)) c2 = leaf; } else c2.replace_all_same_leaves(leaf, tolerance); diff --git a/trunk/reprap/host/src/org/reprap/geometry/polygons/TestMain.java b/trunk/reprap/host/src/org/reprap/geometry/polygons/TestMain.java index 546f3706..6aeb20bd 100644 --- a/trunk/reprap/host/src/org/reprap/geometry/polygons/TestMain.java +++ b/trunk/reprap/host/src/org/reprap/geometry/polygons/TestMain.java @@ -53,7 +53,6 @@ public class TestMain Rr2Point pp = new Rr2Point(0.35, 0.62); Rr2Point qq = new Rr2Point(0.55, 0.95); Rr2Point rr = new Rr2Point(0.45, 0.5); - Rr2Point ss = new Rr2Point(0.4, 0.3); RrLine x = new RrLine(new Rr2Point(-1, -1), new Rr2Point(1, 1)); RrHalfPlane ph = new RrHalfPlane(p, q); diff --git a/trunk/reprap/host/src/org/reprap/gui/Panel3D.java b/trunk/reprap/host/src/org/reprap/gui/Panel3D.java index 6d9ed229..001465b0 100644 --- a/trunk/reprap/host/src/org/reprap/gui/Panel3D.java +++ b/trunk/reprap/host/src/org/reprap/gui/Panel3D.java @@ -267,7 +267,7 @@ abstract public class Panel3D extends JPanel { javax.media.j3d.Locale locale = createLocale(universe); - BranchGroup sceneBranchGroup = createSceneBranchGroup(); + BranchGroup sceneBG = createSceneBranchGroup(); ViewPlatform vp = createViewPlatform(); BranchGroup viewBranchGroup = createViewBranchGroup( @@ -278,9 +278,9 @@ abstract public class Panel3D extends JPanel { Background background = createBackground(); if (background != null) - sceneBranchGroup.addChild(background); + sceneBG.addChild(background); - locale.addBranchGraph(sceneBranchGroup); + locale.addBranchGraph(sceneBG); addViewBranchGroup(locale, viewBranchGroup); } diff --git a/trunk/reprap/host/src/org/reprap/gui/PreviewPanel.java b/trunk/reprap/host/src/org/reprap/gui/PreviewPanel.java index 28e82a43..241ee037 100644 --- a/trunk/reprap/host/src/org/reprap/gui/PreviewPanel.java +++ b/trunk/reprap/host/src/org/reprap/gui/PreviewPanel.java @@ -114,6 +114,14 @@ public class PreviewPanel extends Panel3D implements Previewer { public void setMaterial(int index) { material = index; } + + /** + * Get the current extrusion material + * @return The current extrusion material as an integer index + */ + public int getMaterial() { + return material; + } /** * Called to add a new segment of extruded material to the preview diff --git a/trunk/reprap/host/src/org/reprap/gui/STLObject.java b/trunk/reprap/host/src/org/reprap/gui/STLObject.java index 08fda822..eb44c7e8 100644 --- a/trunk/reprap/host/src/org/reprap/gui/STLObject.java +++ b/trunk/reprap/host/src/org/reprap/gui/STLObject.java @@ -226,7 +226,7 @@ public class STLObject // method to recursively set the user data for objects in the scenegraph tree // we also set the capabilites on Shape3D and Morph objects required by the PickTool - void recursiveSetUserData( Object value, Object key , String name) + void recursiveSetUserData( Object value, Object key, String nameToSet) { if( value instanceof SceneGraphObject != false ) { @@ -243,11 +243,11 @@ public class STLObject java.util.Enumeration enumKids = g.getAllChildren( ); while( enumKids.hasMoreElements( ) != false ) - recursiveSetUserData( enumKids.nextElement( ), key, name ); + recursiveSetUserData( enumKids.nextElement( ), key, nameToSet ); } else if ( sg instanceof Shape3D || sg instanceof Morph ) { if ( sg instanceof Shape3D) - ((Shape3D)sg).setUserData(name); + ((Shape3D)sg).setUserData(nameToSet); PickTool.setCapabilities( (Node) sg, PickTool.INTERSECT_FULL ); } } diff --git a/trunk/reprap/host/src/org/reprap/gui/extrudertest/Main.java b/trunk/reprap/host/src/org/reprap/gui/extrudertest/Main.java index d48509c9..15b51445 100644 --- a/trunk/reprap/host/src/org/reprap/gui/extrudertest/Main.java +++ b/trunk/reprap/host/src/org/reprap/gui/extrudertest/Main.java @@ -18,6 +18,8 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import org.reprap.comms.Communicator; +import org.reprap.comms.port.Port; +import org.reprap.comms.port.SerialPort; import org.reprap.comms.snap.SNAPAddress; import org.reprap.comms.snap.SNAPCommunicator; import org.reprap.devices.GenericExtruder; @@ -79,7 +81,8 @@ public class Main extends javax.swing.JDialog { SNAPAddress myAddress = new SNAPAddress(localNodeNumber); this.setResizable(false); - communicator = new SNAPCommunicator(commPortName, baudRate, myAddress); + Port port = new SerialPort(commPortName, baudRate); + communicator = new SNAPCommunicator(port, myAddress); extruder = new GenericExtruder(communicator, new SNAPAddress(props.getProperty("Extruder1Address")), diff --git a/trunk/reprap/host/src/org/reprap/gui/steppertest/Main.java b/trunk/reprap/host/src/org/reprap/gui/steppertest/Main.java index cb11d980..6216ea93 100644 --- a/trunk/reprap/host/src/org/reprap/gui/steppertest/Main.java +++ b/trunk/reprap/host/src/org/reprap/gui/steppertest/Main.java @@ -23,6 +23,8 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import org.reprap.comms.Communicator; +import org.reprap.comms.port.Port; +import org.reprap.comms.port.SerialPort; import org.reprap.comms.snap.SNAPAddress; import org.reprap.comms.snap.SNAPCommunicator; import org.reprap.devices.GenericExtruder; @@ -62,7 +64,8 @@ public class Main extends javax.swing.JDialog implements ChangeListener { String commPortName = props.getProperty("Port"); SNAPAddress myAddress = new SNAPAddress(localNodeNumber); - communicator = new SNAPCommunicator(commPortName, baudRate, myAddress); + Port port = new SerialPort(commPortName, baudRate); + communicator = new SNAPCommunicator(port, myAddress); extruder = new GenericExtruder(communicator, new SNAPAddress(props.getProperty("Extruder1Address")), diff --git a/trunk/reprap/host/src/org/reprap/machines/MachineFactory.java b/trunk/reprap/host/src/org/reprap/machines/MachineFactory.java index cfcd782a..1b267f63 100644 --- a/trunk/reprap/host/src/org/reprap/machines/MachineFactory.java +++ b/trunk/reprap/host/src/org/reprap/machines/MachineFactory.java @@ -16,15 +16,11 @@ public class MachineFactory { private MachineFactory() { } - static public Printer create() throws Exception { + static public Printer create(Properties props) throws Exception { // Currently this just always assumes we're building // a 3-axis cartesian printer. It should build an // appropriate type based on the local configuration. - Properties props = new Properties(); - URL url = ClassLoader.getSystemResource("reprap.properties"); - props.load(url.openStream()); - String geometry = props.getProperty("Geometry"); if (geometry.compareToIgnoreCase("cartesian") == 0) @@ -34,6 +30,15 @@ public class MachineFactory { else throw new ReprapException("Invalid geometry in properties file"); + + } + + static public Printer create() throws Exception { + Properties props = new Properties(); + URL url = ClassLoader.getSystemResource("reprap.properties"); + props.load(url.openStream()); + + return create(props); } } diff --git a/trunk/reprap/host/src/org/reprap/machines/Reprap.java b/trunk/reprap/host/src/org/reprap/machines/Reprap.java index 8cca8c06..3a6abe46 100644 --- a/trunk/reprap/host/src/org/reprap/machines/Reprap.java +++ b/trunk/reprap/host/src/org/reprap/machines/Reprap.java @@ -6,6 +6,8 @@ import java.util.Properties; import org.reprap.CartesianPrinter; import org.reprap.ReprapException; import org.reprap.comms.Communicator; +import org.reprap.comms.port.Port; +import org.reprap.comms.port.SerialPort; import org.reprap.comms.snap.SNAPAddress; import org.reprap.comms.snap.SNAPCommunicator; import org.reprap.devices.GenericExtruder; @@ -53,8 +55,9 @@ public class Reprap implements CartesianPrinter { String commPortName = config.getProperty("Port"); - SNAPAddress myAddress = new SNAPAddress(localNodeNumber); - communicator = new SNAPCommunicator(commPortName, baudRate, myAddress); + SNAPAddress myAddress = new SNAPAddress(localNodeNumber); + Port port = new SerialPort(commPortName, baudRate); + communicator = new SNAPCommunicator(port, myAddress); motorX = new GenericStepperMotor(communicator, new SNAPAddress(config.getProperty("Axis1Address")), diff --git a/trunk/reprap/host/src/org/reprap/machines/ReprapTest.java b/trunk/reprap/host/src/org/reprap/machines/ReprapTest.java new file mode 100644 index 00000000..48350e14 --- /dev/null +++ b/trunk/reprap/host/src/org/reprap/machines/ReprapTest.java @@ -0,0 +1,28 @@ +package org.reprap.machines;
+
+import java.util.Properties;
+
+import org.reprap.Printer;
+import org.testng.Assert;
+
+public class ReprapTest {
+
+ Printer reprap;
+
+ public void setup() throws Exception {
+ Properties props = new Properties();
+ props.setProperty("Geometry", "cartesian");
+ reprap = MachineFactory.create(props);
+ }
+
+ public void teardown() {
+
+ }
+ /**
+ * @testng.test groups = "geometry,comms,all,all-offline"
+ */
+ public void testXXX() {
+
+ }
+
+}
|