Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Amanda Ghassaei
DMDesign
Commits
0b2f8621
Commit
0b2f8621
authored
Sep 17, 2015
by
Amanda Ghassaei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eod
parent
196f34dd
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
81 additions
and
34 deletions
+81
-34
js/SerialMonitor/PositionControlPanelView.js
js/SerialMonitor/PositionControlPanelView.js
+5
-0
js/cam/Cam.js
js/cam/Cam.js
+30
-24
js/cam/assemblers/Assembler.js
js/cam/assemblers/Assembler.js
+1
-1
js/cam/processes/GCodeExporter.js
js/cam/processes/GCodeExporter.js
+8
-4
js/menus/SendMenuView.js
js/menus/SendMenuView.js
+0
-3
js/models/MachineState.js
js/models/MachineState.js
+6
-1
js/models/SerialComm.js
js/models/SerialComm.js
+30
-1
node/nodeServer.js
node/nodeServer.js
+1
-0
No files found.
js/SerialMonitor/PositionControlPanelView.js
View file @
0b2f8621
...
...
@@ -40,6 +40,11 @@ define(['jquery', 'underscore', 'backbone', 'text!PositionControlPanelView.html'
this
.
model
.
send
(
"
!
"
);
},
_pause
:
function
(
e
){
e
.
preventDefault
();
this
.
model
.
pauseStream
();
},
_makeTemplateJSON
:
function
(){
return
{};
},
...
...
js/cam/Cam.js
View file @
0b2f8621
...
...
@@ -275,41 +275,47 @@ define(['underscore', 'three', 'backbone', 'appState', 'latticeCAM', 'threeModel
resetSimulation
:
function
(){
this
.
set
(
"
simLineNumber
"
,
0
,
{
silent
:
true
});
appState
.
set
(
"
stockSimulationPlaying
"
,
false
);
//todo isStreaming = false;
three
.
stopAnimationLoop
();
lattice
.
showCells
(
"
cells
"
);
},
_stockSimulation
:
function
(){
if
(
appState
.
get
(
"
stockSimulationPlaying
"
)){
three
.
startAnimationLoop
();
var
currentLine
=
this
.
get
(
"
simLineNumber
"
);
if
(
currentLine
==
0
)
lattice
.
hideCells
(
"
cells
"
);
var
allLines
=
this
.
get
(
"
dataOut
"
).
split
(
"
\n
"
);
if
(
currentLine
<
allLines
.
length
){
var
self
=
this
;
var
scale
=
lattice
.
get
(
"
scale
"
);
var
scaledSettings
=
{
scale
:
scale
,
originPosition
:
this
.
get
(
"
originPosition
"
).
clone
().
divideScalar
(
scale
),
stockPosition
:
this
.
get
(
"
stockPosition
"
).
clone
().
divideScalar
(
scale
),
};
this
.
get
(
"
exporter
"
).
simulate
(
allLines
[
currentLine
],
this
.
get
(
"
assembler
"
),
scaledSettings
,
function
(){
currentLine
++
;
self
.
set
(
"
simLineNumber
"
,
currentLine
);
self
.
_stockSimulation
();
});
}
else
{
//finished simulation
this
.
resetSimulation
();
}
var
currentLineNum
=
this
.
get
(
"
simLineNumber
"
);
var
self
=
this
;
this
.
simulateCurrentLine
(
function
(){
currentLineNum
++
;
self
.
set
(
"
simLineNumber
"
,
currentLineNum
);
self
.
_stockSimulation
();
});
}
else
{
three
.
stopAnimationLoop
();
this
.
get
(
"
assembler
"
).
pause
();
}
},
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
"
);
if
(
lineNum
<
allLines
.
length
){
var
scale
=
lattice
.
get
(
"
scale
"
);
var
scaledSettings
=
{
scale
:
scale
,
originPosition
:
this
.
get
(
"
originPosition
"
).
clone
().
divideScalar
(
scale
),
stockPosition
:
this
.
get
(
"
stockPosition
"
).
clone
().
divideScalar
(
scale
)
};
this
.
get
(
"
exporter
"
).
simulate
(
allLines
[
lineNum
],
this
.
get
(
"
assembler
"
),
scaledSettings
,
callback
);
}
else
{
//finished simulation
this
.
resetSimulation
();
}
},
...
...
js/cam/assemblers/Assembler.js
View file @
0b2f8621
...
...
@@ -239,7 +239,7 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
function
sketchyCallback
(){
totalThreads
-=
1
;
if
(
totalThreads
>
0
)
return
;
callback
();
if
(
callback
)
callback
();
}
var
startingPos
=
this
.
components
.
xAxis
.
getPosition
().
add
(
this
.
components
.
yAxis
.
getPosition
().
add
(
this
.
components
.
zAxis
.
getPosition
()));
//this.components.zAxis.getAbsolutePosition();//get position of end effector
...
...
js/cam/processes/GCodeExporter.js
View file @
0b2f8621
...
...
@@ -123,20 +123,24 @@ define(['underscore', 'cam', 'lattice', 'three'], function(_, cam, lattice, THRE
var
json
=
line
.
substr
(
1
,
line
.
length
-
2
);
json
=
JSON
.
parse
(
json
);
machine
.
releaseStock
(
json
,
settings
);
return
callback
();
if
(
callback
)
callback
();
return
;
}
if
(
line
[
0
]
==
"
F
"
){
//speed
this
.
animationSpeed
=
line
.
split
(
"
F
"
)[
1
]
/
settings
.
scale
;
return
callback
();
if
(
callback
)
callback
();
return
;
}
if
(
line
==
""
||
line
[
0
]
==
"
(
"
||
!
this
.
_isMoveCommand
(
line
)){
return
callback
();
if
(
callback
)
callback
();
return
;
}
if
(
this
.
_isMoveCommand
(
line
)){
return
this
.
_simulateMove
(
line
,
this
.
animationSpeed
,
machine
,
settings
,
callback
);
}
else
{
console
.
warn
(
"
problem parsing gcode:
"
+
line
);
return
callback
();
if
(
callback
)
callback
();
return
;
}
};
...
...
js/menus/SendMenuView.js
View file @
0b2f8621
...
...
@@ -29,19 +29,16 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s
_startStream
:
function
(
e
){
e
.
preventDefault
();
this
.
model
.
set
(
"
stockSimulationPlaying
"
,
true
);
serialComm
.
startStream
();
},
_pauseStream
:
function
(
e
){
e
.
preventDefault
();
this
.
model
.
set
(
"
stockSimulationPlaying
"
,
false
);
serialComm
.
pauseStream
();
},
_stopMachine
:
function
(
e
){
e
.
preventDefault
();
this
.
model
.
set
(
"
stockSimulationPlaying
"
,
false
);
serialComm
.
stopStream
();
},
...
...
js/models/MachineState.js
View file @
0b2f8621
...
...
@@ -25,7 +25,7 @@ define(['underscore', 'backbone'], function(_, Backbone){
});
if
(
data
.
stat
!==
null
&&
data
.
stat
!==
undefined
)
{
this
.
set
(
"
status
"
,
data
.
stat
);
if
(
data
.
stat
==
1
||
data
.
stat
==
3
||
data
.
stat
==
4
)
this
.
_triggerNextCommand
();
if
(
this
.
isReadyStatus
(
data
.
stat
)
)
this
.
_triggerNextCommand
();
}
},
...
...
@@ -36,6 +36,11 @@ define(['underscore', 'backbone'], function(_, Backbone){
}
else
this
.
set
(
"
status
"
,
10
);
},
isReadyStatus
:
function
(
status
){
if
(
status
==
undefined
)
status
=
this
.
get
(
"
status
"
);
return
status
==
1
||
status
==
3
||
status
==
4
;
},
_triggerNextCommand
:
function
(){
this
.
trigger
(
"
readyForNextCommand
"
);
},
...
...
js/models/SerialComm.js
View file @
0b2f8621
...
...
@@ -2,7 +2,8 @@
* Created by aghassaei on 6/17/15.
*/
define
([
'
underscore
'
,
'
backbone
'
,
'
socketio
'
,
'
machineState
'
],
function
(
_
,
Backbone
,
io
,
machineState
){
define
([
'
underscore
'
,
'
backbone
'
,
'
socketio
'
,
'
machineState
'
],
function
(
_
,
Backbone
,
io
,
machineState
){
var
SerialComm
=
Backbone
.
Model
.
extend
({
...
...
@@ -60,6 +61,33 @@ define(['underscore', 'backbone', 'socketio', 'machineState'], function(_, Backb
this
.
socket
.
emit
(
"
stopStream
"
);
},
sendGCode
:
function
(){
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
);
}
}
});
},
refreshMachineState
:
function
(){
//when updating connection, create a new instance of machine state
this
.
machineState
.
refresh
();
},
...
...
@@ -119,6 +147,7 @@ define(['underscore', 'backbone', 'socketio', 'machineState'], function(_, Backb
socket
.
on
(
'
isStreaming
'
,
function
(
data
){
serialComm
.
set
(
"
isStreaming
"
,
data
);
if
(
data
==
true
)
serialComm
.
sendGCode
();
});
socket
.
on
(
'
portConnected
'
,
function
(
data
){
...
...
node/nodeServer.js
View file @
0b2f8621
...
...
@@ -171,6 +171,7 @@ io.on('connection', function(socket){
function
onPortOpen
(
name
,
baud
){
io
.
emit
(
"
portConnected
"
,
{
baudRate
:
baud
,
portName
:
name
});
setIsStreaming
(
false
);
}
function
onPortData
(
data
){
...
...
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