Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
freeopcua
src
serverapp
server_main.cpp
Go to the documentation of this file.
1
11
#ifdef _WIN32
12
#include <windows.h>
13
#endif
14
15
#include <
opc/ua/server/addons/common_addons.h
>
16
#include "
daemon.h
"
17
#include "
server_options.h
"
18
19
#include <thread>
20
#include <iostream>
21
22
/*
23
#ifdef _WIN32
24
25
int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow)
26
{
27
int argc = __argc;
28
char** argv = __argv;
29
30
#else
31
*/
32
int
main
(
int
argc,
char
** argv)
33
{
34
//#endif
35
auto
logger =
spdlog::stderr_color_mt
(
"server"
);
36
logger->set_level(
spdlog::level::info
);
37
38
try
39
{
40
const
char
** arv = (
const
char
**)argv;
41
OpcUa::Server::CommandLine
options(argc, arv);
42
43
if
(!options.
NeedStartServer
())
44
{
45
return
0;
46
}
47
48
OpcUa::Daemon
daemon;
49
50
if
(options.
IsDaemonMode
())
51
{
52
daemon.
Daemonize
(options.
GetLogFile
());
53
}
54
55
Common::AddonsManager::UniquePtr manager =
Common::CreateAddonsManager
(logger);
56
OpcUa::Server::LoadConfiguration
(options.
GetConfigDir
(), *manager);
57
58
manager->Start();
59
daemon.
WaitForTerminate
();
60
manager->Stop();
61
62
return
0;
63
}
64
65
catch
(
const
std::exception & exc)
66
{
67
std::cout << exc.what() << std::endl;
68
}
69
70
catch
(...)
71
{
72
std::cout <<
"Unknown error."
<< std::endl;
73
}
74
75
return
-1;
76
}
77
daemon.h
spdlog::level::info
Definition:
include/opc/spdlog/common.h:77
OpcUa::Server::LoadConfiguration
void LoadConfiguration(const std::string &configDirectoryPath, Common::AddonsManager &addons)
Load parameters from configuration files. This function will enumerate '*.config' files in the direct...
Definition:
common_addons.cpp:247
OpcUa::Daemon::WaitForTerminate
void WaitForTerminate()
Definition:
daemon.cpp:26
OpcUa::Server::CommandLine::GetLogFile
std::string GetLogFile() const
Definition:
server_options.h:47
OpcUa::Server::CommandLine::NeedStartServer
bool NeedStartServer() const
Definition:
server_options.h:32
Common::CreateAddonsManager
AddonsManager::UniquePtr CreateAddonsManager(const Common::Logger::SharedPtr &logger)
Get instance of addons core.
Definition:
addon_manager.cpp:313
OpcUa::Server::CommandLine::GetConfigDir
std::string GetConfigDir() const
Definition:
server_options.h:42
common_addons.h
OpcUa::Daemon::Daemonize
void Daemonize(const std::string &str)
Definition:
daemon_lin.cpp:68
OpcUa::Server::CommandLine
Definition:
server_options.h:27
OpcUa::Daemon
Definition:
daemon.h:18
server_options.h
main
int main(int argc, char **argv)
OPC UA Server main. GNU LGPL.
Definition:
server_main.cpp:32
OpcUa::Server::CommandLine::IsDaemonMode
bool IsDaemonMode() const
Definition:
server_options.h:37
spdlog::stderr_color_mt
std::shared_ptr< logger > stderr_color_mt(const std::string &logger_name)
Definition:
spdlog_impl.h:150
ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:12:07