Remove deprecated query format
[clinton/Smoothieware.git] / src / libs / Kernel.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 KERNEL_H
9 #define KERNEL_H
10
11 #define THEKERNEL Kernel::instance
12 #define THECONVEYOR THEKERNEL->conveyor
13 #define THEROBOT THEKERNEL->robot
14
15 #include "Module.h"
16 #include <array>
17 #include <vector>
18 #include <string>
19
20 //Module manager
21 class Config;
22 class Module;
23 class Conveyor;
24 class SlowTicker;
25 class SerialConsole;
26 class StreamOutputPool;
27 class GcodeDispatch;
28 class Robot;
29 class Planner;
30 class StepTicker;
31 class Adc;
32 class PublicData;
33 class SimpleShell;
34 class Configurator;
35
36 class Kernel {
37 public:
38 Kernel();
39 static Kernel* instance; // the Singleton instance of Kernel usable anywhere
40 const char* config_override_filename(){ return "/sd/config-override"; }
41
42 void add_module(Module* module);
43 void register_for_event(_EVENT_ENUM id_event, Module *module);
44 void call_event(_EVENT_ENUM id_event, void * argument= nullptr);
45
46 bool kernel_has_event(_EVENT_ENUM id_event, Module *module);
47 void unregister_for_event(_EVENT_ENUM id_event, Module *module);
48
49 bool is_using_leds() const { return use_leds; }
50 bool is_halted() const { return halted; }
51 bool is_grbl_mode() const { return grbl_mode; }
52 bool is_ok_per_line() const { return ok_per_line; }
53
54 void set_feed_hold(bool f) { feed_hold= f; }
55 bool get_feed_hold() const { return feed_hold; }
56 bool is_feed_hold_enabled() const { return enable_feed_hold; }
57
58 std::string get_query_string();
59
60 // These modules are available to all other modules
61 SerialConsole* serial;
62 StreamOutputPool* streams;
63 GcodeDispatch* gcode_dispatch;
64 Robot* robot;
65 Planner* planner;
66 Config* config;
67 Conveyor* conveyor;
68 Configurator* configurator;
69 SimpleShell* simpleshell;
70
71 SlowTicker* slow_ticker;
72 StepTicker* step_ticker;
73 Adc* adc;
74 std::string current_path;
75 uint32_t base_stepping_frequency;
76
77 private:
78 // When a module asks to be called for a specific event ( a hook ), this is where that request is remembered
79 std::array<std::vector<Module*>, NUMBER_OF_DEFINED_EVENTS> hooks;
80 struct {
81 bool use_leds:1;
82 bool halted:1;
83 bool grbl_mode:1;
84 bool feed_hold:1;
85 bool ok_per_line:1;
86 bool enable_feed_hold:1;
87 };
88
89 };
90
91 #endif