these do not need to be modules
authorJim Morris <morris@wolfman.com>
Mon, 16 Jun 2014 01:02:30 +0000 (18:02 -0700)
committerJim Morris <morris@wolfman.com>
Mon, 16 Jun 2014 01:02:30 +0000 (18:02 -0700)
src/main.cpp
src/modules/tools/extruder/ExtruderMaker.cpp
src/modules/tools/extruder/ExtruderMaker.h
src/modules/tools/switch/SwitchPool.cpp
src/modules/tools/switch/SwitchPool.h
src/modules/tools/temperaturecontrol/TemperatureControlPool.cpp
src/modules/tools/temperaturecontrol/TemperatureControlPool.h

index 99834bb..c3deb31 100644 (file)
@@ -108,19 +108,28 @@ int main() {
     kernel->add_module( new SimpleShell() );
     kernel->add_module( new Configurator() );
     kernel->add_module( new CurrentControl() );
-    kernel->add_module( new SwitchPool() );
     kernel->add_module( new PauseButton() );
     kernel->add_module( new PlayLed() );
     kernel->add_module( new Endstops() );
     kernel->add_module( new Player() );
 
+
     // these modules can be completely disabled in the Makefile by adding to EXCLUDE_MODULES
+    #ifndef NO_TOOLS_SWITCH
+    SwitchPool *sp= new SwitchPool();
+    sp->load_tools();
+    delete sp;
+    #endif
     #ifndef NO_TOOLS_EXTRUDER
-    kernel->add_module( new ExtruderMaker() );
+    ExtruderMaker *em= new ExtruderMaker();
+    em->load_tools();
+    delete em;
     #endif
     #ifndef NO_TOOLS_TEMPERATURECONTROL
     // Note order is important here must be after extruder
-    kernel->add_module( new TemperatureControlPool() );
+    TemperatureControlPool *tp= new TemperatureControlPool();
+    tp->load_tools();
+    delete tp;
     #endif
     #ifndef NO_TOOLS_LASER
     kernel->add_module( new Laser() );
index b958089..4655e40 100644 (file)
@@ -5,9 +5,9 @@
       You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "ExtruderMaker.h"
 #include "libs/Module.h"
 #include "libs/Kernel.h"
-#include "ExtruderMaker.h"
 #include "Extruder.h"
 #include "Config.h"
 #include "ToolManager.h"
@@ -23,7 +23,7 @@ using namespace std;
 #define extruder_checksum                    CHECKSUM("extruder")
 #define enable_checksum                      CHECKSUM("enable")
 
-void ExtruderMaker::on_module_loaded(){
+void ExtruderMaker::load_tools(){
 
     // If there is a "single" extruder configured ( old config syntax from when there was only one extruder module, no pool/maker
     if( THEKERNEL->config->value( extruder_module_enable_checksum )->by_default(false)->as_bool() ){
@@ -45,8 +45,6 @@ void ExtruderMaker::on_module_loaded(){
 
     if(modules.size() == 0) {
         THEKERNEL->streams->printf("NOTE: No extruders configured\n");
-        // no extruders
-        delete this;
         return;
     }
 
@@ -60,7 +58,6 @@ void ExtruderMaker::on_module_loaded(){
 
     if(cnt == 0) {
         THEKERNEL->streams->printf("NOTE: No extruders enabled\n");
-        delete this;
         return;
     }
 
index 0abe466..a4939ac 100644 (file)
@@ -8,10 +8,9 @@
 #ifndef EXTRUDERMAKER_H
 #define EXTRUDERMAKER_H
 
-class ExtruderMaker : public Module {
+class ExtruderMaker {
     public:
-        ExtruderMaker(){}
-        void on_module_loaded();
+        void load_tools();
 };
 
 
index 68c150c..17b31eb 100644 (file)
@@ -19,19 +19,16 @@ using namespace std;
 #define switch_checksum CHECKSUM("switch")
 #define enable_checksum CHECKSUM("enable")
 
-SwitchPool::SwitchPool(){}
-
-void SwitchPool::on_module_loaded(){
-
+void SwitchPool::load_tools()
+{
     vector<uint16_t> modules;
     THEKERNEL->config->get_module_list( &modules, switch_checksum );
 
-    for( unsigned int i = 0; i < modules.size(); i++ ){
+    for( unsigned int i = 0; i < modules.size(); i++ ) {
         // If module is enabled
-        if( THEKERNEL->config->value(switch_checksum, modules[i], enable_checksum )->as_bool() == true ){
-            Switchcontroller = new Switch(modules[i]);
+        if( THEKERNEL->config->value(switch_checksum, modules[i], enable_checksum )->as_bool() == true ) {
+            Switch *controller = new Switch(modules[i]);
             THEKERNEL->add_module(controller);
-            //this->controllers.push_back( controller );
         }
     }
 
index aeffd9b..04a0ed6 100644 (file)
@@ -8,21 +8,9 @@
 #ifndef SWITCHPOOL_H
 #define SWITCHPOOL_H
 
-#include "Switch.h"
-#include <math.h>
-using namespace std;
-#include <vector>
-
-class SwitchPool : public Module {
+class SwitchPool{
     public:
-        SwitchPool();
-
-        void on_module_loaded();
-
-    private:
-        //vector<Switch*> controllers;
+        void load_tools();
 };
 
-
-
 #endif // SWITCHPOOL_H
index e2036bf..aa33d99 100644 (file)
@@ -20,9 +20,7 @@ using namespace std;
 
 #define enable_checksum              CHECKSUM("enable")
 
-TemperatureControlPool::TemperatureControlPool(){}
-
-void TemperatureControlPool::on_module_loaded(){
+void TemperatureControlPool::load_tools(){
 
     vector<uint16_t> modules;
     THEKERNEL->config->get_module_list( &modules, temperature_control_checksum );
@@ -41,9 +39,6 @@ void TemperatureControlPool::on_module_loaded(){
       PID_Autotuner* pidtuner = new PID_Autotuner();
       THEKERNEL->add_module( pidtuner );
     }
-
-    // no need to keep this around once it is done
-    delete this;
 }
 
 
index d279ebd..d6f931a 100644 (file)
@@ -8,16 +8,9 @@
 #ifndef TEMPERATURECONTROLPOOL_H
 #define TEMPERATURECONTROLPOOL_H
 
-class TemperatureControl;
-
-class TemperatureControlPool : public Module {
+class TemperatureControlPool {
     public:
-        TemperatureControlPool();
-
-        void on_module_loaded();
-
-    private:
-        //vector<TemperatureControl*> controllers;
+        void load_tools();
 };