From a17dd15bd0ea1aed9c26901391956113694f6615 Mon Sep 17 00:00:00 2001 From: Jake <jake.read@cba.mit.edu> Date: Sun, 11 Nov 2018 22:53:07 -0500 Subject: [PATCH] state loads --- client/style.css | 4 ++ modules/util/delay.js | 2 +- programs.js | 8 ++-- programs/dflt2.json | 102 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 5 deletions(-) create mode 100644 programs/dflt2.json diff --git a/client/style.css b/client/style.css index 4c3c94d..af472f1 100644 --- a/client/style.css +++ b/client/style.css @@ -123,4 +123,8 @@ li:active{ width: 80px; padding: 3px; background-color: #303030; +} + +#nav { + font-size: 15px; } \ No newline at end of file diff --git a/modules/util/delay.js b/modules/util/delay.js index abf1b6f..fd7b9f0 100644 --- a/modules/util/delay.js +++ b/modules/util/delay.js @@ -32,8 +32,8 @@ function Delay() { } function onMsChange(){ + // a test fn console.log("noting state change", state.ms) - state.ms = 1200 } function onDelayBegin(input){ diff --git a/programs.js b/programs.js index 9221b38..369a8f0 100644 --- a/programs.js +++ b/programs.js @@ -200,10 +200,10 @@ function openProgram(path) { // restoring state for (key in mdlRep.state) { if (isStateKey(key)) { - console.log("STATE - NEEDS WORK", key) - // want to do this without asserting the change though - // actually, if new paradigm, we don't call .onChange - // rename .onChange for 'onUiChange' or something + // 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] } } diff --git a/programs/dflt2.json b/programs/dflt2.json new file mode 100644 index 0000000..4a80267 --- /dev/null +++ b/programs/dflt2.json @@ -0,0 +1,102 @@ +{ + "description": { + "name": "tstprgmem", + "counter": 3 + }, + "modules": { + "gate-1": { + "description": { + "id": "gate-1", + "name": "gate", + "alt": "in ... out", + "path": "./modules/util/gate.js", + "position": { + "left": 10, + "top": 30 + } + }, + "inputs": { + "thru": { + "accepts": "any" + } + }, + "outputs": { + "out": { + "emits": "any", + "calls": [ + { + "parentId": "delay-2", + "key": "thru" + } + ] + } + }, + "state": { + "toggle": { + "type": "button", + "isPressed": false, + "label": "Open / Close" + }, + "message": "closed" + } + }, + "delay-2": { + "description": { + "id": "delay-2", + "name": "delay", + "alt": "in ... out", + "path": "./modules/util/delay.js", + "position": { + "left": 132, + "top": 225 + } + }, + "inputs": { + "thru": { + "accepts": "any" + } + }, + "outputs": { + "out": { + "emits": "any", + "calls": [ + { + "parentId": "logger-3", + "key": "thru" + } + ] + } + }, + "state": { + "ms": 1200 + } + }, + "logger-3": { + "description": { + "id": "logger-3", + "name": "logger", + "alt": "in ... out to console", + "path": "./modules/util/log.js", + "position": { + "left": 123, + "top": 367 + } + }, + "inputs": { + "thru": { + "accepts": "any" + } + }, + "outputs": { + "throughput": { + "emits": "any", + "calls": [] + } + }, + "state": { + "prefix": "LOGGER:", + "message": "---" + } + } + } +} \ No newline at end of file -- GitLab