Commit 0349a2ef authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

rapid commands

parent ac787769
...@@ -50,13 +50,13 @@ define(['underscore', 'cam', 'lattice', 'three'], function(_, cam, lattice, THRE ...@@ -50,13 +50,13 @@ define(['underscore', 'cam', 'lattice', 'three'], function(_, cam, lattice, THRE
GCodeExporter.prototype.rapidXY = function(position, settings){ GCodeExporter.prototype.rapidXY = function(position, settings){
var data = ""; var data = "";
if (this.postSpeed != settings.rapidSpeeds.x) data += this._setSpeed(settings.rapidSpeeds.x); if (this.postSpeed != settings.rapidSpeeds.x) data += this._setSpeed(settings.rapidSpeeds.x);
return data + this._goXYZ(position.x, position.y, null); return data + this._rapidXYZ(position.x, position.y, null);
}; };
GCodeExporter.prototype.rapidZ = function(z, settings){ GCodeExporter.prototype.rapidZ = function(z, settings){
var data = ""; var data = "";
if (this.postSpeed != settings.rapidSpeeds.z) data += this._setSpeed(settings.rapidSpeeds.z); if (this.postSpeed != settings.rapidSpeeds.z) data += this._setSpeed(settings.rapidSpeeds.z);
return data + this._goXYZ(null, null, z); return data + this._rapidXYZ(null, null, z);
}; };
GCodeExporter.prototype.moveXY = function(x, y, settings){ GCodeExporter.prototype.moveXY = function(x, y, settings){
...@@ -71,7 +71,7 @@ define(['underscore', 'cam', 'lattice', 'three'], function(_, cam, lattice, THRE ...@@ -71,7 +71,7 @@ define(['underscore', 'cam', 'lattice', 'three'], function(_, cam, lattice, THRE
return data + this._goXYZ(null, null, z); return data + this._goXYZ(null, null, z);
}; };
GCodeExporter.prototype._goXYZ = function(x, y, z){ GCodeExporter.prototype._goXYZ = function(x, y, z, command){
if (x !== null) { if (x !== null) {
x = "X"+parseFloat(x).toFixed(3); x = "X"+parseFloat(x).toFixed(3);
this.postPosition.x = x; this.postPosition.x = x;
...@@ -84,9 +84,14 @@ define(['underscore', 'cam', 'lattice', 'three'], function(_, cam, lattice, THRE ...@@ -84,9 +84,14 @@ define(['underscore', 'cam', 'lattice', 'three'], function(_, cam, lattice, THRE
z = "Z"+parseFloat(z).toFixed(3); z = "Z"+parseFloat(z).toFixed(3);
this.postPosition.z = z; this.postPosition.z = z;
} }
if (command) return this.addLine(command, [x,y,z]);
return this.addLine("G01", [x,y,z]); return this.addLine("G01", [x,y,z]);
}; };
GCodeExporter.prototype._rapidXYZ = function(x, y, z){
return this._goXYZ(x, y, z, "G0");
};
GCodeExporter.prototype.goHome = function(settings){ GCodeExporter.prototype.goHome = function(settings){
var data = this.rapidZ(settings.rapidHeight, settings); var data = this.rapidZ(settings.rapidHeight, settings);
return data + this.rapidXY({x:0, y:0}, settings); return data + this.rapidXY({x:0, y:0}, settings);
...@@ -124,18 +129,22 @@ define(['underscore', 'cam', 'lattice', 'three'], function(_, cam, lattice, THRE ...@@ -124,18 +129,22 @@ define(['underscore', 'cam', 'lattice', 'three'], function(_, cam, lattice, THRE
this.animationSpeed = line.split("F")[1] / settings.scale; this.animationSpeed = line.split("F")[1] / settings.scale;
return callback(); return callback();
} }
if (line == "" || line[0] == "(" || line.substr(0,3) != "G01"){ if (line == "" || line[0] == "(" || !this._isMoveCommand(line)){
return callback(); return callback();
} }
if (line.substr(0,3) == "G01"){ if (this._isMoveCommand(line)){
return this._simulateG01(line, this.animationSpeed, machine, settings, callback); return this._simulateMove(line, this.animationSpeed, machine, settings, callback);
} else { } else {
console.warn("problem parsing gcode: " + line); console.warn("problem parsing gcode: " + line);
return callback(); return callback();
} }
}; };
GCodeExporter.prototype._simulateG01 = function(line, speed, machine, settings, callback){ GCodeExporter.prototype._isMoveCommand = function(line){
return line.substr(0,3) == "G01" || line.substr(0,2) == "G0";
};
GCodeExporter.prototype._simulateMove = function(line, speed, machine, settings, callback){
var data = line.split(" "); var data = line.split(" ");
var position = {x:null,y:null,z:null}; var position = {x:null,y:null,z:null};
if (data.length<2) { if (data.length<2) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment