trouble loading program from file in main.js
hi jake, this isn't critical since i can manually load and save programs, but i thought i'd share...
When i run "node main", I get the following error message:
ERROR MESSAGE:
/Users/quacht/Documents/Course/htmaa/rndmc/views.js:122
if (sckt.readyState === 1) {
^
TypeError: Cannot read property 'readyState' of null
at Object.socketSend [as send] (/Users/quacht/Documents/Course/htmaa/rndmc/views.js:122:14)
at pushState (/Users/quacht/Documents/Course/htmaa/rndmc/programs.js:173:12)
at Object.set [as isRunning] (/Users/quacht/Documents/Course/htmaa/rndmc/programs.js:133:17)
at Object.Planner.planner.init (/Users/quacht/Documents/Course/htmaa/rndmc/modules/motion/planner.js:61:25)
at Object.openProgram [as open] (/Users/quacht/Documents/Course/htmaa/rndmc/programs.js:278:17)
at Object.<anonymous> (/Users/quacht/Documents/Course/htmaa/rndmc/main.js:39:24)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
The last logs before the error message were
ADDING Multi-line Text Input-12 to new program1
ATTACHING acks to ack
ATTACHING acks to ack
ATTACHING acks to ack
ATTACHING thru to whammy
ATTACHING evt to whammy
ATTACHING req to out
ATTACHING run to out
ATTACHING trapezoid to moves
ATTACHING trapezoid to moves
ATTACHING trapezoid to moves
ATTACHING trapezoid to moves
ATTACHING req to moveComplete
main.js CODE:
//
//
// new node controller / HEAP
//
// main.js
//
//
// Jake Read at the Center for Bits and Atoms
// (c) Massachusetts Institute of Technology 2018
//
// This work may be reproduced, modified, distributed, performed, and
// displayed for any purpose, but must acknowledge the mods
// project. Copyright is retained and must be preserved. The work is
// provided as is; no warranty is provided, and users accept all
// liability.
/*
RULES:
modules are objects having inputs, outputs, and state
programs are assemblies of modules
*/
// business
const Reps = require('./reps.js')
const Programs = require('./programs.js')
// // create a new program
// var program = Programs.new('new program')
// UI
const View = require('./views.js')
View.startHttp()
View.startWs()
Programs.assignSocket(View.uiSocket)
var program = Programs.open('./programs/fourmotors-oneplanner.json')
// load modules
var input2d = Programs.loadModuleFromSource(program, './modules/input/input2d.js')
var multiline = Programs.loadModuleFromSource(program, './modules/ui/multiline.js')
var gcode = Programs.loadModuleFromSource(program, './modules/parsing/gcode.js')
var logger = Programs.loadModuleFromSource(program, './modules/util/log.js')
// connect modules
input2d.outputs.gcode.attach(gcode.inputs.lineIn)
// multiline.outputs.gcode.attach(gcode.inputs.lineIn)
// position modules
// gcode.description.position = {
// left: 100,
// top: 400
// }
View.assignProgram(program)