mirror of
https://github.com/synthetos/g2.git
synced 2026-09-25 00:00:56 +08:00
merged 100.16 into dev-109-tool-offset
This commit is contained in:
Executable → Regular
+23
-17
@@ -44,7 +44,7 @@
|
||||
* functions. Data from the Gcode model is transferred to the motion planner by the mp_xxxx()
|
||||
* functions called by the canonical machine.
|
||||
*
|
||||
* The planner should only use data in the planner model. When a move (block) is ready for
|
||||
* The planner should only use data in the planner model. When a move (buffer) is ready for
|
||||
* execution the relevant data from the planner is transferred to the runtime model,
|
||||
* which should also be isolated.
|
||||
*
|
||||
@@ -172,6 +172,14 @@ stat_t planner_test_assertions()
|
||||
(BAD_MAGIC(mr.magic_start)) || (BAD_MAGIC(mr.magic_end))) {
|
||||
return(cm_panic(STAT_PLANNER_ASSERTION_FAILURE, "planner_test_assertions()"));
|
||||
}
|
||||
// for (uint8_t i=0; i < PLANNER_BUFFER_POOL_SIZE; i++) {
|
||||
// if (mb.bf[i].nx == nullptr) {
|
||||
// _debug_trap("buffer has nullptr for nx");
|
||||
// }
|
||||
// if (mb.bf[i].pv == nullptr) {
|
||||
// _debug_trap("buffer has nullptr for pv");
|
||||
// }
|
||||
// }
|
||||
return (STAT_OK);
|
||||
}
|
||||
|
||||
@@ -462,8 +470,8 @@ bool mp_is_phat_city_time()
|
||||
* mp_planner_callback()'s job is to invoke backward planning intelligently.
|
||||
* The flow of control and division of responsibilities for planning is:
|
||||
*
|
||||
* - mp_aline() receives new Gcode blocks and initializes the local variables
|
||||
* for the new block.
|
||||
* - mp_aline() receives new Gcode moves and initializes the local variables
|
||||
* for the new buffer.
|
||||
*
|
||||
* - mp_planner_callback() is called regularly from the main loop.
|
||||
* It's job is to determine whether or not to call mp_plan_block_list(),
|
||||
@@ -472,9 +480,9 @@ bool mp_is_phat_city_time()
|
||||
* mp_planner_callback() also manages planner state - whether the planner
|
||||
* is IDLE, in STARTUP or in one of the running states.
|
||||
*
|
||||
* - _plan_block_list() / _planblock() is the backward planning function.
|
||||
* - _plan_block() is the backward planning function for a single buffer.
|
||||
*
|
||||
* - Forward planning is just-in-time by the execution runtime
|
||||
* - Just-in-time forward planning is performed by mp_plan_move() in the plan_exec.cpp runtime executive
|
||||
*
|
||||
* Some Items to note:
|
||||
*
|
||||
@@ -534,12 +542,9 @@ void mp_replan_queue(mpBuf_t *bf)
|
||||
{
|
||||
do {
|
||||
if (bf->buffer_state >= MP_BUFFER_PLANNED) {
|
||||
// revert from PLANNED state
|
||||
bf->buffer_state = MP_BUFFER_PREPPED;
|
||||
} else {
|
||||
// If it's not "planned" then it's either PREPPED or earlier.
|
||||
// We don't need to adjust it.
|
||||
break;
|
||||
bf->buffer_state = MP_BUFFER_PREPPED; // revert from PLANNED state
|
||||
} else { // If it's not "planned" then it's either PREPPED or earlier.
|
||||
break; // We don't need to adjust it.
|
||||
}
|
||||
} while ((bf = mp_get_next_buffer(bf)) != mb.r);
|
||||
|
||||
@@ -697,25 +702,26 @@ static inline void _clear_buffer(mpBuf_t *bf)
|
||||
// the pointers and buffer number during interrupts
|
||||
|
||||
// We'll have to figure something else out for C, sorry.
|
||||
bf->clear();
|
||||
bf->reset();
|
||||
}
|
||||
|
||||
void mp_init_buffers(void)
|
||||
{
|
||||
mpBuf_t *pv, *nx;
|
||||
uint8_t i, nx_i;
|
||||
|
||||
memset(&mb, 0, sizeof(mb)); // clear all values, pointers and status
|
||||
//memset(&mb, 0, sizeof(mb)); // clear all values, pointers and status
|
||||
mb.magic_start = MAGICNUM;
|
||||
mb.magic_end = MAGICNUM;
|
||||
|
||||
mb.w = &mb.bf[0]; // init all buffer pointers
|
||||
mb.r = &mb.bf[0];
|
||||
pv = &mb.bf[PLANNER_BUFFER_POOL_SIZE-1];
|
||||
for (i=0; i < PLANNER_BUFFER_POOL_SIZE; i++) {
|
||||
for (uint8_t i=0; i < PLANNER_BUFFER_POOL_SIZE; i++) {
|
||||
_clear_buffer(&mb.bf[i]);
|
||||
uint8_t nx_i = ((i<(PLANNER_BUFFER_POOL_SIZE-1))?(i+1):0); // buffer incr & wrap
|
||||
|
||||
mb.bf[i].buffer_number = i; //+++++ number it for diagnostics only (otherwise not used)
|
||||
|
||||
nx_i = ((i<PLANNER_BUFFER_POOL_SIZE-1)?(i+1):0); // buffer incr & wrap
|
||||
nx = &mb.bf[nx_i];
|
||||
mb.bf[i].nx = nx; // setup ring pointers
|
||||
mb.bf[i].pv = pv;
|
||||
@@ -785,7 +791,7 @@ void mp_commit_write_buffer(const blockType block_type)
|
||||
if ((mp.planner_state > PLANNER_STARTUP) && (cm.hold_state == FEEDHOLD_OFF)) {
|
||||
// NB: BEWARE! the exec may result in the planner buffer being
|
||||
// processed IMMEDIATELY and then freed - invalidating the contents
|
||||
st_request_plan_move(); // request an exec if the runtime is not busy
|
||||
st_request_forward_plan(); // request an exec if the runtime is not busy
|
||||
}
|
||||
}
|
||||
mb.w->plannable = true; // enable block for planning
|
||||
|
||||
Reference in New Issue
Block a user