X-Git-Url: https://git.hcoop.net/clinton/Smoothieware.git/blobdiff_plain/561e913f9d3759b8ad5f1fd72edfddbd4f8d2dcb..e0ee24edfbdd8066681f98f78098384bd062fca6:/src/modules/robot/Conveyor.cpp?ds=inline diff --git a/src/modules/robot/Conveyor.cpp b/src/modules/robot/Conveyor.cpp index 9fb78d77..f91709fd 100644 --- a/src/modules/robot/Conveyor.cpp +++ b/src/modules/robot/Conveyor.cpp @@ -32,7 +32,7 @@ void Conveyor::on_module_loaded(){ // Delete blocks here, because they can't be deleted in interrupt context ( see Block.cpp:release ) void Conveyor::on_idle(void* argument){ - if (flush_blocks){ + while (flush_blocks > 0){ // Cleanly delete block Block* block = queue.get_tail_ref(); block->gcodes.clear(); @@ -43,26 +43,28 @@ void Conveyor::on_idle(void* argument){ } } +void Conveyor::append_gcode(Gcode* gcode) +{ + gcode->mark_as_taken(); + if (queue.size() == 0) + THEKERNEL->call_event(ON_GCODE_EXECUTE, gcode); + else + queue.get_ref(queue.size() - 1)->append_gcode(gcode); +} + // Append a block to the list Block* Conveyor::new_block(){ // Take the next untaken block on the queue ( the one after the last one ) Block* block = this->queue.get_head_ref(); // Then clean it up - if( block->conveyor == this ){ - block->gcodes.clear(); - } + block->clear(); - // Create a new virgin Block in the queue - this->queue.push_back(Block()); - block = this->queue.get_ref( this->queue.size()-1 ); - while( block == NULL ){ - block = this->queue.get_ref( this->queue.size()-1 ); - } - block->is_ready = false; block->initial_rate = -2; block->final_rate = -2; - block->conveyor = this; + + // Create a new virgin Block in the queue + this->queue.push_back(Block()); return block; }