Fixed merge

This commit is contained in:
Sandy Noble 2017-06-25 21:58:42 +01:00
commit f2b1df7405
2 changed files with 19 additions and 26 deletions

View File

@ -33,7 +33,7 @@ ControlFrameSimple addSerialPortControlFrame(String theName, int theWidth, int t
.setPosition(10, 10) .setPosition(10, 10)
.setSize(150, 450) .setSize(150, 450)
.setBarHeight(20) .setBarHeight(20)
.setItemHeight(20) .setItemHeight(16)
.plugTo(this, "dropdown_serialPort"); .plugTo(this, "dropdown_serialPort");
sl.addItem("No serial connection", -1); sl.addItem("No serial connection", -1);
@ -61,9 +61,11 @@ ControlFrameSimple addSerialPortControlFrame(String theName, int theWidth, int t
void dropdown_serialPort(int newSerialPort) void dropdown_serialPort(int newSerialPort)
{ {
println("In dropdown_serialPort, newSerialPort: " + newSerialPort); println("In dropdown_serialPort, newSerialPort: " + newSerialPort);
// No serial in list is slot 0 in code because of list index
// So shift port index by one
newSerialPort -= 1; newSerialPort -= 1;
if (newSerialPort == -2) if (newSerialPort == -2)
{ {
} }

View File

@ -58,7 +58,7 @@ import java.lang.reflect.Method;
int majorVersionNo = 2; int majorVersionNo = 2;
int minorVersionNo = 5; int minorVersionNo = 5;
int buildNo = 0; int buildNo = 1;
String programTitle = "Polargraph Controller v" + majorVersionNo + "." + minorVersionNo + " build " + buildNo; String programTitle = "Polargraph Controller v" + majorVersionNo + "." + minorVersionNo + " build " + buildNo;
ControlP5 cp5; ControlP5 cp5;
@ -1331,6 +1331,7 @@ RShape loadShapeFromGCodeFile(String filename) {
boolean reportStatus = true; boolean reportStatus = true;
while ((line = reader.readLine ()) != null) { while ((line = reader.readLine ()) != null) {
lineNo++; lineNo++;
// println("Line: " + line);
if (reportStatus) { if (reportStatus) {
float percent = ((float)lineNo / (float)countLines) * 100.0; float percent = ((float)lineNo / (float)countLines) * 100.0;
@ -1354,10 +1355,8 @@ RShape loadShapeFromGCodeFile(String filename) {
println(e.toString()); println(e.toString());
continue; continue;
} }
// println("Ins: " + ins);
Integer code = Math.round(ins.get("G")); Integer code = Math.round(ins.get("G"));
if (code >= 2) {
continue;
}
Float z = ins.get("Z"); Float z = ins.get("Z");
if (z != null) { if (z != null) {
@ -1400,19 +1399,6 @@ RShape loadShapeFromGCodeFile(String filename) {
parent.addMoveTo(x, y); parent.addMoveTo(x, y);
} }
} }
// RPoint[][] points = parent.getPointsInPaths();
// totalPoints = 0;
// if (points != null) {
// for (int i = 0; i<points.length; i++) {
// if (points[i] != null) {
// for (int j = 0; j<points[i].length; j++) {
// totalPoints++;
// }
// }
// }
// }
// points = null;
// println("" + totalPoints + " points.");
} }
else { else {
@ -1433,7 +1419,7 @@ RShape loadShapeFromGCodeFile(String filename) {
} }
} }
catch (IOException e) { catch (IOException e) {
println("Execption reading lines from the gcode file " + filename); println("IOExecption reading lines from the gcode file " + filename);
e.printStackTrace(); e.printStackTrace();
} }
finally { finally {
@ -1441,7 +1427,7 @@ RShape loadShapeFromGCodeFile(String filename) {
reader.close(); reader.close();
} }
catch (IOException e) { catch (IOException e) {
println("Exception closing the gcode file " + filename); println("IOException closing the gcode file " + filename);
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -1478,18 +1464,23 @@ Map<String, Float> unpackGCodeInstruction(String line) throws Exception {
// remove ; character // remove ; character
splitted[i] = splitted[i].replace(";", ""); splitted[i] = splitted[i].replace(";", "");
String axis = splitted[i].substring(0, 1); String axis = splitted[i].substring(0, 1);
Float value = Float.parseFloat(splitted[i].substring(1)); String sanitisedValue = splitted[i].substring(1);
sanitisedValue = sanitisedValue.replace(",", ".");
Float value = Float.parseFloat(sanitisedValue);
if ("X".equalsIgnoreCase(axis) || "Y".equalsIgnoreCase(axis) || "Z".equalsIgnoreCase(axis) || "G".equalsIgnoreCase(axis)) { if ("X".equalsIgnoreCase(axis) || "Y".equalsIgnoreCase(axis) || "Z".equalsIgnoreCase(axis) || "G".equalsIgnoreCase(axis)) {
instruction.put(axis, value); instruction.put(axis.toUpperCase(), value);
} }
} }
// println("instruction: " + instruction); // println("instruction: " + instruction);
if (instruction.isEmpty()) { if (instruction.isEmpty()) {
throw new Exception(); throw new Exception("Empty instruction");
} }
} }
catch (NumberFormatException nfe) {
println("Number format exception: " + nfe.getMessage());
}
catch (Exception e) { catch (Exception e) {
println("e: " + e);
throw new Exception("Exception while reading the lines from a gcode file: " + line + ", " + e.getMessage()); throw new Exception("Exception while reading the lines from a gcode file: " + line + ", " + e.getMessage());
} }