Commit 15d7b772 authored by Jake Read's avatar Jake Read

dynamic script load bones of

parent 091bd07e
...@@ -73,7 +73,7 @@ To run the program, we launch the main.js file with node, from the command line. ...@@ -73,7 +73,7 @@ To run the program, we launch the main.js file with node, from the command line.
cd to the rndmc folder and run: cd to the rndmc folder and run:
``node main`` ``node rundmc``
It's handy to keep a terminal window open beside a browser when running the software - it's not perfect yet - I do this: It's handy to keep a terminal window open beside a browser when running the software - it's not perfect yet - I do this:
...@@ -149,11 +149,11 @@ Besides Inputs, Outputs, a Description and State object, anything else goes. I.E ...@@ -149,11 +149,11 @@ Besides Inputs, Outputs, a Description and State object, anything else goes. I.E
```javascript ```javascript
// boilerplate rndmc header // boilerplate rndmc header
const InOut = require('../../lib/jsunit.js') const JSUnit = require('../../src/jsunit.js')
let Input = InOut.Input let Input = JSUnit.Input
let Output = InOut.Output let Output = JSUnit.Output
let State = InOut.State let State = JSUnit.State
let Button = InOut.Button let Button = JSUnit.Button
// a constructor, a fn, a javascript mess // a constructor, a fn, a javascript mess
function uiNum() { function uiNum() {
...@@ -265,27 +265,47 @@ View.assignProgram(program) ...@@ -265,27 +265,47 @@ View.assignProgram(program)
# Development Notes # Development Notes
## For MW ## Immediately
- want that better-planner - ui / button
- do axis pullout separately from stepper motor ?
- bug hunting - would like to send board with new buck out to fab
- dereferenced events / stepper axis vector - just do stepper23, bc if that's it, that's it ?
- multiple button calls ...
- stepper / planner bug
- is load / save really consistent ? what is the state answer ?
- title is still 'xperiment' - tuning:
- stepper move.vector is a ref issue? derefed before running calcTrap() ? runs ? in planner ? - mrobot having PI, PID terms
- having position-set input (also gets output?)
- having position-actual output
- graphing these things
- use UI slider (external) to set PID terms?
- should be able to use the same slider element directly inline
- example modules - cleaning up reps
- looking for heirarchy demonstration
- imagining microcontrollers
- working on robot to inform desires: i.e. ui charts and graphs
## For Madison Park
- want that better-planner, better-stepper, better-inputs and graphic ui w/ 3js
- want network to not blow
- tokens w/ crc bit-level ?
- app does keepalive / green-when-on etc ?
- example of setup-for-consistent-feedback of variable, on a timer? tuning loops ... search ...
- do axis pullout separately from stepper motor ? accel command ? deep jog desire ... architecture still messy though
- bug hunting
- multiline change input paste doesn't work ... big state problem
- is load / save really consistent ? what is the state answer ?
- expected behavior: pressing the button on the raw move module should result in a move for every button press
- observed behavior: to send another raw move (via the button on the raw move module), we must reset the motor drivers.
- add reset button to hardware
- add router for reset, test - add router for reset, test
## Documentation ## Forever
- GIFS
- open the door, no cuffs
- option for 'native' multithreading by opening workers on each event ?
## Questionable Moves ## Questionable Moves
- module deletion seems unclean - module deletion seems unclean
...@@ -294,8 +314,6 @@ View.assignProgram(program) ...@@ -294,8 +314,6 @@ View.assignProgram(program)
## WRT Representations ## WRT Representations
OK, should write this out properly at some point.
Module have Module have
Inputs Inputs
Outputs Outputs
...@@ -320,6 +338,11 @@ To assemble a representation of these, we want to have a kind of 'netlist' that, ...@@ -320,6 +338,11 @@ To assemble a representation of these, we want to have a kind of 'netlist' that,
- 's' for save program uses hack-asf DOM alert to ask for path - 's' for save program uses hack-asf DOM alert to ask for path
## Desires ## Desires
- reload / edit individual modules ?
- modules spawn new inputs / outputs ?
- big UI ?
- arrows catch for jogging
- editing ?
- heirarchy zoom - heirarchy zoom
- architectural clarity betwixt UI and Heap - architectural clarity betwixt UI and Heap
- some auto load / save currently.json file so that we can restart program w/o pain ... maybe just save on new user inputs ? - some auto load / save currently.json file so that we can restart program w/o pain ... maybe just save on new user inputs ?
...@@ -333,6 +356,7 @@ To assemble a representation of these, we want to have a kind of 'netlist' that, ...@@ -333,6 +356,7 @@ To assemble a representation of these, we want to have a kind of 'netlist' that,
- consistent dereferencing, type checking implementation? - consistent dereferencing, type checking implementation?
## UI Desires ## UI Desires
- scroll / grab events for touchpads etc ... find a mac user and workshop this for one afternoon ?
- modules have visual ways to throw errors - i.e. flashing red, popping up... - modules have visual ways to throw errors - i.e. flashing red, popping up...
- off-screen divs get pointers-to so that we don't get lost - off-screen divs get pointers-to so that we don't get lost
- 'h' or something to zoom-to-extents - 'h' or something to zoom-to-extents
......
...@@ -31,6 +31,8 @@ var lastPos = { x: 10, y: 30 } ...@@ -31,6 +31,8 @@ var lastPos = { x: 10, y: 30 }
var wrapper = {} var wrapper = {}
var nav = {} var nav = {}
var verbose = false
/* /*
STARTUP --------------------------------------------------- STARTUP ---------------------------------------------------
...@@ -64,7 +66,7 @@ window.onload = function() { ...@@ -64,7 +66,7 @@ window.onload = function() {
sckt = this sckt = this
// say hello // say hello
socketSend('console', 'hello server') socketSend('console', 'hello server')
console.log('socket open') console.log('SCKT: socket open')
// ask for the current program // ask for the current program
socketSend('get current program', '') socketSend('get current program', '')
// main socket entry point // main socket entry point
...@@ -75,10 +77,10 @@ window.onload = function() { ...@@ -75,10 +77,10 @@ window.onload = function() {
this.onerror = (err) => { this.onerror = (err) => {
alert('link to server is broken') alert('link to server is broken')
location.reload() location.reload()
console.log('socket error', err) console.log('SCKT: socket error', err)
} }
this.onclose = (evt) => { this.onclose = (evt) => {
console.log('socket closed', evt) console.log('SCKT: socket closed', evt)
sckt = null sckt = null
} }
} }
...@@ -110,33 +112,37 @@ function socketRecv(evt) { ...@@ -110,33 +112,37 @@ function socketRecv(evt) {
console.log('RECV CONSOLE:', data) console.log('RECV CONSOLE:', data)
break break
case 'put module menu': case 'put module menu':
console.log('RECV MODULE MENU') if(verbose) console.log('RECV MODULE MENU')
heapSendsModuleMenu(data) heapSendsModuleMenu(data)
break break
case 'put program menu': case 'put program menu':
console.log('RECV PRG MENU') if(verbose) console.log('RECV PRG MENU')
heapSendsProgramMenu(data) heapSendsProgramMenu(data)
break break
case 'put program': case 'put program':
console.log('RECV PROGRAM') if(verbose) console.log('RECV PROGRAM')
heapSendsNewProgram(data) heapSendsNewProgram(data)
break break
case 'put module': case 'put module':
console.log('RECV NEW MODULE') if(verbose) console.log('RECV NEW MODULE')
heapSendsNewModule(data) heapSendsNewModule(data)
break break
case 'put module change': case 'put module change':
console.log('RECV MODULE CHANGE') if(verbose) console.log('RECV MODULE CHANGE')
heapSendsModuleChange(data) heapSendsModuleChange(data)
break break
case 'put state change': case 'put state change':
console.log('RECV STATE CHANGE') if(verbose) console.log('RECV STATE CHANGE')
heapSendsStateChange(data) heapSendsStateChange(data)
break break
case 'put ui change':
if(verbose) console.log('RECV UI CHANGE')
heapSendsUiChange(data)
break
case 'restart': case 'restart':
location.reload() location.reload()
default: default:
console.log('ERR recv with non recognized type', recv) console.log('ERR: recv with non recognized type', recv)
break break
} }
} }
...@@ -157,7 +163,7 @@ HEAP -> SERVER --------------------------------------------------- ...@@ -157,7 +163,7 @@ HEAP -> SERVER ---------------------------------------------------
// always a rep, tho // always a rep, tho
var program = {} var program = {}
// re-writes the program, adds a description, // re-writes t program, adds a description,
// and loads multiple representations of modules to the view // and loads multiple representations of modules to the view
function heapSendsNewProgram(prgm) { function heapSendsNewProgram(prgm) {
...@@ -166,7 +172,7 @@ function heapSendsNewProgram(prgm) { ...@@ -166,7 +172,7 @@ function heapSendsNewProgram(prgm) {
program = prgm program = prgm
// 1st we want to git rm old files ... // 1st we want to git rm old files ...
// when adding links, we'll have to add all and then draw links // when adding links, we'll have to add all and then draw links
console.log(program) if(verbose) console.log('LOAD PROGRAM', program)
for (mdlName in program.modules) { for (mdlName in program.modules) {
addRepToView(program.modules[mdlName]) addRepToView(program.modules[mdlName])
} }
...@@ -186,11 +192,11 @@ function heapSendsNewModule(mdl) { ...@@ -186,11 +192,11 @@ function heapSendsNewModule(mdl) {
} }
// writes DOM elements to represent the module, appends to the wrapper // writes DOM elements to represent the module, appends to the wrapper
// and appends to the rep object a .ui object // and appends to the rep object a .dom object
// containing references to those DOM objects // containing references to those DOM objects
function heapSendsModuleChange(data) { function heapSendsModuleChange(data) {
console.log(data) if(verbose) console.log('HEAP SENDS MODULE CHANGE', data)
// data should be rep of changed module // data should be rep of changed module
var rep = program.modules[data.description.id] var rep = program.modules[data.description.id]
// we want a general case, but for now we know we're looking for // we want a general case, but for now we know we're looking for
...@@ -206,7 +212,7 @@ function heapSendsModuleChange(data) { ...@@ -206,7 +212,7 @@ function heapSendsModuleChange(data) {
var stateItem = rep.state[key] var stateItem = rep.state[key]
if (stateItem != data.state[key]) { if (stateItem != data.state[key]) {
stateItem = data.state[key] stateItem = data.state[key]
rep.ui.state[key].value = data.state[key] rep.dom.state[key].value = data.state[key]
} }
} }
// wreckless or wonderful? // wreckless or wonderful?
...@@ -216,16 +222,21 @@ function heapSendsModuleChange(data) { ...@@ -216,16 +222,21 @@ function heapSendsModuleChange(data) {
// update state from server to UI // update state from server to UI
function heapSendsStateChange(data) { function heapSendsStateChange(data) {
console.log('HEAP SENDS CHANGE STATE IN MODULE', data) if(verbose) console.log('HEAP SENDS CHANGE STATE IN MODULE', data)
var rep = program.modules[data.id] var rep = program.modules[data.id]
rep.state[data.key] = data.val rep.state[data.key] = data.val
if (rep.state[data.key].type == 'multiline') { if (typeof data.val == 'boolean') {
rep.ui.state[data.key].value = data.val.value rep.dom.state[data.key].innerHTML = data.key + ':\t\t' + rep.state[data.key].toString()
} else { } else {
rep.ui.state[data.key].value = data.val rep.dom.state[data.key].value = data.val
} }
} }
function heapSendsUiChange(data){
if(true) console.log('HEAP SENDS CHANG UI IN MODULE', data)
//
}
/* /*
UI -> HEAP --------------------------------------------------- UI -> HEAP ---------------------------------------------------
...@@ -298,14 +309,6 @@ UTILITIES --------------------------------------------------- ...@@ -298,14 +309,6 @@ UTILITIES ---------------------------------------------------
*/ */
function isStateKey(key) {
if (key.indexOf('_') == 0 || key == 'emitters' || key == 'onChange' || key == 'emitChange') {
return false
} else {
return true
}
}
function redrawLinks() { function redrawLinks() {
// probably not a great way to do this, we're removing everything // probably not a great way to do this, we're removing everything
// svg -rm -r // svg -rm -r
...@@ -313,14 +316,14 @@ function redrawLinks() { ...@@ -313,14 +316,14 @@ function redrawLinks() {
svg.removeChild(svg.firstChild) svg.removeChild(svg.firstChild)
} }
// draw origin // draw origin
var og1 = newLine(-15,0,15,0,5, false) var og1 = newLine(-15, 0, 15, 0, 5, false)
var og2 = newLine(0,-15,0,15,5, false) var og2 = newLine(0, -15, 0, 15, 5, false)
// find that link // find that link
var lnkPt var lnkPt
var nLnk = 0 var nLnk = 0
for (mdlName in program.modules) { for (mdlName in program.modules) {
if (program.modules[mdlName].description.isLink) { if (program.modules[mdlName].description.isLink) {
lnkPt = getLeftWall(program.modules[mdlName].ui.domElem) lnkPt = getLeftWall(program.modules[mdlName].dom.domElem)
} }
} }
// redraw thru all links, just look at reps // redraw thru all links, just look at reps
...@@ -328,11 +331,11 @@ function redrawLinks() { ...@@ -328,11 +331,11 @@ function redrawLinks() {
var mdlRep = program.modules[mdlName] var mdlRep = program.modules[mdlName]
for (key in mdlRep.outputs) { for (key in mdlRep.outputs) {
var output = mdlRep.outputs[key] var output = mdlRep.outputs[key]
var outputUi = mdlRep.ui.outputs[key] var outputUi = mdlRep.dom.outputs[key]
for (input in output.calls) { for (input in output.calls) {
var toId = output.calls[input].parentId var toId = output.calls[input].parentId
var toKey = output.calls[input].key var toKey = output.calls[input].key
var inputUi = program.modules[toId].ui.inputs[toKey] var inputUi = program.modules[toId].dom.inputs[toKey]
var outPos = getOutputArrow(outputUi) var outPos = getOutputArrow(outputUi)
var inPos = getInputArrow(inputUi) var inPos = getInputArrow(inputUi)
if (inputUi.isHovering || outputUi.isHovering) { if (inputUi.isHovering || outputUi.isHovering) {
...@@ -344,7 +347,7 @@ function redrawLinks() { ...@@ -344,7 +347,7 @@ function redrawLinks() {
} }
if (mdlRep.description.isHardware && !mdlRep.description.isLink) { if (mdlRep.description.isHardware && !mdlRep.description.isLink) {
nLnk++ nLnk++
var hwPt = getRightWall(mdlRep.ui.domElem) var hwPt = getRightWall(mdlRep.dom.domElem)
lnkPt.y += 5 * nLnk lnkPt.y += 5 * nLnk
var ln = newLine(hwPt.x, hwPt.y, lnkPt.x, lnkPt.y, 7, true) var ln = newLine(hwPt.x, hwPt.y, lnkPt.x, lnkPt.y, 7, true)
} }
...@@ -463,7 +466,6 @@ function mouseUpDragListener(evt) { ...@@ -463,7 +466,6 @@ function mouseUpDragListener(evt) {
// get json menu item and render // get json menu item and render
// and ask for module at /obj/key // and ask for module at /obj/key
oncontextmenu = function(evt) { oncontextmenu = function(evt) {
console.log(evt.target)
if (evt.target.className == 'modname') { if (evt.target.className == 'modname') {
var modRep = program.modules[evt.target.innerHTML] var modRep = program.modules[evt.target.innerHTML]
if (modRep) { if (modRep) {
...@@ -503,6 +505,9 @@ document.onkeydown = function(evt) { ...@@ -503,6 +505,9 @@ document.onkeydown = function(evt) {
case 'm': case 'm':
socketSend('get module menu', '') socketSend('get module menu', '')
break break
case 'd':
console.log(program)
break
default: default:
break break
} }
...@@ -511,8 +516,8 @@ document.onkeydown = function(evt) { ...@@ -511,8 +516,8 @@ document.onkeydown = function(evt) {
function writeModuleOptionMenu(modRep) { function writeModuleOptionMenu(modRep) {
var menuDom = document.createElement('div') var menuDom = document.createElement('div')
menuDom.id = 'perModuleMenu' menuDom.id = 'perModuleMenu'
menuDom.style.left = 10 + modRep.ui.domElem.offsetLeft + modRep.ui.domElem.offsetWidth + 'px' menuDom.style.left = 10 + modrep.dom.domElem.offsetLeft + modrep.dom.domElem.offsetWidth + 'px'
menuDom.style.top = modRep.ui.domElem.offsetTop + 'px' menuDom.style.top = modRep.dom.domElem.offsetTop + 'px'
// future: rm all inputs, rm all outputs, rename, open (heirarchy) // future: rm all inputs, rm all outputs, rename, open (heirarchy)
var opts = ['delete', 'copy'] var opts = ['delete', 'copy']
for (i in opts) { for (i in opts) {
......
This diff is collapsed.
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
<body> <body>
<link href="style.css" rel="stylesheet"> <link href="style.css" rel="stylesheet">
<!-- <script type="text/javascript" src="dat.gui.js"></script>
<script type="text/javascript" src="dummies.js"></script> -->
<script type="text/javascript" src="divtools.js"></script> <script type="text/javascript" src="divtools.js"></script>
<script type="text/javascript" src="client.js"></script> <script type="text/javascript" src="client.js"></script>
<div id = "nav"> <div id = "nav">
......
This diff is collapsed.
console.log('hello lib load')
\ No newline at end of file
G0 F25 Z5 G0 F25 Z5
G0 X27.5Y111.5 G0 X27.5Y111.5
G0 Z-2 G0 Z3
G0 Y83.5 G0 Y83.5
G0 X14.5 G0 X14.5
G0 Y27.5 G0 Y27.5
...@@ -13,7 +13,7 @@ G0 Y83.5 ...@@ -13,7 +13,7 @@ G0 Y83.5
G0 X-1.5 G0 X-1.5
G0 Y111.5 G0 Y111.5
G0 X27.5 G0 X27.5
G0 Z-4 G0 Z2
G0 Y83.5 G0 Y83.5
G0 X14.5 G0 X14.5
G0 Y27.5 G0 Y27.5
...@@ -26,7 +26,7 @@ G0 Y83.5 ...@@ -26,7 +26,7 @@ G0 Y83.5
G0 X-1.5 G0 X-1.5
G0 Y111.5 G0 Y111.5
G0 X27.5 G0 X27.5
G0 Z-6 G0 Z1
G0 Y83.5 G0 Y83.5
G0 X14.5 G0 X14.5
G0 Y27.5 G0 Y27.5
...@@ -39,5 +39,5 @@ G0 Y83.5 ...@@ -39,5 +39,5 @@ G0 Y83.5
G0 X-1.5 G0 X-1.5
G0 Y111.5 G0 Y111.5
G0 X27.5 G0 X27.5
G0 Z10 G0 Z5
G0 X-40Y140 G0 X10Y100
\ No newline at end of file \ No newline at end of file
// boilerplate atkapi header // boilerplate atkapi header
const InOut = require('../../lib/jsunit.js') const JSUnit = require('../../src/jsunit.js')
let Input = InOut.Input let Input = JSUnit.Input
let Output = InOut.Output let Output = JSUnit.Output
let State = InOut.State let State = JSUnit.State
let Button = InOut.Button let Button = JSUnit.Button
// the 'andflow' flowcontrol unit only lets events through once both have occurred ... // the 'andflow' flowcontrol unit only lets events through once both have occurred ...
......
// boilerplate atkapi header // boilerplate atkapi header
const InOut = require('../../lib/jsunit.js') const JSUnit = require('../../src/jsunit.js')
let Input = InOut.Input let Input = JSUnit.Input
let Output = InOut.Output let Output = JSUnit.Output
let State = InOut.State let State = JSUnit.State
let Button = InOut.Button let Button = JSUnit.Button
const Hardware = require('../../lib/atkunit.js') const Hardware = require('../../src/atkunit.js')
const PCKT = require('../../lib/packets.js') const PCKT = require('../../src/packets.js')
// a constructor, a fn, a javascript mess // a constructor, a fn, a javascript mess
function ATKBreadBoardBoard() { function ATKBreadBoardBoard() {
......
// boilerplate atkapi header // boilerplate atkapi header
const InOut = require('../../lib/jsunit.js') const JSUnit = require('../../src/jsunit.js')
let Input = InOut.Input let Input = JSUnit.Input
let Output = InOut.Output let Output = JSUnit.Output
let State = InOut.State let State = JSUnit.State
let Button = InOut.Button let Button = JSUnit.Button
const Hardware = require('../../lib/atkunit.js') const Hardware = require('../../src/atkunit.js')
const PCKT = require('../../lib/packets.js') const PCKT = require('../../src/packets.js')
// a constructor, a fn, a javascript mess // a constructor, a fn, a javascript mess
function ATKMathRobot() { function ATKMathRobot() {
......
// boilerplate atkapi header // boilerplate atkapi header
const InOut = require('../../lib/jsunit.js') const JSUnit = require('../../src/jsunit.js')
let Input = InOut.Input let Input = JSUnit.Input
let Output = InOut.Output let Output = JSUnit.Output
let State = InOut.State let State = JSUnit.State
let Button = InOut.Button let Button = JSUnit.Button
const SerialPort = require('serialport') const SerialPort = require('serialport')
......
// boilerplate atkapi header // boilerplate atkapi header
const InOut = require('../../lib/jsunit.js') const JSUnit = require('../../src/jsunit.js')
let Input = InOut.Input let Input = JSUnit.Input
let Output = InOut.Output let Output = JSUnit.Output
let State = InOut.State let State = JSUnit.State
let Button = InOut.Button let Button = JSUnit.Button
const MJS = require('mathjs') const MJS = require('mathjs')
const DCRT = require('../../lib/cartesian.js') const DCRT = require('../../src/cartesian.js')
const Hardware = require('../../lib/atkunit.js') const Hardware = require('../../src/atkunit.js')
const PCKT = require('../../lib/packets.js') const PCKT = require('../../src/packets.js')
function Stepper() { function Stepper() {
......
// boilerplate atkapi header // boilerplate atkapi header
const InOut = require('../../lib/jsunit.js') const JSUnit = require('../../src/jsunit.js')
let Input = InOut.Input let Input = JSUnit.Input
let Output = InOut.Output let Output = JSUnit.Output
let State = InOut.State let State = JSUnit.State
let Button = InOut.Button let Button = JSUnit.Button
var NodeWebcam = require("node-webcam") var NodeWebcam = require("node-webcam")
......
// boilerplate atkapi header // boilerplate atkapi header
const InOut = require('../../lib/jsunit.js') const JSUnit = require('../../src/jsunit.js')
let Input = InOut.Input let Input = JSUnit.Input
let Output = InOut.Output let Output = JSUnit.Output
let State = InOut.State let State = JSUnit.State
let Button = InOut.Button let Button = JSUnit.Button
// descartes, to you // descartes, to you
const DCRT = require('../../lib/cartesian.js') const DCRT = require('../../src/cartesian.js')
const MJS = require('mathjs') const MJS = require('mathjs')
// planner consumes target moves (i.e. segments having uniform speed throughout) // planner consumes target moves (i.e. segments having uniform speed throughout)
......
// boilerplate atkapi header // boilerplate atkapi header
const InOut = require('../../lib/jsunit.js') const JSUnit = require('../../src/jsunit.js')
let Input = InOut.Input let Input = JSUnit.Input
let Output = InOut.Output let Output = JSUnit.Output
let State = InOut.State let State = JSUnit.State
let Button = InOut.Button let Button = JSUnit.Button
function RawMove() { function RawMove() {
var rawmove = { var rawmove = {
......
// boilerplate atkapi header // boilerplate atkapi header
const InOut = require('../../lib/jsunit.js') const JSUnit = require('../../src/jsunit.js')
let Input = InOut.Input let Input = JSUnit.Input
let Output = InOut.Output let Output = JSUnit.Output
let State = InOut.State let State = JSUnit.State
function Gcode() { function Gcode() {
......