Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
DMDesign
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Amanda Ghassaei
DMDesign
Commits
464ffb3e
Commit
464ffb3e
authored
Sep 18, 2015
by
Amanda Ghassaei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comm is nearly there
parent
0b2f8621
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
86 additions
and
44 deletions
+86
-44
js/SerialMonitor/PositionControlPanelView.js
js/SerialMonitor/PositionControlPanelView.js
+1
-1
js/SerialMonitor/fakeCam.js
js/SerialMonitor/fakeCam.js
+12
-0
js/SerialMonitor/main.js
js/SerialMonitor/main.js
+2
-1
js/cam/Cam.js
js/cam/Cam.js
+13
-1
js/cam/assemblers/Assembler.js
js/cam/assemblers/Assembler.js
+8
-0
js/cam/assemblers/Component.js
js/cam/assemblers/Component.js
+9
-1
js/menus/SendMenuView.js
js/menus/SendMenuView.js
+13
-6
js/menus/templates/SendMenuView.html
js/menus/templates/SendMenuView.html
+1
-1
js/models/MachineState.js
js/models/MachineState.js
+1
-8
js/models/SerialComm.js
js/models/SerialComm.js
+26
-25
No files found.
js/SerialMonitor/PositionControlPanelView.js
View file @
464ffb3e
...
...
@@ -30,7 +30,7 @@ define(['jquery', 'underscore', 'backbone', 'text!PositionControlPanelView.html'
$
(
"
#positionData
"
).
html
(
_
.
template
(
positionTemplate
)(
machineState
.
toJSON
()));
},
_askForPosition
:
function
(
e
){
_askForPosition
:
function
(
e
){
//todo should be in machine state init
if
(
e
)
e
.
preventDefault
();
this
.
model
.
send
(
'
{"sr":n}
'
);
},
...
...
js/SerialMonitor/fakeCam.js
0 → 100644
View file @
464ffb3e
/**
* Created by aghassaei on 9/18/15.
*/
define
([],
function
(){
return
{
setPosition
:
function
(){}
}
});
\ No newline at end of file
js/SerialMonitor/main.js
View file @
464ffb3e
...
...
@@ -22,7 +22,8 @@ require.config({
plist
:
'
../plists/PList
'
,
commPlist
:
'
../plists/commPlist
'
,
serialComm
:
'
../models/SerialComm
'
,
machineState
:
'
../models/MachineState
'
machineState
:
'
../models/MachineState
'
,
cam
:
'
fakeCam
'
},
...
...
js/cam/Cam.js
View file @
464ffb3e
...
...
@@ -297,7 +297,6 @@ define(['underscore', 'three', 'backbone', 'appState', 'latticeCAM', 'threeModel
simulateCurrentLine
:
function
(
callback
){
var
lineNum
=
this
.
get
(
"
simLineNumber
"
);
console
.
log
(
lineNum
);
three
.
startAnimationLoop
();
if
(
lineNum
==
0
)
lattice
.
hideCells
(
"
cells
"
);
var
allLines
=
this
.
get
(
"
dataOut
"
).
split
(
"
\n
"
);
...
...
@@ -318,6 +317,19 @@ define(['underscore', 'three', 'backbone', 'appState', 'latticeCAM', 'threeModel
}
},
setPosition
:
function
(
position
){
var
scale
=
lattice
.
get
(
"
scale
"
);
_
.
each
(
position
,
function
(
val
,
key
){
position
[
key
]
=
val
/
scale
;
});
this
.
get
(
"
assembler
"
).
immediatelyMoveTo
(
position
);
three
.
render
();
},
...
...
js/cam/assemblers/Assembler.js
View file @
464ffb3e
...
...
@@ -232,6 +232,14 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
Assembler
.
prototype
.
pause
=
function
(){
};
Assembler
.
prototype
.
immediatelyMoveTo
=
function
(
data
){
this
.
components
.
xAxis
.
immediatelySetPosition
(
new
THREE
.
Vector3
(
data
.
x
,
0
,
0
));
this
.
components
.
yAxis
.
immediatelySetPosition
(
new
THREE
.
Vector3
(
0
,
data
.
y
,
0
));
this
.
components
.
zAxis
.
immediatelySetPosition
(
new
THREE
.
Vector3
(
0
,
0
,
data
.
z
));
if
(
data
.
a
!=
0
)
this
.
components
.
substrate
.
immediatelySetAngle
(
-
Math
.
PI
/
2
);
else
this
.
components
.
substrate
.
immediatelySetAngle
(
data
.
a
);
};
Assembler
.
prototype
.
moveTo
=
function
(
position
,
speed
,
settings
,
callback
){
...
...
js/cam/assemblers/Component.js
View file @
464ffb3e
...
...
@@ -171,7 +171,15 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
//simulation animation
//simulation
Component
.
prototype
.
immediatelySetAngle
=
function
(
angle
){
this
.
secondWrapper
.
rotation
.
z
=
angle
;
};
Component
.
prototype
.
immediatelySetPosition
=
function
(
nextPos
){
this
.
object3D
.
position
.
set
(
nextPos
.
x
,
nextPos
.
y
,
nextPos
.
z
);
};
Component
.
prototype
.
getObject3D
=
function
(){
return
this
.
object3D
;
...
...
js/menus/SendMenuView.js
View file @
464ffb3e
...
...
@@ -23,8 +23,11 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s
this
.
listenTo
(
this
.
model
,
"
change:stockSimulationPlaying
"
,
this
.
render
);
this
.
listenTo
(
serialComm
,
"
change:isStreaming
"
,
this
.
render
);
this
.
listenTo
(
cam
,
"
change:simLineNumber
"
,
this
.
_lineNumChanged
);
},
this
.
nextLine
=
cam
.
get
(
"
simLineNumber
"
);
_getPropertyOwner
:
function
(
$target
){
if
(
$target
.
hasClass
(
"
cam
"
))
return
cam
;
return
null
;
},
_startStream
:
function
(
e
){
...
...
@@ -44,13 +47,13 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s
_decrementLineNum
:
function
(
e
){
e
.
preventDefault
();
var
nextLine
=
this
.
nextLine
-
1
;
var
nextLine
=
cam
.
get
(
"
simLineNumber
"
)
-
1
;
this
.
_setNextLine
(
nextLine
);
},
_incrementLineNum
:
function
(
e
){
e
.
preventDefault
();
var
nextLine
=
this
.
nextLine
+
1
;
var
nextLine
=
cam
.
get
(
"
simLineNumber
"
)
+
1
;
this
.
_setNextLine
(
nextLine
);
},
...
...
@@ -58,8 +61,12 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s
var
length
=
cam
.
get
(
"
dataOut
"
).
split
(
"
\n
"
).
length
;
if
(
nextLine
<
0
)
nextLine
=
length
-
1
;
if
(
nextLine
>
length
-
1
)
nextLine
=
0
;
this
.
nextLine
=
nextLine
;
$
(
"
#nextLine
"
).
val
(
this
.
nextLine
);
cam
.
set
(
"
simLineNumber
"
,
nextLine
);
},
_showNextLine
:
function
(
nextLine
){
console
.
log
(
nextLine
);
$
(
"
#nextLine
"
).
val
(
nextLine
);
this
.
_drawGcodeHighlighter
(
nextLine
);
},
...
...
@@ -70,7 +77,7 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s
_lineNumChanged
:
function
(){
var
lineNum
=
cam
.
get
(
"
simLineNumber
"
);
this
.
_s
et
NextLine
(
lineNum
);
this
.
_s
how
NextLine
(
lineNum
);
},
_drawGcodeHighlighter
:
function
(
lineNum
){
...
...
js/menus/templates/SendMenuView.html
View file @
464ffb3e
...
...
@@ -10,7 +10,7 @@
<
%
}
%
>
<br/>
<a
href=
"#"
id=
"openSerialMonitor"
class=
"btn btn-block btn-lg btn-default"
>
Open Serial Monitor
</a><br/>
Next Line:
<input
id=
"nextLine"
value=
<%=
nextLine
%
>
placeholder="##" class="intInput form-control unresponsiveInput
" type="text">
Next Line:
<input
id=
"nextLine"
property=
"simLineNumber"
value=
"<%= nextLine %>"
placeholder=
"##"
class=
"intInput form-control cam
"
type=
"text"
>
<a
href=
"#"
id=
"previousLineButton"
class=
"btn btn-lg btn-default"
><span
class=
"fui-triangle-up"
></span></a>
<a
href=
"#"
id=
"nextLineButton"
class=
"btn btn-lg btn-default"
><span
class=
"fui-triangle-down"
></span></a><br/><br/>
<div
id=
"gcodeEditor"
><
%=
dataOut
%
></div><br/>
...
...
js/models/MachineState.js
View file @
464ffb3e
...
...
@@ -29,15 +29,8 @@ define(['underscore', 'backbone'], function(_, Backbone){
}
},
setFooterStatus
:
function
(
data
){
if
(
data
[
1
]
==
0
){
//ok status
this
.
set
(
"
status
"
,
3
);
this
.
_triggerNextCommand
();
}
else
this
.
set
(
"
status
"
,
10
);
},
isReadyStatus
:
function
(
status
){
if
(
status
==
undefined
)
status
=
this
.
get
(
"
status
"
);
if
(
status
==
=
undefined
)
status
=
this
.
get
(
"
status
"
);
return
status
==
1
||
status
==
3
||
status
==
4
;
},
...
...
js/models/SerialComm.js
View file @
464ffb3e
...
...
@@ -2,8 +2,8 @@
* Created by aghassaei on 6/17/15.
*/
define
([
'
underscore
'
,
'
backbone
'
,
'
socketio
'
,
'
machineState
'
],
function
(
_
,
Backbone
,
io
,
machineState
){
define
([
'
underscore
'
,
'
backbone
'
,
'
socketio
'
,
'
machineState
'
,
'
cam
'
],
function
(
_
,
Backbone
,
io
,
machineState
,
cam
){
var
SerialComm
=
Backbone
.
Model
.
extend
({
...
...
@@ -21,6 +21,7 @@ define(['underscore', 'backbone', 'socketio', 'machineState'],
initialize
:
function
(){
this
.
machineState
=
machineState
;
this
.
listenTo
(
machineState
,
"
change
"
,
this
.
_updateVirtualMachine
);
this
.
attemptToConnectToNode
();
},
...
...
@@ -61,31 +62,33 @@ define(['underscore', 'backbone', 'socketio', 'machineState'],
this
.
socket
.
emit
(
"
stopStream
"
);
},
_updateVirtualMachine
:
function
(){
cam
.
setPosition
(
this
.
getMachineState
().
toJSON
());
},
sendGCode
:
function
(){
if
(
!
this
.
get
(
"
isStreaming
"
))
return
;
if
(
!
cam
.
initialize
)
return
;
//don't do this from serial monitor window
var
self
=
this
;
var
machineState
=
this
.
getMachineState
();
require
([
'
cam
'
],
function
(
cam
){
if
(
machineState
&&
machineState
.
isReadyStatus
()){
var
lineNum
=
cam
.
get
(
"
simLineNumber
"
);
var
allLines
=
cam
.
get
(
"
dataOut
"
).
split
(
"
\n
"
);
if
(
lineNum
>=
0
&&
lineNum
<
allLines
.
length
)
{
var
line
=
allLines
[
lineNum
];
self
.
listenToOnce
(
machineState
,
"
readyForNextCommand
"
,
function
(){
lineNum
++
;
cam
.
set
(
"
simLineNumber
"
,
lineNum
);
self
.
sendGCode
();
});
self
.
send
(
'
{"gc":"
'
+
line
+
'
"}
'
);
cam
.
simulateCurrentLine
();
}
else
if
(
lineNum
==
allLines
.
length
){
cam
.
simulateCurrentLine
();
self
.
pauseStream
();
}
else
{
console
.
warn
(
"
invalid line number
"
+
lineNum
);
}
if
(
machineState
&&
machineState
.
isReadyStatus
()){
var
lineNum
=
cam
.
get
(
"
simLineNumber
"
);
var
allLines
=
cam
.
get
(
"
dataOut
"
).
split
(
"
\n
"
);
if
(
lineNum
>=
0
&&
lineNum
<
allLines
.
length
)
{
var
line
=
allLines
[
lineNum
];
self
.
listenToOnce
(
machineState
,
"
readyForNextCommand
"
,
function
(){
lineNum
++
;
cam
.
set
(
"
simLineNumber
"
,
lineNum
);
self
.
sendGCode
();
});
self
.
send
(
'
{"gc":"
'
+
line
+
'
"}
'
);
}
else
if
(
lineNum
==
allLines
.
length
){
self
.
pauseStream
();
}
else
{
console
.
warn
(
"
invalid line number
"
+
lineNum
);
}
});
}
else
console
.
warn
(
"
machine not ready
"
);
},
refreshMachineState
:
function
(){
//when updating connection, create a new instance of machine state
...
...
@@ -135,8 +138,6 @@ define(['underscore', 'backbone', 'socketio', 'machineState'],
}
else
if
(
json
.
sr
){
serialComm
.
getMachineState
().
setPosition
(
json
.
sr
);
}
if
(
json
.
f
)
serialComm
.
getMachineState
().
setFooterStatus
(
json
.
f
);
else
if
(
json
.
r
.
f
)
serialComm
.
getMachineState
().
setFooterStatus
(
json
.
r
.
f
);
}
catch
(
err
)
{}
});
...
...
Write
Preview
Markdown
is supported
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