Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Amanda Ghassaei
DMDesign
Commits
7187c3aa
Commit
7187c3aa
authored
Aug 28, 2015
by
Amanda Ghassaei
Browse files
parent for comm menu
parent
e6ba3fbd
Changes
8
Hide whitespace changes
Inline
Side-by-side
js/main.js
View file @
7187c3aa
...
...
@@ -39,6 +39,7 @@ require.config({
//communication
socketio
:
'
../dependencies/socket.io-1.3.5
'
,
serialComm
:
'
models/SerialComm
'
,
commPlist
:
'
plists/CommPlist
'
,
//lattice classes and extra methods
latticeBase
:
'
lattice/LatticeBase
'
,
...
...
@@ -140,6 +141,7 @@ require.config({
mDynamicMenu
:
'
menus/MDynamicMenuView
'
,
assemblerSetupMenu
:
'
menus/AssemblerSetupMenuView
'
,
editComponentMenu
:
'
menus/EditComponentMenuView
'
,
commParentMenu
:
'
menus/CommParentMenu
'
,
//templates
navViewMenuTemplate
:
'
menus/templates/NavViewMenu.html
'
,
...
...
js/menus/CommParentMenu.js
0 → 100644
View file @
7187c3aa
/**
* Created by aghassaei on 8/28/15.
*/
define
([
'
jquery
'
,
'
underscore
'
,
'
menuParent
'
,
'
plist
'
,
'
serialComm
'
,
'
text!setupCommMenuTemplate
'
,
'
commPlist
'
],
function
(
$
,
_
,
MenuParentView
,
plist
,
serialComm
,
template
,
commPlist
){
return
MenuParentView
.
extend
({
parentEvents
:
{
"
change #sendSerialMessage
"
:
"
_sendMessage
"
},
_initialize
:
function
(){
_
.
extend
(
this
.
events
,
this
.
parentEvents
);
this
.
listenTo
(
serialComm
,
"
change
"
,
this
.
render
);
this
.
listenTo
(
serialComm
,
"
change:lastMessageReceived
"
,
this
.
_updateIncomingMessage
);
this
.
inTimeout
=
false
;
if
(
this
.
__initialize
)
this
.
__initialize
();
},
getPropertyOwner
:
function
(
$target
){
if
(
$target
.
hasClass
(
"
serialComm
"
))
return
serialComm
;
return
null
;
},
_sendMessage
:
function
(
e
){
e
.
preventDefault
();
var
message
=
$
(
"
#sendSerialMessage
"
).
val
();
$
(
"
#sendSerialMessage
"
).
val
(
""
);
if
(
message
==
""
)
return
;
serialComm
.
send
(
message
);
},
_updateIncomingMessage
:
function
(){
var
message
=
serialComm
.
get
(
"
lastMessageReceived
"
);
var
$message
=
$
(
"
#incomingSerialMessage
"
);
$message
.
html
(
message
);
$message
.
css
(
"
background
"
,
"
#ffff99
"
);
if
(
!
this
.
inTimeout
)
{
this
.
inTimeout
=
true
;
var
self
=
this
;
setTimeout
(
function
(){
$message
.
css
(
"
background
"
,
"
white
"
);
self
.
inTimeout
=
false
;
},
100
);
}
}
});
});
\ No newline at end of file
js/menus/SendMenuView.js
View file @
7187c3aa
...
...
@@ -2,21 +2,25 @@
* Created by aghassaei on 3/11/15.
*/
define
([
'
jquery
'
,
'
underscore
'
,
'
menuParent
'
,
'
plist
'
,
'
lattice
'
,
'
text!sendMenuTemplate
'
],
function
(
$
,
_
,
MenuParentView
,
plist
,
lattice
,
template
){
define
([
'
jquery
'
,
'
underscore
'
,
'
commParentMenu
'
,
'
serialComm
'
,
'
commPlist
'
,
'
text!sendMenuTemplate
'
],
function
(
$
,
_
,
CommParentMenu
,
serialComm
,
commPlist
,
template
){
return
CommParentMenu
.
extend
({
return
MenuParentView
.
extend
({
events
:
{
},
_initialize
:
function
(){
//bind events
__initialize
:
function
(){
},
_makeTemplateJSON
:
function
(){
return
null
;
console
.
log
(
"
render
"
);
return
_
.
extend
(
serialComm
.
toJSON
(),
commPlist
);
},
template
:
_
.
template
(
template
)
});
});
\ No newline at end of file
js/menus/SetupCommMenuView.js
View file @
7187c3aa
...
...
@@ -3,58 +3,21 @@
*/
define
([
'
jquery
'
,
'
underscore
'
,
'
menu
Parent
'
,
'
plist
'
,
'
serialComm
'
,
'
text!setupCommMenuTemplate
'
],
function
(
$
,
_
,
Menu
Parent
View
,
plist
,
serialComm
,
template
){
define
([
'
jquery
'
,
'
underscore
'
,
'
comm
Parent
Menu
'
,
'
serialComm
'
,
'
text!setupCommMenuTemplate
'
,
'
commPlist
'
],
function
(
$
,
_
,
Comm
Parent
Menu
,
serialComm
,
template
,
commPlist
){
return
MenuParentView
.
extend
({
return
CommParentMenu
.
extend
({
events
:
{
"
click #serialFlushBuffer
"
:
"
_flushBuffer
"
,
"
click #nodeSetupInstructions
"
:
"
_setupInstructions
"
,
"
click #refreshPorts
"
:
"
_refreshPorts
"
,
"
change #seriallTestMessage
"
:
"
_sendTestMessage
"
,
"
click #reconnectToNode
"
:
"
_reconnectToNode
"
},
_initialize
:
function
(){
this
.
listenTo
(
serialComm
,
"
change
"
,
this
.
render
);
this
.
listenTo
(
serialComm
,
"
change:lastMessageReceived
"
,
this
.
_updateIncomingMessage
);
this
.
inTimeout
=
false
;
},
getPropertyOwner
:
function
(
$target
){
if
(
$target
.
hasClass
(
"
serialComm
"
))
return
serialComm
;
return
null
;
},
_sendTestMessage
:
function
(
e
){
e
.
preventDefault
();
var
message
=
$
(
"
#seriallTestMessage
"
).
val
();
$
(
"
#seriallTestMessage
"
).
val
(
""
);
if
(
message
==
""
)
return
;
serialComm
.
send
(
message
);
},
_updateIncomingMessage
:
function
(){
var
message
=
serialComm
.
get
(
"
lastMessageReceived
"
);
var
$message
=
$
(
"
#incomingSerialMessage
"
);
console
.
log
(
message
);
$message
.
html
(
message
);
$message
.
css
(
"
background
"
,
"
#ffff99
"
);
if
(
!
this
.
inTimeout
)
{
this
.
inTimeout
=
true
;
var
self
=
this
;
setTimeout
(
function
(){
$message
.
css
(
"
background
"
,
"
white
"
);
self
.
inTimeout
=
false
;
},
100
);
}
__initialize
:
function
(){
},
_flushBuffer
:
function
(
e
){
...
...
@@ -83,7 +46,8 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'serialComm', 'text!setup
},
_makeTemplateJSON
:
function
(){
return
_
.
extend
(
this
.
model
.
toJSON
(),
serialComm
.
toJSON
(),
{
allBaudRates
:
[
300
,
600
,
1200
,
2400
,
4800
,
9600
,
14400
,
19200
,
28800
,
38400
,
57600
,
115200
]});
console
.
log
(
"
render
"
);
return
_
.
extend
(
serialComm
.
toJSON
(),
commPlist
);
},
template
:
_
.
template
(
template
),
...
...
js/menus/templates/SendMenuView.html
View file @
7187c3aa
realtime communication with machine
\ No newline at end of file
Incoming:
<pre
id=
"incomingSerialMessage"
></pre><br/><br/>
Out:
<input
id=
"sendSerialMessage"
value=
""
placeholder=
"Send Message"
class=
"seventyFiveWidth form-control unresponsiveInput"
type=
"text"
><br/><br/>
<a
href=
"#"
id=
"stopMachine"
class=
"btn btn-block btn-lg btn-danger"
>
Stop
</a><br/>
\ No newline at end of file
js/menus/templates/SetupCommMenuView.html
View file @
7187c3aa
...
...
@@ -23,7 +23,7 @@
</div>
<a
href=
"#"
id=
"refreshPorts"
class=
"btn btn-lg btn-default btn-icon"
><img
src=
"assets/imgs/refreshIcon.png"
></a><br/><br/>
Incoming:
<pre
id=
"incomingSerialMessage"
></pre><br/><br/>
Out:
<input
id=
"serial
lTest
Message"
value=
"
<%= testMessage %>
"
placeholder=
"Send Message"
class=
"seventyFiveWidth form-control unresponsiveInput"
type=
"text"
><br/><br/>
Out:
<input
id=
"se
ndSe
rialMessage"
value=
""
placeholder=
"Send Message"
class=
"seventyFiveWidth form-control unresponsiveInput"
type=
"text"
><br/><br/>
<a
href=
"#"
id=
"serialFlushBuffer"
class=
"btn btn-block btn-lg btn-danger"
>
Flush Buffer
</a><br/>
<
%
}
else
{
%
>
No node server found.
<br/><br/>
...
...
js/models/SerialComm.js
View file @
7187c3aa
...
...
@@ -13,8 +13,8 @@ define(['underscore', 'backbone', 'socketio'], function(_, Backbone, io){
portName
:
"
Select Port
"
,
baudRate
:
200
,
error
:
null
,
te
stMessage
:
""
,
lastMessage
Received
:
""
la
stMessage
Received
:
""
,
lastMessage
Sent
:
""
},
initialize
:
function
(){
...
...
js/plists/CommPlist.js
0 → 100644
View file @
7187c3aa
/**
* Created by aghassaei on 8/28/15.
*/
define
([],
function
(){
return
{
allBaudRates
:
[
300
,
600
,
1200
,
2400
,
4800
,
9600
,
14400
,
19200
,
28800
,
38400
,
57600
,
115200
]
}
});
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment