Onboot #124

Merged
merged 8 commits into from Feb 17, 2013
+320 −187
Split
View
@@ -20,7 +20,7 @@
#include "modules/robot/Planner.h"
#include "modules/robot/Robot.h"
#include "modules/robot/Stepper.h"
-#include "modules/robot/Player.h"
+#include "modules/robot/Conveyor.h"
#include <malloc.h>
@@ -93,7 +93,7 @@ Kernel::Kernel(){
this->add_module( this->robot = new Robot() );
this->add_module( this->stepper = new Stepper() );
this->add_module( this->planner = new Planner() );
- this->add_module( this->player = new Player() );
+ this->add_module( this->conveyor = new Conveyor() );
this->add_module( this->pauser = new Pauser() );
}
View
@@ -23,7 +23,7 @@
//Module manager
class Module;
-class Player;
+class Conveyor;
class SlowTicker;
class Kernel {
public:
@@ -42,7 +42,7 @@ class Kernel {
Stepper* stepper;
Planner* planner;
Config* config;
- Player* player;
+ Conveyor* conveyor;
Pauser* pauser;
int debug;
View
@@ -11,8 +11,8 @@
#include "modules/tools/temperaturecontrol/TemperatureControlPool.h"
#include "modules/tools/endstops/Endstops.h"
#include "modules/tools/switch/SwitchPool.h"
+#include "modules/robot/Conveyor.h"
#include "modules/utils/button/ButtonPool.h"
-#include "modules/robot/Player.h"
#include "modules/utils/simpleshell/SimpleShell.h"
#include "modules/utils/configurator/Configurator.h"
#include "modules/utils/currentcontrol/CurrentControl.h"
@@ -12,7 +12,7 @@ using std::string;
#include "utils/Gcode.h"
#include "libs/nuts_bolts.h"
#include "GcodeDispatch.h"
-#include "modules/robot/Player.h"
+#include "modules/robot/Conveyor.h"
#include "libs/SerialMessage.h"
#include "libs/StreamOutput.h"
@@ -12,7 +12,7 @@
#include <string>
#include "Block.h"
#include "Planner.h"
-#include "Player.h"
+#include "Conveyor.h"
using std::string;
#include <vector>
#include "../communication/utils/Gcode.h"
@@ -41,12 +41,12 @@ void Block::debug(Kernel* kernel){
//*/
void Block::calculate_trapezoid( double entryfactor, double exitfactor ){
- //this->player->kernel->streams->printf("%p calculating trapezoid\r\n", this);
+ //this->conveyor->kernel->streams->printf("%p calculating trapezoid\r\n", this);
this->initial_rate = ceil(this->nominal_rate * entryfactor); // (step/min)
this->final_rate = ceil(this->nominal_rate * exitfactor); // (step/min)
- //this->player->kernel->streams->printf("initrate:%f finalrate:%f\r\n", this->initial_rate, this->final_rate);
+ //this->conveyor->kernel->streams->printf("initrate:%f finalrate:%f\r\n", this->initial_rate, this->final_rate);
double acceleration_per_minute = this->rate_delta * this->planner->kernel->stepper->acceleration_ticks_per_second * 60.0; // ( step/min^2)
int accelerate_steps = ceil( this->estimate_acceleration_distance( this->initial_rate, this->nominal_rate, acceleration_per_minute ) );
@@ -56,7 +56,7 @@ void Block::calculate_trapezoid( double entryfactor, double exitfactor ){
// Calculate the size of Plateau of Nominal Rate.
int plateau_steps = this->steps_event_count-accelerate_steps-decelerate_steps;
- //this->player->kernel->streams->printf("accelperminute:%f accelerate_steps:%d decelerate_steps:%d plateau:%d \r\n", acceleration_per_minute, accelerate_steps, decelerate_steps, plateau_steps );
+ //this->conveyor->kernel->streams->printf("accelperminute:%f accelerate_steps:%d decelerate_steps:%d plateau:%d \r\n", acceleration_per_minute, accelerate_steps, decelerate_steps, plateau_steps );
// Is the Plateau of Nominal Rate smaller than nothing? That means no cruising, and we will
// have to use intersection_distance() to calculate when to abort acceleration and start braking
@@ -71,7 +71,7 @@ void Block::calculate_trapezoid( double entryfactor, double exitfactor ){
this->accelerate_until = accelerate_steps;
this->decelerate_after = accelerate_steps+plateau_steps;
- //this->debug(this->player->kernel);
+ //this->debug(this->conveyor->kernel);
/*
// TODO: FIX THIS: DIRTY HACK so that we don't end too early for blocks with 0 as final_rate. Doing the math right would be better. Probably fixed in latest grbl
@@ -179,10 +179,10 @@ void Block::pop_and_execute_gcode(Kernel* &kernel){
}
}
-// Signal the player that this block is ready to be injected into the system
+// Signal the conveyor that this block is ready to be injected into the system
void Block::ready(){
this->is_ready = true;
- this->player->new_block_added();
+ this->conveyor->new_block_added();
}
// Mark the block as taken by one more module
@@ -197,31 +197,31 @@ void Block::release(){
this->times_taken--;
//printf("releasing %p times now:%d\r\n", this, int(this->times_taken) );
if( this->times_taken < 1 ){
- this->player->kernel->call_event(ON_BLOCK_END, this);
- this->pop_and_execute_gcode(this->player->kernel);
- Player* player = this->player;
+ this->conveyor->kernel->call_event(ON_BLOCK_END, this);
+ this->pop_and_execute_gcode(this->conveyor->kernel);
+ Conveyor* conveyor = this->conveyor;
- if( player->queue.size() > player->flush_blocks ){
- player->flush_blocks++;
+ if( conveyor->queue.size() > conveyor->flush_blocks ){
+ conveyor->flush_blocks++;
}
- if( player->looking_for_new_block == false ){
- if( player->queue.size() > player->flush_blocks ){
- Block* candidate = player->queue.get_ref(player->flush_blocks);
+ if( conveyor->looking_for_new_block == false ){
+ if( conveyor->queue.size() > 0 ){
+ Block* candidate = conveyor->queue.get_ref(conveyor->flush_blocks);
if( candidate->is_ready ){
- player->current_block = candidate;
- player->kernel->call_event(ON_BLOCK_BEGIN, player->current_block);
- if( player->current_block->times_taken < 1 ){
- player->current_block->times_taken = 1;
- player->current_block->release();
+ conveyor->current_block = candidate;
+ conveyor->kernel->call_event(ON_BLOCK_BEGIN, conveyor->current_block);
+ if( conveyor->current_block->times_taken < 1 ){
+ conveyor->current_block->times_taken = 1;
+ conveyor->current_block->release();
}
}else{
- player->current_block = NULL;
+ conveyor->current_block = NULL;
}
}else{
- player->current_block = NULL;
+ conveyor->current_block = NULL;
}
}
}
@@ -16,7 +16,7 @@ using namespace std;
#include "../communication/utils/Gcode.h"
#include "Planner.h"
class Planner;
-class Player;
+class Conveyor;
double max_allowable_speed( double acceleration, double target_velocity, double distance);
@@ -59,8 +59,8 @@ class Block {
double max_entry_speed;
Planner* planner;
- Player* player;
-
+ Conveyor* conveyor;
+
bool is_ready;
short times_taken; // A block can be "taken" by any number of modules, and the next block is not moved to until all the modules have "released" it. This value serves as a tracker.
@@ -15,21 +15,21 @@ using namespace std;
#include "Timer.h" // mbed.h lib
#include "wait_api.h" // mbed.h lib
#include "Block.h"
-#include "Player.h"
+#include "Conveyor.h"
#include "Planner.h"
-Player::Player(){
+Conveyor::Conveyor(){
this->current_block = NULL;
this->looking_for_new_block = false;
flush_blocks = 0;
}
-void Player::on_module_loaded()
+void Conveyor::on_module_loaded()
{
register_for_event(ON_IDLE);
}
-void Player::on_idle(void* argument)
+void Conveyor::on_idle(void* argument)
{
if (flush_blocks)
{
@@ -50,7 +50,7 @@ void Player::on_idle(void* argument)
}
// Append a block to the list
-Block* Player::new_block(){
+Block* Conveyor::new_block(){
// Clean up the vector of commands in the block we are about to replace
// It is quite strange to do this here, we really should do it inside Block->pop_and_execute_gcode
@@ -60,7 +60,7 @@ Block* Player::new_block(){
Block* block = this->queue.get_ref( this->queue.size() );
// printf("cleanup %p\n", block);
// Then clean it up
- if( block->player == this ){
+ if( block->conveyor == this ){
for(; block->gcodes.size(); ){
Gcode* g = block->gcodes.back();
// printf("Block:pop %p (%d refs)\n", g, g->queued);
@@ -79,20 +79,20 @@ Block* Player::new_block(){
block->is_ready = false;
block->initial_rate = -2;
block->final_rate = -2;
- block->player = this;
-
+ block->conveyor = this;
+
return block;
}
// Used by blocks to signal when they are ready to be used by the system
-void Player::new_block_added(){
+void Conveyor::new_block_added(){
if( this->current_block == NULL ){
this->pop_and_process_new_block(33);
}
}
// Process a new block in the queue
-void Player::pop_and_process_new_block(int debug){
+void Conveyor::pop_and_process_new_block(int debug){
if( this->looking_for_new_block ){ return; }
this->looking_for_new_block = true;
@@ -122,7 +122,7 @@ void Player::pop_and_process_new_block(int debug){
}
-void Player::wait_for_queue(int free_blocks)
+void Conveyor::wait_for_queue(int free_blocks)
{
while( this->queue.size() >= this->queue.capacity()-free_blocks ){
this->kernel->call_event(ON_IDLE);
@@ -5,17 +5,18 @@
You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef PLAYER_H
-#define PLAYER_H
+#ifndef CONVEYOR_H
+#define CONVEYOR_H
+
#include "libs/Module.h"
#include "libs/Kernel.h"
using namespace std;
#include <string>
#include <vector>
-class Player : public Module {
+class Conveyor : public Module {
public:
- Player();
+ Conveyor();
void on_module_loaded(void);
void on_idle(void*);
@@ -32,6 +33,4 @@ class Player : public Module {
volatile int flush_blocks;
};
-
-
-#endif
+#endif // CONVEYOR_H
Oops, something went wrong.