Subversion Repositories HomeAutomation

Rev

Rev 1596 | Rev 1599 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. /*
  2.  *
  3.  *  Copyright (C) 2010  Mattias Runge
  4.  *
  5.  *  This program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2 of the License, or
  8.  *  (at your option) any later version.
  9.  *
  10.  *  This program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *  GNU General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License along
  16.  *  with this program; if not, write to the Free Software Foundation, Inc.,
  17.  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18.  *
  19.  */
  20.  
  21. #include <boost/program_options.hpp>
  22.  
  23. #include "net/Manager.h"
  24. #include "net/types.h"
  25.  
  26. #include "timer/Manager.h"
  27. #include "timer/types.h"
  28.  
  29. #include "config/Manager.h"
  30.  
  31. #include "logging/Logger.h"
  32.  
  33. #include "can/Network.h"
  34. #include "can/Monitor.h"
  35. #include "can/Manager.h"
  36. #include "can/Protocol.h"
  37.  
  38. using namespace atom;
  39.  
  40. logging::Logger LOG("Main");
  41.  
  42. void CleanUp();
  43.  
  44. int main(int argc, char **argv)
  45. {
  46.     std::vector<broker::Subscriber::Pointer> subscribers;
  47.  
  48.     if (!config::Manager::Instance()->Set(argc, argv))
  49.     {
  50.         CleanUp();
  51.         return EXIT_SUCCESS;
  52.     }
  53.    
  54.     if (config::Manager::Instance()->Exist("ProtocolFile"))
  55.     {
  56.         can::Protocol::Instance()->Load(config::Manager::Instance()->GetAsString("ProtocolFile"));
  57.     }
  58.    
  59.     if (config::Manager::Instance()->Exist("MonitorPort"))
  60.     {
  61.         subscribers.push_back(can::Monitor::Pointer(new can::Monitor(config::Manager::Instance()->GetAsInt("MonitorPort"))));  
  62.     }
  63.    
  64.     subscribers.push_back(can::Manager::Instance());  
  65.    
  66.     if (config::Manager::Instance()->Exist("CanNet"))
  67.     {
  68.         type::StringList cannetworks = config::Manager::Instance()->GetAsStringVector("CanNet");
  69.        
  70.         for (int n = 0; n < cannetworks.size(); n++)
  71.         {
  72.             subscribers.push_back(can::Network::Pointer(new can::Network(cannetworks[n])));            
  73.         }
  74.        
  75.     }
  76.    
  77.     sleep(100000000);
  78.    
  79.     subscribers.clear();
  80.    
  81.     CleanUp();
  82.    
  83.     return EXIT_SUCCESS;
  84. }
  85.  
  86. void CleanUp()
  87. {
  88.     config::Manager::Delete();
  89.     net::Manager::Delete();
  90.     can::Manager::Delete();
  91.     timer::Manager::Delete();
  92. }