started hacking on the new conveyor model
[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 #ifndef CONVEYOR_H
9 #define CONVEYOR_H
10
11 #include "libs/Module.h"
12 #include "HeapRing.h"
13
14 using namespace std;
15 #include <string>
16 #include <vector>
17
18 class Gcode;
19 class Block;
20
21 class Conveyor : public Module
22 {
23 public:
24 Conveyor();
25
26 void on_module_loaded(void);
27 void on_idle(void *);
28 void on_main_loop(void *);
29 void on_block_end(Block *);
30 void on_block_begin(Block *);
31 void on_halt(void *);
32
33 void wait_for_empty_queue();
34 bool is_queue_empty() { return queue.is_empty(); };
35 bool is_queue_full() { return queue.is_full(); };
36
37
38 //void append_gcode(Gcode *);
39 void queue_head_block(void);
40
41 void dump_queue(void);
42 void flush_queue(void);
43 bool is_flushing() const { return flush; }
44
45 friend class Planner; // for queue
46
47 private:
48 void all_moves_finished();
49 void ensure_running(void);
50
51 using Queue_t= HeapRing<Block>;
52 Queue_t queue; // Queue of Blocks
53 volatile unsigned int gc_pending;
54
55 struct {
56 volatile bool running:1;
57 volatile bool flush:1;
58 volatile bool halted:1;
59 };
60
61 };
62
63 #endif // CONVEYOR_H