Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jake Read
rndmc
Commits
45dc48cf
Commit
45dc48cf
authored
Nov 15, 2018
by
Jake Read
Browse files
rm bug for routes not attaching on program load
parent
3743db70
Changes
16
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
45dc48cf
...
...
@@ -17,6 +17,8 @@ It's in the early stages, so bear with us. Everything is going to be great.
To Run DMC, you'll need to install node.js, and then the packages serialport and ws (websocket).
### Install Node.js
Node.js is a runtime environment for javascript, so you can write and run js locally.
[
Download and install it here
](
https://nodejs.org/en/download/
)
.
...
...
@@ -110,9 +112,15 @@ Herein will contain a list of known problems / common errors and their fixes.
## For MW
- bug hunting
- dereferenced events / stepper axis vector
- multiple button calls ...
- stepper / planner bug
- is load / save really consistent ? what is the state answer ?
- title is still 'xperiment'
-
do hw if you can, and gifs / demo at the same time?
- some example program
-
stepper move.vector is a ref issue? derefed before running calcTrap() ? runs ? in planner ?
- example modules
- add reset button to hardware
...
...
client/client.js
View file @
45dc48cf
...
...
@@ -342,7 +342,7 @@ function redrawLinks() {
if
(
mdlRep
.
description
.
isHardware
&&
!
mdlRep
.
description
.
isLink
)
{
nLnk
++
var
hwPt
=
getRightWall
(
mdlRep
.
ui
.
domElem
)
lnkPt
.
y
+=
10
*
nLnk
lnkPt
.
y
+=
5
*
nLnk
var
ln
=
newLine
(
hwPt
.
x
,
hwPt
.
y
,
lnkPt
.
x
,
lnkPt
.
y
)
}
}
...
...
client/divtools.js
View file @
45dc48cf
...
...
@@ -301,9 +301,10 @@ function getInputArrow(div) {
function
newLine
(
x1
,
y1
,
x2
,
y2
)
{
var
ln
=
{}
ln
.
elem
=
document
.
createElementNS
(
svgns
,
'
line
'
)
ln
.
elem
.
style
.
stroke
=
'
#fcd17b
'
ln
.
elem
.
style
.
stroke
=
'
#1a1a1a
'
ln
.
elem
.
setAttribute
(
'
stroke-dasharray
'
,
'
21, 7, 7, 7
'
)
ln
.
elem
.
style
.
fill
=
'
none
'
ln
.
elem
.
style
.
strokeWidth
=
'
7
px
'
ln
.
elem
.
style
.
strokeWidth
=
'
6
px
'
ln
.
x1
=
x1
ln
.
y1
=
y1
ln
.
x2
=
x2
...
...
client/index.html
View file @
45dc48cf
...
...
@@ -2,7 +2,7 @@
<html>
<head>
<title>
xperiment
</title>
<title>
RuNDMC
</title>
</head>
<body>
...
...
lib/atkunit.js
View file @
45dc48cf
...
...
@@ -7,7 +7,7 @@ let Output = InOut.Output
let
State
=
InOut
.
State
let
Button
=
InOut
.
Button
cons
t
ATKRoute
=
require
(
'
./atkroute.js
'
)
le
t
ATKRoute
=
require
(
'
./atkroute.js
'
)
function
Hardware
(){
var
hardware
=
{
...
...
main.js
View file @
45dc48cf
...
...
@@ -29,7 +29,7 @@ const Programs = require('./programs.js')
var
program
=
Programs
.
new
(
'
new program
'
)
var
step
=
Programs
.
loadModuleFromSource
(
program
,
'
./modules/hardware/atkstepper.js
'
)
//
var step = Programs.loadModuleFromSource(program, './modules/hardware/atkstepper.js')
// UI
const
View
=
require
(
'
./views.js
'
)
...
...
modules/hardware/atkseriallink.js
View file @
45dc48cf
...
...
@@ -19,8 +19,8 @@ function ATKSerialLink() {
routes
:
new
Array
()
}
var
state
=
State
()
atkSerialLink
.
state
=
state
atkSerialLink
.
state
=
State
()
var
state
=
atkSerialLink
.
state
state
.
portName
=
'
---
'
state
.
connect
=
Button
(
'
click to find and connect
'
,
findSerialPort
)
...
...
@@ -61,7 +61,7 @@ function ATKSerialLink() {
})
})
if
(
!
found
){
console
.
log
(
'
no CP2102 device found, try serialport-list to make sure it is available to the system
'
)
console
.
log
(
'
LINK ERR:
no CP2102 device found, try serialport-list to make sure it is available to the system
'
)
state
.
portStatus
=
'
no CP2102 device found
'
}
}
...
...
@@ -110,7 +110,7 @@ function ATKSerialLink() {
if
(
writeToSerialPort
(
pckt
))
{
console
.
log
(
'
PCKT OOT >>
'
,
pckt
.
toString
())
}
else
{
console
.
log
(
'
ERR: attempt to send to hardware, port not writable
'
)
console
.
log
(
'
LINK
ERR: attempt to send to hardware, port not writable
'
)
}
}
}
else
{
...
...
modules/parsing/gcode.js
View file @
45dc48cf
...
...
@@ -36,8 +36,8 @@ function Gcode() {
console
.
log
(
'
GCODE:
'
,
instruction
)
gcode
.
outputs
.
instructionOut
.
emit
(
instruction
)
}
else
{
console
.
log
(
'
GCODE:
'
,
gcode
.
ui
.
mode
)
gcode
.
outputs
.
modeChange
.
emit
(
gcode
.
ui
.
mode
)
console
.
log
(
'
GCODE:
'
,
gcode
.
state
.
mode
)
gcode
.
outputs
.
modeChange
.
emit
(
gcode
.
state
.
mode
)
}
}
...
...
modules/ui/button.js
View file @
45dc48cf
...
...
@@ -11,7 +11,7 @@ function uiButton() {
var
button
=
{
// descriptions are used in UI
description
:
{
name
:
'
Button
!
'
,
name
:
'
Button
'
,
alt
:
'
for clicking
'
}
}
...
...
@@ -20,8 +20,7 @@ function uiButton() {
// alias !
var
state
=
button
.
state
state
.
button
=
Button
(
'
WHAM
'
)
state
.
onChange
(
'
button
'
,
onButtonPress
)
state
.
button
=
Button
(
'
WHAM
'
,
onButtonPress
)
button
.
inputs
=
{
thru
:
Input
(
'
any
'
,
onButtonPress
)
// makes anything into '1' event
...
...
modules/ui/number.js
View file @
45dc48cf
...
...
@@ -11,7 +11,7 @@ function uiNum() {
var
uinum
=
{
// descriptions are used in UI
description
:
{
name
:
'
number output
!
'
,
name
:
'
number output
'
,
alt
:
'
for clicking
'
}
}
...
...
package.json
View file @
45dc48cf
...
...
@@ -9,7 +9,7 @@
"dependencies"
:
{
"
express
"
:
"
^4.16.3
"
,
"
http
"
:
"
0.0.0
"
,
"
mathjs
"
:
"
^5.
1.2
"
,
"
mathjs
"
:
"
^5.
2.3
"
,
"
node-webcam
"
:
"
^0.4.5
"
,
"
readline
"
:
"
^1.3.0
"
,
"
serialport
"
:
"
^6.2.2
"
,
...
...
programs.js
View file @
45dc48cf
...
...
@@ -30,7 +30,7 @@ function loadModuleFromSource(program, path, id) {
program
.
description
.
counter
++
}
// make unique name
// make unique name
, or recall from program save
if
(
id
)
{
mod
.
description
.
id
=
id
}
else
{
...
...
@@ -38,22 +38,22 @@ function loadModuleFromSource(program, path, id) {
}
mod
.
description
.
path
=
path
// add to program object
program
.
modules
[
mod
.
description
.
id
]
=
mod
/* ---------------------------------- */
// WARN! Corner Case should Go Away or Improve at next spiral
if
(
mod
.
description
.
isLink
){
if
(
mod
.
description
.
isLink
)
{
for
(
mdlName
in
program
.
modules
)
{
if
(
program
.
modules
[
mdlName
].
description
.
isLink
)
{
console
.
log
(
"
PRGMEM ONLY BIG ENOUGH FOR ONE LINK
"
)
process
.
exit
()
//
process.exit()
}
}
}
// end corner case code
/* ---------------------------------- */
// add to program object
program
.
modules
[
mod
.
description
.
id
]
=
mod
// input need references for later hookup
for
(
key
in
mod
.
inputs
)
{
mod
.
inputs
[
key
].
parentId
=
mod
.
description
.
id
...
...
@@ -89,9 +89,9 @@ function loadModuleFromSource(program, path, id) {
// here's what we'll do
// if it's hardware, and we're not loading from some saved program (no id)
//
if
(
mod
.
description
.
isHardware
&&
!
mod
.
description
.
isLink
&&
id
==
null
)
{
if
(
mod
.
description
.
isHardware
&&
!
mod
.
description
.
isLink
/*
&& id == null
*/
)
{
// make sure we haven't already done this, thx
var
lnk
=
null
var
lnk
=
null
for
(
mdlName
in
program
.
modules
)
{
if
(
program
.
modules
[
mdlName
].
description
.
isLink
)
{
lnk
=
mdlName
...
...
@@ -120,7 +120,7 @@ function writeStateObject(mod, key) {
set
:
function
(
x
)
{
// update internal value
this
[
'
_
'
+
key
]
=
x
//console.log('SET', key, this['_' + key])
//
console.log('SET', key, this['_' + key])
// push to internal state change handler
// let's call emitChange from the server-side ...
// so that we don't get into any heavy VIR
...
...
@@ -229,7 +229,7 @@ function openProgram(path) {
var
mdl
=
program
.
modules
[
modName
]
if
(
mdl
==
null
)
{
console
.
log
(
'
NULL
'
)
console
.
log
(
'
-------------------------------- NULL MDL at openProgram
'
)
console
.
log
(
'
prgRep modules
'
,
prgRep
.
modules
)
console
.
log
(
'
program modules
'
,
program
.
modules
)
}
...
...
@@ -249,17 +249,30 @@ function openProgram(path) {
}
// restoring state
for
(
key
in
mdlRep
.
state
)
{
if
(
isStateKey
(
key
))
{
// I think this is OK?
// would prefer to do this before we write getters and setters
// for now we walk-around to secret key ...
mdl
.
state
[
'
_
'
+
key
]
=
mdlRep
.
state
[
key
]
/* the first wrap, only here to prevent link not-reconnecting on program restart, should go away */
if
(
!
mdlRep
.
description
.
isLink
)
{
for
(
key
in
mdlRep
.
state
)
{
if
(
isStateKey
(
key
))
{
// I think this is OK?
// would prefer to do this before we write getters and setters
// for now we walk-around to secret key ...
if
(
mdl
.
state
[
key
].
type
==
'
button
'
||
mdl
.
state
[
key
].
type
==
'
multiline
'
)
{
// defaul vals
}
else
if
(
key
==
'
route
'
){
// absolutely does not belong here
// TODO: states: sometimes we load, we want to run the change emitter ... sometimes we don't
// what choice ?
mdl
.
state
[
'
_
'
+
key
]
=
mdlRep
.
state
[
key
]
mdl
.
state
.
emitChange
(
'
route
'
)
}
else
{
mdl
.
state
[
'
_
'
+
key
]
=
mdlRep
.
state
[
key
]
}
}
}
}
console
.
log
(
'
mdlRep
'
,
mdlRep
)
console
.
log
(
'
mdl
'
,
mdl
)
//
console.log('mdlRep', mdlRep)
//
console.log('mdl', mdl)
// restore position / UI state
if
(
mdlRep
.
description
.
position
!=
null
)
{
// ??
...
...
programs/hwtest-2.json
0 → 100644
View file @
45dc48cf
{
"description"
:
{
"name"
:
"new program"
,
"counter"
:
12
},
"modules"
:
{
"Serialport ATK Link-1"
:
{
"description"
:
{
"id"
:
"Serialport ATK Link-1"
,
"name"
:
"Serialport ATK Link"
,
"alt"
:
"window into hardware world"
,
"path"
:
"./modules/hardware/atkseriallink.js"
,
"isHardware"
:
true
,
"isLink"
:
true
,
"position"
:
{
"left"
:
968
,
"top"
:
347
}
},
"inputs"
:
{},
"outputs"
:
{},
"state"
:
{
"portName"
:
"COM10"
,
"connect"
:
{
"type"
:
"button"
,
"label"
:
"click to find and connect"
},
"portStatus"
:
"open"
}
},
"ATKStepper-0"
:
{
"description"
:
{
"id"
:
"ATKStepper-0"
,
"name"
:
"ATKStepper"
,
"alt"
:
"software representation of stepper motor"
,
"path"
:
"./modules/hardware/atkstepper.js"
,
"isHardware"
:
true
,
"position"
:
{
"left"
:
457
,
"top"
:
91
}
},
"inputs"
:
{
"trapezoid"
:
{
"accepts"
:
"move instruction"
},
"accel"
:
{
"accepts"
:
"number"
},
"rmtrig"
:
{
"accepts"
:
"event"
}
},
"outputs"
:
{
"ack"
:
{
"emits"
:
"move acknowledgement"
,
"calls"
:
[]
},
"position"
:
{
"emits"
:
"number"
,
"calls"
:
[]
}
},
"state"
:
{
"reset"
:
{
"type"
:
"button"
,
"label"
:
"reset hardware"
},
"test"
:
{
"type"
:
"button"
,
"label"
:
"test network"
},
"message"
:
"test OK"
,
"route"
:
"0,3"
,
"rate"
:
2000
,
"axis"
:
"X"
,
"spu"
:
200
,
"rawMove"
:
-10
,
"makeMove"
:
{
"type"
:
"button"
,
"label"
:
"test move"
},
"lead"
:
0
,
"position"
:
0
}
},
"ATKStepper-2"
:
{
"description"
:
{
"id"
:
"ATKStepper-2"
,
"name"
:
"ATKStepper"
,
"alt"
:
"software representation of stepper motor"
,
"path"
:
"./modules/hardware/atkstepper.js"
,
"isHardware"
:
true
,
"position"
:
{
"left"
:
456
,
"top"
:
491
}
},
"inputs"
:
{
"trapezoid"
:
{
"accepts"
:
"move instruction"
},
"accel"
:
{
"accepts"
:
"number"
},
"rmtrig"
:
{
"accepts"
:
"event"
}
},
"outputs"
:
{
"ack"
:
{
"emits"
:
"move acknowledgement"
,
"calls"
:
[]
},
"position"
:
{
"emits"
:
"number"
,
"calls"
:
[]
}
},
"state"
:
{
"reset"
:
{
"type"
:
"button"
,
"label"
:
"reset hardware"
},
"test"
:
{
"type"
:
"button"
,
"label"
:
"test network"
},
"message"
:
"test OK"
,
"route"
:
"0,0"
,
"rate"
:
2000
,
"axis"
:
"Y"
,
"spu"
:
-200
,
"rawMove"
:
-10
,
"makeMove"
:
{
"type"
:
"button"
,
"label"
:
"test move"
},
"lead"
:
0
,
"position"
:
0
}
},
"ATKStepper-3"
:
{
"description"
:
{
"id"
:
"ATKStepper-3"
,
"name"
:
"ATKStepper"
,
"alt"
:
"software representation of stepper motor"
,
"path"
:
"./modules/hardware/atkstepper.js"
,
"isHardware"
:
true
,
"position"
:
{
"left"
:
457
,
"top"
:
883
}
},
"inputs"
:
{
"trapezoid"
:
{
"accepts"
:
"move instruction"
},
"accel"
:
{
"accepts"
:
"number"
},
"rmtrig"
:
{
"accepts"
:
"event"
}
},
"outputs"
:
{
"ack"
:
{
"emits"
:
"move acknowledgement"
,
"calls"
:
[]
},
"position"
:
{
"emits"
:
"number"
,
"calls"
:
[]
}
},
"state"
:
{
"reset"
:
{
"type"
:
"button"
,
"label"
:
"reset hardware"
},
"test"
:
{
"type"
:
"button"
,
"label"
:
"test network"
},
"message"
:
"test OK"
,
"route"
:
"0,5"
,
"rate"
:
2000
,
"axis"
:
"Y"
,
"spu"
:
200
,
"rawMove"
:
-10
,
"makeMove"
:
{
"type"
:
"button"
,
"label"
:
"test move"
},
"lead"
:
0
,
"position"
:
0
}
},
"ATKStepper-4"
:
{
"description"
:
{
"id"
:
"ATKStepper-4"
,
"name"
:
"ATKStepper"
,
"alt"
:
"software representation of stepper motor"
,
"path"
:
"./modules/hardware/atkstepper.js"
,
"isHardware"
:
true
,
"position"
:
{
"left"
:
459
,
"top"
:
1274
}
},
"inputs"
:
{
"trapezoid"
:
{
"accepts"
:
"move instruction"
},
"accel"
:
{
"accepts"
:
"number"
},
"rmtrig"
:
{
"accepts"
:
"event"
}
},
"outputs"
:
{
"ack"
:
{
"emits"
:
"move acknowledgement"
,
"calls"
:
[]
},
"position"
:
{
"emits"
:
"number"
,
"calls"
:
[]
}
},
"state"
:
{
"reset"
:
{
"type"
:
"button"
,
"label"
:
"reset hardware"
},
"test"
:
{
"type"
:
"button"
,
"label"
:
"test network"
},
"message"
:
"test packet out"
,
"route"
:
"0,1"
,
"rate"
:
2000
,
"axis"
:
"Z"
,
"spu"
:
200
,
"rawMove"
:
-10
,
"makeMove"
:
{
"type"
:
"button"
,
"label"
:
"test move"
},
"lead"
:
-2000
,
"position"
:
0
}
},
"ATKBBB-Servo-5"
:
{
"description"
:
{
"id"
:
"ATKBBB-Servo-5"
,
"name"
:
"ATKBBB-Servo"
,
"alt"
:
"software representation of networked hardware object"
,
"path"
:
"./modules/hardware/atkbreadboard.js"
,
"isHardware"
:
true
,
"position"
:
{
"left"
:
891
,
"top"
:
1354
}
},
"inputs"
:
{
"servoVal"
:
{
"accepts"
:
"number"
},
"adcRequest"
:
{
"accepts"
:
"event"
}
},
"outputs"
:
{
"servoConf"
:
{
"emits"
:
"event"
,
"calls"
:
[]
},
"adcValue"
:
{
"emits"
:
"number"
,
"calls"
:
[]
}
},
"state"
:
{
"reset"
:
{
"type"
:
"button"
,
"label"
:
"reset hardware"
},
"test"
:
{
"type"
:
"button"
,
"label"
:
"test network"
},
"message"
:
"test OK"
,
"route"
:
"0,2"
,
"servoButton"
:
{
"type"
:
"button"
,
"label"
:
"SEND VALUE"
},
"servoVal"
:
0
,
"adcButton"
:
{
"type"
:
"button"
,
"label"
:
"REQUEST ADC CONVERSION"
}
}
},
"Button-7"
:
{
"description"
:
{
"id"
:
"Button-7"
,
"name"
:
"Button"
,
"alt"
:
"for clicking"
,
"path"
:
"./modules/ui/button.js"
,
"position"
:
{
"left"
:
-544
,
"top"
:
337
}
},
"inputs"
:
{
"thru"
:
{
"accepts"
:
"any"
}
},
"outputs"
:
{
"whammy"
:
{
"emits"
:
"number"
,
"calls"
:
[
{
"parentId"
:
"delay-9"
,
"key"
:
"thru"
},
{
"parentId"
:
"number output-8"
,
"key"
:
"evt"
}
]
}
},
"state"
:
{
"button"
:
{
"type"
:
"button"
,
"label"
:
"WHAM"
}
}
},
"number output-8"
:
{
"description"
:
{
"id"
:
"number output-8"
,
"name"
:
"number output"
,
"alt"
:
"for clicking"
,
"path"
:
"./modules/ui/number.js"
,
"position"
:
{
"left"
:
-545
,
"top"
:
605
}