make the tick_info in Block a vector, assigning how ever many registered motors there are
[clinton/Smoothieware.git] / src / modules / robot / Conveyor.h
1 /*
2 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
3 Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4 Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
6 */
7
8 #pragma once
9
10 #include "libs/Module.h"
11 #include "HeapRing.h"
12
13 using namespace std;
14 #include <string>
15 #include <vector>
16
17 class Gcode;
18 class Block;
19
20 class Conveyor : public Module
21 {
22 public:
23 Conveyor();
24 void start(uint8_t n_actuators);
25
26 void on_module_loaded(void);
27 void on_idle(void *);
28 void on_halt(void *);
29
30 void wait_for_empty_queue();
31 bool is_queue_empty() { return queue.is_empty(); };
32 bool is_queue_full() { return queue.is_full(); };
33 bool is_idle() const;
34
35 // returns next available block writes it to block and returns true
36 bool get_next_block(Block **block);
37 void block_finished();
38
39 void dump_queue(void);
40 void flush_queue(void);
41 float get_current_feedrate() const { return current_feedrate; }
42
43 friend class Planner; // for queue
44
45 private:
46 // void all_moves_finished();
47 void check_queue(bool force= false);
48 void queue_head_block(void);
49
50 using Queue_t= HeapRing<Block>;
51 Queue_t queue; // Queue of Blocks
52 //volatile unsigned int gc_pending;
53
54 uint32_t queue_delay_time_ms;
55 size_t queue_size;
56 float current_feedrate{0}; // actual nominal feedrate that current block is running at in mm/sec
57
58 struct {
59 volatile bool running:1;
60 volatile bool halted:1;
61 volatile bool allow_fetch:1;
62 bool flush:1;
63 };
64
65 };