added missing files, working on extruder module ( not finished, removing
[clinton/Smoothieware.git] / src / libs / Kernel.h
CommitLineData
4cff3ded
AW
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"
ded56b35 12#include "libs/SlowTicker.h"
3b1e82d2 13#include "libs/StepTicker.h"
4cff3ded
AW
14#include "modules/communication/SerialConsole.h"
15#include "modules/communication/GcodeDispatch.h"
16#include "modules/robot/Planner.h"
17#include "modules/robot/Robot.h"
18#include "modules/robot/Stepper.h"
19#include "mbed.h"
20
21// See : http://smoothieware.org/listofevents
befcf5cc 22#define NUMBER_OF_DEFINED_EVENTS 11
4cff3ded
AW
23#define ON_MAIN_LOOP 0
24#define ON_CONSOLE_LINE_RECEIVED 1
25#define ON_GCODE_RECEIVED 2
26#define ON_STEPPER_WAKE_UP 3 //TODO : Remove the need for this event, then this event itself eg: have planner call stepper directly
27#define ON_GCODE_EXECUTE 4
28#define ON_SPEED_CHANGE 5
29#define ON_BLOCK_BEGIN 6
30#define ON_BLOCK_END 7
da24d6ae 31#define ON_CONFIG_RELOAD 8
befcf5cc
AW
32#define ON_PLAY 9
33#define ON_PAUSE 10
34
4cff3ded
AW
35
36using namespace std;
37#include <vector>
38
39typedef void (Module::*ModuleCallback)(void * argument);
40
41//Module manager
42class Module;
3a4fa0c1 43class Player;
4cff3ded
AW
44class Kernel {
45 public:
46 Kernel();
47 void add_module(Module* module);
48 void register_for_event(unsigned int id_event, Module* module);
49 void call_event(unsigned int id_event);
50 void call_event(unsigned int id_event, void * argument);
51
52 // These modules are aviable to all other modules
53 SerialConsole* serial;
54 GcodeDispatch* gcode_dispatch;
55 Robot* robot;
56 Stepper* stepper;
57 Planner* planner;
58 Config* config;
3a4fa0c1 59 Player* player;
4cff3ded 60
13e4a3f9 61 int debug;
ded56b35 62 SlowTicker* slow_ticker;
3b1e82d2 63 StepTicker* step_ticker;
13e4a3f9 64
4cff3ded
AW
65 private:
66 vector<Module*> hooks[NUMBER_OF_DEFINED_EVENTS]; // When a module asks to be called for a specific event ( a hook ), this is where that request is remembered
67
68};
69
70#endif