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