Commit | Line | Data |
---|---|---|
df27a6a3 | 1 | /* |
4cff3ded AW |
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. | |
df27a6a3 | 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. |
4cff3ded AW |
6 | */ |
7 | ||
8 | #ifndef MODULE_H | |
9 | #define MODULE_H | |
10 | ||
af9072ee | 11 | // See : http://smoothieware.org/listofevents |
3d1a4519 JM |
12 | // When adding a new event the virtual method needs to be defined in class Module and the method pointer need to be defined in |
13 | // Module.cpp:16 in the same order | |
af9072ee | 14 | enum _EVENT_ENUM { |
e0d0ea84 JM |
15 | ON_MAIN_LOOP, |
16 | ON_CONSOLE_LINE_RECEIVED, | |
17 | ON_GCODE_RECEIVED, | |
e0d0ea84 | 18 | ON_IDLE, |
e0d0ea84 JM |
19 | ON_SECOND_TICK, |
20 | ON_GET_PUBLIC_DATA, | |
21 | ON_SET_PUBLIC_DATA, | |
3d1a4519 | 22 | ON_HALT, |
0bfaf040 | 23 | ON_ENABLE, |
af9072ee MM |
24 | NUMBER_OF_DEFINED_EVENTS |
25 | }; | |
26 | ||
8da186de | 27 | class Module; |
b375ba1d | 28 | typedef void (Module::*ModuleCallback)(void *argument); |
8da186de JM |
29 | extern const ModuleCallback kernel_callback_functions[NUMBER_OF_DEFINED_EVENTS]; |
30 | ||
e0d0ea84 JM |
31 | // Module base class |
32 | // All modules must extend this class, see http://smoothieware.org/moduleexample | |
33 | class Module | |
34 | { | |
35 | public: | |
36 | Module(); | |
37 | virtual ~Module(); | |
b375ba1d | 38 | virtual void on_module_loaded() {}; |
ab2a4410 | 39 | |
e0d0ea84 | 40 | void register_for_event(_EVENT_ENUM event_id); |
ab2a4410 | 41 | |
e0d0ea84 | 42 | // event callbacks, not every module will implement all of these |
96f67b65 | 43 | // there should be one for each _EVENT_ENUM |
b375ba1d JM |
44 | virtual void on_main_loop(void *) {}; |
45 | virtual void on_console_line_received(void *) {}; | |
46 | virtual void on_gcode_received(void *) {}; | |
b375ba1d JM |
47 | virtual void on_idle(void *) {}; |
48 | virtual void on_second_tick(void *) {}; | |
49 | virtual void on_get_public_data(void *) {}; | |
50 | virtual void on_set_public_data(void *) {}; | |
51 | virtual void on_halt(void *) {}; | |
0bfaf040 | 52 | virtual void on_enable(void *) {}; |
ab2a4410 | 53 | |
4cff3ded AW |
54 | }; |
55 | ||
56 | #endif |