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