Commit 916e16cb authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

setting up serial monitor window

parent 8d8b4d41
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
<link href="dependencies/flatUI/css/vendor/bootstrap.min.css" rel="stylesheet"><!-- Loading Bootstrap --> <link href="dependencies/flatUI/css/vendor/bootstrap.min.css" rel="stylesheet"><!-- Loading Bootstrap -->
<link href="dependencies/flatUI/css/flat-ui.css" rel="stylesheet"><!-- Loading Flat UI --> <link href="dependencies/flatUI/css/flat-ui.css" rel="stylesheet"><!-- Loading Flat UI -->
<link href="css/serialMonitor.css" rel="stylesheet"><!-- Loading custom stylingI --> <link href="css/serialMonitor.css" rel="stylesheet"><!-- Loading custom stylingI -->
<script data-main="js/menus/SerialMonitorView" src="dependencies/require/require.js"></script>
</head> </head>
<html><div id="serialMonitorView"> <html><div id="serialMonitorView">
serial monitor serial monitor
<input id="serialMonitorSend" value="" placeholder="Send Message" class="form-control" type="text"> <input id="sendSerialMessage" value="" placeholder="Send Message" class="form-control" type="text">
</div> </div>
</html> </html>
\ No newline at end of file
...@@ -142,7 +142,7 @@ require.config({ ...@@ -142,7 +142,7 @@ require.config({
assemblerSetupMenu: 'menus/AssemblerSetupMenuView', assemblerSetupMenu: 'menus/AssemblerSetupMenuView',
editComponentMenu: 'menus/EditComponentMenuView', editComponentMenu: 'menus/EditComponentMenuView',
commParentMenu: 'menus/CommParentMenu', commParentMenu: 'menus/CommParentMenu',
serialMonitor: 'menus/SerialMonitorView', serialMonitorController: 'menus/SerialMonitorController',
//templates //templates
navViewMenuTemplate: 'menus/templates/NavViewMenu.html', navViewMenuTemplate: 'menus/templates/NavViewMenu.html',
......
...@@ -32,6 +32,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'serialComm', 'text!setup ...@@ -32,6 +32,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'serialComm', 'text!setup
}, },
_sendMessage: function(e){ _sendMessage: function(e){
console.log("here");
e.preventDefault(); e.preventDefault();
var message = $("#sendSerialMessage").val(); var message = $("#sendSerialMessage").val();
$("#sendSerialMessage").val(""); $("#sendSerialMessage").val("");
......
/**
* Created by aghassaei on 9/8/15.
*/
define(['jquery', 'underscore', 'backbone'], function($, _, Backbone){
var SerialMonitorView = Backbone.View.extend({
events: {
},
initialize: function(){
this.popup = null;
var self = this;
$(window).unload(function(){
self.popup.close();//close popup when leaving page
});
},
open: function(){
if (this.popup){
this.popup.focus();
return;
}
this.popup = window.open('SerialMonitor.html', '', 'height=400, width=400, titlebar=no, toolbar=no, menubar=yes, scrollbars=no, resizable=yes, location=no, directories=no, status=no');
var self = this;
$(this.popup).unload(function(){
self.onClose();
});
},
onClose: function(){
var self = this;
setTimeout(function(){
if (self.popup.closed) self.popup = null;
}, 100);//todo this is stupid, find an event that fires with window.closed == true
}
});
return new SerialMonitorView();
});
\ No newline at end of file
/** /**
* Created by aghassaei on 9/8/15. * Created by aghassaei on 9/9/15.
*/ */
require.config({
define(['jquery', 'underscore', 'backbone'], function($, _, Backbone){ baseUrl: 'js',
var SerialMonitorView = Backbone.View.extend({ paths: {
jquery: '../dependencies/jquery-2.1.3',
el: "#serialMonitorView", underscore: '../dependencies/underscore',
backbone: '../dependencies/backbone'
events: {
}, },
initialize: function(){ shim: {
this.open(); three: {
exports: 'THREE'
}, },
orbitControls: {
open: function(){ deps: ['three'],
window.open('SerialMonitor.html', '', 'height=400, width=400, titlebar=no, toolbar=no, menubar=yes, scrollbars=no, resizable=yes, location=no, directories=no, status=no'); exports: 'THREE'
},
stlLoader: {
deps: ['three'],
exports: 'THREE'
},
fileSaverLib: {
exports: 'saveAs'
},
flatUI: {
deps: ['jquery']
},
bootstrapSlider:{
deps: ['jquery'],
exports: '$'
},
'socketio': {
exports: 'io'
}, },
'numeric': {
exports: 'numeric'
}
}
});
onClose: function(){ console.log("hi");
}, require(['jquery', 'underscore', 'backbone'], function($, _, Backbone){
_destroy: function(){ console.log("here45");
var SerialMonitorView = Backbone.View.extend({
el: "#serialMonitorView",
initialize: function(){
$("#serialMonitorView").html("working");
} }
}); });
return SerialMonitorView; new SerialMonitorView();
}); });
\ No newline at end of file
...@@ -49,9 +49,7 @@ define(['jquery', 'underscore', 'commParentMenu', 'serialComm', 'text!setupCommM ...@@ -49,9 +49,7 @@ define(['jquery', 'underscore', 'commParentMenu', 'serialComm', 'text!setupCommM
_openSerialMonitor: function(e){ _openSerialMonitor: function(e){
e.preventDefault(); e.preventDefault();
require(['serialMonitor'], function(SerialMonitor){ serialComm.openSerialMonitor();
var serialMonitor = new SerialMonitor();
});
}, },
_makeTemplateJSON: function(){ _makeTemplateJSON: function(){
......
<% if(error){ %>
<div class="inlineWarning"><%= error %></div>
<% } %>
<% if(connected){ %> <% if(connected){ %>
<% if(error){ %>
<div class="inlineWarning"><%= error %></div>
<% } %>
Status: &nbsp;&nbsp;<% if (portConnected){ %> Connected <% } else { %> <span class="red">Disconnected</span> <% } %><br/><br/> Status: &nbsp;&nbsp;<% if (portConnected){ %> Connected <% } else { %> <span class="red">Disconnected</span> <% } %><br/><br/>
Baud Rate: &nbsp;&nbsp; Baud Rate: &nbsp;&nbsp;
<div class="btn-group"> <div class="btn-group">
......
...@@ -50,6 +50,12 @@ define(['underscore', 'backbone', 'socketio'], function(_, Backbone, io){ ...@@ -50,6 +50,12 @@ define(['underscore', 'backbone', 'socketio'], function(_, Backbone, io){
if (property === null || property === undefined || value === null || value === undefined) return; if (property === null || property === undefined || value === null || value === undefined) return;
this.socket.emit(property, value);//always pass user interaction on this.socket.emit(property, value);//always pass user interaction on
this.set(property, value); this.set(property, value);
},
openSerialMonitor: function(){
require(['serialMonitorController'], function(serialMonitorController){
serialMonitorController.open();
});
} }
}); });
...@@ -86,8 +92,9 @@ define(['underscore', 'backbone', 'socketio'], function(_, Backbone, io){ ...@@ -86,8 +92,9 @@ define(['underscore', 'backbone', 'socketio'], function(_, Backbone, io){
serialComm.set("portConnected", false); serialComm.set("portConnected", false);
}); });
socket.on("errorMsg", function(error){ socket.on("errorMsg", function(data){
serialComm.set("error", error); console.log(data);
serialComm.set("error", data.error);
}); });
socket.on("error", function(error){ socket.on("error", function(error){
......
...@@ -159,7 +159,7 @@ io.on('connection', function(socket){ ...@@ -159,7 +159,7 @@ io.on('connection', function(socket){
function onPortError(error){ function onPortError(error){
console.log("Serial port error " + error); console.log("Serial port error " + error);
socket.emit("errorMsg", error); socket.emit("errorMsg", {error:String(error)});
} }
}); });
......
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