From 404c91f4048784c40ade1fa3d06142e2fb207a91 Mon Sep 17 00:00:00 2001
From: Jake <jake.read@cba.mit.edu>
Date: Sun, 11 Nov 2018 18:54:14 -0500
Subject: [PATCH] ...

---
 README.md         |   1 +
 client/dummies.js |  47 -----------
 main.js           |   1 -
 programs.js       |   2 +
 programs/dmz.json | 210 ++++++++++++++++++++++++++++++++++++++++++++++
 src/util/gate.js  |   3 +-
 6 files changed, 215 insertions(+), 49 deletions(-)
 delete mode 100644 client/dummies.js
 create mode 100644 programs/dmz.json

diff --git a/README.md b/README.md
index 1818901..1ec3780 100644
--- a/README.md
+++ b/README.md
@@ -35,6 +35,7 @@ This project serves the developement environment / api we use to write and repre
   - change settings 
 
 ## Questionable Moves
+ - test load of dmz.json - unordered list / names / no mdl ? 
  - module deletion seems unclean
  - input / output objects should be able to unhook themselves: 
   - keep references of what-is-attached ? 
diff --git a/client/dummies.js b/client/dummies.js
deleted file mode 100644
index c2dafcb..0000000
--- a/client/dummies.js
+++ /dev/null
@@ -1,47 +0,0 @@
-
-var gcodeDummy = {
-    name: 'gcode',
-    id: 12,
-    state: {
-        mode: 'G0',
-        flavor: 'sensible',
-        speeds: {
-            G0: 1200,
-            G1: 400
-        }
-    },
-    inputs: {
-        lineIn: {
-            type: 'string',
-            description: 'single line to parse'
-        }
-    },
-    outputs: {
-        instruction: {
-            type: 'object',
-            class: 'MoveInstruction',
-            description: 'parsed move instruction'
-        }
-    }
-}
-
-
-var terminalDummy = {
-    name: 'terminal',
-    id: 13,
-    state: {
-        width: 64,
-        height: 48
-    },
-    inputs: {
-        lineIn: {
-            type: 'object'
-        }
-    },
-    outputs: {
-        lineOut: {
-            type: 'string',
-            description: 'line from terminal'
-        }
-    }
-}
\ No newline at end of file
diff --git a/main.js b/main.js
index 51c6645..aa864d4 100644
--- a/main.js
+++ b/main.js
@@ -31,7 +31,6 @@ var program = {}
 
 program = Programs.open('programs/default.json')
 
-
 // UI 
 const View = require('./views.js')
 View.startHttp() 
diff --git a/programs.js b/programs.js
index f46a749..072d432 100644
--- a/programs.js
+++ b/programs.js
@@ -169,6 +169,7 @@ function openProgram(path){
         // keys should be identical for rep and heap
         // this is the representation that we're opening up from 
         var mdlRep = prgRep.modules[modName]
+
         // this is the actual object, having functions and whatnot 
         var mdl = program.modules[modName]
 
@@ -198,6 +199,7 @@ function openProgram(path){
 
         // restore position / UI state
         if(mdlRep.description.position != null){
+            // ??
             mdl.description.position = {}
             mdl.description.position.left = mdlRep.description.position.left
             mdl.description.position.top = mdlRep.description.position.top 
diff --git a/programs/dmz.json b/programs/dmz.json
new file mode 100644
index 0000000..f71cd7c
--- /dev/null
+++ b/programs/dmz.json
@@ -0,0 +1,210 @@
+{
+  "description": {
+    "name": "tstprgmem",
+    "counter": 9
+  },
+  "modules": {
+    "gate-1": {
+      "description": {
+        "id": "gate-1",
+        "name": "gate",
+        "alt": "in ... out",
+        "path": "./src/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",
+          "label": "Open / Close"
+        },
+        "message": "closed"
+      }
+    },
+    "delay-2": {
+      "description": {
+        "id": "delay-2",
+        "name": "delay",
+        "alt": "in ... out",
+        "path": "./src/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": "./src/util/log.js",
+        "position": {
+          "left": 123,
+          "top": 367
+        }
+      },
+      "inputs": {
+        "thru": {
+          "accepts": "any"
+        }
+      },
+      "outputs": {
+        "throughput": {
+          "emits": "any",
+          "calls": []
+        }
+      },
+      "state": {
+        "prefix": "LOGGER:",
+        "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": {
+      "description": {
+        "id": "delay-7",
+        "name": "delay",
+        "alt": "in ... out",
+        "path": "./src/util/delay.js",
+        "position": {
+          "left": 627,
+          "top": 193
+        }
+      },
+      "inputs": {
+        "thru": {
+          "accepts": "any"
+        }
+      },
+      "outputs": {
+        "out": {
+          "emits": "any",
+          "calls": []
+        }
+      },
+      "state": {
+        "ms": 100
+      }
+    },
+    "delay-8": {
+      "description": {
+        "id": "delay-8",
+        "name": "delay",
+        "alt": "in ... out",
+        "path": "./src/util/delay.js",
+        "position": {
+          "left": 676,
+          "top": 345
+        }
+      },
+      "inputs": {
+        "thru": {
+          "accepts": "any"
+        }
+      },
+      "outputs": {
+        "out": {
+          "emits": "any",
+          "calls": []
+        }
+      },
+      "state": {
+        "ms": 100
+      }
+    },
+    "logger-9": {
+      "description": {
+        "id": "logger-9",
+        "name": "logger",
+        "alt": "in ... out to console",
+        "path": "./src/util/log.js",
+        "position": {
+          "left": 622,
+          "top": 467
+        }
+      },
+      "inputs": {
+        "thru": {
+          "accepts": "any"
+        }
+      },
+      "outputs": {
+        "throughput": {
+          "emits": "any",
+          "calls": []
+        }
+      },
+      "state": {
+        "prefix": "LOGGER:",
+        "message": "---"
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/util/gate.js b/src/util/gate.js
index cb46f95..ea6e1c9 100644
--- a/src/util/gate.js
+++ b/src/util/gate.js
@@ -21,9 +21,10 @@ function Gate() {
     var state = gate.state 
 
     state.toggle = Button("Open / Close", onButtonPress)
+    state.message = 'closed'
+
     // yikes 
     gate.isOpen = false
-    state.message = 'closed'
 
     gate.inputs = {
         thru: Input('any', gateKeeper) // makes anything into '1' event
-- 
GitLab