Change default
[clinton/Smoothieware.git] / src / modules / robot / Conveyor.h
index 5ccdd96..936a750 100644 (file)
@@ -9,28 +9,57 @@
 #define CONVEYOR_H
 
 #include "libs/Module.h"
-#include "libs/Kernel.h"
+#include "HeapRing.h"
+
 using namespace std;
 #include <string>
 #include <vector>
 
-class Conveyor : public Module {
-    public:
-        Conveyor();
+class Gcode;
+class Block;
+
+class Conveyor : public Module
+{
+public:
+    Conveyor();
+
+    void on_module_loaded(void);
+    void on_idle(void *);
+    void on_main_loop(void *);
+    void on_block_end(void *);
+    void on_halt(void *);
+    void on_config_reload(void *);
+
+    void notify_block_finished(Block *);
+
+    void wait_for_empty_queue();
+    bool is_queue_empty() { return queue.is_empty(); };
+    bool is_queue_full() { return queue.is_full(); };
+
+    void ensure_running(void);
+
+    void append_gcode(Gcode *);
+    void queue_head_block(void);
+
+    void dump_queue(void);
+    void flush_queue(void);
+    bool is_flushing() const { return flush; }
+    float get_current_feedrate() const { return current_feedrate; }
+    friend class Planner; // for queue
 
-        void on_module_loaded(void);
-        void on_idle(void*);
+private:
+    typedef HeapRing<Block> Queue_t;
 
-        Block* new_block();
-        void new_block_added();
-        void pop_and_process_new_block(int debug);
-        void wait_for_queue(int free_blocks);
+    Queue_t queue;  // Queue of Blocks
+    volatile unsigned int gc_pending;
+    float current_feedrate{0}; // actual nominal feedrate that current block is running at in mm/sec
 
-        RingBuffer<Block,16> queue;  // Queue of Blocks
-        Block* current_block;
-        bool looking_for_new_block;
+    struct {
+        volatile bool running:1;
+        volatile bool flush:1;
+        volatile bool halted:1;
+    };
 
-        volatile int flush_blocks;
 };
 
 #endif // CONVEYOR_H