Details | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1309 | runge | 1 | //============================================================================ |
| 2 | // Name : Atom.cpp |
||
| 3 | // Author : Mattias Runge |
||
| 4 | // Version : 2.0 |
||
| 5 | // Copyright : GPL |
||
| 6 | //============================================================================ |
||
| 7 | |||
| 8 | #include <iostream> |
||
| 9 | #include <istream> |
||
| 10 | #include <ostream> |
||
| 11 | #include <string> |
||
| 12 | #include <fstream> |
||
| 13 | #include <iterator> |
||
| 14 | |||
| 15 | #include <stdio.h> |
||
| 16 | |||
| 1310 | runge | 17 | #include "version.h" |
| 1309 | runge | 18 | #include <boost/asio.hpp> |
| 19 | #include <boost/bind.hpp> |
||
| 20 | #include <boost/foreach.hpp> |
||
| 21 | #include <boost/program_options.hpp> |
||
| 22 | #include "broker/Broker.h" |
||
| 23 | #include "message/Message.h" |
||
| 24 | #include "subscribers/monitor/Monitor.h" |
||
| 25 | #include "subscribers/cannet/CanNet.h" |
||
| 26 | #include "xml/Node.h" |
||
| 1317 | runge | 27 | #include "thread/Thread.h" |
| 1309 | runge | 28 | #include "utils/BitBuffer.h" |
| 1317 | runge | 29 | #include "net/UdpServer.h" |
| 1309 | runge | 30 | #include "xml/Node.h" |
| 1311 | runge | 31 | #include "protocol/Protocol.h" |
| 1315 | runge | 32 | #include "log/Logger.h" |
| 1309 | runge | 33 | |
| 34 | namespace po = boost::program_options; |
||
| 35 | |||
| 36 | #define foreach BOOST_FOREACH |
||
| 37 | #define reverse_foreach BOOST_REVERSE_FOREACH |
||
| 38 | using namespace std; |
||
| 39 | |||
| 40 | |||
| 41 | using namespace atom; |
||
| 42 | |||
| 43 | int main(int argc, char* argv[]) |
||
| 44 | { |
||
| 1315 | runge | 45 | log::Logger LOG; |
| 1310 | runge | 46 | LOG.setName("Main"); |
| 47 | |||
| 48 | LOG.info("Atom (" + string(AutoVersion::FULLVERSION_STRING) + " " + string(AutoVersion::STATUS) + ")"); |
||
| 49 | LOG.info("Written by Mattias Runge 2009"); |
||
| 50 | |||
| 51 | |||
| 1318 | runge | 52 | |
| 1311 | runge | 53 | Protocol::pointer protocol = Protocol::getInstance(); |
| 54 | protocol->load("../../Configuration/protocol.xml"); |
||
| 55 | cout << protocol->getRootNode().toString() << endl; |
||
| 1310 | runge | 56 | |
| 57 | |||
| 1309 | runge | 58 | broker::Broker::pointer broker = broker::Broker::getInstance(); |
| 59 | |||
| 60 | subscribers::Monitor::pointer monitorSubscriber(new subscribers::Monitor(broker)); |
||
| 61 | subscribers::CanNet::pointer canNetSubscriber(new subscribers::CanNet(broker, "192.168.1.250", 1100)); |
||
| 62 | |||
| 63 | |||
| 64 | sleep(10000000); |
||
| 65 | |||
| 66 | |||
| 1310 | runge | 67 | return 0; |
| 1309 | runge | 68 | //udpSubscriber->write(utils::BitBuffer(startPacket)); |
| 69 | |||
| 70 | |||
| 71 | cout << "ABC123" << endl; |
||
| 72 | |||
| 73 | return 0; |
||
| 1310 | runge | 74 | /*sleep(1); |
| 1309 | runge | 75 | |
| 1310 | runge | 76 | messagebroker::Message message(""); |
| 1309 | runge | 77 | |
| 78 | |||
| 1310 | runge | 79 | message.data = "test1"; |
| 80 | broker.put(message); |
||
| 1309 | runge | 81 | |
| 1310 | runge | 82 | message.setOrigin(monitorSubscriber); |
| 83 | message.data = "test2"; |
||
| 84 | broker.put(message); |
||
| 85 | sleep(1); |
||
| 86 | delete monitorSubscriber; |
||
| 1309 | runge | 87 | |
| 1310 | runge | 88 | message.data = "test3"; |
| 89 | broker.put(message); |
||
| 90 | sleep(1); |
||
| 91 | delete udpSubscriber; |
||
| 1309 | runge | 92 | |
| 93 | |||
| 1310 | runge | 94 | try |
| 95 | { |
||
| 96 | // Declare a group of options that will be |
||
| 97 | // allowed only on command line |
||
| 98 | po::options_description generic("Generic options"); |
||
| 99 | generic.add_options() ("version,v", "print version string") |
||
| 100 | ("help", "produce help message"); |
||
| 1309 | runge | 101 | |
| 1310 | runge | 102 | // Declare a group of options that will be |
| 103 | // allowed both on command line and in |
||
| 104 | // config file |
||
| 105 | po::options_description config("Configuration"); |
||
| 106 | config.add_options()("optimization", po::value<int>()->default_value(10), "optimization level") |
||
| 107 | ("include-path,I", po::value<vector<string> >()->composing(), "include path"); |
||
| 1309 | runge | 108 | |
| 1310 | runge | 109 | // Hidden options, will be allowed both on command line and |
| 110 | // in config file, but will not be shown to the user. |
||
| 111 | po::options_description hidden("Hidden options"); |
||
| 112 | hidden.add_options()("input-file", po::value<vector<string> >(), "input file"); |
||
| 1309 | runge | 113 | |
| 1310 | runge | 114 | po::options_description cmdline_options; |
| 115 | cmdline_options.add(generic).add(config).add(hidden); |
||
| 1309 | runge | 116 | |
| 1310 | runge | 117 | po::options_description config_file_options; |
| 118 | config_file_options.add(config).add(hidden); |
||
| 1309 | runge | 119 | |
| 1310 | runge | 120 | po::options_description visible("Allowed options"); |
| 121 | visible.add(generic).add(config); |
||
| 1309 | runge | 122 | |
| 1310 | runge | 123 | po::positional_options_description p; |
| 124 | p.add("input-file", -1); |
||
| 1309 | runge | 125 | |
| 1310 | runge | 126 | po::variables_map vm; |
| 127 | store(po::command_line_parser(argc, argv).options(cmdline_options).positional(p).run(), vm); |
||
| 1309 | runge | 128 | |
| 1310 | runge | 129 | ifstream ifs("multiple_sources.cfg"); |
| 130 | store(parse_config_file(ifs, config_file_options), vm); |
||
| 131 | notify(vm); |
||
| 1309 | runge | 132 | |
| 1310 | runge | 133 | if (vm.count("help")) |
| 134 | { |
||
| 135 | cout << visible << "\n"; |
||
| 136 | return 0; |
||
| 137 | } |
||
| 1309 | runge | 138 | |
| 1310 | runge | 139 | if (vm.count("version")) |
| 140 | { |
||
| 141 | cout << "Multiple sources example, version 1.0\n"; |
||
| 142 | return 0; |
||
| 143 | } |
||
| 1309 | runge | 144 | |
| 1310 | runge | 145 | if (vm.count("include-path")) |
| 146 | { |
||
| 147 | //cout << "Include paths are: " << vm["include-path"].as<vector<string>>() << "\n"; |
||
| 148 | } |
||
| 1309 | runge | 149 | |
| 1310 | runge | 150 | if (vm.count("input-file")) |
| 151 | { |
||
| 152 | //cout << "Input files are: " << vm["input-file"].as<vector<string>>() << "\n"; |
||
| 153 | } |
||
| 1309 | runge | 154 | |
| 1310 | runge | 155 | //cout << "Optimization level is " << opt << "\n"; |
| 1309 | runge | 156 | |
| 1310 | runge | 157 | */ |
| 158 | /*if (argc != 3) |
||
| 159 | { |
||
| 160 | std::cout << "Usage: async_client <server> <path>\n"; |
||
| 161 | std::cout << "Example:\n"; |
||
| 162 | std::cout << " async_client www.boost.org /LICENSE_1_0.txt\n"; |
||
| 163 | return 1; |
||
| 164 | } |
||
| 1309 | runge | 165 | |
| 1310 | runge | 166 | boost::asio::io_service io_service; |
| 167 | client c(io_service, argv[1], argv[2]); |
||
| 168 | io_service.run();*/ |
||
| 169 | /* |
||
| 170 | std::string hello( "Hello, world!" ); |
||
| 1309 | runge | 171 | |
| 1310 | runge | 172 | foreach( char ch, hello ) |
| 173 | { |
||
| 174 | std::cout << ch; |
||
| 175 | } |
||
| 176 | |||
| 177 | } |
||
| 178 | catch (std::exception& e) |
||
| 1309 | runge | 179 | { |
| 1310 | runge | 180 | std::cout << "Exception: " << e.what() << "\n"; |
| 1309 | runge | 181 | } |
| 1310 | runge | 182 | */ |
| 1309 | runge | 183 | return 0; |
| 184 | } |