moved play command into the new utils/Player module from SimpleShell, also added...
[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 #include "libs/Module.h"
11 #include "libs/Config.h"
12 #include "libs/SlowTicker.h"
13 #include "libs/StreamOutputPool.h"
14 #include "libs/StepTicker.h"
15 #include "libs/Adc.h"
16 #include "libs/Digipot.h"
17 #include "libs/Pauser.h"
18 #include "modules/communication/SerialConsole.h"
19 #include "modules/communication/GcodeDispatch.h"
20 #include "modules/robot/Planner.h"
21 #include "modules/robot/Robot.h"
22 #include "modules/robot/Stepper.h"
23 #include "modules/utils/simpleshell/SimpleShell.h"
24
25 // See : http://smoothieware.org/listofevents
26 #define NUMBER_OF_DEFINED_EVENTS 12
27 #define ON_MAIN_LOOP 0
28 #define ON_CONSOLE_LINE_RECEIVED 1
29 #define ON_GCODE_RECEIVED 2
30 #define ON_STEPPER_WAKE_UP 3 //TODO : Remove the need for this event, then this event itself eg: have planner call stepper directly
31 #define ON_GCODE_EXECUTE 4
32 #define ON_SPEED_CHANGE 5
33 #define ON_BLOCK_BEGIN 6
34 #define ON_BLOCK_END 7
35 #define ON_CONFIG_RELOAD 8
36 #define ON_PLAY 9
37 #define ON_PAUSE 10
38 #define ON_IDLE 11
39
40
41 typedef void (Module::*ModuleCallback)(void * argument);
42
43 //Module manager
44 class Module;
45 class Conveyor;
46 class SlowTicker;
47 class Kernel {
48 public:
49 Kernel();
50 void add_module(Module* module);
51 void register_for_event(unsigned int id_event, Module* module);
52 void call_event(unsigned int id_event);
53 void call_event(unsigned int id_event, void * argument);
54
55 // These modules are aviable to all other modules
56 SerialConsole* serial;
57 StreamOutputPool* streams;
58
59 GcodeDispatch* gcode_dispatch;
60 Robot* robot;
61 Stepper* stepper;
62 Planner* planner;
63 Config* config;
64 Conveyor* conveyor;
65 Pauser* pauser;
66 SimpleShell* simpleshell;
67
68 int debug;
69 SlowTicker* slow_ticker;
70 StepTicker* step_ticker;
71 Adc* adc;
72 Digipot* digipot;
73
74 private:
75 Module* hooks[NUMBER_OF_DEFINED_EVENTS][32]; // When a module asks to be called for a specific event ( a hook ), this is where that request is remembered
76
77 };
78
79 #endif