Commit dc278a7f authored by Amanda Ghassaei's avatar Amanda Ghassaei

edits for tinyg

parent 26de4b83
......@@ -23,6 +23,10 @@ define(['jquery', 'underscore', 'backbone', 'text!PositionControlPanelView.html'
this.listenTo(this.model.getMachineState(), "change", this._renderPositionData);
this.render();
this._askForPosition();
this.model.send('{"sr":{"stat":t, "posx":t, "posy":t, "posz":t, "posa":t, "line":t}}');
this.model.send('$ej=1');
this.model.send('$sv=2');
},
_renderPositionData: function(){
......
......@@ -319,14 +319,17 @@ define(['underscore', 'three', 'backbone', 'appState', 'latticeCAM', 'threeModel
setPosition: function(position){
var scale = lattice.get("scale");
var originOffset = this.get("originPosition");
_.each(position, function(val, key){
if (key == "x") position[key] -= originOffset.x;
if (key == "y") position[key] -= originOffset.y;
if (key == "z") position[key] -= originOffset.z;
position[key] = val/scale;
});
this.get("assembler").immediatelyMoveTo(position);
three.render();
},
......
......@@ -137,14 +137,18 @@ define(['underscore', 'backbone', 'socketio', 'machineState', 'cam'],
if (data == "" || data == '\n' || data == "\r") return;
serialComm.set("lastMessageReceived", data, {silent:true});
serialComm.trigger("change:lastMessageReceived");
console.log(data);
try {
var json = JSON.parse(data);
console.log(json);
if (json.r && json.r.sr){
serialComm.getMachineState().setPosition(json.r.sr);
} else if (json.sr){
serialComm.getMachineState().setPosition(json.sr);
}
} catch(err) {}
} catch(err) {
console.warn(err);
}
});
socket.on('dataSent', function(data){
......
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