mvsim-cli-server.cpp
Go to the documentation of this file.
1 /*+-------------------------------------------------------------------------+
2  | MultiVehicle simulator (libmvsim) |
3  | |
4  | Copyright (C) 2014-2020 Jose Luis Blanco Claraco |
5  | Copyright (C) 2017 Borys Tymchenko (Odessa Polytechnic University) |
6  | Distributed under 3-clause BSD License |
7  | See COPYING |
8  +-------------------------------------------------------------------------+ */
9 
10 #include <mrpt/core/exceptions.h>
11 #include <mvsim/Comms/Server.h>
12 #include <mvsim/Comms/ports.h> // MVSIM_PORTNO_MAIN_REP
13 
14 #include "mvsim-cli.h"
15 
17  "p", "port", "TCP port to listen at", false, mvsim::MVSIM_PORTNO_MAIN_REP,
18  "TCP port", cmd);
19 
20 static std::shared_ptr<mvsim::Server> server;
21 
23 {
24  ASSERT_(!server);
25 
26  // Start network server:
27  server = std::make_shared<mvsim::Server>();
28 
29  if (argPort.isSet()) server->listenningPort(argPort.getValue());
30 
31  server->setMinLoggingLevel(
32  mrpt::typemeta::TEnumType<mrpt::system::VerbosityLevel>::name2value(
33  argVerbosity.getValue()));
34 
35  server->start();
36 }
37 
39 {
40  if (argHelp.isSet())
41  {
42  fprintf(
43  stdout,
44  R"XXX(Usage: mvsim server
45 
46 Available options:
47  -p %5u, --port %5u Listen on given TCP port.
48  -v, --verbosity Set verbosity level: DEBUG, INFO (default), WARN, ERROR
49 )XXX",
51  return 0;
52  }
53 
55  return 0;
56 }
void commonLaunchServer()
TCLAP::SwitchArg argHelp("h","help","Shows more detailed help for command", cmd)
TCLAP::ValueArg< int > argPort("p","port","TCP port to listen at", false, mvsim::MVSIM_PORTNO_MAIN_REP,"TCP port", cmd)
int BASE_IMPEXP fprintf(FILE *fil, const char *format,...) MRPT_NO_THROWS MRPT_printf_format_check(2
int launchStandAloneServer()
TCLAP::ValueArg< std::string > argVerbosity("v","verbose","Verbosity level", false,"INFO","ERROR|WARN|INFO|DEBUG", cmd)
bool isSet() const
TCLAP::CmdLine cmd("mvsim", ' ',"version", false)
constexpr unsigned int MVSIM_PORTNO_MAIN_REP
Definition: ports.h:17
#define ASSERT_(f)
static std::shared_ptr< mvsim::Server > server


mvsim
Author(s):
autogenerated on Fri May 7 2021 03:05:51