Skip to content
Snippets Groups Projects
Commit 3a9e50d2 authored by Jake Read's avatar Jake Read
Browse files

fix bug where not asserting OG module name / id on load from file

parent 404c91f4
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,10 @@ This project serves the developement environment / api we use to write and repre ...@@ -15,6 +15,10 @@ This project serves the developement environment / api we use to write and repre
## For MW ## For MW
- change /src to /modules or /units ?
- bug is -num modules on load
- walk program units and change - walk program units and change
- rename inout to jsunit - rename inout to jsunit
- buttons get onClick evt - buttons get onClick evt
......
...@@ -5,7 +5,7 @@ const Reps = require('./reps.js') ...@@ -5,7 +5,7 @@ const Reps = require('./reps.js')
const JSUnit = require('./lib/jsunit.js') const JSUnit = require('./lib/jsunit.js')
let isStateKey = JSUnit.isStateKey let isStateKey = JSUnit.isStateKey
function loadModuleFromSource(program, path) { function loadModuleFromSource(program, path, id) {
// source -> heap // source -> heap
if (fs.existsSync(path)) { if (fs.existsSync(path)) {
var src = require(path) var src = require(path)
...@@ -19,7 +19,11 @@ function loadModuleFromSource(program, path) { ...@@ -19,7 +19,11 @@ function loadModuleFromSource(program, path) {
} }
// make unique name // make unique name
if (id) {
mod.description.id = id
} else {
mod.description.id = mod.description.name + '-' + program.description.counter mod.description.id = mod.description.name + '-' + program.description.counter
}
mod.description.path = path mod.description.path = path
// add to program object // add to program object
...@@ -161,7 +165,7 @@ function openProgram(path){ ...@@ -161,7 +165,7 @@ function openProgram(path){
for (key in prgRep.modules) { for (key in prgRep.modules) {
var mdlRep = prgRep.modules[key] var mdlRep = prgRep.modules[key]
loadModuleFromSource(program, mdlRep.description.path) loadModuleFromSource(program, mdlRep.description.path, mdlRep.description.id)
} }
// restore saved state and links // restore saved state and links
...@@ -173,6 +177,12 @@ function openProgram(path){ ...@@ -173,6 +177,12 @@ function openProgram(path){
// this is the actual object, having functions and whatnot // this is the actual object, having functions and whatnot
var mdl = program.modules[modName] var mdl = program.modules[modName]
if (mdl == null) {
console.log('NULL')
console.log('prgRep modules', prgRep.modules)
console.log('program modules', program.modules)
}
// hooking outputs -> inputs // hooking outputs -> inputs
for (outName in mdlRep.outputs) { for (outName in mdlRep.outputs) {
var outRep = mdlRep.outputs[outName] var outRep = mdlRep.outputs[outName]
...@@ -197,6 +207,8 @@ function openProgram(path){ ...@@ -197,6 +207,8 @@ function openProgram(path){
} }
} }
console.log('mdlRep', mdlRep)
console.log('mdl', mdl)
// restore position / UI state // restore position / UI state
if (mdlRep.description.position != null) { if (mdlRep.description.position != null) {
// ?? // ??
......
...@@ -97,36 +97,6 @@ ...@@ -97,36 +97,6 @@
"message": "---" "message": "---"
} }
}, },
"Breadboard Servo Signal Generator-6": {
"description": {
"id": "Breadboard Servo Signal Generator-6",
"name": "Breadboard Servo Signal Generator",
"alt": "servo",
"path": "./src/hardware/servo.js",
"position": {
"left": 583,
"top": 632
}
},
"inputs": {
"packet": {
"accepts": "headless packet"
}
},
"outputs": {
"packet": {
"emits": "number",
"calls": []
}
},
"state": {
"button": {
"type": "button",
"label": "SEND"
},
"servoVal": 0
}
},
"delay-7": { "delay-7": {
"description": { "description": {
"id": "delay-7", "id": "delay-7",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment