Skip to content
Snippets Groups Projects
Commit dc374af5 authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

working on sbp exporter

parent 7899179f
Branches
Tags
No related merge requests found
...@@ -15,6 +15,13 @@ Assembler = Backbone.Model.extend({ ...@@ -15,6 +15,13 @@ Assembler = Backbone.Model.extend({
}, },
processAndSave: function(){
var exporter;
if (this.get("camProcess") == "shopbot") exporter = new ShopbotExporter();
if (exporter) exporter.processAndSave();
else console.warn("cam process not supported");
},
destroy: function(){ destroy: function(){
} }
......
...@@ -6,6 +6,54 @@ function ShopbotExporter() { ...@@ -6,6 +6,54 @@ function ShopbotExporter() {
} }
ShopbotExporter.prototype.exportAndSave = function(){ ShopbotExporter.prototype.processAndSave = function(){
var data = "";
data = this.makeHeader(data);
data = this.moveZ(data, 3);
data = this.jog3(data, 1, 4, 5);
this.save(data);
};
ShopbotExporter.prototype.makeHeader = function(data){
data = this.addLine(data, "FG", [], "single step mode");
data = this.goHome(data);
data = this.addLine(data, "SM", [4, 1], "set to move/cut mode");
data = this.addLine(data, "JS", [4, 1], "jog speed- xy, z inches per sec");
data = this.addLine(data, "MS", [4, 1], "move speed- xy, z inches per sec");
return data;
};
ShopbotExporter.prototype.addLine = function(data, command, params, comment){
data += command + " ";
_.each(params, function(param){
data += param + ", ";
});
if (comment) data += "'" +comment;
data += "\n";
return data;
};
ShopbotExporter.prototype.jog3 = function(data, x, y, z){
return this.addLine(data, "J3", [x,y,z]);
};
ShopbotExporter.prototype.move3 = function(data, x, y, z){
return this.addLine(data, "M3", [x,y,z]);
};
ShopbotExporter.prototype.goHome = function(data){
return this.addLine(data, "JH", [], "go home");
};
ShopbotExporter.prototype.moveZ = function(data, z){
return this.move3(data, "", "", z);
};
ShopbotExporter.prototype.save = function(data){
var blob = new Blob([data], {type: "text/plain;charset=utf-8"});
saveAs(blob, "ShopbotExport" + ".sbp");
}; };
...@@ -8,7 +8,8 @@ CamMenuView = Backbone.View.extend({ ...@@ -8,7 +8,8 @@ CamMenuView = Backbone.View.extend({
el: "#menuContent", el: "#menuContent",
events: { events: {
"click .camProcess": "_selectCamProcess" "click .camProcess": "_selectCamProcess",
"click #saveCam": "_processAndSave"
}, },
...@@ -26,6 +27,11 @@ CamMenuView = Backbone.View.extend({ ...@@ -26,6 +27,11 @@ CamMenuView = Backbone.View.extend({
this.assembler.set("camProcess", $(e.target).data("type")); this.assembler.set("camProcess", $(e.target).data("type"));
}, },
_processAndSave: function(e){
e.preventDefault();
this.assembler.processAndSave();
},
render: function(){ render: function(){
if (this.model.get("currentTab") != "cam") return; if (this.model.get("currentTab") != "cam") return;
this.$el.html(this.template(_.extend(this.model.toJSON(), this.assembler.toJSON()))); this.$el.html(this.template(_.extend(this.model.toJSON(), this.assembler.toJSON())));
...@@ -41,6 +47,7 @@ CamMenuView = Backbone.View.extend({ ...@@ -41,6 +47,7 @@ CamMenuView = Backbone.View.extend({
<% }); %>\ <% }); %>\
</ul>\ </ul>\
</div><br/><br/>\ </div><br/><br/>\
<a href="#" id="saveCam" class=" btn btn-block btn-lg btn-default">Process and Save</a><br/>\
') ')
}); });
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment