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.
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:
......@@ -149,11 +149,11 @@ Besides Inputs, Outputs, a Description and State object, anything else goes. I.E
```javascript
// boilerplate rndmc header
const InOut = require('../../lib/jsunit.js')
let Input = InOut.Input
let Output = InOut.Output
let State = InOut.State
let Button = InOut.Button
const JSUnit = require('../../src/jsunit.js')
let Input = JSUnit.Input
let Output = JSUnit.Output
let State = JSUnit.State
let Button = JSUnit.Button
// a constructor, a fn, a javascript mess
function uiNum() {
......@@ -265,27 +265,47 @@ View.assignProgram(program)
# Development Notes
## For MW
## Immediately
- want that better-planner
- do axis pullout separately from stepper motor ?
- ui / button
- bug hunting
- dereferenced events / stepper axis vector
- multiple button calls ...
- stepper / planner bug
- is load / save really consistent ? what is the state answer ?
- would like to send board with new buck out to fab
- just do stepper23, bc if that's it, that's it ?
- title is still 'xperiment'
- stepper move.vector is a ref issue? derefed before running calcTrap() ? runs ? in planner ?
- tuning:
- 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
## Documentation
- GIFS
## Forever
- open the door, no cuffs
- option for 'native' multithreading by opening workers on each event ?
## Questionable Moves
- module deletion seems unclean
......@@ -294,8 +314,6 @@ View.assignProgram(program)
## WRT Representations
OK, should write this out properly at some point.
Module have
Inputs
Outputs
......@@ -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
## Desires
- reload / edit individual modules ?
- modules spawn new inputs / outputs ?
- big UI ?
- arrows catch for jogging
- editing ?
- heirarchy zoom
- 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 ?
......@@ -333,6 +356,7 @@ To assemble a representation of these, we want to have a kind of 'netlist' that,
- consistent dereferencing, type checking implementation?
## 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...
- off-screen divs get pointers-to so that we don't get lost
- 'h' or something to zoom-to-extents
......
......@@ -31,6 +31,8 @@ var lastPos = { x: 10, y: 30 }
var wrapper = {}
var nav = {}
var verbose = false
/*
STARTUP ---------------------------------------------------
......@@ -64,7 +66,7 @@ window.onload = function() {
sckt = this
// say hello
socketSend('console', 'hello server')
console.log('socket open')
console.log('SCKT: socket open')
// ask for the current program
socketSend('get current program', '')
// main socket entry point
......@@ -75,10 +77,10 @@ window.onload = function() {
this.onerror = (err) => {
alert('link to server is broken')
location.reload()
console.log('socket error', err)
console.log('SCKT: socket error', err)
}
this.onclose = (evt) => {
console.log('socket closed', evt)
console.log('SCKT: socket closed', evt)
sckt = null
}
}
......@@ -110,33 +112,37 @@ function socketRecv(evt) {
console.log('RECV CONSOLE:', data)
break
case 'put module menu':
console.log('RECV MODULE MENU')
if(verbose) console.log('RECV MODULE MENU')
heapSendsModuleMenu(data)
break
case 'put program menu':
console.log('RECV PRG MENU')
if(verbose) console.log('RECV PRG MENU')
heapSendsProgramMenu(data)
break
case 'put program':
console.log('RECV PROGRAM')
if(verbose) console.log('RECV PROGRAM')
heapSendsNewProgram(data)
break
case 'put module':
console.log('RECV NEW MODULE')
if(verbose) console.log('RECV NEW MODULE')
heapSendsNewModule(data)
break
case 'put module change':
console.log('RECV MODULE CHANGE')
if(verbose) console.log('RECV MODULE CHANGE')
heapSendsModuleChange(data)
break
case 'put state change':
console.log('RECV STATE CHANGE')
if(verbose) console.log('RECV STATE CHANGE')
heapSendsStateChange(data)
break
case 'put ui change':
if(verbose) console.log('RECV UI CHANGE')
heapSendsUiChange(data)
break
case 'restart':
location.reload()
default:
console.log('ERR recv with non recognized type', recv)
console.log('ERR: recv with non recognized type', recv)
break
}
}
......@@ -157,7 +163,7 @@ HEAP -> SERVER ---------------------------------------------------
// always a rep, tho
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
function heapSendsNewProgram(prgm) {
......@@ -166,7 +172,7 @@ function heapSendsNewProgram(prgm) {
program = prgm
// 1st we want to git rm old files ...
// 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) {
addRepToView(program.modules[mdlName])
}
......@@ -186,11 +192,11 @@ function heapSendsNewModule(mdl) {
}
// 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
function heapSendsModuleChange(data) {
console.log(data)
if(verbose) console.log('HEAP SENDS MODULE CHANGE', data)
// data should be rep of changed module
var rep = program.modules[data.description.id]
// we want a general case, but for now we know we're looking for
......@@ -206,7 +212,7 @@ function heapSendsModuleChange(data) {
var stateItem = rep.state[key]
if (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?
......@@ -216,16 +222,21 @@ function heapSendsModuleChange(data) {
// update state from server to UI
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]
rep.state[data.key] = data.val
if (rep.state[data.key].type == 'multiline') {
rep.ui.state[data.key].value = data.val.value
if (typeof data.val == 'boolean') {
rep.dom.state[data.key].innerHTML = data.key + ':\t\t' + rep.state[data.key].toString()
} 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 ---------------------------------------------------
......@@ -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() {
// probably not a great way to do this, we're removing everything
// svg -rm -r
......@@ -313,14 +316,14 @@ function redrawLinks() {
svg.removeChild(svg.firstChild)
}
// draw origin
var og1 = newLine(-15,0,15,0,5, false)
var og2 = newLine(0,-15,0,15,5, false)
var og1 = newLine(-15, 0, 15, 0, 5, false)
var og2 = newLine(0, -15, 0, 15, 5, false)
// find that link
var lnkPt
var nLnk = 0
for (mdlName in program.modules) {
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
......@@ -328,11 +331,11 @@ function redrawLinks() {
var mdlRep = program.modules[mdlName]
for (key in mdlRep.outputs) {
var output = mdlRep.outputs[key]
var outputUi = mdlRep.ui.outputs[key]
var outputUi = mdlRep.dom.outputs[key]
for (input in output.calls) {
var toId = output.calls[input].parentId
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 inPos = getInputArrow(inputUi)
if (inputUi.isHovering || outputUi.isHovering) {
......@@ -344,7 +347,7 @@ function redrawLinks() {
}
if (mdlRep.description.isHardware && !mdlRep.description.isLink) {
nLnk++
var hwPt = getRightWall(mdlRep.ui.domElem)
var hwPt = getRightWall(mdlRep.dom.domElem)
lnkPt.y += 5 * nLnk
var ln = newLine(hwPt.x, hwPt.y, lnkPt.x, lnkPt.y, 7, true)
}
......@@ -463,7 +466,6 @@ function mouseUpDragListener(evt) {
// get json menu item and render
// and ask for module at /obj/key
oncontextmenu = function(evt) {
console.log(evt.target)
if (evt.target.className == 'modname') {
var modRep = program.modules[evt.target.innerHTML]
if (modRep) {
......@@ -503,6 +505,9 @@ document.onkeydown = function(evt) {
case 'm':
socketSend('get module menu', '')
break
case 'd':
console.log(program)
break
default:
break
}
......@@ -511,8 +516,8 @@ document.onkeydown = function(evt) {
function writeModuleOptionMenu(modRep) {
var menuDom = document.createElement('div')
menuDom.id = 'perModuleMenu'
menuDom.style.left = 10 + modRep.ui.domElem.offsetLeft + modRep.ui.domElem.offsetWidth + 'px'
menuDom.style.top = modRep.ui.domElem.offsetTop + 'px'
menuDom.style.left = 10 + modrep.dom.domElem.offsetLeft + modrep.dom.domElem.offsetWidth + 'px'
menuDom.style.top = modRep.dom.domElem.offsetTop + 'px'
// future: rm all inputs, rm all outputs, rename, open (heirarchy)
var opts = ['delete', 'copy']
for (i in opts) {
......
This diff is collapsed.
......@@ -7,8 +7,6 @@
<body>
<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="client.js"></script>
<div id = "nav">
......
This diff is collapsed.
console.log('hello lib load')
\ No newline at end of file
G0 F25 Z5
G0 X27.5Y111.5
G0 Z-2
G0 Z3
G0 Y83.5
G0 X14.5
G0 Y27.5
......@@ -13,7 +13,7 @@ G0 Y83.5
G0 X-1.5
G0 Y111.5
G0 X27.5
G0 Z-4
G0 Z2
G0 Y83.5
G0 X14.5
G0 Y27.5
......@@ -26,7 +26,7 @@ G0 Y83.5
G0 X-1.5
G0 Y111.5
G0 X27.5
G0 Z-6
G0 Z1
G0 Y83.5
G0 X14.5
G0 Y27.5
......@@ -39,5 +39,5 @@ G0 Y83.5
G0 X-1.5
G0 Y111.5
G0 X27.5
G0 Z10
G0 X-40Y140
\ No newline at end of file
G0 Z5
G0 X10Y100
\ No newline at end of file
// boilerplate atkapi header
const InOut = require('../../lib/jsunit.js')
let Input = InOut.Input
let Output = InOut.Output
let State = InOut.State
let Button = InOut.Button
const JSUnit = require('../../src/jsunit.js')
let Input = JSUnit.Input
let Output = JSUnit.Output
let State = JSUnit.State
let Button = JSUnit.Button
// the 'andflow' flowcontrol unit only lets events through once both have occurred ...
......
// boilerplate atkapi header
const InOut = require('../../lib/jsunit.js')
let Input = InOut.Input
let Output = InOut.Output
let State = InOut.State
let Button = InOut.Button
const Hardware = require('../../lib/atkunit.js')
const PCKT = require('../../lib/packets.js')
const JSUnit = require('../../src/jsunit.js')
let Input = JSUnit.Input
let Output = JSUnit.Output
let State = JSUnit.State
let Button = JSUnit.Button
const Hardware = require('../../src/atkunit.js')
const PCKT = require('../../src/packets.js')
// a constructor, a fn, a javascript mess
function ATKBreadBoardBoard() {
......
// boilerplate atkapi header
const InOut = require('../../lib/jsunit.js')
let Input = InOut.Input
let Output = InOut.Output
let State = InOut.State
let Button = InOut.Button
const Hardware = require('../../lib/atkunit.js')
const PCKT = require('../../lib/packets.js')
const JSUnit = require('../../src/jsunit.js')
let Input = JSUnit.Input
let Output = JSUnit.Output
let State = JSUnit.State
let Button = JSUnit.Button
const Hardware = require('../../src/atkunit.js')
const PCKT = require('../../src/packets.js')
// a constructor, a fn, a javascript mess
function ATKMathRobot() {
......
// boilerplate atkapi header
const InOut = require('../../lib/jsunit.js')
let Input = InOut.Input
let Output = InOut.Output
const JSUnit = require('../../src/jsunit.js')
let Input = JSUnit.Input
let Output = JSUnit.Output
let State = InOut.State
let Button = InOut.Button
let State = JSUnit.State
let Button = JSUnit.Button
const SerialPort = require('serialport')
......
// boilerplate atkapi header
const InOut = require('../../lib/jsunit.js')
let Input = InOut.Input
let Output = InOut.Output
const JSUnit = require('../../src/jsunit.js')
let Input = JSUnit.Input
let Output = JSUnit.Output
let State = InOut.State
let Button = InOut.Button
let State = JSUnit.State
let Button = JSUnit.Button
const MJS = require('mathjs')
const DCRT = require('../../lib/cartesian.js')
const DCRT = require('../../src/cartesian.js')
const Hardware = require('../../lib/atkunit.js')
const PCKT = require('../../lib/packets.js')
const Hardware = require('../../src/atkunit.js')
const PCKT = require('../../src/packets.js')
function Stepper() {
......
// boilerplate atkapi header
const InOut = require('../../lib/jsunit.js')
let Input = InOut.Input
let Output = InOut.Output
let State = InOut.State
let Button = InOut.Button
const JSUnit = require('../../src/jsunit.js')
let Input = JSUnit.Input
let Output = JSUnit.Output
let State = JSUnit.State
let Button = JSUnit.Button
var NodeWebcam = require("node-webcam")
......
// boilerplate atkapi header
const InOut = require('../../lib/jsunit.js')
let Input = InOut.Input
let Output = InOut.Output
let State = InOut.State
let Button = InOut.Button
const JSUnit = require('../../src/jsunit.js')
let Input = JSUnit.Input
let Output = JSUnit.Output
let State = JSUnit.State
let Button = JSUnit.Button
// descartes, to you
const DCRT = require('../../lib/cartesian.js')
const DCRT = require('../../src/cartesian.js')
const MJS = require('mathjs')
// planner consumes target moves (i.e. segments having uniform speed throughout)
......
// boilerplate atkapi header
const InOut = require('../../lib/jsunit.js')
let Input = InOut.Input
let Output = InOut.Output
let State = InOut.State
let Button = InOut.Button
const JSUnit = require('../../src/jsunit.js')
let Input = JSUnit.Input
let Output = JSUnit.Output
let State = JSUnit.State
let Button = JSUnit.Button
function RawMove() {
var rawmove = {
......
// boilerplate atkapi header
const InOut = require('../../lib/jsunit.js')
let Input = InOut.Input
let Output = InOut.Output
let State = InOut.State
const JSUnit = require('../../src/jsunit.js')
let Input = JSUnit.Input
let Output = JSUnit.Output
let State = JSUnit.State
function Gcode() {
......
// boilerplate atkapi header
const InOut = require('../../lib/jsunit.js')
let Input = InOut.Input
let Output = InOut.Output
let State = InOut.State
let Button = InOut.Button
const JSUnit = require('../../src/jsunit.js')
let Input = JSUnit.Input
let Output = JSUnit.Output
let State = JSUnit.State
let Button = JSUnit.Button
// a constructor, a fn, a javascript mess
function uiButton() {
......
// boilerplate atkapi header
const InOut = require('../../lib/jsunit.js')
let Input = InOut.Input
let Output = InOut.Output
let State = InOut.State
const JSUnit = require('../../src/jsunit.js')
let Input = JSUnit.Input
let Output = JSUnit.Output
let MultiLine = InOut.MultiLine
let Button = InOut.Button
let State = JSUnit.State
const fs = require('fs')
......@@ -22,9 +20,8 @@ function MultiLineIn() {
multilinein.state = State()
// alias !
var state = multilinein.state
state.load = Button('LOAD', onLoadFile)
state.thru = Button('WHAM', lineThru)
state.load = State.newButton('--', onLoadFile)
state.thru = Button('THRU', lineThru)
state.previously = MultiLine('lines complete', 11)
state.now = MultiLine('line just out', 1)
state.incoming = MultiLine('future lines', 36)
......@@ -94,6 +91,8 @@ function MultiLineIn() {
multilinein.load = onLoadFile
onLoadFile('./files/dogbone.gcode')
function onExternalLine(str) {
// push new str to bottom of queue
}
......
// boilerplate rndmc header
const InOut = require('../../lib/jsunit.js')
let Input = InOut.Input
let Output = InOut.Output
let State = InOut.State
let Button = InOut.Button
const JSUnit = require('../../src/jsunit.js')
let Input = JSUnit.Input
let Output = JSUnit.Output
let State = JSUnit.State
let Button = JSUnit.Button
// a constructor, a fn, a javascript mess
function uiNum() {
......
const JSUnit = require('../../src/jsunit.js')
let Input = JSUnit.Input
let Output = JSUnit.Output
let State = JSUnit.State
// interface elements
const JSUI = require('../../src/jsui.js')
let UI = JSUI.UI
function STest() {
var stest = {
description:{
name: 'test-for-state',
alt: 'a description'
}
}
// state is numbers, strings, arrays of either, booleans
// booleans are buttons
stest.state = State()
var state = stest.state
state.num = 12
state.str = 'one string'
state.arr = new Array()
state.arr.push(12)
state.arr.push(24)
state.strarr = new Array()
state.strarr.push('str1')
state.strarr.push('str2')
state.boolean = false
stest.inputs = {
inp: Input('any', onInp)
}
function onInp(evt){
console.log('ex input', evt)
}
stest.outputs = {
outp: Output('any')
}
// other items for interaction are explicitly UI
stest.ui = UI()
var ui = stest.ui
ui.addElement('btnex', './ui/uiButton.js', onButtonData)
function onButtonData(evt){
console.log('button change evt', evt)
ui.btnex.isPressed = true
}
return stest
}
module.exports = STest
\ No newline at end of file
// boilerplate atkapi header
const InOut = require('../../lib/jsunit.js')
let Input = InOut.Input
let Output = InOut.Output
let State = InOut.State
const JSUnit = require('../../src/jsunit.js')
let Input = JSUnit.Input
let Output = JSUnit.Output
let State = JSUnit.State
// a constructor, a fn, a javascript mess
function Terminal() {
......
// boilerplate atkapi header
const InOut = require('../../lib/jsunit.js')
let Input = InOut.Input
let Output = InOut.Output
let State = InOut.State
let Button = InOut.Button
const JSUnit = require('../../src/jsunit.js')
let Input = JSUnit.Input
let Output = JSUnit.Output
let State = JSUnit.State
let Button = JSUnit.Button
// a constructor, a fn, a javascript mess
function AndFlowControl() {
......
// boilerplate atkapi header
// boilerplate header
const JSUnit = require('../../lib/jsunit.js')
const JSUnit = require('../../src/jsunit.js')
let Input = JSUnit.Input
let Output = JSUnit.Output
let State = JSUnit.State
......
// boilerplate header
const JSUnit = require('../../lib/jsunit.js')
const JSUnit