Commit | Line | Data |
---|---|---|
f80d18b9 L |
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 | ||
f6542ad9 | 8 | #pragma once |
f80d18b9 L |
9 | |
10 | #include "libs/Module.h" | |
c501670b | 11 | #include "HeapRing.h" |
e0ee24ed | 12 | |
f80d18b9 L |
13 | using namespace std; |
14 | #include <string> | |
15 | #include <vector> | |
16 | ||
e0ee24ed | 17 | class Gcode; |
61134a65 | 18 | class Block; |
e0ee24ed | 19 | |
95b4885b JM |
20 | class Conveyor : public Module |
21 | { | |
22 | public: | |
23 | Conveyor(); | |
8a9f9313 | 24 | void start(uint8_t n_actuators); |
95b4885b JM |
25 | |
26 | void on_module_loaded(void); | |
b5708347 | 27 | void on_idle(void *); |
b375ba1d | 28 | void on_halt(void *); |
95b4885b | 29 | |
6c0d8cf7 | 30 | void wait_for_idle(bool wait_for_motors=true); |
38bf9a1c | 31 | bool is_queue_empty() { return queue.is_empty(); }; |
728477c4 | 32 | bool is_queue_full() { return queue.is_full(); }; |
b5708347 | 33 | bool is_idle() const; |
2134bcf2 | 34 | |
f6542ad9 JM |
35 | // returns next available block writes it to block and returns true |
36 | bool get_next_block(Block **block); | |
a19a873f | 37 | void block_finished(); |
e0ee24ed | 38 | |
a617ac35 | 39 | void dump_queue(void); |
b375ba1d | 40 | void flush_queue(void); |
c7f4902c | 41 | float get_current_feedrate() const { return current_feedrate; } |
a617ac35 | 42 | |
38bf9a1c JM |
43 | friend class Planner; // for queue |
44 | ||
45 | private: | |
d1d120e1 JM |
46 | // void all_moves_finished(); |
47 | void check_queue(bool force= false); | |
e518eb86 | 48 | void queue_head_block(void); |
c501670b | 49 | |
9e6014a6 | 50 | using Queue_t= HeapRing<Block>; |
c501670b | 51 | Queue_t queue; // Queue of Blocks |
d1d120e1 | 52 | //volatile unsigned int gc_pending; |
c501670b | 53 | |
121844b7 JM |
54 | uint32_t queue_delay_time_ms; |
55 | size_t queue_size; | |
788e5809 | 56 | float current_feedrate{0}; // actual nominal feedrate that current block is running at in mm/sec |
121844b7 | 57 | |
b375ba1d JM |
58 | struct { |
59 | volatile bool running:1; | |
728477c4 | 60 | volatile bool halted:1; |
f6542ad9 | 61 | volatile bool allow_fetch:1; |
a19a873f | 62 | bool flush:1; |
b375ba1d | 63 | }; |
95b4885b | 64 | |
f80d18b9 | 65 | }; |