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
ef1e6396
Commit
ef1e6396
authored
Sep 17, 2015
by
Amanda Ghassaei
Browse files
position data updating machine sate
parent
2310e25a
Changes
9
Show whitespace changes
Inline
Side-by-side
css/serialMonitor.css
View file @
ef1e6396
...
...
@@ -91,3 +91,9 @@ span.outgoing {
text-align
:
center
;
padding-top
:
20px
;
}
.positionVal
{
color
:
#7777FF
;
font-size
:
30px
;
padding-left
:
5px
;
}
js/SerialMonitor/PositionControlPanelView.html
View file @
ef1e6396
<div
id=
"positionData"
>
</div><br/>
<a
href=
"#"
id=
"askForPosition"
class=
"btn btn-block btn-lg btn-default"
>
Refresh
</a
>
<a
href=
"#"
id=
"askForPosition"
class=
"btn btn-block btn-lg btn-default"
>
Refresh
Position
</a><br/
>
<a
href=
"#"
id=
"pauseOutput"
class=
"btn btn-block btn-lg btn-warning"
>
Pause
</a>
<a
href=
"#"
id=
"stopMachine"
class=
"btn pull-right btn-block btn-lg btn-danger"
>
Stop
</a>
\ No newline at end of file
js/SerialMonitor/PositionControlPanelView.js
View file @
ef1e6396
...
...
@@ -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
(
"
<div id='positionDataError'>no position data available</div>
"
);
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
{};
},
...
...
js/SerialMonitor/PositionDataView.html
View file @
ef1e6396
X:
<
%=
xAxis
%
><br/>
Y:
<
%=
yAxis
%
><br/>
Z:
<
%=
zAxis
%
><br/><br/>
A:
<
%=
aAxis
%
><br/>
B:
<
%=
bAxis
%
><br/>
C:
<
%=
cAxis
%
><br/>
\ No newline at end of file
X:
<span
class=
"positionVal"
><
%=
x
%
></span><br/>
Y:
<span
class=
"positionVal"
><
%=
y
%
></span><br/>
Z:
<span
class=
"positionVal"
><
%=
z
%
></span><br/><br/>
A:
<span
class=
"positionVal"
><
%=
a
%
></span><br/>
B:
<span
class=
"positionVal"
><
%=
b
%
></span><br/>
C:
<span
class=
"positionVal"
><
%=
c
%
></span><br/>
\ No newline at end of file
js/SerialMonitor/SerialMonitorView.js
View file @
ef1e6396
...
...
@@ -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
){
...
...
js/lattice/Lattice.js
View file @
ef1e6396
...
...
@@ -15,7 +15,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre
cellType
:
"
cube
"
,
connectionType
:
"
gik
"
,
latticeType
:
"
dnaBricks
"
,
latticeType
:
"
willGik
"
,
partType
:
null
,
aspectRatio
:
null
,
...
...
js/models/AppState.js
View file @
ef1e6396
...
...
@@ -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
,
...
...
js/models/MachineState.js
View file @
ef1e6396
...
...
@@ -3,31 +3,34 @@
*/
define
([
'
backbone
'
],
function
(
Backbone
){
define
([
'
underscore
'
,
'
backbone
'
],
function
(
_
,
Backbone
){
var
MachineState
=
Backbone
.
Model
.
extend
({
defaults
:{
x
Axis
:
null
,
y
Axis
:
null
,
z
Axis
:
null
,
a
Axis
:
null
,
b
Axis
:
null
,
c
Axis
:
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
js/models/SerialComm.js
View file @
ef1e6396
...
...
@@ -2,7 +2,7 @@
* Created by aghassaei on 6/17/15.
*/
define
([
'
underscore
'
,
'
backbone
'
,
'
socketio
'
,
'
machineState
'
],
function
(
_
,
Backbone
,
io
,
M
achineState
){
define
([
'
underscore
'
,
'
backbone
'
,
'
socketio
'
,
'
machineState
'
],
function
(
_
,
Backbone
,
io
,
m
achineState
){
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
){
...
...
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