From c5a969775ca39391adab3027d117e1e327cb0080 Mon Sep 17 00:00:00 2001 From: Alden Hart Date: Sat, 11 Mar 2017 08:55:50 -0500 Subject: [PATCH] Removed MOTION_HOLD state --- g2core/canonical_machine.cpp | 11 ++++++----- g2core/canonical_machine.h | 4 ++-- g2core/cycle_feedhold.cpp | 6 +++--- g2core/plan_exec.cpp | 10 ++++++---- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/g2core/canonical_machine.cpp b/g2core/canonical_machine.cpp index 082fd591..187bb52e 100644 --- a/g2core/canonical_machine.cpp +++ b/g2core/canonical_machine.cpp @@ -259,12 +259,13 @@ stat_t canonical_machine_test_assertions(cmMachine_t *_cm) void cm_set_motion_state(const cmMotionState motion_state) { cm->motion_state = motion_state; + ACTIVE_MODEL = (motion_state ? MODEL : RUNTIME); - switch (motion_state) { - case (MOTION_STOP): { ACTIVE_MODEL = MODEL; break; } - case (MOTION_RUN): { ACTIVE_MODEL = RUNTIME; break; } - case (MOTION_HOLD): { ACTIVE_MODEL = RUNTIME; break; } - } +// switch (motion_state) { +// case (MOTION_STOP): { ACTIVE_MODEL = MODEL; break; } +// case (MOTION_RUN): { ACTIVE_MODEL = RUNTIME; break; } +// case (MOTION_HOLD): { ACTIVE_MODEL = RUNTIME; break; } +// } } /* diff --git a/g2core/canonical_machine.h b/g2core/canonical_machine.h index aeccc690..fb8a181a 100644 --- a/g2core/canonical_machine.h +++ b/g2core/canonical_machine.h @@ -95,8 +95,8 @@ typedef enum { // Note: MachineState signals if the machine is typedef enum { MOTION_STOP = 0, // motion has stopped: set when the steppers reach the end of the planner queue - MOTION_RUN, // machine is in motion: set when the steppers execute an ALINE segment - MOTION_HOLD // feedhold in progress: set whenever we leave FEEDHOLD_OFF, unset whenever we enter FEEDHOLD_OFF + MOTION_RUN // machine is in motion: set when the steppers execute an ALINE segment +// MOTION_HOLD // feedhold in progress: set whenever we leave FEEDHOLD_OFF, unset whenever we enter FEEDHOLD_OFF } cmMotionState; typedef enum { diff --git a/g2core/cycle_feedhold.cpp b/g2core/cycle_feedhold.cpp index 6a2f8f5a..3a714b9f 100644 --- a/g2core/cycle_feedhold.cpp +++ b/g2core/cycle_feedhold.cpp @@ -428,7 +428,7 @@ void cm_start_hold() { // Can only request a feedhold if the machine is in motion and there not one is not already in progress if ((cm1.hold_state == FEEDHOLD_OFF) && (mp_has_runnable_buffer(mp))) { - cm_set_motion_state(MOTION_HOLD); +// cm_set_motion_state(MOTION_HOLD); cm1.hold_state = FEEDHOLD_SYNC; // invokes hold from aline execution } } @@ -463,7 +463,7 @@ stat_t cm_feedhold_sequencing_callback() // invoking a p1 feedhold is a 2 step process - get to the stop, then execute the hold actions if (cm1.hold_state == FEEDHOLD_INITIATED) { if (mp_has_runnable_buffer(&mp1)) { // bypass cm_start_hold() to start from here - cm_set_motion_state(MOTION_HOLD); +// cm_set_motion_state(MOTION_HOLD); cm1.hold_state = FEEDHOLD_SYNC; // invokes hold from aline execution } } @@ -474,7 +474,7 @@ stat_t cm_feedhold_sequencing_callback() // p2 feedhold states - feedhold in feedhold if (cm2.hold_state == FEEDHOLD_INITIATED) { if (mp_has_runnable_buffer(&mp2)) { - cm_set_motion_state(MOTION_HOLD); +// cm_set_motion_state(MOTION_HOLD); cm2.hold_state = FEEDHOLD_SYNC; } } diff --git a/g2core/plan_exec.cpp b/g2core/plan_exec.cpp index c6ba70d7..1bdea124 100644 --- a/g2core/plan_exec.cpp +++ b/g2core/plan_exec.cpp @@ -307,8 +307,8 @@ stat_t mp_exec_move() } // Manage motion state transitions - if ((cm->motion_state != MOTION_RUN) && (cm->motion_state != MOTION_HOLD)) { -// +++++ if (cm->motion_state != MOTION_RUN) { +// if ((cm->motion_state != MOTION_RUN) && (cm->motion_state != MOTION_HOLD)) { + if (cm->motion_state != MOTION_RUN) { cm_set_motion_state(MOTION_RUN); // also sets active model to RUNTIME } } @@ -486,7 +486,8 @@ stat_t mp_exec_aline(mpBuf_t *bf) // Feed Override Processing - We need to handle the following cases (listed in rough sequence order): // Feedhold Processing - We need to handle the following cases (listed in rough sequence order): - if (cm->motion_state == MOTION_HOLD) { +// if (cm->motion_state == MOTION_HOLD) { + if (cm->hold_state != FEEDHOLD_OFF) { // if FEEDHOLD_P2_START, FEEDHOLD_P2_WAIT, FEEDHOLD HOLD or FEEDHOLD_P2_EXIT if (cm->hold_state >= FEEDHOLD_P2_START) { // handles _exec_aline_feedhold_processing case (7) return (STAT_NOOP); // VERY IMPORTANT to exit as a NOOP. Do not load another move @@ -899,7 +900,8 @@ static stat_t _exec_aline_segment() // Otherwise if not at a section waypoint compute target from segment time and velocity // Don't do waypoint correction if you are going into a hold. - if ((--mr->segment_count == 0) && (cm->motion_state != MOTION_HOLD)) { +// if ((--mr->segment_count == 0) && (cm->motion_state != MOTION_HOLD)) { + if ((--mr->segment_count == 0) && (cm->hold_state == FEEDHOLD_OFF)) { copy_vector(mr->gm.target, mr->waypoint[mr->section]); } else { float segment_length = mr->segment_velocity * mr->segment_time;