@@ -58,7 +58,7 @@ import java.lang.reflect.Method;
5858
5959int majorVersionNo = 2 ;
6060int minorVersionNo = 5 ;
61- int buildNo = 0 ;
61+ int buildNo = 1 ;
6262
6363String programTitle = " Polargraph Controller v" + majorVersionNo + " ." + minorVersionNo + " build " + buildNo;
6464ControlP5 cp5;
@@ -1331,6 +1331,7 @@ RShape loadShapeFromGCodeFile(String filename) {
13311331 boolean reportStatus = true ;
13321332 while ((line = reader. readLine ()) != null ) {
13331333 lineNo++ ;
1334+ // println("Line: " + line);
13341335
13351336 if (reportStatus) {
13361337 float percent = ((float )lineNo / (float )countLines) * 100.0 ;
@@ -1354,10 +1355,8 @@ RShape loadShapeFromGCodeFile(String filename) {
13541355 println (e. toString());
13551356 continue ;
13561357 }
1358+ // println("Ins: " + ins);
13571359 Integer code = Math . round(ins. get(" G" ));
1358- if (code >= 2 ) {
1359- continue ;
1360- }
13611360
13621361 Float z = ins. get(" Z" );
13631362 if (z != null ) {
@@ -1400,19 +1399,6 @@ RShape loadShapeFromGCodeFile(String filename) {
14001399 parent. addMoveTo(x, y);
14011400 }
14021401 }
1403- // RPoint[][] points = parent.getPointsInPaths();
1404- // totalPoints = 0;
1405- // if (points != null) {
1406- // for (int i = 0; i<points.length; i++) {
1407- // if (points[i] != null) {
1408- // for (int j = 0; j<points[i].length; j++) {
1409- // totalPoints++;
1410- // }
1411- // }
1412- // }
1413- // }
1414- // points = null;
1415- // println("" + totalPoints + " points.");
14161402 }
14171403 else {
14181404
@@ -1433,15 +1419,15 @@ RShape loadShapeFromGCodeFile(String filename) {
14331419 }
14341420 }
14351421 catch (IOException e) {
1436- println (" Execption reading lines from the gcode file " + filename);
1422+ println (" IOExecption reading lines from the gcode file " + filename);
14371423 e. printStackTrace();
14381424 }
14391425 finally {
14401426 try {
14411427 reader. close();
14421428 }
14431429 catch (IOException e) {
1444- println (" Exception closing the gcode file " + filename);
1430+ println (" IOException closing the gcode file " + filename);
14451431 e. printStackTrace();
14461432 }
14471433 }
@@ -1478,18 +1464,23 @@ Map<String, Float> unpackGCodeInstruction(String line) throws Exception {
14781464 // remove ; character
14791465 splitted[i] = splitted[i]. replace(" ;" , " " );
14801466 String axis = splitted[i]. substring(0 , 1 );
1481- Float value = Float . parseFloat(splitted[i]. substring(1 ));
1482-
1467+ String sanitisedValue = splitted[i]. substring(1 );
1468+ sanitisedValue = sanitisedValue. replace(" ," , " ." );
1469+ Float value = Float . parseFloat(sanitisedValue);
14831470 if (" X" . equalsIgnoreCase(axis) || " Y" . equalsIgnoreCase(axis) || " Z" . equalsIgnoreCase(axis) || " G" . equalsIgnoreCase(axis)) {
1484- instruction. put(axis, value);
1471+ instruction. put(axis. toUpperCase() , value);
14851472 }
14861473 }
14871474// println("instruction: " + instruction);
14881475 if (instruction. isEmpty()) {
1489- throw new Exception ();
1476+ throw new Exception (" Empty instruction " );
14901477 }
1491- }
1478+ }
1479+ catch (NumberFormatException nfe) {
1480+ println (" Number format exception: " + nfe. getMessage());
1481+ }
14921482 catch (Exception e) {
1483+ println (" e: " + e);
14931484 throw new Exception (" Exception while reading the lines from a gcode file: " + line + " , " + e. getMessage());
14941485 }
14951486
0 commit comments