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

setting up serial monitor window

parent 8d8b4d41
......@@ -5,9 +5,10 @@
<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="css/serialMonitor.css" rel="stylesheet"><!-- Loading custom stylingI -->
<script data-main="js/menus/SerialMonitorView" src="dependencies/require/require.js"></script>
</head>
<html><div id="serialMonitorView">
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>
</html>
\ No newline at end of file
......@@ -142,7 +142,7 @@ require.config({
assemblerSetupMenu: 'menus/AssemblerSetupMenuView',
editComponentMenu: 'menus/EditComponentMenuView',
commParentMenu: 'menus/CommParentMenu',
serialMonitor: 'menus/SerialMonitorView',
serialMonitorController: 'menus/SerialMonitorController',
//templates
navViewMenuTemplate: 'menus/templates/NavViewMenu.html',
......
......@@ -32,6 +32,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'serialComm', 'text!setup
},
_sendMessage: function(e){
console.log("here");
e.preventDefault();
var message = $("#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({
el: "#serialMonitorView",
paths: {
jquery: '../dependencies/jquery-2.1.3',
underscore: '../dependencies/underscore',
backbone: '../dependencies/backbone'
},
events: {
shim: {
three: {
exports: 'THREE'
},
initialize: function(){
this.open();
orbitControls: {
deps: ['three'],
exports: 'THREE'
},
open: function(){
window.open('SerialMonitor.html', '', 'height=400, width=400, titlebar=no, toolbar=no, menubar=yes, scrollbars=no, resizable=yes, location=no, directories=no, status=no');
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
_openSerialMonitor: function(e){
e.preventDefault();
require(['serialMonitor'], function(SerialMonitor){
var serialMonitor = new SerialMonitor();
});
serialComm.openSerialMonitor();
},
_makeTemplateJSON: function(){
......
<% if(error){ %>
<div class="inlineWarning"><%= error %></div>
<% } %>
<% if(connected){ %>
<% if(error){ %>
<div class="inlineWarning"><%= error %></div>
<% } %>
Status: &nbsp;&nbsp;<% if (portConnected){ %> Connected <% } else { %> <span class="red">Disconnected</span> <% } %><br/><br/>
Baud Rate: &nbsp;&nbsp;
<div class="btn-group">
......
......@@ -50,6 +50,12 @@ define(['underscore', 'backbone', 'socketio'], function(_, Backbone, io){
if (property === null || property === undefined || value === null || value === undefined) return;
this.socket.emit(property, value);//always pass user interaction on
this.set(property, value);
},
openSerialMonitor: function(){
require(['serialMonitorController'], function(serialMonitorController){
serialMonitorController.open();
});
}
});
......@@ -86,8 +92,9 @@ define(['underscore', 'backbone', 'socketio'], function(_, Backbone, io){
serialComm.set("portConnected", false);
});
socket.on("errorMsg", function(error){
serialComm.set("error", error);
socket.on("errorMsg", function(data){
console.log(data);
serialComm.set("error", data.error);
});
socket.on("error", function(error){
......
......@@ -159,7 +159,7 @@ io.on('connection', function(socket){
function onPortError(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