server_main.cpp
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 #ifdef _WIN32
00012 #include <windows.h>
00013 #endif
00014 
00015 #include <opc/ua/server/addons/common_addons.h>
00016 #include "daemon.h"
00017 #include "server_options.h"
00018 
00019 #include <thread>
00020 #include <iostream>
00021 
00022 /*
00023 #ifdef _WIN32
00024 
00025 int CALLBACK WinMain(_In_  HINSTANCE hInstance, _In_  HINSTANCE hPrevInstance, _In_  LPSTR lpCmdLine, _In_  int nCmdShow)
00026 {
00027   int argc = __argc;
00028   char** argv = __argv;
00029 
00030 #else
00031 */
00032 int main(int argc, char** argv)
00033 {
00034 
00035 //#endif
00036   try
00037   {
00038     const char** arv = (const char**)argv;
00039     OpcUa::Server::CommandLine options(argc, arv);
00040     if (!options.NeedStartServer())
00041     {
00042       return 0;
00043     }
00044 
00045     OpcUa::Daemon daemon;
00046     if (options.IsDaemonMode())
00047     {
00048       daemon.Daemonize(options.GetLogFile());
00049     }
00050 
00051     Common::AddonsManager::UniquePtr manager = Common::CreateAddonsManager();
00052     OpcUa::Server::LoadConfiguration(options.GetConfigDir(), *manager);
00053 
00054     manager->Start();
00055     daemon.WaitForTerminate();
00056     manager->Stop();
00057 
00058     return 0;
00059   }
00060   catch (const std::exception& exc)
00061   {
00062     std::cout << exc.what() << std::endl;
00063   }
00064   catch (...)
00065   {
00066     std::cout << "Unknown error." << std::endl;
00067   }
00068   return -1;
00069 }
00070 


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Sat Jun 8 2019 18:24:56