diff --git a/css/serialMonitor.css b/css/serialMonitor.css
index e5b0d44edbdbfa07132c6cf7bd62207e83d4a55b..f8c385d2a60f0ffa47b56526b6d69459e61517ce 100644
--- a/css/serialMonitor.css
+++ b/css/serialMonitor.css
@@ -91,3 +91,9 @@ span.outgoing {
text-align: center;
padding-top: 20px;
}
+
+.positionVal {
+ color: #7777FF;
+ font-size: 30px;
+ padding-left: 5px;
+}
diff --git a/js/SerialMonitor/PositionControlPanelView.html b/js/SerialMonitor/PositionControlPanelView.html
index 2d2e2df18b6a6a7e2047e7d91b8b4d5b62ce8684..40e0024bbf85ec2866b43774bd434f20ccea7a00 100644
--- a/js/SerialMonitor/PositionControlPanelView.html
+++ b/js/SerialMonitor/PositionControlPanelView.html
@@ -1,5 +1,5 @@
-Refresh
+Refresh Position
Pause
Stop
\ No newline at end of file
diff --git a/js/SerialMonitor/PositionControlPanelView.js b/js/SerialMonitor/PositionControlPanelView.js
index 60775b9040ddf94272dea77a165f1e8a71d88978..6b7016bb70ca2eaf0034b4a14c19c6f23bc5cc2a 100644
--- a/js/SerialMonitor/PositionControlPanelView.js
+++ b/js/SerialMonitor/PositionControlPanelView.js
@@ -2,6 +2,7 @@
* Created by aghassaei on 9/11/15.
*/
+//this.model == serialComm
define(['jquery', 'underscore', 'backbone', 'text!PositionControlPanelView.html', 'text!PositionDataView.html'],
function($, _, Backbone, template, positionTemplate){
@@ -18,18 +19,28 @@ define(['jquery', 'underscore', 'backbone', 'text!PositionControlPanelView.html'
initialize: function(){
+
+ this.listenTo(this.model.getMachineState(), "change", this._renderPositionData);
this.render();
+ this._askForPosition();
},
_renderPositionData: function(){
var machineState = this.model.getMachineState();
- if (machineState === null) {
- $("#positionData").html("no position data available
");
- return;
- }
+ console.log(machineState.toJSON());
$("#positionData").html(_.template(positionTemplate)(machineState.toJSON()));
},
+ _askForPosition: function(e){
+ if (e) e.preventDefault();
+ this.model.send('{"sr":n}');
+ },
+
+ _stopMachine: function(e){
+ e.preventDefault();
+ this.model.send("!");
+ },
+
_makeTemplateJSON: function(){
return {};
},
diff --git a/js/SerialMonitor/PositionDataView.html b/js/SerialMonitor/PositionDataView.html
index 3a26afc04d56479127e0b09460a822ecc26932e8..33e871bb89047120be950b422d0ffdd8a69ab9f5 100644
--- a/js/SerialMonitor/PositionDataView.html
+++ b/js/SerialMonitor/PositionDataView.html
@@ -1,6 +1,6 @@
-X: <%= xAxis %>
-Y: <%= yAxis %>
-Z: <%= zAxis %>
-A: <%= aAxis %>
-B: <%= bAxis %>
-C: <%= cAxis %>
\ No newline at end of file
+X: <%= x %>
+Y: <%= y %>
+Z: <%= z %>
+A: <%= a %>
+B: <%= b %>
+C: <%= c %>
\ No newline at end of file
diff --git a/js/SerialMonitor/SerialMonitorView.js b/js/SerialMonitor/SerialMonitorView.js
index 20992a10540580b0162349f4c2dd40f6150c6ca7..688066a4f2461d33e26beec0838f07f1801f2aa1 100644
--- a/js/SerialMonitor/SerialMonitorView.js
+++ b/js/SerialMonitor/SerialMonitorView.js
@@ -102,7 +102,7 @@ define(['jquery', 'underscore', 'backbone', 'serialComm', 'text!SerialMonitorVie
_addOutputData: function(html){
var $output = $("#serialMonitorOutput");
$output.append(html);
- if (this.model.get("autoscroll")) $output.animate({scrollTop:$output.scrollTop()+$output.innerHeight()}, "fast");
+ if (this.model.get("autoscroll")) $output.scrollTop($output.scrollTop()+$output.innerHeight());
},
_clear: function(e){
diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js
index d2f2c28a719668814c1271186e9561963ab74f85..3982b4a4a30e8dcb7ef5a9cc500875625fcdaa8c 100644
--- a/js/lattice/Lattice.js
+++ b/js/lattice/Lattice.js
@@ -15,7 +15,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
cellType: "cube",
connectionType: "gik",
- latticeType: "dnaBricks",
+ latticeType: "willGik",
partType: null,
aspectRatio: null,
diff --git a/js/models/AppState.js b/js/models/AppState.js
index 1d4112ce2733d14d7de8b37db24c0285782dd601..4faa639d6e6b626eb027ac718e4f44c7bd5a45e6 100644
--- a/js/models/AppState.js
+++ b/js/models/AppState.js
@@ -36,7 +36,7 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu
cellsVisible: true,
superCellIndex: new THREE.Vector3(0,0,0),//offset of superCell adds
- gikLength: 2,//this updates super cell range when using non-composite materials
+ gikLength: 4,//this updates super cell range when using non-composite materials
superCellRange: new THREE.Vector3(1,1,1),
realisticColorScheme: false,
diff --git a/js/models/MachineState.js b/js/models/MachineState.js
index 87abf7cba4f3048e90c6fec60a8115f10b8bd69f..b90b7458f24f07ab9f1e52428637d3190b85a0f7 100644
--- a/js/models/MachineState.js
+++ b/js/models/MachineState.js
@@ -3,31 +3,34 @@
*/
-define(['backbone'], function(Backbone){
+define(['underscore', 'backbone'], function(_, Backbone){
var MachineState = Backbone.Model.extend({
defaults:{
- xAxis: null,
- yAxis: null,
- zAxis: null,
- aAxis: null,
- bAxis: null,
- cAxis: null
+ x: null,
+ y: null,
+ z: null,
+ a: null,
+ b: null,
+ c: null
},
- destroy: function(){
- this.set("xAxis", null, {silent:true});
- this.set("yAxis", null, {silent:true});
- this.set("zAxis", null, {silent:true});
- this.set("aAxis", null, {silent:true});
- this.set("bAxis", null, {silent:true});
- this.set("cAxis", null, {silent:true});
+ setPosition: function(data){
+ var self = this;
+ _.each(this.attributes, function(attribute, key){
+ var val = data["pos" + key];
+ if (val !== null && val !== undefined) self.set(key, val);
+ });
+ },
+
+ refresh: function(){
+ this.set(this.defaults);
}
});
- return MachineState;
+ return new MachineState();
});
\ No newline at end of file
diff --git a/js/models/SerialComm.js b/js/models/SerialComm.js
index f341e3c7fcbd9bf0d4af4b2e6f8523fee4f4cf5d..bbd1af23af0db6b805676c0b6680f51769bc8a29 100644
--- a/js/models/SerialComm.js
+++ b/js/models/SerialComm.js
@@ -2,7 +2,7 @@
* Created by aghassaei on 6/17/15.
*/
-define(['underscore', 'backbone', 'socketio', 'machineState'], function(_, Backbone, io, MachineState){
+define(['underscore', 'backbone', 'socketio', 'machineState'], function(_, Backbone, io, machineState){
var SerialComm = Backbone.Model.extend({
@@ -19,7 +19,7 @@ define(['underscore', 'backbone', 'socketio', 'machineState'], function(_, Backb
},
initialize: function(){
- this.machineState = null;
+ this.machineState = machineState;
this.attemptToConnectToNode();
},
@@ -61,8 +61,7 @@ define(['underscore', 'backbone', 'socketio', 'machineState'], function(_, Backb
},
refreshMachineState: function(){//when updating connection, create a new instance of machine state
- if (this.machineState) this.machineState.destroy();
- this.machineState = new MachineState();
+ this.machineState.refresh();
},
getMachineState: function(){
@@ -101,6 +100,14 @@ define(['underscore', 'backbone', 'socketio', 'machineState'], function(_, Backb
if (data == "" || data == '\n' || data == "\r") return;
serialComm.set("lastMessageReceived", data, {silent:true});
serialComm.trigger("change:lastMessageReceived");
+ try {
+ var json = JSON.parse(data);
+ if (json.r && json.r.sr){
+ serialComm.getMachineState().setPosition(json.r.sr);
+ } else if (json.sr){
+ serialComm.getMachineState().setPosition(json.sr);
+ }
+ } catch(err) {}
});
socket.on('dataSent', function(data){