Michael Spencer / Smoothie

Dependencies:   mbed

Fork of Smoothie by Stéphane Cachat

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Kernel.h Source File

Kernel.h

00001 /*
00002       This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
00003       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.
00004       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.
00005       You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
00006 */
00007 
00008 #ifndef KERNEL_H
00009 #define KERNEL_H
00010 
00011 #include "mbed.h"
00012 
00013 #include "libs/Module.h"
00014 #include "libs/Config.h"
00015 #include "libs/SlowTicker.h"
00016 #include "libs/StreamOutputPool.h"
00017 #include "libs/StepTicker.h"
00018 #include "libs/Pauser.h"
00019 #include "libs/PublicData.h"
00020 #include "modules/communication/SerialConsole.h"
00021 #include "modules/communication/GcodeDispatch.h"
00022 #include "modules/tools/toolsmanager/ToolsManager.h"
00023 #include "modules/robot/Planner.h"
00024 #include "modules/robot/Robot.h"
00025 #include "modules/robot/Stepper.h"
00026 
00027 #define THEKERNEL Kernel::instance
00028 
00029 //Module manager
00030 class Config;
00031 class Module;
00032 class Conveyor;
00033 class SlowTicker;
00034 class Pauser;
00035 
00036 class Kernel {
00037     public:
00038         Kernel();
00039         static Kernel* instance; // the Singleton instance of Kernel usable anywhere
00040         const char* config_override_filename(){ return "/sd/config-override"; }
00041 
00042         void add_module(Module* module);
00043         void register_for_event(_EVENT_ENUM id_event, Module* module);
00044         void call_event(_EVENT_ENUM id_event);
00045         void call_event(_EVENT_ENUM id_event, void * argument);
00046 
00047         // These modules are aviable to all other modules
00048         SerialConsole*    serial;
00049         StreamOutputPool* streams;
00050 
00051         GcodeDispatch*    gcode_dispatch;
00052         Robot*            robot;
00053         Stepper*          stepper;
00054         Planner*          planner;
00055         Config*           config;
00056         Conveyor*         conveyor;
00057         Pauser*           pauser;
00058         ToolsManager*     toolsmanager;
00059 
00060         int debug;
00061         SlowTicker*       slow_ticker;
00062         StepTicker*       step_ticker;
00063         AnalogIn*         adc;
00064         PublicData*       public_data;
00065         bool              use_leds;
00066         string            current_path;
00067 
00068     private:
00069         std::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
00070 
00071 };
00072 
00073 #endif