diff --git a/js/cam/processes/GCodeExporter.js b/js/cam/processes/GCodeExporter.js index b7a7869f8bbb67aa10275d0440cebe60f4d14c23..9c945d36907acc785d6f7c3c6c5f1171164a5eaf 100644 --- a/js/cam/processes/GCodeExporter.js +++ b/js/cam/processes/GCodeExporter.js @@ -85,7 +85,7 @@ define(['underscore', 'cam', 'lattice', 'three'], function(_, cam, lattice, THRE z = "Z"+parseFloat(z).toFixed(3); } if (command) return this.addLine(command, [x,y,z]); - return this.addLine("G01", [x,y,z]); + return this.addLine("G1", [x,y,z]); }; GCodeExporter.prototype._rapidXYZ = function(x, y, z){ diff --git a/js/menus/SendMenuView.js b/js/menus/SendMenuView.js index 61a9f6ea78c63be51a0a863d74a194b7a32eb6db..0e77a9023036db2cf89dd50b5a20cf48f0e50994 100644 --- a/js/menus/SendMenuView.js +++ b/js/menus/SendMenuView.js @@ -2,8 +2,8 @@ * Created by aghassaei on 3/11/15. */ -define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!sendMenuTemplate', 'cam', 'camPlist'], - function($, _, MenuParent, serialComm, commPlist, template, cam, camPlist){ +define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!sendMenuTemplate', 'text!menus/templates/SendControlPanel.html', 'cam', 'camPlist'], + function($, _, MenuParent, serialComm, commPlist, template, controlPanelTemplate, cam, camPlist){ return MenuParent.extend({ @@ -20,13 +20,14 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s _initialize: function(){ - this.listenTo(this.model, "change:stockSimulationPlaying", this.render); - this.listenTo(serialComm, "change:isStreaming", this.render); + this.listenTo(serialComm, "change", this._renderControls); + this.listenTo(cam, "change", this._renderControls); this.listenTo(cam, "change:simLineNumber", this._lineNumChanged); }, - _getPropertyOwner: function($target){ + getPropertyOwner: function($target){ if ($target.hasClass("cam")) return cam; + if ($target.hasClass("comm")) return serialComm; return null; }, @@ -64,12 +65,6 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s cam.set("simLineNumber", nextLine); }, - _showNextLine: function(nextLine){ - console.log(nextLine); - $("#nextLine").val(nextLine); - this._drawGcodeHighlighter(nextLine); - }, - _openSerialMonitor: function(e){ e.preventDefault(); serialComm.openSerialMonitor(); @@ -77,7 +72,7 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s _lineNumChanged: function(){ var lineNum = cam.get("simLineNumber"); - this._showNextLine(lineNum); + this._drawGcodeHighlighter(lineNum); }, _drawGcodeHighlighter: function(lineNum){ @@ -100,16 +95,25 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s $editor.css({height:height +"px"}); }, + _makeControlTemplateJSON: function(){ + + }, + _makeTemplateJSON: function(){ - return _.extend(serialComm.toJSON(), commPlist, cam.toJSON(), camPlist, {nextLine:this.nextLine}); + return _.extend(serialComm.toJSON(), cam.toJSON(), camPlist); + }, + + _renderControls: function(){ + $("#sendControls").html(this.controlPanelTemplate(this._makeTemplateJSON())); }, _render: function(){ - if (serialComm.get("lastMessageReceived") === null) $("#incomingSerialMessage").hide(); this._setEditorHeight(); - this._drawGcodeHighlighter(this.nextLine); + this._drawGcodeHighlighter(cam.get("simLineNumber")); + this._renderControls(); }, + controlPanelTemplate: _.template(controlPanelTemplate), template: _.template(template) }); diff --git a/js/menus/templates/SendControlPanel.html b/js/menus/templates/SendControlPanel.html new file mode 100644 index 0000000000000000000000000000000000000000..33e275d1d14b9637e73206396c6d08651adea954 --- /dev/null +++ b/js/menus/templates/SendControlPanel.html @@ -0,0 +1,14 @@ +<% if(isStreaming){ %> + <a href="#" id="pauseStream" class="btn btn-halfWidth btn-lg btn-warning">Pause</a> + <a href="#" id="stopMachine" class="btn pull-right btn-halfWidth btn-lg btn-danger">Stop</a><br/> + <% }else{ %> + <a href="#" id="streamCommands" class="btn btn-block btn-lg btn-success">Stream</a> + <% } %> +<label class="checkbox" for="rapidPosRel"> + <input id="rapidPosRel" data-property="singleStepMode" type="checkbox" <% if (singleStepMode){ %> checked="checked"<% } %> value="" data-toggle="checkbox" class="comm custom-checkbox"> + <span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span> +Single step mode</label> +<a href="#" id="openSerialMonitor" class="btn btn-block btn-lg btn-default">Open Serial Monitor</a><br/> +Next Line: <input id="nextLine" property="simLineNumber" value="<%= simLineNumber %>" placeholder="##" class="intInput form-control cam" type="text"> + <a href="#" id="previousLineButton" class="btn btn-lg btn-default"><span class="fui-triangle-up"></span></a> + <a href="#" id="nextLineButton" class="btn btn-lg btn-default"><span class="fui-triangle-down"></span></a><br/><br/> \ No newline at end of file diff --git a/js/menus/templates/SendMenuView.html b/js/menus/templates/SendMenuView.html index e3243e88cc41bafd9b88463b680914c6587dd5b9..57ff76fea48de81518174544bfc51967e219afd5 100644 --- a/js/menus/templates/SendMenuView.html +++ b/js/menus/templates/SendMenuView.html @@ -2,17 +2,7 @@ <% if(dataOut==0){ %> You need to go through the Assemble workflow to setup your machine and create <%= allCamProcesses[camProcess] %> first. <% }else{ %> - <% if(isStreaming){ %> - <a href="#" id="pauseStream" class="btn btn-halfWidth btn-lg btn-warning">Pause</a> - <a href="#" id="stopMachine" class="btn pull-right btn-halfWidth btn-lg btn-danger">Stop</a><br/> - <% }else{ %> - <a href="#" id="streamCommands" class="btn btn-block btn-lg btn-success">Stream</a> - <% } %> - <br/> - <a href="#" id="openSerialMonitor" class="btn btn-block btn-lg btn-default">Open Serial Monitor</a><br/> - Next Line: <input id="nextLine" property="simLineNumber" value="<%= nextLine %>" placeholder="##" class="intInput form-control cam" type="text"> - <a href="#" id="previousLineButton" class="btn btn-lg btn-default"><span class="fui-triangle-up"></span></a> - <a href="#" id="nextLineButton" class="btn btn-lg btn-default"><span class="fui-triangle-down"></span></a><br/><br/> + <div id="sendControls"></div> <div id="gcodeEditor"><%= dataOut %></div><br/> <% } %> <% } else { %> diff --git a/js/models/SerialComm.js b/js/models/SerialComm.js index 5c6b3a095c3c1287139a1c613c031cf783fa6d71..3aaccbbaca13c7bddfb63fcbd57317c66b11e1f7 100644 --- a/js/models/SerialComm.js +++ b/js/models/SerialComm.js @@ -16,7 +16,8 @@ define(['underscore', 'backbone', 'socketio', 'machineState', 'cam'], error: null, lastMessageReceived: null, lastMessageSent: "", - isStreaming: false + isStreaming: false, + singleStepMode: true }, initialize: function(){ @@ -79,11 +80,16 @@ define(['underscore', 'backbone', 'socketio', 'machineState', 'cam'], self.listenToOnce(machineState, "readyForNextCommand", function(){ lineNum ++; cam.set("simLineNumber", lineNum); + if (self.get("singleStepMode")){ + self.pauseStream(); + return; + } self.sendGCode(); }); self.send('{"gc":"' + line + '"}'); } else if (lineNum == allLines.length){ self.pauseStream(); + cam.set("simLineNumber", 0); } else { console.warn("invalid line number " + lineNum); } diff --git a/js/plists/CamPList.js b/js/plists/CamPList.js index 5efccb86025a207cc07919d83c3c176bbf941039..2dc55b669b42712be4d9df2e2c81c2700228f1e3 100644 --- a/js/plists/CamPList.js +++ b/js/plists/CamPList.js @@ -132,7 +132,7 @@ define(['three'], function(THREE){ safeHeight: 4, originPosition: new THREE.Vector3(0,0,0), rapidSpeeds:{xy: 250, z: 250}, - feedRate:{xy: 6, z: 6} + feedRate:{xy: 100, z: 100} }, customPost: {} },