From cecee6d001cb2ae9a64b882c90bb739b033159c4 Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Mon, 12 Sep 2016 18:30:35 -0700 Subject: [PATCH] run_state -> buffer_state --- src/plan/buffer.c | 2 +- src/plan/buffer.h | 14 +++++++------- src/plan/exec.c | 12 ++++++------ src/plan/planner.c | 6 +++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/plan/buffer.c b/src/plan/buffer.c index c900a74..45146d7 100644 --- a/src/plan/buffer.c +++ b/src/plan/buffer.c @@ -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(); } diff --git a/src/plan/buffer.h b/src/plan/buffer.h index 90e1f99..9212194 100644 --- a/src/plan/buffer.h +++ b/src/plan/buffer.h @@ -34,12 +34,12 @@ 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 diff --git a/src/plan/exec.c b/src/plan/exec.c index 5e63704..c2f0d39 100644 --- a/src/plan/exec.c +++ b/src/plan/exec.c @@ -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 diff --git a/src/plan/planner.c b/src/plan/planner.c index 1097d28..aebc97a 100644 --- a/src/plan/planner.c +++ b/src/plan/planner.c @@ -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; } -- 2.27.0