Implemented stepping
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Tue, 13 Sep 2016 10:21:47 +0000 (03:21 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Tue, 13 Sep 2016 10:21:47 +0000 (03:21 -0700)
src/jade/templates/control-view.jade
src/js/control-view.js
src/py/bbctrl/AVR.py
src/py/bbctrl/Web.py

index 6862e54b15c9ff878cfb5ab482b8ad64faee162c..247b29680fd9ae85ec94ed1f1a38a66b9209b9d6 100644 (file)
@@ -31,7 +31,7 @@ script#control-view-template(type="text/x-template")
         td
       tr
         th Reason
-        td {{state.pr}}
+        td {{get_reason()}}
         td
       tr
         th Feed
@@ -53,7 +53,7 @@ script#control-view-template(type="text/x-template")
         td mm/min
       tr
         th Line
-        td {{state.ln || ''}}
+        td {{0 <= state.ln ? state.ln : '-'}}
         td
       tr
         th Tool
@@ -89,7 +89,7 @@ script#control-view-template(type="text/x-template")
       button.pure-button(
         title="{{state.x == 'RUNNING' ? 'Pause' : 'Start'}} program.",
         @click="start_pause",
-        :disabled="state.c == 'HOMING'")
+        :disabled="state.c == 'HOMING' || !file")
         .fa(:class="state.x == 'RUNNING' ? 'fa-pause' : 'fa-play'")
 
       button.pure-button(title="Stop program.", @click="stop",
index 4510c5150d1c9ee32860088b83b1cc710566cad8..b9260887df1e3066d84f040ca80f38671c5da70e 100644 (file)
@@ -52,8 +52,13 @@ module.exports = {
   methods: {
     get_state: function () {
       var state = this.state.x || '';
-      if (state == 'running' && this.state.c) state = this.state.c;
-      return state.toUpperCase();
+      if (state == 'RUNNING' && this.state.c) state = this.state.c;
+      return state;
+    },
+
+
+    get_reason: function () {
+      return this.state.x == 'HOLDING' ? this.state.pr : '';
     },
 
 
@@ -77,8 +82,9 @@ module.exports = {
 
       if (0 <= this.state.ln) {
         var line = this.state.ln - 1;
-        $('#gcode-line-' + line)
-          .addClass('highlight')[0]
+        var e = $('#gcode-line-' + line);
+        if (e.length)
+          e.addClass('highlight')[0]
           .scrollIntoView({behavior: 'smooth'});
 
         this.last_line = line;
@@ -141,7 +147,7 @@ module.exports = {
 
       api.get('file/' + file)
         .done(function (data) {
-          var lines = data.split(/\r?\n/);
+          var lines = data.trimRight().split(/\r?\n/);
           var html = '<ul>';
 
           for (var i = 0; i < lines.length; i++)
@@ -188,7 +194,7 @@ module.exports = {
     unpause: function () {api.put('unpause')},
     optional_pause: function () {api.put('pause/optional')},
     stop: function () {api.put('stop')},
-    step: function () {api.put('step')},
+    step: function () {api.put('step/' + this.file).done(this.update)},
 
 
     override_feed: function () {
index b933fd8d23dc7b0da9028ae9c84b13c429b0cc24..fb6d6f208e8fa8e4635365d922aea3c7729bd5c7 100644 (file)
@@ -246,6 +246,12 @@ class AVR():
             self._i2c_command(I2C_RUN)
 
 
+    def step(self, path):
+        self._i2c_command(I2C_STEP)
+        if self.stream is None and path and self.vars.get('x', '') == 'READY':
+            self._start_sending_gcode(path)
+
+
     def stop(self):
         self._i2c_command(I2C_FLUSH)
         self._stop_sending_gcode()
@@ -255,5 +261,4 @@ class AVR():
     def pause(self): self._i2c_command(I2C_PAUSE)
     def unpause(self): self._i2c_command(I2C_RUN)
     def optional_pause(self): self._i2c_command(I2C_OPTIONAL_PAUSE)
-    def step(self): self._i2c_command(I2C_STEP)
     def zero(self, axis = None): self._i2c_command(I2C_ZERO, byte = axis)
index 8877cc3649c5eaba54751d7f2e17b98ac6ee653b..2fecf6705ac9db258fe7e8b66d8036bf865b4e5b 100644 (file)
@@ -53,7 +53,7 @@ class OptionalPauseHandler(bbctrl.APIHandler):
 
 
 class StepHandler(bbctrl.APIHandler):
-    def put_ok(self): self.ctrl.avr.step()
+    def put_ok(self, path): self.ctrl.avr.step(path)
 
 
 class ZeroHandler(bbctrl.APIHandler):
@@ -115,7 +115,7 @@ class Web(tornado.web.Application):
             (r'/api/pause', PauseHandler),
             (r'/api/unpause', UnpauseHandler),
             (r'/api/pause/optional', OptionalPauseHandler),
-            (r'/api/step', StepHandler),
+            (r'/api/step(/.+)', StepHandler),
             (r'/api/zero(/[xyzabcXYZABC])?', ZeroHandler),
             (r'/api/override/feed/([\d.]+)', OverrideFeedHandler),
             (r'/api/override/speed/([\d.]+)', OverrideSpeedHandler),