run_state -> buffer_state
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Tue, 13 Sep 2016 01:30:35 +0000 (18:30 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Tue, 13 Sep 2016 01:30:35 +0000 (18:30 -0700)
src/plan/buffer.c
src/plan/buffer.h
src/plan/exec.c
src/plan/planner.c

index c900a74d3f48096a763b0b4817f5dadda2a1f0f8..45146d7b73c59dd892777e18a3f5ad313129e648 100644 (file)
@@ -138,7 +138,7 @@ void mp_queue_push(buffer_cb_t cb, uint32_t line) {
   mb.tail->ts = rtc_get_time();
   mb.tail->cb = cb;
   mb.tail->line = line;
-  mb.tail->run_state = MOVE_NEW;
+  mb.tail->state = BUFFER_NEW;
 
   _push();
 }
index 90e1f9971777d26791a3623ce9cd1240eb86a75b..92121946cb65159c268db664a4970574357f70b1 100644 (file)
 
 
 typedef enum {
-  MOVE_OFF,                // move inactive
-  MOVE_NEW,                // initial value
-  MOVE_INIT,               // first run
-  MOVE_RUN,                // subsequent runs
-  MOVE_RESTART,            // restart buffer when done
-} run_state_t;
+  BUFFER_OFF,                // move inactive
+  BUFFER_NEW,                // initial value
+  BUFFER_INIT,               // first run
+  BUFFER_ACTIVE,             // subsequent runs
+  BUFFER_RESTART,            // restart buffer when done
+} buffer_state_t;
 
 
 // Callbacks
@@ -55,7 +55,7 @@ typedef struct mp_buffer_t {      // See Planning Velocity Notes
   int32_t line;                   // gcode block line number
   buffer_cb_t cb;                 // callback to buffer exec function
 
-  run_state_t run_state;          // run state machine sequence
+  buffer_state_t state;           // buffer state
   bool replannable;               // true if move can be re-planned
 
   float value;                    // used in dwell and other callbacks
index 5e6370416b74e256cf7a3d5c86f84577049d9ee2..c2f0d39fb0b744001d57f7cabed8d67f877ad1eb 100644 (file)
@@ -392,7 +392,7 @@ static void _plan_hold() {
     bf->length = available_length - braking_length;
     bf->delta_vmax = mp_get_target_velocity(0, bf->length, bf);
     bf->entry_vmax = 0;
-    bf->run_state = MOVE_RESTART; // Restart the buffer when done
+    bf->state = BUFFER_RESTART; // Restart the buffer when done
 
   } else {
     // Case 2: deceleration exceeds length remaining in buffer
@@ -496,8 +496,8 @@ stat_t mp_exec_aline(mp_buffer_t *bf) {
   stat_t status = STAT_OK;
 
   // Start a new move
-  if (bf->run_state == MOVE_INIT) {
-    bf->run_state = MOVE_RUN;
+  if (bf->state == BUFFER_INIT) {
+    bf->state = BUFFER_ACTIVE;
     status = _exec_aline_init(bf);
     if (status != STAT_OK) return status;
   }
@@ -529,13 +529,13 @@ stat_t mp_exec_move() {
     return STAT_NOOP; // Nothing running
   }
 
-  if (bf->run_state == MOVE_NEW) {
+  if (bf->state == BUFFER_NEW) {
     // On restart wait a bit to give planner queue a chance to fill
     if (!mp_runtime_is_busy() && mp_queue_get_fill() < 4 &&
       !rtc_expired(bf->ts + 250)) return STAT_NOOP;
 
     // Take control of buffer
-    bf->run_state = MOVE_INIT;
+    bf->state = BUFFER_INIT;
     bf->replannable = false;
 
     // Update runtime
@@ -555,7 +555,7 @@ stat_t mp_exec_move() {
     }
 
     // Handle buffer run state
-    if (bf->run_state == MOVE_RESTART) bf->run_state = MOVE_NEW;
+    if (bf->state == BUFFER_RESTART) bf->state = BUFFER_NEW;
     else {
       // Solves a potential race condition where the current move ends but
       // the new move has not started because the current move is still
index 1097d28784fe11b9b2de7c084151246391b04925..aebc97a855b55d8ef4e779e18c6221d75a7ea575 100644 (file)
@@ -460,7 +460,7 @@ void mp_print_queue(mp_buffer_t *bf) {
              bp->entry_vmax, bp->cruise_vmax, bp->exit_vmax);
 
     bp = mp_buffer_prev(bp);
-    if (bp == bf || bp->run_state == MOVE_OFF) break;
+    if (bp == bf || bp->state == BUFFER_OFF) break;
   }
 
   while (!usart_tx_empty()) continue;
@@ -513,7 +513,7 @@ void mp_print_queue(mp_buffer_t *bf) {
  *
  * Variables that are ignored but here's what you would expect them to be:
  *
- *   bf->run_state         - NEW for all blocks but the earliest
+ *   bf->state             - BUFFER_NEW for all blocks but the earliest
  *   bf->target[]          - block target position
  *   bf->unit[]            - block unit vector
  *   bf->jerk              - source of the other jerk variables.
@@ -589,7 +589,7 @@ void mp_replan_blocks() {
   while (true) {
     bp->replannable = true;
     mp_buffer_t *next = mp_buffer_next(bp);
-    if (next->run_state == MOVE_OFF || next == bf) break;
+    if (next->state == BUFFER_OFF || next == bf) break;
     bp = next;
   }