Commit 26de4b83 authored by Amanda Ghassaei's avatar Amanda Ghassaei

comm working

parent 464ffb3e
...@@ -85,7 +85,7 @@ define(['underscore', 'cam', 'lattice', 'three'], function(_, cam, lattice, THRE ...@@ -85,7 +85,7 @@ define(['underscore', 'cam', 'lattice', 'three'], function(_, cam, lattice, THRE
z = "Z"+parseFloat(z).toFixed(3); z = "Z"+parseFloat(z).toFixed(3);
} }
if (command) return this.addLine(command, [x,y,z]); 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){ GCodeExporter.prototype._rapidXYZ = function(x, y, z){
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
* Created by aghassaei on 3/11/15. * Created by aghassaei on 3/11/15.
*/ */
define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!sendMenuTemplate', 'cam', 'camPlist'], define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!sendMenuTemplate', 'text!menus/templates/SendControlPanel.html', 'cam', 'camPlist'],
function($, _, MenuParent, serialComm, commPlist, template, cam, camPlist){ function($, _, MenuParent, serialComm, commPlist, template, controlPanelTemplate, cam, camPlist){
return MenuParent.extend({ return MenuParent.extend({
...@@ -20,13 +20,14 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s ...@@ -20,13 +20,14 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s
_initialize: function(){ _initialize: function(){
this.listenTo(this.model, "change:stockSimulationPlaying", this.render); this.listenTo(serialComm, "change", this._renderControls);
this.listenTo(serialComm, "change:isStreaming", this.render); this.listenTo(cam, "change", this._renderControls);
this.listenTo(cam, "change:simLineNumber", this._lineNumChanged); this.listenTo(cam, "change:simLineNumber", this._lineNumChanged);
}, },
_getPropertyOwner: function($target){ getPropertyOwner: function($target){
if ($target.hasClass("cam")) return cam; if ($target.hasClass("cam")) return cam;
if ($target.hasClass("comm")) return serialComm;
return null; return null;
}, },
...@@ -64,12 +65,6 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s ...@@ -64,12 +65,6 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s
cam.set("simLineNumber", nextLine); cam.set("simLineNumber", nextLine);
}, },
_showNextLine: function(nextLine){
console.log(nextLine);
$("#nextLine").val(nextLine);
this._drawGcodeHighlighter(nextLine);
},
_openSerialMonitor: function(e){ _openSerialMonitor: function(e){
e.preventDefault(); e.preventDefault();
serialComm.openSerialMonitor(); serialComm.openSerialMonitor();
...@@ -77,7 +72,7 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s ...@@ -77,7 +72,7 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s
_lineNumChanged: function(){ _lineNumChanged: function(){
var lineNum = cam.get("simLineNumber"); var lineNum = cam.get("simLineNumber");
this._showNextLine(lineNum); this._drawGcodeHighlighter(lineNum);
}, },
_drawGcodeHighlighter: function(lineNum){ _drawGcodeHighlighter: function(lineNum){
...@@ -100,16 +95,25 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s ...@@ -100,16 +95,25 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s
$editor.css({height:height +"px"}); $editor.css({height:height +"px"});
}, },
_makeControlTemplateJSON: function(){
},
_makeTemplateJSON: 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(){ _render: function(){
if (serialComm.get("lastMessageReceived") === null) $("#incomingSerialMessage").hide();
this._setEditorHeight(); this._setEditorHeight();
this._drawGcodeHighlighter(this.nextLine); this._drawGcodeHighlighter(cam.get("simLineNumber"));
this._renderControls();
}, },
controlPanelTemplate: _.template(controlPanelTemplate),
template: _.template(template) template: _.template(template)
}); });
......
<% 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: &nbsp;&nbsp;<input id="nextLine" property="simLineNumber" value="<%= simLineNumber %>" placeholder="##" class="intInput form-control cam" type="text">
&nbsp;&nbsp;<a href="#" id="previousLineButton" class="btn btn-lg btn-default"><span class="fui-triangle-up"></span></a>
&nbsp;&nbsp;<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
...@@ -2,17 +2,7 @@ ...@@ -2,17 +2,7 @@
<% if(dataOut==0){ %> <% if(dataOut==0){ %>
You need to go through the Assemble workflow to setup your machine and create <%= allCamProcesses[camProcess] %> first. You need to go through the Assemble workflow to setup your machine and create <%= allCamProcesses[camProcess] %> first.
<% }else{ %> <% }else{ %>
<% if(isStreaming){ %> <div id="sendControls"></div>
<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: &nbsp;&nbsp;<input id="nextLine" property="simLineNumber" value="<%= nextLine %>" placeholder="##" class="intInput form-control cam" type="text">
&nbsp;&nbsp;<a href="#" id="previousLineButton" class="btn btn-lg btn-default"><span class="fui-triangle-up"></span></a>
&nbsp;&nbsp;<a href="#" id="nextLineButton" class="btn btn-lg btn-default"><span class="fui-triangle-down"></span></a><br/><br/>
<div id="gcodeEditor"><%= dataOut %></div><br/> <div id="gcodeEditor"><%= dataOut %></div><br/>
<% } %> <% } %>
<% } else { %> <% } else { %>
......
...@@ -16,7 +16,8 @@ define(['underscore', 'backbone', 'socketio', 'machineState', 'cam'], ...@@ -16,7 +16,8 @@ define(['underscore', 'backbone', 'socketio', 'machineState', 'cam'],
error: null, error: null,
lastMessageReceived: null, lastMessageReceived: null,
lastMessageSent: "", lastMessageSent: "",
isStreaming: false isStreaming: false,
singleStepMode: true
}, },
initialize: function(){ initialize: function(){
...@@ -79,11 +80,16 @@ define(['underscore', 'backbone', 'socketio', 'machineState', 'cam'], ...@@ -79,11 +80,16 @@ define(['underscore', 'backbone', 'socketio', 'machineState', 'cam'],
self.listenToOnce(machineState, "readyForNextCommand", function(){ self.listenToOnce(machineState, "readyForNextCommand", function(){
lineNum ++; lineNum ++;
cam.set("simLineNumber", lineNum); cam.set("simLineNumber", lineNum);
if (self.get("singleStepMode")){
self.pauseStream();
return;
}
self.sendGCode(); self.sendGCode();
}); });
self.send('{"gc":"' + line + '"}'); self.send('{"gc":"' + line + '"}');
} else if (lineNum == allLines.length){ } else if (lineNum == allLines.length){
self.pauseStream(); self.pauseStream();
cam.set("simLineNumber", 0);
} else { } else {
console.warn("invalid line number " + lineNum); console.warn("invalid line number " + lineNum);
} }
......
...@@ -132,7 +132,7 @@ define(['three'], function(THREE){ ...@@ -132,7 +132,7 @@ define(['three'], function(THREE){
safeHeight: 4, safeHeight: 4,
originPosition: new THREE.Vector3(0,0,0), originPosition: new THREE.Vector3(0,0,0),
rapidSpeeds:{xy: 250, z: 250}, rapidSpeeds:{xy: 250, z: 250},
feedRate:{xy: 6, z: 6} feedRate:{xy: 100, z: 100}
}, },
customPost: {} customPost: {}
}, },
......
Markdown is supported
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