Subversion Repositories HomeAutomation

Rev

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

Rev Author Line No. Line
1598 runge 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
 */
1592 runge 20
 
1594 runge 21
#include <boost/program_options.hpp>
1592 runge 22
 
23
#include "net/Manager.h"
1595 runge 24
#include "net/types.h"
1592 runge 25
 
1593 runge 26
#include "timer/Manager.h"
1595 runge 27
#include "timer/types.h"
1593 runge 28
 
1594 runge 29
#include "config/Manager.h"
1593 runge 30
 
1594 runge 31
#include "logging/Logger.h"
32
 
1596 runge 33
#include "can/Network.h"
34
#include "can/Monitor.h"
1598 runge 35
#include "can/Manager.h"
1596 runge 36
#include "can/Protocol.h"
37
 
1592 runge 38
using namespace atom;
1593 runge 39
 
1596 runge 40
logging::Logger LOG("Main");
1592 runge 41
 
1598 runge 42
void CleanUp();
1592 runge 43
 
44
int main(int argc, char **argv)
45
{
1596 runge 46
    std::vector<broker::Subscriber::Pointer> subscribers;
1594 runge 47
 
1598 runge 48
    if (!config::Manager::Instance()->Set(argc, argv))
1594 runge 49
    {
1598 runge 50
        CleanUp();
51
        return EXIT_SUCCESS;
1594 runge 52
    }
53
 
1598 runge 54
    if (config::Manager::Instance()->Exist("ProtocolFile"))
1596 runge 55
    {
1598 runge 56
        can::Protocol::Instance()->Load(config::Manager::Instance()->GetAsString("ProtocolFile"));
1596 runge 57
    }
58
 
1598 runge 59
    if (config::Manager::Instance()->Exist("MonitorPort"))
1594 runge 60
    {
1598 runge 61
        subscribers.push_back(can::Monitor::Pointer(new can::Monitor(config::Manager::Instance()->GetAsInt("MonitorPort"))));  
1594 runge 62
    }
63
 
1598 runge 64
    subscribers.push_back(can::Manager::Instance());  
65
 
66
    if (config::Manager::Instance()->Exist("CanNet"))
1594 runge 67
    {
1598 runge 68
        type::StringList cannetworks = config::Manager::Instance()->GetAsStringVector("CanNet");
1594 runge 69
 
1598 runge 70
        for (int n = 0; n < cannetworks.size(); n++)
1594 runge 71
        {
1598 runge 72
            subscribers.push_back(can::Network::Pointer(new can::Network(cannetworks[n])));            
1594 runge 73
        }
74
 
75
    }
1596 runge 76
 
1598 runge 77
    sleep(100000000);
1596 runge 78
 
1598 runge 79
    subscribers.clear();
1594 runge 80
 
1598 runge 81
    CleanUp();
1594 runge 82
 
1598 runge 83
    return EXIT_SUCCESS;
1592 runge 84
}
1598 runge 85
 
86
void CleanUp()
87
{
88
    config::Manager::Delete();
89
    net::Manager::Delete();
90
    can::Manager::Delete();
91
    timer::Manager::Delete();
92
}