Added support for new output configs
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Sat, 15 Jul 2017 05:31:50 +0000 (22:31 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Sat, 15 Jul 2017 05:31:50 +0000 (22:31 -0700)
src/jade/index.jade
src/jade/templates/io-view.jade [new file with mode: 0644]
src/jade/templates/switches-view.jade [deleted file]
src/js/app.js
src/js/io-view.js [new file with mode: 0644]
src/js/switches-view.js [deleted file]
src/py/bbctrl/Config.py
src/resources/config-template.json
src/stylus/style.styl

index 61f18d5980cd4e14b2ac64e6bbe6f2070448614b..3de168c8bf1b7f64557a4c9294b604b00fca366d 100644 (file)
@@ -47,7 +47,7 @@ html(lang="en")
               a.pure-menu-link(href="#spindle") Spindle
 
             li.pure-menu-heading
-              a.pure-menu-link(href="#switches") Switches
+              a.pure-menu-link(href="#io") I/O
 
             li.pure-menu-heading
               a.pure-menu-link(href="#gcode") Gcode
diff --git a/src/jade/templates/io-view.jade b/src/jade/templates/io-view.jade
new file mode 100644 (file)
index 0000000..b119082
--- /dev/null
@@ -0,0 +1,15 @@
+script#io-view-template(type="text/x-template")
+  #io
+    h1 I/O Configuration
+
+    h2 Switches
+    form.pure-form.pure-form-aligned
+      fieldset
+        templated-input(v-for="templ in template.switches", :name="$key",
+          :model.sync="switches[$key]", :template="templ")
+
+    h2 Outputs
+    form.pure-form.pure-form-aligned
+      fieldset
+        templated-input(v-for="templ in template.outputs", :name="$key",
+          :model.sync="outputs[$key]", :template="templ")
diff --git a/src/jade/templates/switches-view.jade b/src/jade/templates/switches-view.jade
deleted file mode 100644 (file)
index a8dc77b..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-script#switches-view-template(type="text/x-template")
-  #switches
-    h1 Switch Configuration
-
-    form.pure-form.pure-form-aligned
-      fieldset
-        templated-input(v-for="templ in template.switches", :name="$key",
-          :model.sync="switches[$key]", :template="templ")
index a4fc937d4789f545a78e1b4a890442935f43b19e..cdf61072c4785d20fc36e217a950d61c267fc50b 100644 (file)
@@ -27,7 +27,7 @@ module.exports = new Vue({
     'control-view': require('./control-view'),
     'motor-view': require('./motor-view'),
     'spindle-view': require('./spindle-view'),
-    'switches-view': require('./switches-view'),
+    'io-view': require('./io-view'),
     'gcode-view': require('./gcode-view'),
     'admin-view': require('./admin-view')
   },
diff --git a/src/js/io-view.js b/src/js/io-view.js
new file mode 100644 (file)
index 0000000..1430f10
--- /dev/null
@@ -0,0 +1,53 @@
+'use strict'
+
+
+module.exports = {
+  template: '#io-view-template',
+  props: ['config', 'template'],
+
+
+  data: function () {
+    return {
+      switches: {},
+      outputs: {}
+    }
+  },
+
+
+  events: {
+    'input-changed': function() {
+      this.$dispatch('config-changed');
+      return false;
+    }
+  },
+
+
+  ready: function () {this.update()},
+
+
+  methods: {
+    update: function () {
+      Vue.nextTick(function () {
+        // Switches
+        if (this.config.hasOwnProperty('switches'))
+          this.switches = this.config.switches;
+        else this.switches = {};
+
+        var template = this.template.switches;
+        for (var key in template)
+          if (!this.switches.hasOwnProperty(key))
+            this.$set('switches["' + key + '"]', template[key].default);
+
+        // Outputs
+        if (this.config.hasOwnProperty('outputs'))
+          this.outputs = this.config.outputs;
+        else this.outputs = {};
+
+        var template = this.template.outputs;
+        for (var key in template)
+          if (!this.outputs.hasOwnProperty(key))
+            this.$set('outputs["' + key + '"]', template[key].default);
+      }.bind(this));
+    }
+  }
+}
diff --git a/src/js/switches-view.js b/src/js/switches-view.js
deleted file mode 100644 (file)
index 6c0957a..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-'use strict'
-
-
-module.exports = {
-  template: '#switches-view-template',
-  props: ['config', 'template'],
-
-
-  data: function () {
-    return {
-      switches: {}
-    }
-  },
-
-
-  events: {
-    'input-changed': function() {
-      this.$dispatch('config-changed');
-      return false;
-    }
-  },
-
-
-  ready: function () {
-    this.update();
-  },
-
-
-  methods: {
-    update: function () {
-      Vue.nextTick(function () {
-        if (this.config.hasOwnProperty('switches'))
-          this.switches = this.config.switches;
-        else this.switches = {};
-
-        var template = this.template.switches;
-        for (var key in template)
-          if (!this.switches.hasOwnProperty(key))
-            this.$set('switches["' + key + '"]', template[key].default);
-      }.bind(this));
-    }
-  }
-}
index 9cc26d39261ea9cdba3189faf201e283bf23dc3a..d0e5c91a72758144c45eeeeaed1140da79ff9ce0 100644 (file)
@@ -16,7 +16,9 @@ default_config = {
         {"axis": "A"},
         ],
     "switches": {},
+    "outputs": {},
     "spindle": {},
+    "gcode": {},
     }
 
 
@@ -41,6 +43,11 @@ class Config(object):
         try:
             config = self.load_path('config.json')
             config['version'] = self.version
+
+            # Add missing sections
+            for key, value in default_config.items():
+                if not key in config: config[key] = value
+
             return config
 
         except Exception as e:
index 45271f4dfe057a8ead303e1273c44a4bce94bdf1..e5de560b89ab33f2b07c92d888548f056480b043 100644 (file)
     "estop": {
       "type": "enum",
       "values": ["disabled", "normally-open", "normally-closed"],
-      "default": "disabled",
+      "default": "normally-open",
       "code": "et"
     },
     "probe": {
       "type": "enum",
       "values": ["disabled", "normally-open", "normally-closed"],
-      "default": "disabled",
+      "default": "normally-open",
       "code": "pt"
     }
   },
 
+  "outputs": {
+    "load-1": {
+      "type": "enum",
+      "values": ["disabled", "lo-hi", "hi-lo", "tri-lo", "tri-hi", "lo-tri",
+                 "hi-tri"],
+      "default": "lo-hi",
+      "code": "1om"
+    },
+    "load-2": {
+      "type": "enum",
+      "values": ["disabled", "lo-hi", "hi-lo", "tri-lo", "tri-hi", "lo-tri",
+                 "hi-tri"],
+      "default": "lo-hi",
+      "code": "2om"
+    },
+    "fault": {
+      "type": "enum",
+      "values": ["disabled", "lo-hi", "hi-lo", "tri-lo", "tri-hi", "lo-tri",
+                 "hi-tri"],
+      "default": "lo-hi",
+      "code": "fom"
+    }
+  },
+
   "gcode": {
     "preamble": {
       "type": "text",
index eed5df41faa3e064df7d8393655a6023cbb3df5b..39151540a78b71770732d17db02baa81e0c06796 100644 (file)
@@ -126,7 +126,7 @@ body
   50%
     fill #ff9d00
 
-.estop
+.header-content .estop
   width 130px
   transition 250ms