Subversion Repositories HomeAutomation

Rev

Rev 1322 | Rev 1328 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1322 Rev 1326
Line 18... Line 18...
18
#include <boost/asio.hpp>
18
#include <boost/asio.hpp>
19
#include <boost/bind.hpp>
19
#include <boost/bind.hpp>
20
#include <boost/foreach.hpp>
20
#include <boost/foreach.hpp>
21
#include <boost/program_options.hpp>
21
#include <boost/program_options.hpp>
22
#include "broker/Broker.h"
22
#include "broker/Broker.h"
-
 
23
#include "message/Header.h"
23
#include "message/Message.h"
24
#include "message/Message.h"
24
#include "subscribers/monitor/Monitor.h"
25
#include "subscribers/monitor/Monitor.h"
25
#include "subscribers/cannet/CanNet.h"
26
#include "subscribers/cannet/CanNet.h"
26
#include "xml/Node.h"
27
#include "xml/Node.h"
27
#include "thread/Thread.h"
28
#include "thread/Thread.h"
28
#include "net/UdpServer.h"
29
#include "net/UdpServer.h"
29
#include "xml/Node.h"
30
#include "xml/Node.h"
30
#include "protocol/Protocol.h"
31
#include "protocol/Protocol.h"
31
#include "log/Logger.h"
32
#include "log/Logger.h"
-
 
33
#include "Exception.hpp"
32
 
34
 
33
namespace po = boost::program_options;
35
namespace po = boost::program_options;
34
 
36
 
35
#define foreach         BOOST_FOREACH
37
#define foreach         BOOST_FOREACH
36
#define reverse_foreach BOOST_REVERSE_FOREACH
38
#define reverse_foreach BOOST_REVERSE_FOREACH
Line 38... Line 40...
38
 
40
 
39
 
41
 
40
using namespace atom;
42
using namespace atom;
41
 
43
 
42
int main(int argc, char* argv[])
44
int main(int argc, char* argv[])
-
 
45
{
-
 
46
    try
43
{
47
    {
44
    log::Logger LOG;
48
        log::Logger LOG;
45
    LOG.setName("Main");
49
        LOG.setName("Main");
46
 
50
 
47
    LOG.info("Atom (" + string(AutoVersion::FULLVERSION_STRING) + " " + string(AutoVersion::STATUS) + ")");
51
        LOG.info("Atom (" + string(AutoVersion::FULLVERSION_STRING) + " " + string(AutoVersion::STATUS) + ")");
48
    LOG.info("Written by Mattias Runge 2009");
52
        LOG.info("Written by Mattias Runge 2009");
49
 
53
 
50
    float log2_2 = log2f(2);
-
 
51
 
-
 
52
    LOG.info("bitcount: 0 :: " + convert::int2string(ceil(log2f(0+1)/log2_2)) + " == " + convert::uint2string(convert::stateCount2bitCount(0)));
-
 
53
    LOG.info("bitcount: 1 :: " + convert::int2string(ceil(log2f(1+1)/log2_2)) + " == " + convert::uint2string(convert::stateCount2bitCount(1)));
-
 
54
    LOG.info("bitcount: 2 :: " + convert::int2string(ceil(log2f(2+1)/log2_2)) + " == " + convert::uint2string(convert::stateCount2bitCount(2)));
-
 
55
    LOG.info("bitcount: 3 :: " + convert::int2string(ceil(log2f(3+1)/log2_2)) + " == " + convert::uint2string(convert::stateCount2bitCount(3)));
-
 
56
    LOG.info("bitcount: 4 :: " + convert::int2string(ceil(log2f(4+1)/log2_2)) + " == " + convert::uint2string(convert::stateCount2bitCount(4)));
-
 
57
    LOG.info("bitcount: 5 :: " + convert::int2string(ceil(log2f(5+1)/log2_2)) + " == " + convert::uint2string(convert::stateCount2bitCount(5)));
-
 
58
    LOG.info("bitcount: 6 :: " + convert::int2string(ceil(log2f(6+1)/log2_2)) + " == " + convert::uint2string(convert::stateCount2bitCount(6)));
-
 
59
    LOG.info("bitcount: 7 :: " + convert::int2string(ceil(log2f(7+1)/log2_2)) + " == " + convert::uint2string(convert::stateCount2bitCount(7)));
-
 
60
    LOG.info("bitcount: 8 :: " + convert::int2string(ceil(log2f(8+1)/log2_2)) + " == " + convert::uint2string(convert::stateCount2bitCount(8)));
-
 
61
 
-
 
62
    Protocol::pointer protocol = Protocol::getInstance();
-
 
63
    protocol->load("../../Configuration/protocol.xml");
54
        Protocol::getInstance()->load("../../Configuration/protocol.xml", "../../Configuration/protocol-cache.xml");
64
    cout << protocol->getRootNode().toString() << endl;
-
 
65
 
-
 
66
 
55
 
67
    broker::Broker::pointer broker = broker::Broker::getInstance();
56
        broker::Broker::pointer broker = broker::Broker::getInstance();
68
 
-
 
69
    subscribers::Monitor::pointer monitorSubscriber(new subscribers::Monitor(broker));
-
 
70
    subscribers::CanNet::pointer canNetSubscriber(new subscribers::CanNet(broker, "192.168.1.250", 1100));
-
 
71
 
57
 
-
 
58
        subscribers::Monitor::pointer monitorSubscriber(new subscribers::Monitor(broker));
-
 
59
        //subscribers::CanNet::pointer canNetSubscriber(new subscribers::CanNet(broker, "192.168.1.250", 1100));
-
 
60
 
-
 
61
        LOG.info("Will now try to send a message...");
-
 
62
 
-
 
63
        message::Header header(0, "irTranceiver", "temperature");
-
 
64
 
-
 
65
        LOG.info("Header constructed...");
-
 
66
 
-
 
67
        message::Message::pointer message(new message::Message(header));
-
 
68
 
-
 
69
        LOG.info("Message constructed...");
-
 
70
 
-
 
71
        broker->put(message);
72
 
72
 
73
    sleep(10000000);
73
        sleep(10000000);
-
 
74
    }
-
 
75
    catch (Exception * e)
-
 
76
    {
-
 
77
        cout << "Exception: " << e->getDescription() << endl;
-
 
78
    }
-
 
79
 
-
 
80
 
74
 
81
 
75
 
82
 
76
    return 0;
83
    return 0;
77
    //udpSubscriber->write(utils::BitBuffer(startPacket));
84
    //udpSubscriber->write(utils::BitBuffer(startPacket));
78
 
85